Cleanup: replace members m_ prefix by _ suffix in Compositor
To convert old code to the current convention and use a single code style.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
CPUDevice::CPUDevice(int thread_id) : m_thread_id(thread_id)
|
||||
CPUDevice::CPUDevice(int thread_id) : thread_id_(thread_id)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +39,11 @@ class CPUDevice : public Device {
|
||||
|
||||
int thread_id()
|
||||
{
|
||||
return m_thread_id;
|
||||
return thread_id_;
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_thread_id;
|
||||
int thread_id_;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -22,20 +22,20 @@ namespace blender::compositor {
|
||||
|
||||
CompositorContext::CompositorContext()
|
||||
{
|
||||
m_scene = nullptr;
|
||||
m_rd = nullptr;
|
||||
m_quality = eCompositorQuality::High;
|
||||
m_hasActiveOpenCLDevices = false;
|
||||
m_fastCalculation = false;
|
||||
m_viewSettings = nullptr;
|
||||
m_displaySettings = nullptr;
|
||||
m_bnodetree = nullptr;
|
||||
scene_ = nullptr;
|
||||
rd_ = nullptr;
|
||||
quality_ = eCompositorQuality::High;
|
||||
hasActiveOpenCLDevices_ = false;
|
||||
fastCalculation_ = false;
|
||||
viewSettings_ = nullptr;
|
||||
displaySettings_ = nullptr;
|
||||
bnodetree_ = nullptr;
|
||||
}
|
||||
|
||||
int CompositorContext::getFramenumber() const
|
||||
{
|
||||
BLI_assert(m_rd);
|
||||
return m_rd->cfra;
|
||||
BLI_assert(rd_);
|
||||
return rd_->cfra;
|
||||
}
|
||||
|
||||
Size2f CompositorContext::get_render_size() const
|
||||
@@ -47,8 +47,8 @@ Size2f CompositorContext::get_render_size() const
|
||||
eExecutionModel CompositorContext::get_execution_model() const
|
||||
{
|
||||
if (U.experimental.use_full_frame_compositor) {
|
||||
BLI_assert(m_bnodetree != nullptr);
|
||||
switch (m_bnodetree->execution_mode) {
|
||||
BLI_assert(bnodetree_ != nullptr);
|
||||
switch (bnodetree_->execution_mode) {
|
||||
case 1:
|
||||
return eExecutionModel::FullFrame;
|
||||
case 0:
|
||||
|
||||
@@ -38,55 +38,55 @@ class CompositorContext {
|
||||
* editor) This field is initialized in ExecutionSystem and must only be read from that point
|
||||
* on. \see ExecutionSystem
|
||||
*/
|
||||
bool m_rendering;
|
||||
bool rendering_;
|
||||
|
||||
/**
|
||||
* \brief The quality of the composite.
|
||||
* This field is initialized in ExecutionSystem and must only be read from that point on.
|
||||
* \see ExecutionSystem
|
||||
*/
|
||||
eCompositorQuality m_quality;
|
||||
eCompositorQuality quality_;
|
||||
|
||||
Scene *m_scene;
|
||||
Scene *scene_;
|
||||
|
||||
/**
|
||||
* \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.
|
||||
* \see ExecutionSystem
|
||||
*/
|
||||
RenderData *m_rd;
|
||||
RenderData *rd_;
|
||||
|
||||
/**
|
||||
* \brief reference to the bNodeTree
|
||||
* This field is initialized in ExecutionSystem and must only be read from that point on.
|
||||
* \see ExecutionSystem
|
||||
*/
|
||||
bNodeTree *m_bnodetree;
|
||||
bNodeTree *bnodetree_;
|
||||
|
||||
/**
|
||||
* \brief Preview image hash table
|
||||
* 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?
|
||||
*/
|
||||
bool m_hasActiveOpenCLDevices;
|
||||
bool hasActiveOpenCLDevices_;
|
||||
|
||||
/**
|
||||
* \brief Skip slow nodes
|
||||
*/
|
||||
bool m_fastCalculation;
|
||||
bool fastCalculation_;
|
||||
|
||||
/* \brief color management settings */
|
||||
const ColorManagedViewSettings *m_viewSettings;
|
||||
const ColorManagedDisplaySettings *m_displaySettings;
|
||||
const ColorManagedViewSettings *viewSettings_;
|
||||
const ColorManagedDisplaySettings *displaySettings_;
|
||||
|
||||
/**
|
||||
* \brief active rendering view name
|
||||
*/
|
||||
const char *m_viewName;
|
||||
const char *viewName_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setRendering(bool rendering)
|
||||
{
|
||||
m_rendering = rendering;
|
||||
rendering_ = rendering;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ class CompositorContext {
|
||||
*/
|
||||
bool isRendering() const
|
||||
{
|
||||
return m_rendering;
|
||||
return rendering_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setRenderData(RenderData *rd)
|
||||
{
|
||||
m_rd = rd;
|
||||
rd_ = rd;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setbNodeTree(bNodeTree *bnodetree)
|
||||
{
|
||||
m_bnodetree = bnodetree;
|
||||
bnodetree_ = bnodetree;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ class CompositorContext {
|
||||
*/
|
||||
const bNodeTree *getbNodeTree() const
|
||||
{
|
||||
return m_bnodetree;
|
||||
return bnodetree_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,16 +139,16 @@ class CompositorContext {
|
||||
*/
|
||||
const RenderData *getRenderData() const
|
||||
{
|
||||
return m_rd;
|
||||
return rd_;
|
||||
}
|
||||
|
||||
void setScene(Scene *scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
scene_ = scene;
|
||||
}
|
||||
Scene *getScene() const
|
||||
{
|
||||
return m_scene;
|
||||
return scene_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setPreviewHash(bNodeInstanceHash *previews)
|
||||
{
|
||||
m_previews = previews;
|
||||
previews_ = previews;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ class CompositorContext {
|
||||
*/
|
||||
bNodeInstanceHash *getPreviewHash() const
|
||||
{
|
||||
return m_previews;
|
||||
return previews_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +172,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setViewSettings(const ColorManagedViewSettings *viewSettings)
|
||||
{
|
||||
m_viewSettings = viewSettings;
|
||||
viewSettings_ = viewSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +180,7 @@ class CompositorContext {
|
||||
*/
|
||||
const ColorManagedViewSettings *getViewSettings() const
|
||||
{
|
||||
return m_viewSettings;
|
||||
return viewSettings_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings)
|
||||
{
|
||||
m_displaySettings = displaySettings;
|
||||
displaySettings_ = displaySettings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +196,7 @@ class CompositorContext {
|
||||
*/
|
||||
const ColorManagedDisplaySettings *getDisplaySettings() const
|
||||
{
|
||||
return m_displaySettings;
|
||||
return displaySettings_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setQuality(eCompositorQuality quality)
|
||||
{
|
||||
m_quality = quality;
|
||||
quality_ = quality;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +212,7 @@ class CompositorContext {
|
||||
*/
|
||||
eCompositorQuality getQuality() const
|
||||
{
|
||||
return m_quality;
|
||||
return quality_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +225,7 @@ class CompositorContext {
|
||||
*/
|
||||
bool getHasActiveOpenCLDevices() const
|
||||
{
|
||||
return m_hasActiveOpenCLDevices;
|
||||
return hasActiveOpenCLDevices_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,13 +233,13 @@ class CompositorContext {
|
||||
*/
|
||||
void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices)
|
||||
{
|
||||
m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices;
|
||||
hasActiveOpenCLDevices_ = hasAvtiveOpenCLDevices;
|
||||
}
|
||||
|
||||
/** Whether it has a view with a specific name and not the default one. */
|
||||
bool has_explicit_view() const
|
||||
{
|
||||
return m_viewName && m_viewName[0] != '\0';
|
||||
return viewName_ && viewName_[0] != '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +247,7 @@ class CompositorContext {
|
||||
*/
|
||||
const char *getViewName() const
|
||||
{
|
||||
return m_viewName;
|
||||
return viewName_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,7 +255,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setViewName(const char *viewName)
|
||||
{
|
||||
m_viewName = viewName;
|
||||
viewName_ = viewName;
|
||||
}
|
||||
|
||||
int getChunksize() const
|
||||
@@ -265,11 +265,11 @@ class CompositorContext {
|
||||
|
||||
void setFastCalculation(bool fastCalculation)
|
||||
{
|
||||
m_fastCalculation = fastCalculation;
|
||||
fastCalculation_ = fastCalculation;
|
||||
}
|
||||
bool isFastCalculation() const
|
||||
{
|
||||
return m_fastCalculation;
|
||||
return fastCalculation_;
|
||||
}
|
||||
bool isGroupnodeBufferEnabled() const
|
||||
{
|
||||
@@ -282,7 +282,7 @@ class CompositorContext {
|
||||
*/
|
||||
float getRenderPercentageAsFactor() const
|
||||
{
|
||||
return m_rd->size * 0.01f;
|
||||
return rd_->size * 0.01f;
|
||||
}
|
||||
|
||||
Size2f get_render_size() const;
|
||||
|
||||
@@ -35,12 +35,12 @@ extern "C" {
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
int DebugInfo::m_file_index = 0;
|
||||
DebugInfo::NodeNameMap DebugInfo::m_node_names;
|
||||
DebugInfo::OpNameMap DebugInfo::m_op_names;
|
||||
std::string DebugInfo::m_current_node_name;
|
||||
std::string DebugInfo::m_current_op_name;
|
||||
DebugInfo::GroupStateMap DebugInfo::m_group_states;
|
||||
int DebugInfo::file_index_ = 0;
|
||||
DebugInfo::NodeNameMap DebugInfo::node_names_;
|
||||
DebugInfo::OpNameMap DebugInfo::op_names_;
|
||||
std::string DebugInfo::current_node_name_;
|
||||
std::string DebugInfo::current_op_name_;
|
||||
DebugInfo::GroupStateMap DebugInfo::group_states_;
|
||||
|
||||
static std::string operation_class_name(const NodeOperation *op)
|
||||
{
|
||||
@@ -53,8 +53,8 @@ static std::string operation_class_name(const NodeOperation *op)
|
||||
|
||||
std::string DebugInfo::node_name(const Node *node)
|
||||
{
|
||||
NodeNameMap::const_iterator it = m_node_names.find(node);
|
||||
if (it != m_node_names.end()) {
|
||||
NodeNameMap::const_iterator it = node_names_.find(node);
|
||||
if (it != node_names_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return "";
|
||||
@@ -62,8 +62,8 @@ std::string DebugInfo::node_name(const Node *node)
|
||||
|
||||
std::string DebugInfo::operation_name(const NodeOperation *op)
|
||||
{
|
||||
OpNameMap::const_iterator it = m_op_names.find(op);
|
||||
if (it != m_op_names.end()) {
|
||||
OpNameMap::const_iterator it = op_names_.find(op);
|
||||
if (it != op_names_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return "";
|
||||
@@ -300,25 +300,25 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
|
||||
std::map<NodeOperation *, std::vector<std::string>> op_groups;
|
||||
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, "subgraph cluster_%d{\r\n", index);
|
||||
/* 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");
|
||||
}
|
||||
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, "color=black\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, "color=black\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);
|
||||
op_groups[operation].push_back(std::string(strbuf));
|
||||
@@ -332,7 +332,7 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
}
|
||||
|
||||
/* 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()) {
|
||||
continue;
|
||||
}
|
||||
@@ -343,7 +343,7 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
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) {
|
||||
ReadBufferOperation *read = (ReadBufferOperation *)operation;
|
||||
WriteBufferOperation *write = read->getMemoryProxy()->getWriteBufferOperation();
|
||||
@@ -364,8 +364,8 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
}
|
||||
}
|
||||
|
||||
for (NodeOperation *op : system->m_operations) {
|
||||
for (NodeOperationInput &to : op->m_inputs) {
|
||||
for (NodeOperation *op : system->operations_) {
|
||||
for (NodeOperationInput &to : op->inputs_) {
|
||||
NodeOperationOutput *from = to.getLink();
|
||||
|
||||
if (!from) {
|
||||
@@ -418,7 +418,7 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
|
||||
const bool has_execution_groups = system->getContext().get_execution_model() ==
|
||||
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 += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
|
||||
@@ -437,13 +437,13 @@ void DebugInfo::graphviz(const ExecutionSystem *system, StringRefNull name)
|
||||
char filename[FILE_MAX];
|
||||
|
||||
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 {
|
||||
BLI_strncpy(basename, (name + ".dot").c_str(), sizeof(basename));
|
||||
}
|
||||
BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), basename);
|
||||
m_file_index++;
|
||||
file_index_++;
|
||||
|
||||
std::cout << "Writing compositor debug to: " << filename << "\n";
|
||||
|
||||
|
||||
@@ -52,33 +52,33 @@ class DebugInfo {
|
||||
static std::string operation_name(const NodeOperation *op);
|
||||
|
||||
private:
|
||||
static int m_file_index;
|
||||
static int file_index_;
|
||||
/** 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. */
|
||||
static OpNameMap m_op_names;
|
||||
static OpNameMap op_names_;
|
||||
/** 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. */
|
||||
static std::string m_current_op_name;
|
||||
static std::string current_op_name_;
|
||||
/** For visualizing group states. */
|
||||
static GroupStateMap m_group_states;
|
||||
static GroupStateMap group_states_;
|
||||
|
||||
public:
|
||||
static void convert_started()
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_op_names.clear();
|
||||
op_names_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
static void execute_started(const ExecutionSystem *system)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_file_index = 1;
|
||||
m_group_states.clear();
|
||||
for (ExecutionGroup *execution_group : system->m_groups) {
|
||||
m_group_states[execution_group] = EG_WAIT;
|
||||
file_index_ = 1;
|
||||
group_states_.clear();
|
||||
for (ExecutionGroup *execution_group : system->groups_) {
|
||||
group_states_[execution_group] = EG_WAIT;
|
||||
}
|
||||
}
|
||||
if (COM_EXPORT_OPERATION_BUFFERS) {
|
||||
@@ -89,41 +89,41 @@ class DebugInfo {
|
||||
static void node_added(const Node *node)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_node_names[node] = std::string(node->getbNode() ? node->getbNode()->name : "");
|
||||
node_names_[node] = std::string(node->getbNode() ? node->getbNode()->name : "");
|
||||
}
|
||||
}
|
||||
|
||||
static void node_to_operations(const Node *node)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_group_states[group] = EG_RUNNING;
|
||||
group_states_[group] = EG_RUNNING;
|
||||
}
|
||||
};
|
||||
static void execution_group_finished(const ExecutionGroup *group)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_group_states[group] = EG_FINISHED;
|
||||
group_states_[group] = EG_FINISHED;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -55,17 +55,17 @@ std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags)
|
||||
|
||||
ExecutionGroup::ExecutionGroup(int id)
|
||||
{
|
||||
m_id = id;
|
||||
m_bTree = nullptr;
|
||||
m_height = 0;
|
||||
m_width = 0;
|
||||
m_max_read_buffer_offset = 0;
|
||||
m_x_chunks_len = 0;
|
||||
m_y_chunks_len = 0;
|
||||
m_chunks_len = 0;
|
||||
m_chunks_finished = 0;
|
||||
BLI_rcti_init(&m_viewerBorder, 0, 0, 0, 0);
|
||||
m_executionStartTime = 0;
|
||||
id_ = id;
|
||||
bTree_ = nullptr;
|
||||
height_ = 0;
|
||||
width_ = 0;
|
||||
max_read_buffer_offset_ = 0;
|
||||
x_chunks_len_ = 0;
|
||||
y_chunks_len_ = 0;
|
||||
chunks_len_ = 0;
|
||||
chunks_finished_ = 0;
|
||||
BLI_rcti_init(&viewerBorder_, 0, 0, 0, 0);
|
||||
executionStartTime_ = 0;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ExecutionGroup &execution_group)
|
||||
@@ -84,7 +84,7 @@ eCompositorPriority ExecutionGroup::getRenderPriority()
|
||||
|
||||
bool ExecutionGroup::can_contain(NodeOperation &operation)
|
||||
{
|
||||
if (!m_flags.initialized) {
|
||||
if (!flags_.initialized) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ bool ExecutionGroup::can_contain(NodeOperation &operation)
|
||||
}
|
||||
|
||||
/* complex groups don't allow further ops (except read buffer and values, see above) */
|
||||
if (m_flags.complex) {
|
||||
if (flags_.complex) {
|
||||
return false;
|
||||
}
|
||||
/* complex ops can't be added to other groups (except their own, which they initialize, see
|
||||
@@ -119,13 +119,13 @@ bool ExecutionGroup::addOperation(NodeOperation *operation)
|
||||
|
||||
if (!operation->get_flags().is_read_buffer_operation &&
|
||||
!operation->get_flags().is_write_buffer_operation) {
|
||||
m_flags.complex = operation->get_flags().complex;
|
||||
m_flags.open_cl = operation->get_flags().open_cl;
|
||||
m_flags.single_threaded = operation->get_flags().single_threaded;
|
||||
m_flags.initialized = true;
|
||||
flags_.complex = operation->get_flags().complex;
|
||||
flags_.open_cl = operation->get_flags().open_cl;
|
||||
flags_.single_threaded = operation->get_flags().single_threaded;
|
||||
flags_.initialized = true;
|
||||
}
|
||||
|
||||
m_operations.append(operation);
|
||||
operations_.append(operation);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -133,20 +133,20 @@ bool ExecutionGroup::addOperation(NodeOperation *operation)
|
||||
NodeOperation *ExecutionGroup::getOutputOperation() const
|
||||
{
|
||||
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()
|
||||
{
|
||||
m_work_packages.clear();
|
||||
if (m_chunks_len != 0) {
|
||||
m_work_packages.resize(m_chunks_len);
|
||||
for (unsigned int index = 0; index < m_chunks_len; index++) {
|
||||
m_work_packages[index].type = eWorkPackageType::Tile;
|
||||
m_work_packages[index].state = eWorkPackageState::NotScheduled;
|
||||
m_work_packages[index].execution_group = this;
|
||||
m_work_packages[index].chunk_number = index;
|
||||
determineChunkRect(&m_work_packages[index].rect, index);
|
||||
work_packages_.clear();
|
||||
if (chunks_len_ != 0) {
|
||||
work_packages_.resize(chunks_len_);
|
||||
for (unsigned int index = 0; index < chunks_len_; index++) {
|
||||
work_packages_[index].type = eWorkPackageType::Tile;
|
||||
work_packages_[index].state = eWorkPackageState::NotScheduled;
|
||||
work_packages_[index].execution_group = this;
|
||||
work_packages_[index].chunk_number = index;
|
||||
determineChunkRect(&work_packages_[index].rect, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,15 +154,15 @@ void ExecutionGroup::init_work_packages()
|
||||
void ExecutionGroup::init_read_buffer_operations()
|
||||
{
|
||||
unsigned int max_offset = 0;
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
for (NodeOperation *operation : operations_) {
|
||||
if (operation->get_flags().is_read_buffer_operation) {
|
||||
ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation);
|
||||
m_read_operations.append(readOperation);
|
||||
read_operations_.append(readOperation);
|
||||
max_offset = MAX2(max_offset, readOperation->getOffset());
|
||||
}
|
||||
}
|
||||
max_offset++;
|
||||
m_max_read_buffer_offset = max_offset;
|
||||
max_read_buffer_offset_ = max_offset;
|
||||
}
|
||||
|
||||
void ExecutionGroup::initExecution()
|
||||
@@ -174,12 +174,12 @@ void ExecutionGroup::initExecution()
|
||||
|
||||
void ExecutionGroup::deinitExecution()
|
||||
{
|
||||
m_work_packages.clear();
|
||||
m_chunks_len = 0;
|
||||
m_x_chunks_len = 0;
|
||||
m_y_chunks_len = 0;
|
||||
m_read_operations.clear();
|
||||
m_bTree = nullptr;
|
||||
work_packages_.clear();
|
||||
chunks_len_ = 0;
|
||||
x_chunks_len_ = 0;
|
||||
y_chunks_len_ = 0;
|
||||
read_operations_.clear();
|
||||
bTree_ = nullptr;
|
||||
}
|
||||
|
||||
void ExecutionGroup::determineResolution(unsigned int resolution[2])
|
||||
@@ -188,30 +188,30 @@ void ExecutionGroup::determineResolution(unsigned int resolution[2])
|
||||
resolution[0] = operation->getWidth();
|
||||
resolution[1] = operation->getHeight();
|
||||
this->setResolution(resolution);
|
||||
BLI_rcti_init(&m_viewerBorder, 0, m_width, 0, m_height);
|
||||
BLI_rcti_init(&viewerBorder_, 0, width_, 0, height_);
|
||||
}
|
||||
|
||||
void ExecutionGroup::init_number_of_chunks()
|
||||
{
|
||||
if (m_flags.single_threaded) {
|
||||
m_x_chunks_len = 1;
|
||||
m_y_chunks_len = 1;
|
||||
m_chunks_len = 1;
|
||||
if (flags_.single_threaded) {
|
||||
x_chunks_len_ = 1;
|
||||
y_chunks_len_ = 1;
|
||||
chunks_len_ = 1;
|
||||
}
|
||||
else {
|
||||
const float chunkSizef = m_chunkSize;
|
||||
const int border_width = BLI_rcti_size_x(&m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&m_viewerBorder);
|
||||
m_x_chunks_len = ceil(border_width / chunkSizef);
|
||||
m_y_chunks_len = ceil(border_height / chunkSizef);
|
||||
m_chunks_len = m_x_chunks_len * m_y_chunks_len;
|
||||
const float chunkSizef = chunkSize_;
|
||||
const int border_width = BLI_rcti_size_x(&viewerBorder_);
|
||||
const int border_height = BLI_rcti_size_y(&viewerBorder_);
|
||||
x_chunks_len_ = ceil(border_width / chunkSizef);
|
||||
y_chunks_len_ = ceil(border_height / chunkSizef);
|
||||
chunks_len_ = x_chunks_len_ * y_chunks_len_;
|
||||
}
|
||||
}
|
||||
|
||||
blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
{
|
||||
blender::Array<unsigned int> chunk_order(m_chunks_len);
|
||||
for (int chunk_index = 0; chunk_index < m_chunks_len; chunk_index++) {
|
||||
blender::Array<unsigned int> chunk_order(chunks_len_);
|
||||
for (int chunk_index = 0; chunk_index < chunks_len_; chunk_index++) {
|
||||
chunk_order[chunk_index] = chunk_index;
|
||||
}
|
||||
|
||||
@@ -227,8 +227,8 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
order_type = viewer->getChunkOrder();
|
||||
}
|
||||
|
||||
const int border_width = BLI_rcti_size_x(&m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&m_viewerBorder);
|
||||
const int border_width = BLI_rcti_size_x(&viewerBorder_);
|
||||
const int border_height = BLI_rcti_size_y(&viewerBorder_);
|
||||
int index;
|
||||
switch (order_type) {
|
||||
case ChunkOrdering::Random: {
|
||||
@@ -241,17 +241,17 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
}
|
||||
case ChunkOrdering::CenterOut: {
|
||||
ChunkOrderHotspot hotspot(border_width * centerX, border_height * centerY, 0.0f);
|
||||
blender::Array<ChunkOrder> chunk_orders(m_chunks_len);
|
||||
for (index = 0; index < m_chunks_len; index++) {
|
||||
const WorkPackage &work_package = m_work_packages[index];
|
||||
blender::Array<ChunkOrder> chunk_orders(chunks_len_);
|
||||
for (index = 0; index < chunks_len_; index++) {
|
||||
const WorkPackage &work_package = work_packages_[index];
|
||||
chunk_orders[index].index = index;
|
||||
chunk_orders[index].x = work_package.rect.xmin - m_viewerBorder.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - m_viewerBorder.ymin;
|
||||
chunk_orders[index].x = work_package.rect.xmin - viewerBorder_.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - viewerBorder_.ymin;
|
||||
chunk_orders[index].update_distance(&hotspot, 1);
|
||||
}
|
||||
|
||||
std::sort(&chunk_orders[0], &chunk_orders[m_chunks_len - 1]);
|
||||
for (index = 0; index < m_chunks_len; index++) {
|
||||
std::sort(&chunk_orders[0], &chunk_orders[chunks_len_ - 1]);
|
||||
for (index = 0; index < chunks_len_; index++) {
|
||||
chunk_order[index] = chunk_orders[index].index;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
unsigned int my = border_height / 2;
|
||||
unsigned int bx = mx + 2 * tx;
|
||||
unsigned int by = my + 2 * ty;
|
||||
float addition = m_chunks_len / COM_RULE_OF_THIRDS_DIVIDER;
|
||||
float addition = chunks_len_ / COM_RULE_OF_THIRDS_DIVIDER;
|
||||
|
||||
ChunkOrderHotspot hotspots[9]{
|
||||
ChunkOrderHotspot(mx, my, addition * 0),
|
||||
@@ -278,18 +278,18 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
ChunkOrderHotspot(mx, by, addition * 8),
|
||||
};
|
||||
|
||||
blender::Array<ChunkOrder> chunk_orders(m_chunks_len);
|
||||
for (index = 0; index < m_chunks_len; index++) {
|
||||
const WorkPackage &work_package = m_work_packages[index];
|
||||
blender::Array<ChunkOrder> chunk_orders(chunks_len_);
|
||||
for (index = 0; index < chunks_len_; index++) {
|
||||
const WorkPackage &work_package = work_packages_[index];
|
||||
chunk_orders[index].index = index;
|
||||
chunk_orders[index].x = work_package.rect.xmin - m_viewerBorder.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - m_viewerBorder.ymin;
|
||||
chunk_orders[index].x = work_package.rect.xmin - viewerBorder_.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - viewerBorder_.ymin;
|
||||
chunk_orders[index].update_distance(hotspots, 9);
|
||||
}
|
||||
|
||||
std::sort(&chunk_orders[0], &chunk_orders[m_chunks_len]);
|
||||
std::sort(&chunk_orders[0], &chunk_orders[chunks_len_]);
|
||||
|
||||
for (index = 0; index < m_chunks_len; index++) {
|
||||
for (index = 0; index < chunks_len_; index++) {
|
||||
chunk_order[index] = chunk_orders[index].index;
|
||||
}
|
||||
|
||||
@@ -310,21 +310,21 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
|
||||
{
|
||||
const CompositorContext &context = graph->getContext();
|
||||
const bNodeTree *bTree = context.getbNodeTree();
|
||||
if (m_width == 0 || m_height == 0) {
|
||||
if (width_ == 0 || height_ == 0) {
|
||||
return;
|
||||
} /** \note Break out... no pixels to calculate. */
|
||||
if (bTree->test_break && bTree->test_break(bTree->tbh)) {
|
||||
return;
|
||||
} /** \note Early break out for blur and preview nodes. */
|
||||
if (m_chunks_len == 0) {
|
||||
if (chunks_len_ == 0) {
|
||||
return;
|
||||
} /** \note Early break out. */
|
||||
unsigned int chunk_index;
|
||||
|
||||
m_executionStartTime = PIL_check_seconds_timer();
|
||||
executionStartTime_ = PIL_check_seconds_timer();
|
||||
|
||||
m_chunks_finished = 0;
|
||||
m_bTree = bTree;
|
||||
chunks_finished_ = 0;
|
||||
bTree_ = bTree;
|
||||
|
||||
blender::Array<unsigned int> chunk_order = get_execution_order();
|
||||
|
||||
@@ -341,12 +341,12 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
|
||||
finished = true;
|
||||
int numberEvaluated = 0;
|
||||
|
||||
for (int index = startIndex; index < m_chunks_len && numberEvaluated < maxNumberEvaluated;
|
||||
for (int index = startIndex; index < chunks_len_ && numberEvaluated < maxNumberEvaluated;
|
||||
index++) {
|
||||
chunk_index = chunk_order[index];
|
||||
int yChunk = chunk_index / m_x_chunks_len;
|
||||
int xChunk = chunk_index - (yChunk * m_x_chunks_len);
|
||||
const WorkPackage &work_package = m_work_packages[chunk_index];
|
||||
int yChunk = chunk_index / x_chunks_len_;
|
||||
int xChunk = chunk_index - (yChunk * x_chunks_len_);
|
||||
const WorkPackage &work_package = work_packages_[chunk_index];
|
||||
switch (work_package.state) {
|
||||
case eWorkPackageState::NotScheduled: {
|
||||
scheduleChunkWhenPossible(graph, xChunk, yChunk);
|
||||
@@ -385,12 +385,12 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
|
||||
|
||||
MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber)
|
||||
{
|
||||
WorkPackage &work_package = m_work_packages[chunkNumber];
|
||||
WorkPackage &work_package = work_packages_[chunkNumber];
|
||||
|
||||
MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN(
|
||||
sizeof(MemoryBuffer *) * m_max_read_buffer_offset, __func__);
|
||||
sizeof(MemoryBuffer *) * max_read_buffer_offset_, __func__);
|
||||
rcti output;
|
||||
for (ReadBufferOperation *readOperation : m_read_operations) {
|
||||
for (ReadBufferOperation *readOperation : read_operations_) {
|
||||
MemoryProxy *memoryProxy = readOperation->getMemoryProxy();
|
||||
this->determineDependingAreaOfInterest(&work_package.rect, readOperation, &output);
|
||||
MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(
|
||||
@@ -411,14 +411,14 @@ MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy &mem
|
||||
|
||||
void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers)
|
||||
{
|
||||
WorkPackage &work_package = m_work_packages[chunkNumber];
|
||||
WorkPackage &work_package = work_packages_[chunkNumber];
|
||||
if (work_package.state == eWorkPackageState::Scheduled) {
|
||||
work_package.state = eWorkPackageState::Executed;
|
||||
}
|
||||
|
||||
atomic_add_and_fetch_u(&m_chunks_finished, 1);
|
||||
atomic_add_and_fetch_u(&chunks_finished_, 1);
|
||||
if (memoryBuffers) {
|
||||
for (unsigned int index = 0; index < m_max_read_buffer_offset; index++) {
|
||||
for (unsigned int index = 0; index < max_read_buffer_offset_; index++) {
|
||||
MemoryBuffer *buffer = memoryBuffers[index];
|
||||
if (buffer) {
|
||||
if (buffer->isTemporarily()) {
|
||||
@@ -429,16 +429,16 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo
|
||||
}
|
||||
MEM_freeN(memoryBuffers);
|
||||
}
|
||||
if (m_bTree) {
|
||||
if (bTree_) {
|
||||
/* Status report is only performed for top level Execution Groups. */
|
||||
float progress = m_chunks_finished;
|
||||
progress /= m_chunks_len;
|
||||
m_bTree->progress(m_bTree->prh, progress);
|
||||
float progress = chunks_finished_;
|
||||
progress /= chunks_len_;
|
||||
bTree_->progress(bTree_->prh, progress);
|
||||
|
||||
char buf[128];
|
||||
BLI_snprintf(
|
||||
buf, sizeof(buf), TIP_("Compositing | Tile %u-%u"), m_chunks_finished, m_chunks_len);
|
||||
m_bTree->stats_draw(m_bTree->sdh, buf);
|
||||
buf, sizeof(buf), TIP_("Compositing | Tile %u-%u"), chunks_finished_, chunks_len_);
|
||||
bTree_->stats_draw(bTree_->sdh, buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,29 +446,29 @@ inline void ExecutionGroup::determineChunkRect(rcti *r_rect,
|
||||
const unsigned int xChunk,
|
||||
const unsigned int yChunk) const
|
||||
{
|
||||
const int border_width = BLI_rcti_size_x(&m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&m_viewerBorder);
|
||||
const int border_width = BLI_rcti_size_x(&viewerBorder_);
|
||||
const int border_height = BLI_rcti_size_y(&viewerBorder_);
|
||||
|
||||
if (m_flags.single_threaded) {
|
||||
BLI_rcti_init(r_rect, m_viewerBorder.xmin, border_width, m_viewerBorder.ymin, border_height);
|
||||
if (flags_.single_threaded) {
|
||||
BLI_rcti_init(r_rect, viewerBorder_.xmin, border_width, viewerBorder_.ymin, border_height);
|
||||
}
|
||||
else {
|
||||
const unsigned int minx = xChunk * m_chunkSize + m_viewerBorder.xmin;
|
||||
const unsigned int miny = yChunk * m_chunkSize + m_viewerBorder.ymin;
|
||||
const unsigned int width = MIN2((unsigned int)m_viewerBorder.xmax, m_width);
|
||||
const unsigned int height = MIN2((unsigned int)m_viewerBorder.ymax, m_height);
|
||||
const unsigned int minx = xChunk * chunkSize_ + viewerBorder_.xmin;
|
||||
const unsigned int miny = yChunk * chunkSize_ + viewerBorder_.ymin;
|
||||
const unsigned int width = MIN2((unsigned int)viewerBorder_.xmax, width_);
|
||||
const unsigned int height = MIN2((unsigned int)viewerBorder_.ymax, height_);
|
||||
BLI_rcti_init(r_rect,
|
||||
MIN2(minx, m_width),
|
||||
MIN2(minx + m_chunkSize, width),
|
||||
MIN2(miny, m_height),
|
||||
MIN2(miny + m_chunkSize, height));
|
||||
MIN2(minx, width_),
|
||||
MIN2(minx + chunkSize_, width),
|
||||
MIN2(miny, height_),
|
||||
MIN2(miny + chunkSize_, height));
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionGroup::determineChunkRect(rcti *r_rect, const unsigned int chunkNumber) const
|
||||
{
|
||||
const unsigned int yChunk = chunkNumber / m_x_chunks_len;
|
||||
const unsigned int xChunk = chunkNumber - (yChunk * m_x_chunks_len);
|
||||
const unsigned int yChunk = chunkNumber / x_chunks_len_;
|
||||
const unsigned int xChunk = chunkNumber - (yChunk * x_chunks_len_);
|
||||
determineChunkRect(r_rect, xChunk, yChunk);
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ MemoryBuffer *ExecutionGroup::allocateOutputBuffer(rcti &rect)
|
||||
|
||||
bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area)
|
||||
{
|
||||
if (m_flags.single_threaded) {
|
||||
if (flags_.single_threaded) {
|
||||
return scheduleChunkWhenPossible(graph, 0, 0);
|
||||
}
|
||||
/* Find all chunks inside the rect
|
||||
@@ -495,18 +495,18 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area
|
||||
* where x and y are chunk-numbers. */
|
||||
|
||||
int indexx, indexy;
|
||||
int minx = max_ii(area->xmin - m_viewerBorder.xmin, 0);
|
||||
int maxx = min_ii(area->xmax - m_viewerBorder.xmin, m_viewerBorder.xmax - m_viewerBorder.xmin);
|
||||
int miny = max_ii(area->ymin - m_viewerBorder.ymin, 0);
|
||||
int maxy = min_ii(area->ymax - m_viewerBorder.ymin, m_viewerBorder.ymax - m_viewerBorder.ymin);
|
||||
int minxchunk = minx / (int)m_chunkSize;
|
||||
int maxxchunk = (maxx + (int)m_chunkSize - 1) / (int)m_chunkSize;
|
||||
int minychunk = miny / (int)m_chunkSize;
|
||||
int maxychunk = (maxy + (int)m_chunkSize - 1) / (int)m_chunkSize;
|
||||
int minx = max_ii(area->xmin - viewerBorder_.xmin, 0);
|
||||
int maxx = min_ii(area->xmax - viewerBorder_.xmin, viewerBorder_.xmax - viewerBorder_.xmin);
|
||||
int miny = max_ii(area->ymin - viewerBorder_.ymin, 0);
|
||||
int maxy = min_ii(area->ymax - viewerBorder_.ymin, viewerBorder_.ymax - viewerBorder_.ymin);
|
||||
int minxchunk = minx / (int)chunkSize_;
|
||||
int maxxchunk = (maxx + (int)chunkSize_ - 1) / (int)chunkSize_;
|
||||
int minychunk = miny / (int)chunkSize_;
|
||||
int maxychunk = (maxy + (int)chunkSize_ - 1) / (int)chunkSize_;
|
||||
minxchunk = max_ii(minxchunk, 0);
|
||||
minychunk = max_ii(minychunk, 0);
|
||||
maxxchunk = min_ii(maxxchunk, (int)m_x_chunks_len);
|
||||
maxychunk = min_ii(maxychunk, (int)m_y_chunks_len);
|
||||
maxxchunk = min_ii(maxxchunk, (int)x_chunks_len_);
|
||||
maxychunk = min_ii(maxychunk, (int)y_chunks_len_);
|
||||
|
||||
bool result = true;
|
||||
for (indexx = minxchunk; indexx < maxxchunk; indexx++) {
|
||||
@@ -522,7 +522,7 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area
|
||||
|
||||
bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber)
|
||||
{
|
||||
WorkPackage &work_package = m_work_packages[chunkNumber];
|
||||
WorkPackage &work_package = work_packages_[chunkNumber];
|
||||
if (work_package.state == eWorkPackageState::NotScheduled) {
|
||||
work_package.state = eWorkPackageState::Scheduled;
|
||||
WorkScheduler::schedule(&work_package);
|
||||
@@ -535,16 +535,16 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph,
|
||||
const int chunk_x,
|
||||
const int chunk_y)
|
||||
{
|
||||
if (chunk_x < 0 || chunk_x >= (int)m_x_chunks_len) {
|
||||
if (chunk_x < 0 || chunk_x >= (int)x_chunks_len_) {
|
||||
return true;
|
||||
}
|
||||
if (chunk_y < 0 || chunk_y >= (int)m_y_chunks_len) {
|
||||
if (chunk_y < 0 || chunk_y >= (int)y_chunks_len_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check if chunk is already executed or scheduled and not yet executed. */
|
||||
const int chunk_index = chunk_y * m_x_chunks_len + chunk_x;
|
||||
WorkPackage &work_package = m_work_packages[chunk_index];
|
||||
const int chunk_index = chunk_y * x_chunks_len_ + chunk_x;
|
||||
WorkPackage &work_package = work_packages_[chunk_index];
|
||||
if (work_package.state == eWorkPackageState::Executed) {
|
||||
return true;
|
||||
}
|
||||
@@ -555,7 +555,7 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph,
|
||||
bool can_be_executed = true;
|
||||
rcti area;
|
||||
|
||||
for (ReadBufferOperation *read_operation : m_read_operations) {
|
||||
for (ReadBufferOperation *read_operation : read_operations_) {
|
||||
BLI_rcti_init(&area, 0, 0, 0, 0);
|
||||
MemoryProxy *memory_proxy = read_operation->getMemoryProxy();
|
||||
determineDependingAreaOfInterest(&work_package.rect, read_operation, &area);
|
||||
@@ -584,8 +584,7 @@ void ExecutionGroup::setViewerBorder(float xmin, float xmax, float ymin, float y
|
||||
{
|
||||
const NodeOperation &operation = *this->getOutputOperation();
|
||||
if (operation.get_flags().use_viewer_border) {
|
||||
BLI_rcti_init(
|
||||
&m_viewerBorder, xmin * m_width, xmax * m_width, ymin * m_height, ymax * m_height);
|
||||
BLI_rcti_init(&viewerBorder_, xmin * width_, xmax * width_, ymin * height_, ymax * height_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,8 +592,7 @@ void ExecutionGroup::setRenderBorder(float xmin, float xmax, float ymin, float y
|
||||
{
|
||||
const NodeOperation &operation = *this->getOutputOperation();
|
||||
if (operation.isOutputOperation(true) && operation.get_flags().use_render_border) {
|
||||
BLI_rcti_init(
|
||||
&m_viewerBorder, xmin * m_width, xmax * m_width, ymin * m_height, ymax * m_height);
|
||||
BLI_rcti_init(&viewerBorder_, xmin * width_, xmax * width_, ymin * height_, ymax * height_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,84 +86,84 @@ class ExecutionGroup {
|
||||
/**
|
||||
* Id of the execution group. For debugging purposes.
|
||||
*/
|
||||
int m_id;
|
||||
int id_;
|
||||
|
||||
/**
|
||||
* \brief list of operations in this ExecutionGroup
|
||||
*/
|
||||
Vector<NodeOperation *> m_operations;
|
||||
Vector<NodeOperation *> operations_;
|
||||
|
||||
ExecutionGroupFlags m_flags;
|
||||
ExecutionGroupFlags flags_;
|
||||
|
||||
/**
|
||||
* \brief Width of the output
|
||||
*/
|
||||
unsigned int m_width;
|
||||
unsigned int width_;
|
||||
|
||||
/**
|
||||
* \brief Height of the output
|
||||
*/
|
||||
unsigned int m_height;
|
||||
unsigned int 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
|
||||
*/
|
||||
unsigned int m_chunkSize;
|
||||
unsigned int chunkSize_;
|
||||
|
||||
/**
|
||||
* \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
|
||||
*/
|
||||
unsigned int m_y_chunks_len;
|
||||
unsigned int y_chunks_len_;
|
||||
|
||||
/**
|
||||
* \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.
|
||||
* \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.
|
||||
*/
|
||||
Vector<ReadBufferOperation *> m_read_operations;
|
||||
Vector<ReadBufferOperation *> read_operations_;
|
||||
|
||||
/**
|
||||
* \brief reference to the original bNodeTree,
|
||||
* this field is only set for the 'top' execution group.
|
||||
* \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
|
||||
*/
|
||||
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
|
||||
* \note measured in pixel space
|
||||
*/
|
||||
rcti m_viewerBorder;
|
||||
rcti viewerBorder_;
|
||||
|
||||
/**
|
||||
* \brief start time of execution
|
||||
*/
|
||||
double m_executionStartTime;
|
||||
double executionStartTime_;
|
||||
|
||||
// methods
|
||||
/**
|
||||
@@ -241,12 +241,12 @@ class ExecutionGroup {
|
||||
|
||||
int get_id() const
|
||||
{
|
||||
return m_id;
|
||||
return id_;
|
||||
}
|
||||
|
||||
const ExecutionGroupFlags get_flags() const
|
||||
{
|
||||
return m_flags;
|
||||
return flags_;
|
||||
}
|
||||
|
||||
// methods
|
||||
@@ -266,7 +266,7 @@ class ExecutionGroup {
|
||||
*/
|
||||
void setOutputExecutionGroup(bool is_output)
|
||||
{
|
||||
m_flags.is_output = is_output;
|
||||
flags_.is_output = is_output;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,8 +281,8 @@ class ExecutionGroup {
|
||||
*/
|
||||
void setResolution(unsigned int resolution[2])
|
||||
{
|
||||
m_width = resolution[0];
|
||||
m_height = resolution[1];
|
||||
width_ = resolution[0];
|
||||
height_ = resolution[1];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,7 +290,7 @@ class ExecutionGroup {
|
||||
*/
|
||||
unsigned int getWidth() const
|
||||
{
|
||||
return m_width;
|
||||
return width_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,7 +298,7 @@ class ExecutionGroup {
|
||||
*/
|
||||
unsigned int getHeight() const
|
||||
{
|
||||
return m_height;
|
||||
return height_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,7 +381,7 @@ class ExecutionGroup {
|
||||
|
||||
void setChunksize(int chunksize)
|
||||
{
|
||||
m_chunkSize = chunksize;
|
||||
chunkSize_ = chunksize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,40 +43,40 @@ ExecutionSystem::ExecutionSystem(RenderData *rd,
|
||||
const char *viewName)
|
||||
{
|
||||
num_work_threads_ = WorkScheduler::get_num_cpu_threads();
|
||||
m_context.setViewName(viewName);
|
||||
m_context.setScene(scene);
|
||||
m_context.setbNodeTree(editingtree);
|
||||
m_context.setPreviewHash(editingtree->previews);
|
||||
m_context.setFastCalculation(fastcalculation);
|
||||
context_.setViewName(viewName);
|
||||
context_.setScene(scene);
|
||||
context_.setbNodeTree(editingtree);
|
||||
context_.setPreviewHash(editingtree->previews);
|
||||
context_.setFastCalculation(fastcalculation);
|
||||
/* initialize the CompositorContext */
|
||||
if (rendering) {
|
||||
m_context.setQuality((eCompositorQuality)editingtree->render_quality);
|
||||
context_.setQuality((eCompositorQuality)editingtree->render_quality);
|
||||
}
|
||||
else {
|
||||
m_context.setQuality((eCompositorQuality)editingtree->edit_quality);
|
||||
context_.setQuality((eCompositorQuality)editingtree->edit_quality);
|
||||
}
|
||||
m_context.setRendering(rendering);
|
||||
m_context.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() &&
|
||||
context_.setRendering(rendering);
|
||||
context_.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() &&
|
||||
(editingtree->flag & NTREE_COM_OPENCL));
|
||||
|
||||
m_context.setRenderData(rd);
|
||||
m_context.setViewSettings(viewSettings);
|
||||
m_context.setDisplaySettings(displaySettings);
|
||||
context_.setRenderData(rd);
|
||||
context_.setViewSettings(viewSettings);
|
||||
context_.setDisplaySettings(displaySettings);
|
||||
|
||||
BLI_mutex_init(&work_mutex_);
|
||||
BLI_condition_init(&work_finished_cond_);
|
||||
|
||||
{
|
||||
NodeOperationBuilder builder(&m_context, editingtree, this);
|
||||
NodeOperationBuilder builder(&context_, editingtree, this);
|
||||
builder.convertToOperations(this);
|
||||
}
|
||||
|
||||
switch (m_context.get_execution_model()) {
|
||||
switch (context_.get_execution_model()) {
|
||||
case eExecutionModel::Tiled:
|
||||
execution_model_ = new TiledExecutionModel(m_context, m_operations, m_groups);
|
||||
execution_model_ = new TiledExecutionModel(context_, operations_, groups_);
|
||||
break;
|
||||
case eExecutionModel::FullFrame:
|
||||
execution_model_ = new FullFrameExecutionModel(m_context, active_buffers_, m_operations);
|
||||
execution_model_ = new FullFrameExecutionModel(context_, active_buffers_, operations_);
|
||||
break;
|
||||
default:
|
||||
BLI_assert_msg(0, "Non implemented execution model");
|
||||
@@ -91,28 +91,28 @@ ExecutionSystem::~ExecutionSystem()
|
||||
|
||||
delete execution_model_;
|
||||
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
for (NodeOperation *operation : operations_) {
|
||||
delete operation;
|
||||
}
|
||||
m_operations.clear();
|
||||
operations_.clear();
|
||||
|
||||
for (ExecutionGroup *group : m_groups) {
|
||||
for (ExecutionGroup *group : groups_) {
|
||||
delete group;
|
||||
}
|
||||
m_groups.clear();
|
||||
groups_.clear();
|
||||
}
|
||||
|
||||
void ExecutionSystem::set_operations(const Vector<NodeOperation *> &operations,
|
||||
const Vector<ExecutionGroup *> &groups)
|
||||
{
|
||||
m_operations = operations;
|
||||
m_groups = groups;
|
||||
operations_ = operations;
|
||||
groups_ = groups;
|
||||
}
|
||||
|
||||
void ExecutionSystem::execute()
|
||||
{
|
||||
DebugInfo::execute_started(this);
|
||||
for (NodeOperation *op : m_operations) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
op->init_data();
|
||||
}
|
||||
execution_model_->execute(*this);
|
||||
@@ -184,7 +184,7 @@ void ExecutionSystem::execute_work(const rcti &work_rect,
|
||||
|
||||
bool ExecutionSystem::is_breaked() const
|
||||
{
|
||||
const bNodeTree *btree = m_context.getbNodeTree();
|
||||
const bNodeTree *btree = context_.getbNodeTree();
|
||||
return btree->test_break(btree->tbh);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,17 +137,17 @@ class ExecutionSystem {
|
||||
/**
|
||||
* \brief the context used during execution
|
||||
*/
|
||||
CompositorContext m_context;
|
||||
CompositorContext context_;
|
||||
|
||||
/**
|
||||
* \brief vector of operations
|
||||
*/
|
||||
Vector<NodeOperation *> m_operations;
|
||||
Vector<NodeOperation *> operations_;
|
||||
|
||||
/**
|
||||
* \brief vector of groups
|
||||
*/
|
||||
Vector<ExecutionGroup *> m_groups;
|
||||
Vector<ExecutionGroup *> groups_;
|
||||
|
||||
/**
|
||||
* Active execution model implementation.
|
||||
@@ -200,7 +200,7 @@ class ExecutionSystem {
|
||||
*/
|
||||
const CompositorContext &getContext() const
|
||||
{
|
||||
return m_context;
|
||||
return context_;
|
||||
}
|
||||
|
||||
SharedOperationBuffers &get_active_buffers()
|
||||
|
||||
@@ -46,30 +46,30 @@ static rcti create_rect(const int width, const int height)
|
||||
|
||||
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state)
|
||||
{
|
||||
m_rect = rect;
|
||||
m_is_a_single_elem = false;
|
||||
m_memoryProxy = memoryProxy;
|
||||
m_num_channels = COM_data_type_num_channels(memoryProxy->getDataType());
|
||||
m_buffer = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * m_num_channels, 16, "COM_MemoryBuffer");
|
||||
rect_ = rect;
|
||||
is_a_single_elem_ = false;
|
||||
memoryProxy_ = memoryProxy;
|
||||
num_channels_ = COM_data_type_num_channels(memoryProxy->getDataType());
|
||||
buffer_ = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer");
|
||||
owns_data_ = true;
|
||||
m_state = state;
|
||||
m_datatype = memoryProxy->getDataType();
|
||||
state_ = state;
|
||||
datatype_ = memoryProxy->getDataType();
|
||||
|
||||
set_strides();
|
||||
}
|
||||
|
||||
MemoryBuffer::MemoryBuffer(DataType dataType, const rcti &rect, bool is_a_single_elem)
|
||||
{
|
||||
m_rect = rect;
|
||||
m_is_a_single_elem = is_a_single_elem;
|
||||
m_memoryProxy = nullptr;
|
||||
m_num_channels = COM_data_type_num_channels(dataType);
|
||||
m_buffer = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * m_num_channels, 16, "COM_MemoryBuffer");
|
||||
rect_ = rect;
|
||||
is_a_single_elem_ = is_a_single_elem;
|
||||
memoryProxy_ = nullptr;
|
||||
num_channels_ = COM_data_type_num_channels(dataType);
|
||||
buffer_ = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer");
|
||||
owns_data_ = true;
|
||||
m_state = MemoryBufferState::Temporary;
|
||||
m_datatype = dataType;
|
||||
state_ = MemoryBufferState::Temporary;
|
||||
datatype_ = dataType;
|
||||
|
||||
set_strides();
|
||||
}
|
||||
@@ -93,53 +93,52 @@ MemoryBuffer::MemoryBuffer(float *buffer,
|
||||
const rcti &rect,
|
||||
const bool is_a_single_elem)
|
||||
{
|
||||
m_rect = rect;
|
||||
m_is_a_single_elem = is_a_single_elem;
|
||||
m_memoryProxy = nullptr;
|
||||
m_num_channels = num_channels;
|
||||
m_datatype = COM_num_channels_data_type(num_channels);
|
||||
m_buffer = buffer;
|
||||
rect_ = rect;
|
||||
is_a_single_elem_ = is_a_single_elem;
|
||||
memoryProxy_ = nullptr;
|
||||
num_channels_ = num_channels;
|
||||
datatype_ = COM_num_channels_data_type(num_channels);
|
||||
buffer_ = buffer;
|
||||
owns_data_ = false;
|
||||
m_state = MemoryBufferState::Temporary;
|
||||
state_ = MemoryBufferState::Temporary;
|
||||
|
||||
set_strides();
|
||||
}
|
||||
|
||||
MemoryBuffer::MemoryBuffer(const MemoryBuffer &src)
|
||||
: MemoryBuffer(src.m_datatype, src.m_rect, false)
|
||||
MemoryBuffer::MemoryBuffer(const MemoryBuffer &src) : MemoryBuffer(src.datatype_, src.rect_, false)
|
||||
{
|
||||
m_memoryProxy = src.m_memoryProxy;
|
||||
memoryProxy_ = src.memoryProxy_;
|
||||
/* src may be single elem buffer */
|
||||
fill_from(src);
|
||||
}
|
||||
|
||||
void MemoryBuffer::set_strides()
|
||||
{
|
||||
if (m_is_a_single_elem) {
|
||||
if (is_a_single_elem_) {
|
||||
this->elem_stride = 0;
|
||||
this->row_stride = 0;
|
||||
}
|
||||
else {
|
||||
this->elem_stride = m_num_channels;
|
||||
this->row_stride = getWidth() * m_num_channels;
|
||||
this->elem_stride = num_channels_;
|
||||
this->row_stride = getWidth() * num_channels_;
|
||||
}
|
||||
to_positive_x_stride_ = m_rect.xmin < 0 ? -m_rect.xmin + 1 : (m_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_x_stride_ = rect_.xmin < 0 ? -rect_.xmin + 1 : (rect_.xmin == 0 ? 1 : 0);
|
||||
to_positive_y_stride_ = rect_.ymin < 0 ? -rect_.ymin + 1 : (rect_.ymin == 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return iterate_with(inputs, m_rect);
|
||||
return iterate_with(inputs, rect_);
|
||||
}
|
||||
|
||||
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) {
|
||||
builder.add_input(input->getBuffer(), input->get_rect(), input->elem_stride);
|
||||
}
|
||||
@@ -153,20 +152,20 @@ BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, c
|
||||
MemoryBuffer *MemoryBuffer::inflate() const
|
||||
{
|
||||
BLI_assert(is_a_single_elem());
|
||||
MemoryBuffer *inflated = new MemoryBuffer(m_datatype, m_rect, false);
|
||||
inflated->copy_from(this, m_rect);
|
||||
MemoryBuffer *inflated = new MemoryBuffer(datatype_, rect_, false);
|
||||
inflated->copy_from(this, rect_);
|
||||
return inflated;
|
||||
}
|
||||
|
||||
float MemoryBuffer::get_max_value() const
|
||||
{
|
||||
float result = m_buffer[0];
|
||||
float result = buffer_[0];
|
||||
const unsigned int size = this->buffer_len();
|
||||
unsigned int i;
|
||||
|
||||
const float *fp_src = m_buffer;
|
||||
const float *fp_src = buffer_;
|
||||
|
||||
for (i = 0; i < size; i++, fp_src += m_num_channels) {
|
||||
for (i = 0; i < size; i++, fp_src += num_channels_) {
|
||||
float value = *fp_src;
|
||||
if (value > result) {
|
||||
result = value;
|
||||
@@ -181,10 +180,10 @@ float MemoryBuffer::get_max_value(const rcti &rect) const
|
||||
rcti rect_clamp;
|
||||
|
||||
/* first clamp the rect by the bounds or we get un-initialized values */
|
||||
BLI_rcti_isect(&rect, &m_rect, &rect_clamp);
|
||||
BLI_rcti_isect(&rect, &rect_, &rect_clamp);
|
||||
|
||||
if (!BLI_rcti_is_empty(&rect_clamp)) {
|
||||
MemoryBuffer temp_buffer(m_datatype, rect_clamp);
|
||||
MemoryBuffer temp_buffer(datatype_, rect_clamp);
|
||||
temp_buffer.fill_from(*this);
|
||||
return temp_buffer.get_max_value();
|
||||
}
|
||||
@@ -195,9 +194,9 @@ float MemoryBuffer::get_max_value(const rcti &rect) const
|
||||
|
||||
MemoryBuffer::~MemoryBuffer()
|
||||
{
|
||||
if (m_buffer && owns_data_) {
|
||||
MEM_freeN(m_buffer);
|
||||
m_buffer = nullptr;
|
||||
if (buffer_ && owns_data_) {
|
||||
MEM_freeN(buffer_);
|
||||
buffer_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,28 +397,28 @@ void MemoryBuffer::fill(const rcti &area,
|
||||
void MemoryBuffer::fill_from(const MemoryBuffer &src)
|
||||
{
|
||||
rcti overlap;
|
||||
overlap.xmin = MAX2(m_rect.xmin, src.m_rect.xmin);
|
||||
overlap.xmax = MIN2(m_rect.xmax, src.m_rect.xmax);
|
||||
overlap.ymin = MAX2(m_rect.ymin, src.m_rect.ymin);
|
||||
overlap.ymax = MIN2(m_rect.ymax, src.m_rect.ymax);
|
||||
overlap.xmin = MAX2(rect_.xmin, src.rect_.xmin);
|
||||
overlap.xmax = MIN2(rect_.xmax, src.rect_.xmax);
|
||||
overlap.ymin = MAX2(rect_.ymin, src.rect_.ymin);
|
||||
overlap.ymax = MIN2(rect_.ymax, src.rect_.ymax);
|
||||
copy_from(&src, overlap);
|
||||
}
|
||||
|
||||
void MemoryBuffer::writePixel(int x, int y, const float color[4])
|
||||
{
|
||||
if (x >= m_rect.xmin && x < m_rect.xmax && y >= m_rect.ymin && y < m_rect.ymax) {
|
||||
if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) {
|
||||
const int offset = get_coords_offset(x, y);
|
||||
memcpy(&m_buffer[offset], color, sizeof(float) * m_num_channels);
|
||||
memcpy(&buffer_[offset], color, sizeof(float) * num_channels_);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryBuffer::addPixel(int x, int y, const float color[4])
|
||||
{
|
||||
if (x >= m_rect.xmin && x < m_rect.xmax && y >= m_rect.ymin && y < m_rect.ymax) {
|
||||
if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) {
|
||||
const int offset = get_coords_offset(x, y);
|
||||
float *dst = &m_buffer[offset];
|
||||
float *dst = &buffer_[offset];
|
||||
const float *src = color;
|
||||
for (int i = 0; i < m_num_channels; i++, dst++, src++) {
|
||||
for (int i = 0; i < num_channels_; i++, dst++, src++) {
|
||||
*dst += *src;
|
||||
}
|
||||
}
|
||||
@@ -434,7 +433,7 @@ static void read_ewa_elem(void *userdata, int x, int y, float result[4])
|
||||
void MemoryBuffer::read_elem_filtered(
|
||||
const float x, const float y, float dx[2], float dy[2], float *out) const
|
||||
{
|
||||
BLI_assert(m_datatype == DataType::Color);
|
||||
BLI_assert(datatype_ == DataType::Color);
|
||||
|
||||
const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}};
|
||||
|
||||
@@ -469,11 +468,11 @@ static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4]
|
||||
/* TODO(manzanilla): to be removed with tiled implementation. */
|
||||
void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2])
|
||||
{
|
||||
if (m_is_a_single_elem) {
|
||||
memcpy(result, m_buffer, sizeof(float) * m_num_channels);
|
||||
if (is_a_single_elem_) {
|
||||
memcpy(result, buffer_, sizeof(float) * num_channels_);
|
||||
}
|
||||
else {
|
||||
BLI_assert(m_datatype == DataType::Color);
|
||||
BLI_assert(datatype_ == DataType::Color);
|
||||
float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight();
|
||||
/* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
|
||||
* but compositor uses pixel space. For now let's just divide the values and
|
||||
|
||||
@@ -77,38 +77,38 @@ class MemoryBuffer {
|
||||
/**
|
||||
* \brief proxy of the memory (same for all chunks in the same buffer)
|
||||
*/
|
||||
MemoryProxy *m_memoryProxy;
|
||||
MemoryProxy *memoryProxy_;
|
||||
|
||||
/**
|
||||
* \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
|
||||
*/
|
||||
rcti m_rect;
|
||||
rcti rect_;
|
||||
|
||||
/**
|
||||
* \brief state of the buffer
|
||||
*/
|
||||
MemoryBufferState m_state;
|
||||
MemoryBufferState state_;
|
||||
|
||||
/**
|
||||
* \brief the actual float buffer/data
|
||||
*/
|
||||
float *m_buffer;
|
||||
float *buffer_;
|
||||
|
||||
/**
|
||||
* \brief the number of channels of a single value in the buffer.
|
||||
* 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.
|
||||
*/
|
||||
bool m_is_a_single_elem;
|
||||
bool is_a_single_elem_;
|
||||
|
||||
/**
|
||||
* Whether MemoryBuffer owns buffer data.
|
||||
@@ -153,21 +153,21 @@ class MemoryBuffer {
|
||||
*/
|
||||
bool is_a_single_elem() const
|
||||
{
|
||||
return m_is_a_single_elem;
|
||||
return is_a_single_elem_;
|
||||
}
|
||||
|
||||
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()));
|
||||
return m_buffer[index];
|
||||
return buffer_[index];
|
||||
}
|
||||
|
||||
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()));
|
||||
return m_buffer[index];
|
||||
return buffer_[index];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ class MemoryBuffer {
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +184,7 @@ class MemoryBuffer {
|
||||
float *get_elem(int x, int y)
|
||||
{
|
||||
BLI_assert(has_coords(x, y));
|
||||
return m_buffer + get_coords_offset(x, y);
|
||||
return buffer_ + get_coords_offset(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +193,7 @@ class MemoryBuffer {
|
||||
const float *get_elem(int x, int y) const
|
||||
{
|
||||
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
|
||||
@@ -219,16 +219,14 @@ class MemoryBuffer {
|
||||
void read_elem_bilinear(float x, float y, float *out) const
|
||||
{
|
||||
/* 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 ||
|
||||
y >= m_rect.ymax) {
|
||||
if (x <= rect_.xmin - 1.0f || x >= rect_.xmax || y <= rect_.ymin - 1.0f || y >= rect_.ymax) {
|
||||
clear_elem(out);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_is_a_single_elem) {
|
||||
if (x >= m_rect.xmin && x < m_rect.xmax - 1.0f && y >= m_rect.ymin &&
|
||||
y < m_rect.ymax - 1.0f) {
|
||||
memcpy(out, m_buffer, get_elem_bytes_len());
|
||||
if (is_a_single_elem_) {
|
||||
if (x >= rect_.xmin && x < rect_.xmax - 1.0f && y >= rect_.ymin && y < rect_.ymax - 1.0f) {
|
||||
memcpy(out, buffer_, get_elem_bytes_len());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -253,15 +251,15 @@ class MemoryBuffer {
|
||||
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;
|
||||
}
|
||||
|
||||
BLI_bilinear_interpolation_fl(m_buffer,
|
||||
BLI_bilinear_interpolation_fl(buffer_,
|
||||
out,
|
||||
getWidth(),
|
||||
getHeight(),
|
||||
m_num_channels,
|
||||
num_channels_,
|
||||
get_relative_x(x),
|
||||
get_relative_y(y));
|
||||
}
|
||||
@@ -288,8 +286,8 @@ class MemoryBuffer {
|
||||
*/
|
||||
float &get_value(int x, int y, int channel)
|
||||
{
|
||||
BLI_assert(has_coords(x, y) && channel >= 0 && channel < m_num_channels);
|
||||
return m_buffer[get_coords_offset(x, y) + channel];
|
||||
BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
|
||||
return buffer_[get_coords_offset(x, y) + channel];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,8 +295,8 @@ class MemoryBuffer {
|
||||
*/
|
||||
const float &get_value(int x, int y, int channel) const
|
||||
{
|
||||
BLI_assert(has_coords(x, y) && channel >= 0 && channel < m_num_channels);
|
||||
return m_buffer[get_coords_offset(x, y) + channel];
|
||||
BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
|
||||
return buffer_[get_coords_offset(x, y) + channel];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,7 +305,7 @@ class MemoryBuffer {
|
||||
const float *get_row_end(int y) const
|
||||
{
|
||||
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(getWidth(), y));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,12 +328,12 @@ class MemoryBuffer {
|
||||
|
||||
uint8_t get_num_channels() const
|
||||
{
|
||||
return m_num_channels;
|
||||
return num_channels_;
|
||||
}
|
||||
|
||||
uint8_t get_elem_bytes_len() const
|
||||
{
|
||||
return m_num_channels * sizeof(float);
|
||||
return num_channels_ * sizeof(float);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,22 +341,22 @@ class MemoryBuffer {
|
||||
*/
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
return BufferArea<float>(m_buffer, getWidth(), area, elem_stride);
|
||||
return BufferArea<float>(buffer_, getWidth(), area, elem_stride);
|
||||
}
|
||||
|
||||
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_, getWidth(), area, elem_stride);
|
||||
}
|
||||
|
||||
BuffersIterator<float> iterate_with(Span<MemoryBuffer *> inputs);
|
||||
@@ -370,13 +368,13 @@ class MemoryBuffer {
|
||||
*/
|
||||
float *getBuffer()
|
||||
{
|
||||
return m_buffer;
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
float *release_ownership_buffer()
|
||||
{
|
||||
owns_data_ = false;
|
||||
return m_buffer;
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
MemoryBuffer *inflate() const;
|
||||
@@ -385,8 +383,8 @@ class MemoryBuffer {
|
||||
{
|
||||
const int w = getWidth();
|
||||
const int h = getHeight();
|
||||
x = x - m_rect.xmin;
|
||||
y = y - m_rect.ymin;
|
||||
x = x - rect_.xmin;
|
||||
y = y - rect_.ymin;
|
||||
|
||||
switch (extend_x) {
|
||||
case MemoryBufferExtend::Clip:
|
||||
@@ -426,8 +424,8 @@ class MemoryBuffer {
|
||||
break;
|
||||
}
|
||||
|
||||
x = x + m_rect.xmin;
|
||||
y = y + m_rect.ymin;
|
||||
x = x + rect_.xmin;
|
||||
y = y + rect_.ymin;
|
||||
}
|
||||
|
||||
inline void wrap_pixel(float &x,
|
||||
@@ -437,8 +435,8 @@ class MemoryBuffer {
|
||||
{
|
||||
const float w = (float)getWidth();
|
||||
const float h = (float)getHeight();
|
||||
x = x - m_rect.xmin;
|
||||
y = y - m_rect.ymin;
|
||||
x = x - rect_.xmin;
|
||||
y = y - rect_.ymin;
|
||||
|
||||
switch (extend_x) {
|
||||
case MemoryBufferExtend::Clip:
|
||||
@@ -478,8 +476,8 @@ class MemoryBuffer {
|
||||
break;
|
||||
}
|
||||
|
||||
x = x + m_rect.xmin;
|
||||
y = y + m_rect.ymin;
|
||||
x = x + rect_.xmin;
|
||||
y = y + rect_.ymin;
|
||||
}
|
||||
|
||||
/* TODO(manzanilla): to be removed with tiled implementation. For applying #MemoryBufferExtend
|
||||
@@ -490,19 +488,19 @@ class MemoryBuffer {
|
||||
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
|
||||
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip)
|
||||
{
|
||||
bool clip_x = (extend_x == MemoryBufferExtend::Clip && (x < m_rect.xmin || x >= m_rect.xmax));
|
||||
bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < m_rect.ymin || y >= m_rect.ymax));
|
||||
bool clip_x = (extend_x == MemoryBufferExtend::Clip && (x < rect_.xmin || x >= rect_.xmax));
|
||||
bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < rect_.ymin || y >= rect_.ymax));
|
||||
if (clip_x || clip_y) {
|
||||
/* clip result outside rect is zero */
|
||||
memset(result, 0, m_num_channels * sizeof(float));
|
||||
memset(result, 0, num_channels_ * sizeof(float));
|
||||
}
|
||||
else {
|
||||
int u = x;
|
||||
int v = y;
|
||||
this->wrap_pixel(u, v, extend_x, extend_y);
|
||||
const int offset = get_coords_offset(u, v);
|
||||
float *buffer = &m_buffer[offset];
|
||||
memcpy(result, buffer, sizeof(float) * m_num_channels);
|
||||
float *buffer = &buffer_[offset];
|
||||
memcpy(result, buffer, sizeof(float) * num_channels_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,11 +518,11 @@ class MemoryBuffer {
|
||||
const int offset = get_coords_offset(u, v);
|
||||
|
||||
BLI_assert(offset >= 0);
|
||||
BLI_assert(offset < this->buffer_len() * m_num_channels);
|
||||
BLI_assert(!(extend_x == MemoryBufferExtend::Clip && (u < m_rect.xmin || u >= m_rect.xmax)) &&
|
||||
!(extend_y == MemoryBufferExtend::Clip && (v < m_rect.ymin || v >= m_rect.ymax)));
|
||||
float *buffer = &m_buffer[offset];
|
||||
memcpy(result, buffer, sizeof(float) * m_num_channels);
|
||||
BLI_assert(offset < this->buffer_len() * num_channels_);
|
||||
BLI_assert(!(extend_x == MemoryBufferExtend::Clip && (u < rect_.xmin || u >= rect_.xmax)) &&
|
||||
!(extend_y == MemoryBufferExtend::Clip && (v < rect_.ymin || v >= rect_.ymax)));
|
||||
float *buffer = &buffer_[offset];
|
||||
memcpy(result, buffer, sizeof(float) * num_channels_);
|
||||
}
|
||||
|
||||
void writePixel(int x, int y, const float color[4]);
|
||||
@@ -540,18 +538,18 @@ class MemoryBuffer {
|
||||
this->wrap_pixel(u, v, extend_x, extend_y);
|
||||
if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= getWidth())) ||
|
||||
(extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= getHeight()))) {
|
||||
copy_vn_fl(result, m_num_channels, 0.0f);
|
||||
copy_vn_fl(result, num_channels_, 0.0f);
|
||||
return;
|
||||
}
|
||||
if (m_is_a_single_elem) {
|
||||
memcpy(result, m_buffer, sizeof(float) * m_num_channels);
|
||||
if (is_a_single_elem_) {
|
||||
memcpy(result, buffer_, sizeof(float) * num_channels_);
|
||||
}
|
||||
else {
|
||||
BLI_bilinear_interpolation_wrap_fl(m_buffer,
|
||||
BLI_bilinear_interpolation_wrap_fl(buffer_,
|
||||
result,
|
||||
getWidth(),
|
||||
getHeight(),
|
||||
m_num_channels,
|
||||
num_channels_,
|
||||
u,
|
||||
v,
|
||||
extend_x == MemoryBufferExtend::Repeat,
|
||||
@@ -566,7 +564,7 @@ class MemoryBuffer {
|
||||
*/
|
||||
inline bool isTemporarily() const
|
||||
{
|
||||
return m_state == MemoryBufferState::Temporary;
|
||||
return state_ == MemoryBufferState::Temporary;
|
||||
}
|
||||
|
||||
void copy_from(const MemoryBuffer *src, const rcti &area);
|
||||
@@ -632,7 +630,7 @@ class MemoryBuffer {
|
||||
*/
|
||||
const rcti &get_rect() const
|
||||
{
|
||||
return m_rect;
|
||||
return rect_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -640,7 +638,7 @@ class MemoryBuffer {
|
||||
*/
|
||||
const int getWidth() const
|
||||
{
|
||||
return BLI_rcti_size_x(&m_rect);
|
||||
return BLI_rcti_size_x(&rect_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -648,7 +646,7 @@ class MemoryBuffer {
|
||||
*/
|
||||
const int getHeight() const
|
||||
{
|
||||
return BLI_rcti_size_y(&m_rect);
|
||||
return BLI_rcti_size_y(&rect_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -668,17 +666,17 @@ class MemoryBuffer {
|
||||
|
||||
void clear_elem(float *out) const
|
||||
{
|
||||
memset(out, 0, m_num_channels * sizeof(float));
|
||||
memset(out, 0, num_channels_ * sizeof(float));
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return y - m_rect.ymin;
|
||||
return y - rect_.ymin;
|
||||
}
|
||||
|
||||
template<typename T> bool has_coords(T x, T y) const
|
||||
@@ -688,12 +686,12 @@ class MemoryBuffer {
|
||||
|
||||
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
|
||||
{
|
||||
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.
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace blender::compositor {
|
||||
|
||||
MemoryProxy::MemoryProxy(DataType datatype)
|
||||
{
|
||||
m_writeBufferOperation = nullptr;
|
||||
m_executor = nullptr;
|
||||
m_datatype = datatype;
|
||||
writeBufferOperation_ = nullptr;
|
||||
executor_ = nullptr;
|
||||
datatype_ = datatype;
|
||||
}
|
||||
|
||||
void MemoryProxy::allocate(unsigned int width, unsigned int height)
|
||||
@@ -36,14 +36,14 @@ void MemoryProxy::allocate(unsigned int width, unsigned int height)
|
||||
result.ymin = 0;
|
||||
result.ymax = height;
|
||||
|
||||
m_buffer = new MemoryBuffer(this, result, MemoryBufferState::Default);
|
||||
buffer_ = new MemoryBuffer(this, result, MemoryBufferState::Default);
|
||||
}
|
||||
|
||||
void MemoryProxy::free()
|
||||
{
|
||||
if (m_buffer) {
|
||||
delete m_buffer;
|
||||
m_buffer = nullptr;
|
||||
if (buffer_) {
|
||||
delete buffer_;
|
||||
buffer_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,22 +42,22 @@ class MemoryProxy {
|
||||
/**
|
||||
* \brief reference to the output operation of the executiongroup
|
||||
*/
|
||||
WriteBufferOperation *m_writeBufferOperation;
|
||||
WriteBufferOperation *writeBufferOperation_;
|
||||
|
||||
/**
|
||||
* \brief reference to the executor. the Execution group that can fill a chunk
|
||||
*/
|
||||
ExecutionGroup *m_executor;
|
||||
ExecutionGroup *executor_;
|
||||
|
||||
/**
|
||||
* \brief the allocated memory
|
||||
*/
|
||||
MemoryBuffer *m_buffer;
|
||||
MemoryBuffer *buffer_;
|
||||
|
||||
/**
|
||||
* \brief datatype of this MemoryProxy
|
||||
*/
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
public:
|
||||
MemoryProxy(DataType type);
|
||||
@@ -68,7 +68,7 @@ class MemoryProxy {
|
||||
*/
|
||||
void setExecutor(ExecutionGroup *executor)
|
||||
{
|
||||
m_executor = executor;
|
||||
executor_ = executor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ class MemoryProxy {
|
||||
*/
|
||||
ExecutionGroup *getExecutor() const
|
||||
{
|
||||
return m_executor;
|
||||
return executor_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ class MemoryProxy {
|
||||
*/
|
||||
void setWriteBufferOperation(WriteBufferOperation *operation)
|
||||
{
|
||||
m_writeBufferOperation = operation;
|
||||
writeBufferOperation_ = operation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ class MemoryProxy {
|
||||
*/
|
||||
WriteBufferOperation *getWriteBufferOperation() const
|
||||
{
|
||||
return m_writeBufferOperation;
|
||||
return writeBufferOperation_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,12 +112,12 @@ class MemoryProxy {
|
||||
*/
|
||||
inline MemoryBuffer *getBuffer()
|
||||
{
|
||||
return m_buffer;
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
inline DataType getDataType()
|
||||
{
|
||||
return m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
|
||||
@@ -29,10 +29,10 @@ namespace blender::compositor {
|
||||
**************/
|
||||
|
||||
Node::Node(bNode *editorNode, bool create_sockets)
|
||||
: m_editorNodeTree(nullptr),
|
||||
m_editorNode(editorNode),
|
||||
m_inActiveGroup(false),
|
||||
m_instanceKey(NODE_INSTANCE_KEY_NONE)
|
||||
: editorNodeTree_(nullptr),
|
||||
editorNode_(editorNode),
|
||||
inActiveGroup_(false),
|
||||
instanceKey_(NODE_INSTANCE_KEY_NONE)
|
||||
{
|
||||
if (create_sockets) {
|
||||
bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
|
||||
@@ -137,13 +137,13 @@ bNodeSocket *Node::getEditorOutputSocket(int editorNodeOutputSocketIndex)
|
||||
*******************/
|
||||
|
||||
NodeInput::NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype)
|
||||
: m_node(node), m_editorSocket(b_socket), m_datatype(datatype), m_link(nullptr)
|
||||
: node_(node), editorSocket_(b_socket), datatype_(datatype), link_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeInput::setLink(NodeOutput *link)
|
||||
{
|
||||
m_link = link;
|
||||
link_ = link;
|
||||
}
|
||||
|
||||
float NodeInput::getEditorValueFloat() const
|
||||
@@ -172,7 +172,7 @@ void NodeInput::getEditorValueVector(float *value) const
|
||||
********************/
|
||||
|
||||
NodeOutput::NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype)
|
||||
: m_node(node), m_editorSocket(b_socket), m_datatype(datatype)
|
||||
: node_(node), editorSocket_(b_socket), datatype_(datatype)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -41,22 +41,22 @@ class Node {
|
||||
/**
|
||||
* \brief stores the reference to the SDNA bNode struct
|
||||
*/
|
||||
bNodeTree *m_editorNodeTree;
|
||||
bNodeTree *editorNodeTree_;
|
||||
|
||||
/**
|
||||
* \brief stores the reference to the SDNA bNode struct
|
||||
*/
|
||||
bNode *m_editorNode;
|
||||
bNode *editorNode_;
|
||||
|
||||
/**
|
||||
* \brief Is this node part of the active group
|
||||
*/
|
||||
bool m_inActiveGroup;
|
||||
bool inActiveGroup_;
|
||||
|
||||
/**
|
||||
* \brief Instance key to identify the node in an instance hash table
|
||||
*/
|
||||
bNodeInstanceKey m_instanceKey;
|
||||
bNodeInstanceKey instanceKey_;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ class Node {
|
||||
*/
|
||||
bNode *getbNode() const
|
||||
{
|
||||
return m_editorNode;
|
||||
return editorNode_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ class Node {
|
||||
*/
|
||||
bNodeTree *getbNodeTree() const
|
||||
{
|
||||
return m_editorNodeTree;
|
||||
return editorNodeTree_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ class Node {
|
||||
*/
|
||||
void setbNode(bNode *node)
|
||||
{
|
||||
m_editorNode = node;
|
||||
editorNode_ = node;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ class Node {
|
||||
*/
|
||||
void setbNodeTree(bNodeTree *nodetree)
|
||||
{
|
||||
m_editorNodeTree = nodetree;
|
||||
editorNodeTree_ = nodetree;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +145,7 @@ class Node {
|
||||
*/
|
||||
void setIsInActiveGroup(bool value)
|
||||
{
|
||||
m_inActiveGroup = value;
|
||||
inActiveGroup_ = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ class Node {
|
||||
*/
|
||||
inline bool isInActiveGroup() const
|
||||
{
|
||||
return m_inActiveGroup;
|
||||
return inActiveGroup_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,11 +172,11 @@ class Node {
|
||||
|
||||
void setInstanceKey(bNodeInstanceKey instance_key)
|
||||
{
|
||||
m_instanceKey = instance_key;
|
||||
instanceKey_ = instance_key;
|
||||
}
|
||||
bNodeInstanceKey getInstanceKey() const
|
||||
{
|
||||
return m_instanceKey;
|
||||
return instanceKey_;
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -206,41 +206,41 @@ class Node {
|
||||
*/
|
||||
class NodeInput {
|
||||
private:
|
||||
Node *m_node;
|
||||
bNodeSocket *m_editorSocket;
|
||||
Node *node_;
|
||||
bNodeSocket *editorSocket_;
|
||||
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
/**
|
||||
* \brief link connected to this NodeInput.
|
||||
* An input socket can only have a single link
|
||||
*/
|
||||
NodeOutput *m_link;
|
||||
NodeOutput *link_;
|
||||
|
||||
public:
|
||||
NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype);
|
||||
|
||||
Node *getNode() const
|
||||
{
|
||||
return m_node;
|
||||
return node_;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
return m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
bNodeSocket *getbNodeSocket() const
|
||||
{
|
||||
return m_editorSocket;
|
||||
return editorSocket_;
|
||||
}
|
||||
|
||||
void setLink(NodeOutput *link);
|
||||
bool isLinked() const
|
||||
{
|
||||
return m_link;
|
||||
return link_;
|
||||
}
|
||||
NodeOutput *getLink()
|
||||
{
|
||||
return m_link;
|
||||
return link_;
|
||||
}
|
||||
|
||||
float getEditorValueFloat() const;
|
||||
@@ -254,25 +254,25 @@ class NodeInput {
|
||||
*/
|
||||
class NodeOutput {
|
||||
private:
|
||||
Node *m_node;
|
||||
bNodeSocket *m_editorSocket;
|
||||
Node *node_;
|
||||
bNodeSocket *editorSocket_;
|
||||
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
public:
|
||||
NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype);
|
||||
|
||||
Node *getNode() const
|
||||
{
|
||||
return m_node;
|
||||
return node_;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
return m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
bNodeSocket *getbNodeSocket() const
|
||||
{
|
||||
return m_editorSocket;
|
||||
return editorSocket_;
|
||||
}
|
||||
|
||||
float getEditorValueFloat();
|
||||
|
||||
@@ -29,38 +29,38 @@
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
NodeConverter::NodeConverter(NodeOperationBuilder *builder) : m_builder(builder)
|
||||
NodeConverter::NodeConverter(NodeOperationBuilder *builder) : builder_(builder)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeConverter::addOperation(NodeOperation *operation)
|
||||
{
|
||||
m_builder->addOperation(operation);
|
||||
builder_->addOperation(operation);
|
||||
}
|
||||
|
||||
void NodeConverter::mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
|
||||
{
|
||||
m_builder->mapInputSocket(node_socket, operation_socket);
|
||||
builder_->mapInputSocket(node_socket, operation_socket);
|
||||
}
|
||||
|
||||
void NodeConverter::mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
|
||||
{
|
||||
m_builder->mapOutputSocket(node_socket, operation_socket);
|
||||
builder_->mapOutputSocket(node_socket, operation_socket);
|
||||
}
|
||||
|
||||
void NodeConverter::addLink(NodeOperationOutput *from, NodeOperationInput *to)
|
||||
{
|
||||
m_builder->addLink(from, to);
|
||||
builder_->addLink(from, to);
|
||||
}
|
||||
|
||||
void NodeConverter::addPreview(NodeOperationOutput *output)
|
||||
{
|
||||
m_builder->addPreview(output);
|
||||
builder_->addPreview(output);
|
||||
}
|
||||
|
||||
void NodeConverter::addNodeInputPreview(NodeInput *input)
|
||||
{
|
||||
m_builder->addNodeInputPreview(input);
|
||||
builder_->addNodeInputPreview(input);
|
||||
}
|
||||
|
||||
NodeOperation *NodeConverter::setInvalidOutput(NodeOutput *output)
|
||||
@@ -71,8 +71,8 @@ NodeOperation *NodeConverter::setInvalidOutput(NodeOutput *output)
|
||||
SetColorOperation *operation = new SetColorOperation();
|
||||
operation->setChannels(warning_color);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->mapOutputSocket(output, operation->getOutputSocket());
|
||||
builder_->addOperation(operation);
|
||||
builder_->mapOutputSocket(output, operation->getOutputSocket());
|
||||
|
||||
return operation;
|
||||
}
|
||||
@@ -80,9 +80,9 @@ NodeOperation *NodeConverter::setInvalidOutput(NodeOutput *output)
|
||||
NodeOperationOutput *NodeConverter::addInputProxy(NodeInput *input, bool use_conversion)
|
||||
{
|
||||
SocketProxyOperation *proxy = new SocketProxyOperation(input->getDataType(), use_conversion);
|
||||
m_builder->addOperation(proxy);
|
||||
builder_->addOperation(proxy);
|
||||
|
||||
m_builder->mapInputSocket(input, proxy->getInputSocket(0));
|
||||
builder_->mapInputSocket(input, proxy->getInputSocket(0));
|
||||
|
||||
return proxy->getOutputSocket();
|
||||
}
|
||||
@@ -90,9 +90,9 @@ NodeOperationOutput *NodeConverter::addInputProxy(NodeInput *input, bool use_con
|
||||
NodeOperationInput *NodeConverter::addOutputProxy(NodeOutput *output, bool use_conversion)
|
||||
{
|
||||
SocketProxyOperation *proxy = new SocketProxyOperation(output->getDataType(), use_conversion);
|
||||
m_builder->addOperation(proxy);
|
||||
builder_->addOperation(proxy);
|
||||
|
||||
m_builder->mapOutputSocket(output, proxy->getOutputSocket());
|
||||
builder_->mapOutputSocket(output, proxy->getOutputSocket());
|
||||
|
||||
return proxy->getInputSocket(0);
|
||||
}
|
||||
@@ -102,8 +102,8 @@ void NodeConverter::addInputValue(NodeOperationInput *input, float value)
|
||||
SetValueOperation *operation = new SetValueOperation();
|
||||
operation->setValue(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->addLink(operation->getOutputSocket(), input);
|
||||
builder_->addOperation(operation);
|
||||
builder_->addLink(operation->getOutputSocket(), input);
|
||||
}
|
||||
|
||||
void NodeConverter::addInputColor(NodeOperationInput *input, const float value[4])
|
||||
@@ -111,8 +111,8 @@ void NodeConverter::addInputColor(NodeOperationInput *input, const float value[4
|
||||
SetColorOperation *operation = new SetColorOperation();
|
||||
operation->setChannels(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->addLink(operation->getOutputSocket(), input);
|
||||
builder_->addOperation(operation);
|
||||
builder_->addLink(operation->getOutputSocket(), input);
|
||||
}
|
||||
|
||||
void NodeConverter::addInputVector(NodeOperationInput *input, const float value[3])
|
||||
@@ -120,8 +120,8 @@ void NodeConverter::addInputVector(NodeOperationInput *input, const float value[
|
||||
SetVectorOperation *operation = new SetVectorOperation();
|
||||
operation->setVector(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->addLink(operation->getOutputSocket(), input);
|
||||
builder_->addOperation(operation);
|
||||
builder_->addLink(operation->getOutputSocket(), input);
|
||||
}
|
||||
|
||||
void NodeConverter::addOutputValue(NodeOutput *output, float value)
|
||||
@@ -129,8 +129,8 @@ void NodeConverter::addOutputValue(NodeOutput *output, float value)
|
||||
SetValueOperation *operation = new SetValueOperation();
|
||||
operation->setValue(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->mapOutputSocket(output, operation->getOutputSocket());
|
||||
builder_->addOperation(operation);
|
||||
builder_->mapOutputSocket(output, operation->getOutputSocket());
|
||||
}
|
||||
|
||||
void NodeConverter::addOutputColor(NodeOutput *output, const float value[4])
|
||||
@@ -138,8 +138,8 @@ void NodeConverter::addOutputColor(NodeOutput *output, const float value[4])
|
||||
SetColorOperation *operation = new SetColorOperation();
|
||||
operation->setChannels(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->mapOutputSocket(output, operation->getOutputSocket());
|
||||
builder_->addOperation(operation);
|
||||
builder_->mapOutputSocket(output, operation->getOutputSocket());
|
||||
}
|
||||
|
||||
void NodeConverter::addOutputVector(NodeOutput *output, const float value[3])
|
||||
@@ -147,18 +147,18 @@ void NodeConverter::addOutputVector(NodeOutput *output, const float value[3])
|
||||
SetVectorOperation *operation = new SetVectorOperation();
|
||||
operation->setVector(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->mapOutputSocket(output, operation->getOutputSocket());
|
||||
builder_->addOperation(operation);
|
||||
builder_->mapOutputSocket(output, operation->getOutputSocket());
|
||||
}
|
||||
|
||||
void NodeConverter::registerViewer(ViewerOperation *viewer)
|
||||
{
|
||||
m_builder->registerViewer(viewer);
|
||||
builder_->registerViewer(viewer);
|
||||
}
|
||||
|
||||
ViewerOperation *NodeConverter::active_viewer() const
|
||||
{
|
||||
return m_builder->active_viewer();
|
||||
return builder_->active_viewer();
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -116,7 +116,7 @@ class NodeConverter {
|
||||
|
||||
private:
|
||||
/** The internal builder for storing the results of the graph construction. */
|
||||
NodeOperationBuilder *m_builder;
|
||||
NodeOperationBuilder *builder_;
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompiler")
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace blender::compositor {
|
||||
|
||||
NodeGraph::~NodeGraph()
|
||||
{
|
||||
while (m_nodes.size()) {
|
||||
delete m_nodes.pop_last();
|
||||
while (nodes_.size()) {
|
||||
delete nodes_.pop_last();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,14 +75,14 @@ void NodeGraph::add_node(Node *node,
|
||||
node->setInstanceKey(key);
|
||||
node->setIsInActiveGroup(is_active_group);
|
||||
|
||||
m_nodes.append(node);
|
||||
nodes_.append(node);
|
||||
|
||||
DebugInfo::node_added(node);
|
||||
}
|
||||
|
||||
void NodeGraph::add_link(NodeOutput *fromSocket, NodeInput *toSocket)
|
||||
{
|
||||
m_links.append(Link(fromSocket, toSocket));
|
||||
links_.append(Link(fromSocket, toSocket));
|
||||
|
||||
/* register with the input */
|
||||
toSocket->setLink(fromSocket);
|
||||
@@ -104,7 +104,7 @@ void NodeGraph::add_bNodeTree(const CompositorContext &context,
|
||||
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. */
|
||||
for (bNodeLink *nodelink = (bNodeLink *)tree->links.first; nodelink; nodelink = nodelink->next) {
|
||||
add_bNodeLink(node_range, nodelink);
|
||||
@@ -285,7 +285,7 @@ void NodeGraph::add_proxies_group(const CompositorContext &context,
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io;
|
||||
|
||||
@@ -47,19 +47,19 @@ class NodeGraph {
|
||||
};
|
||||
|
||||
private:
|
||||
Vector<Node *> m_nodes;
|
||||
Vector<Link> m_links;
|
||||
Vector<Node *> nodes_;
|
||||
Vector<Link> links_;
|
||||
|
||||
public:
|
||||
~NodeGraph();
|
||||
|
||||
const Vector<Node *> &nodes() const
|
||||
{
|
||||
return m_nodes;
|
||||
return nodes_;
|
||||
}
|
||||
const Vector<Link> &links() const
|
||||
{
|
||||
return m_links;
|
||||
return links_;
|
||||
}
|
||||
|
||||
void from_bNodeTree(const CompositorContext &context, bNodeTree *tree);
|
||||
|
||||
@@ -34,20 +34,20 @@ NodeOperation::NodeOperation()
|
||||
{
|
||||
canvas_input_index_ = 0;
|
||||
canvas_ = COM_AREA_NONE;
|
||||
m_btree = nullptr;
|
||||
btree_ = nullptr;
|
||||
}
|
||||
|
||||
/** Get constant value when operation is constant, otherwise return 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 && getOutputSocket()->getDataType() == DataType::Value);
|
||||
return *get_constant_elem_default(&default_value);
|
||||
}
|
||||
|
||||
/** Get constant elem when operation is constant, otherwise return 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) {
|
||||
return static_cast<ConstantOperation *>(this)->get_constant_elem();
|
||||
}
|
||||
@@ -72,15 +72,15 @@ std::optional<NodeOperationHash> NodeOperation::generate_hash()
|
||||
}
|
||||
|
||||
hash_params(canvas_.ymin, canvas_.ymax);
|
||||
if (m_outputs.size() > 0) {
|
||||
BLI_assert(m_outputs.size() == 1);
|
||||
if (outputs_.size() > 0) {
|
||||
BLI_assert(outputs_.size() == 1);
|
||||
hash_param(this->getOutputSocket()->getDataType());
|
||||
}
|
||||
NodeOperationHash hash;
|
||||
hash.params_hash_ = params_hash_;
|
||||
|
||||
hash.parents_hash_ = 0;
|
||||
for (NodeOperationInput &socket : m_inputs) {
|
||||
for (NodeOperationInput &socket : inputs_) {
|
||||
if (!socket.isConnected()) {
|
||||
continue;
|
||||
}
|
||||
@@ -108,29 +108,29 @@ std::optional<NodeOperationHash> NodeOperation::generate_hash()
|
||||
|
||||
NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index)
|
||||
{
|
||||
return &m_outputs[index];
|
||||
return &outputs_[index];
|
||||
}
|
||||
|
||||
NodeOperationInput *NodeOperation::getInputSocket(unsigned int index)
|
||||
{
|
||||
return &m_inputs[index];
|
||||
return &inputs_[index];
|
||||
}
|
||||
|
||||
void NodeOperation::addInputSocket(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)
|
||||
{
|
||||
m_outputs.append(NodeOperationOutput(this, datatype));
|
||||
outputs_.append(NodeOperationOutput(this, datatype));
|
||||
}
|
||||
|
||||
void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
unsigned int used_canvas_index = 0;
|
||||
if (canvas_input_index_ == RESOLUTION_INPUT_ANY) {
|
||||
for (NodeOperationInput &input : m_inputs) {
|
||||
for (NodeOperationInput &input : inputs_) {
|
||||
rcti any_area = COM_AREA_NONE;
|
||||
const bool determined = input.determine_canvas(preferred_area, any_area);
|
||||
if (determined) {
|
||||
@@ -140,8 +140,8 @@ void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
used_canvas_index += 1;
|
||||
}
|
||||
}
|
||||
else if (canvas_input_index_ < m_inputs.size()) {
|
||||
NodeOperationInput &input = m_inputs[canvas_input_index_];
|
||||
else if (canvas_input_index_ < inputs_.size()) {
|
||||
NodeOperationInput &input = inputs_[canvas_input_index_];
|
||||
input.determine_canvas(preferred_area, r_area);
|
||||
used_canvas_index = canvas_input_index_;
|
||||
}
|
||||
@@ -152,11 +152,11 @@ void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
|
||||
rcti unused_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) {
|
||||
continue;
|
||||
}
|
||||
NodeOperationInput &input = m_inputs[index];
|
||||
NodeOperationInput &input = inputs_[index];
|
||||
if (input.isConnected()) {
|
||||
input.determine_canvas(local_preferred_area, unused_area);
|
||||
}
|
||||
@@ -179,22 +179,22 @@ void NodeOperation::initExecution()
|
||||
|
||||
void NodeOperation::initMutex()
|
||||
{
|
||||
BLI_mutex_init(&m_mutex);
|
||||
BLI_mutex_init(&mutex_);
|
||||
}
|
||||
|
||||
void NodeOperation::lockMutex()
|
||||
{
|
||||
BLI_mutex_lock(&m_mutex);
|
||||
BLI_mutex_lock(&mutex_);
|
||||
}
|
||||
|
||||
void NodeOperation::unlockMutex()
|
||||
{
|
||||
BLI_mutex_unlock(&m_mutex);
|
||||
BLI_mutex_unlock(&mutex_);
|
||||
}
|
||||
|
||||
void NodeOperation::deinitMutex()
|
||||
{
|
||||
BLI_mutex_end(&m_mutex);
|
||||
BLI_mutex_end(&mutex_);
|
||||
}
|
||||
|
||||
void NodeOperation::deinitExecution()
|
||||
@@ -219,7 +219,7 @@ const rcti &NodeOperation::get_canvas() const
|
||||
*/
|
||||
void NodeOperation::unset_canvas()
|
||||
{
|
||||
BLI_assert(m_inputs.size() == 0);
|
||||
BLI_assert(inputs_.size() == 0);
|
||||
flags.is_canvas_set = false;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
rcti *output)
|
||||
{
|
||||
if (m_inputs.size() == 0) {
|
||||
if (inputs_.size() == 0) {
|
||||
BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
|
||||
return false;
|
||||
}
|
||||
@@ -445,14 +445,14 @@ void NodeOperation::remove_buffers_and_restore_original_inputs(
|
||||
*****************/
|
||||
|
||||
NodeOperationInput::NodeOperationInput(NodeOperation *op, DataType datatype, ResizeMode resizeMode)
|
||||
: m_operation(op), m_datatype(datatype), m_resizeMode(resizeMode), m_link(nullptr)
|
||||
: operation_(op), datatype_(datatype), resizeMode_(resizeMode), link_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
SocketReader *NodeOperationInput::getReader()
|
||||
{
|
||||
if (isConnected()) {
|
||||
return &m_link->getOperation();
|
||||
return &link_->getOperation();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -463,8 +463,8 @@ SocketReader *NodeOperationInput::getReader()
|
||||
*/
|
||||
bool NodeOperationInput::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
if (m_link) {
|
||||
m_link->determine_canvas(preferred_area, r_area);
|
||||
if (link_) {
|
||||
link_->determine_canvas(preferred_area, r_area);
|
||||
return !BLI_rcti_is_empty(&r_area);
|
||||
}
|
||||
return false;
|
||||
@@ -475,7 +475,7 @@ bool NodeOperationInput::determine_canvas(const rcti &preferred_area, rcti &r_ar
|
||||
******************/
|
||||
|
||||
NodeOperationOutput::NodeOperationOutput(NodeOperation *op, DataType datatype)
|
||||
: m_operation(op), m_datatype(datatype)
|
||||
: operation_(op), datatype_(datatype)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -83,18 +83,18 @@ enum class ResizeMode {
|
||||
|
||||
class NodeOperationInput {
|
||||
private:
|
||||
NodeOperation *m_operation;
|
||||
NodeOperation *operation_;
|
||||
|
||||
/** Datatype of this socket. Is used for automatically data transformation.
|
||||
* \section data-conversion
|
||||
*/
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
/** Resize mode of this socket */
|
||||
ResizeMode m_resizeMode;
|
||||
ResizeMode resizeMode_;
|
||||
|
||||
/** Connected output */
|
||||
NodeOperationOutput *m_link;
|
||||
NodeOperationOutput *link_;
|
||||
|
||||
public:
|
||||
NodeOperationInput(NodeOperation *op,
|
||||
@@ -103,33 +103,33 @@ class NodeOperationInput {
|
||||
|
||||
NodeOperation &getOperation() const
|
||||
{
|
||||
return *m_operation;
|
||||
return *operation_;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
return m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
|
||||
void setLink(NodeOperationOutput *link)
|
||||
{
|
||||
m_link = link;
|
||||
link_ = link;
|
||||
}
|
||||
NodeOperationOutput *getLink() const
|
||||
{
|
||||
return m_link;
|
||||
return link_;
|
||||
}
|
||||
bool isConnected() const
|
||||
{
|
||||
return m_link;
|
||||
return link_;
|
||||
}
|
||||
|
||||
void setResizeMode(ResizeMode resizeMode)
|
||||
{
|
||||
m_resizeMode = resizeMode;
|
||||
resizeMode_ = resizeMode;
|
||||
}
|
||||
ResizeMode getResizeMode() const
|
||||
{
|
||||
return m_resizeMode;
|
||||
return resizeMode_;
|
||||
}
|
||||
|
||||
SocketReader *getReader();
|
||||
@@ -143,23 +143,23 @@ class NodeOperationInput {
|
||||
|
||||
class NodeOperationOutput {
|
||||
private:
|
||||
NodeOperation *m_operation;
|
||||
NodeOperation *operation_;
|
||||
|
||||
/** Datatype of this socket. Is used for automatically data transformation.
|
||||
* \section data-conversion
|
||||
*/
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
public:
|
||||
NodeOperationOutput(NodeOperation *op, DataType datatype);
|
||||
|
||||
NodeOperation &getOperation() const
|
||||
{
|
||||
return *m_operation;
|
||||
return *operation_;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
return m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
|
||||
void determine_canvas(const rcti &preferred_area, rcti &r_area);
|
||||
@@ -314,10 +314,10 @@ struct NodeOperationHash {
|
||||
*/
|
||||
class NodeOperation {
|
||||
private:
|
||||
int m_id;
|
||||
std::string m_name;
|
||||
Vector<NodeOperationInput> m_inputs;
|
||||
Vector<NodeOperationOutput> m_outputs;
|
||||
int id_;
|
||||
std::string name_;
|
||||
Vector<NodeOperationInput> inputs_;
|
||||
Vector<NodeOperationOutput> outputs_;
|
||||
|
||||
size_t params_hash_;
|
||||
bool is_hash_output_params_implemented_;
|
||||
@@ -338,12 +338,12 @@ class NodeOperation {
|
||||
* \see NodeOperation.deinitMutex deinitializes this mutex
|
||||
* \see NodeOperation.getMutex retrieve a pointer to this mutex.
|
||||
*/
|
||||
ThreadMutex m_mutex;
|
||||
ThreadMutex mutex_;
|
||||
|
||||
/**
|
||||
* \brief reference to the editing bNodeTree, used for break and update callback
|
||||
*/
|
||||
const bNodeTree *m_btree;
|
||||
const bNodeTree *btree_;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -367,22 +367,22 @@ class NodeOperation {
|
||||
|
||||
void set_name(const std::string name)
|
||||
{
|
||||
m_name = name;
|
||||
name_ = name;
|
||||
}
|
||||
|
||||
const std::string get_name() const
|
||||
{
|
||||
return m_name;
|
||||
return name_;
|
||||
}
|
||||
|
||||
void set_id(const int id)
|
||||
{
|
||||
m_id = id;
|
||||
id_ = id;
|
||||
}
|
||||
|
||||
const int get_id() const
|
||||
{
|
||||
return m_id;
|
||||
return id_;
|
||||
}
|
||||
|
||||
float get_constant_value_default(float default_value);
|
||||
@@ -397,11 +397,11 @@ class NodeOperation {
|
||||
|
||||
unsigned int getNumberOfInputSockets() const
|
||||
{
|
||||
return m_inputs.size();
|
||||
return inputs_.size();
|
||||
}
|
||||
unsigned int getNumberOfOutputSockets() const
|
||||
{
|
||||
return m_outputs.size();
|
||||
return outputs_.size();
|
||||
}
|
||||
NodeOperationOutput *getOutputSocket(unsigned int index = 0);
|
||||
NodeOperationInput *getInputSocket(unsigned int index);
|
||||
@@ -442,7 +442,7 @@ class NodeOperation {
|
||||
|
||||
void setbNodeTree(const bNodeTree *tree)
|
||||
{
|
||||
m_btree = tree;
|
||||
btree_ = tree;
|
||||
}
|
||||
|
||||
void set_execution_system(ExecutionSystem *system)
|
||||
@@ -561,13 +561,13 @@ class NodeOperation {
|
||||
|
||||
inline bool isBraked() const
|
||||
{
|
||||
return m_btree->test_break(m_btree->tbh);
|
||||
return btree_->test_break(btree_->tbh);
|
||||
}
|
||||
|
||||
inline void updateDraw()
|
||||
{
|
||||
if (m_btree->update_draw) {
|
||||
m_btree->update_draw(m_btree->udh);
|
||||
if (btree_->update_draw) {
|
||||
btree_->update_draw(btree_->udh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ namespace blender::compositor {
|
||||
NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context,
|
||||
bNodeTree *b_nodetree,
|
||||
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)
|
||||
@@ -50,29 +50,29 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
/* interface handle for nodes */
|
||||
NodeConverter converter(this);
|
||||
|
||||
for (Node *node : m_graph.nodes()) {
|
||||
m_current_node = node;
|
||||
for (Node *node : graph_.nodes()) {
|
||||
current_node_ = node;
|
||||
|
||||
DebugInfo::node_to_operations(node);
|
||||
node->convertToOperations(converter, *m_context);
|
||||
node->convertToOperations(converter, *context_);
|
||||
}
|
||||
|
||||
m_current_node = nullptr;
|
||||
current_node_ = nullptr;
|
||||
|
||||
/* The input map constructed by nodes maps operation inputs to node inputs.
|
||||
* Inverting yields a map of node inputs to all connected operation inputs,
|
||||
* so multiple operations can use the same node input.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
for (const NodeGraph::Link &link : m_graph.links()) {
|
||||
for (const NodeGraph::Link &link : graph_.links()) {
|
||||
NodeOutput *from = link.from;
|
||||
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);
|
||||
if (!op_from || op_to_list.is_empty()) {
|
||||
@@ -96,7 +96,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
|
||||
add_datatype_conversions();
|
||||
|
||||
if (m_context->get_execution_model() == eExecutionModel::FullFrame) {
|
||||
if (context_->get_execution_model() == eExecutionModel::FullFrame) {
|
||||
save_graphviz("compositor_prior_folding");
|
||||
ConstantFolder folder(*this);
|
||||
folder.fold_operations();
|
||||
@@ -107,37 +107,37 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
save_graphviz("compositor_prior_merging");
|
||||
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 */
|
||||
add_complex_operation_buffers();
|
||||
}
|
||||
|
||||
/* links not available from here on */
|
||||
/* XXX make m_links a local variable to avoid confusion! */
|
||||
m_links.clear();
|
||||
/* XXX make links_ a local variable to avoid confusion! */
|
||||
links_.clear();
|
||||
|
||||
prune_operations();
|
||||
|
||||
/* ensure topological (link-based) order of nodes */
|
||||
/*sort_operations();*/ /* not needed yet */
|
||||
|
||||
if (m_context->get_execution_model() == eExecutionModel::Tiled) {
|
||||
if (context_->get_execution_model() == eExecutionModel::Tiled) {
|
||||
/* create execution groups */
|
||||
group_operations();
|
||||
}
|
||||
|
||||
/* transfer resulting operations to the system */
|
||||
system->set_operations(m_operations, m_groups);
|
||||
system->set_operations(operations_, groups_);
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::addOperation(NodeOperation *operation)
|
||||
{
|
||||
operation->set_id(m_operations.size());
|
||||
m_operations.append(operation);
|
||||
if (m_current_node) {
|
||||
operation->set_name(m_current_node->getbNode()->name);
|
||||
operation->set_id(operations_.size());
|
||||
operations_.append(operation);
|
||||
if (current_node_) {
|
||||
operation->set_name(current_node_->getbNode()->name);
|
||||
}
|
||||
operation->set_execution_model(m_context->get_execution_model());
|
||||
operation->set_execution_model(context_->get_execution_model());
|
||||
operation->set_execution_system(exec_system_);
|
||||
}
|
||||
|
||||
@@ -153,17 +153,17 @@ void NodeOperationBuilder::unlink_inputs_and_relink_outputs(NodeOperation *unlin
|
||||
NodeOperation *linked_op)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < m_links.size()) {
|
||||
Link &link = m_links[i];
|
||||
while (i < links_.size()) {
|
||||
Link &link = links_[i];
|
||||
if (&link.to()->getOperation() == unlinked_op) {
|
||||
link.to()->setLink(nullptr);
|
||||
m_links.remove(i);
|
||||
links_.remove(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (&link.from()->getOperation() == unlinked_op) {
|
||||
link.to()->setLink(linked_op->getOutputSocket());
|
||||
m_links[i] = Link(linked_op->getOutputSocket(), link.to());
|
||||
links_[i] = Link(linked_op->getOutputSocket(), link.to());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@@ -172,23 +172,23 @@ void NodeOperationBuilder::unlink_inputs_and_relink_outputs(NodeOperation *unlin
|
||||
void NodeOperationBuilder::mapInputSocket(NodeInput *node_socket,
|
||||
NodeOperationInput *operation_socket)
|
||||
{
|
||||
BLI_assert(m_current_node);
|
||||
BLI_assert(node_socket->getNode() == m_current_node);
|
||||
BLI_assert(current_node_);
|
||||
BLI_assert(node_socket->getNode() == current_node_);
|
||||
|
||||
/* NOTE: this maps operation sockets to node sockets.
|
||||
* for resolving links the map will be inverted first in convertToOperations,
|
||||
* 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,
|
||||
NodeOperationOutput *operation_socket)
|
||||
{
|
||||
BLI_assert(m_current_node);
|
||||
BLI_assert(node_socket->getNode() == m_current_node);
|
||||
BLI_assert(current_node_);
|
||||
BLI_assert(node_socket->getNode() == 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)
|
||||
@@ -197,7 +197,7 @@ void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput
|
||||
return;
|
||||
}
|
||||
|
||||
m_links.append(Link(from, to));
|
||||
links_.append(Link(from, to));
|
||||
|
||||
/* register with the input */
|
||||
to->setLink(from);
|
||||
@@ -206,12 +206,12 @@ void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput
|
||||
void NodeOperationBuilder::removeInputLink(NodeOperationInput *to)
|
||||
{
|
||||
int index = 0;
|
||||
for (Link &link : m_links) {
|
||||
for (Link &link : links_) {
|
||||
if (link.to() == to) {
|
||||
/* unregister with the input */
|
||||
to->setLink(nullptr);
|
||||
|
||||
m_links.remove(index);
|
||||
links_.remove(index);
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
@@ -220,28 +220,28 @@ void NodeOperationBuilder::removeInputLink(NodeOperationInput *to)
|
||||
|
||||
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_->getbNode()->flag & NODE_PREVIEW)) {
|
||||
return nullptr;
|
||||
}
|
||||
/* previews only in the active group */
|
||||
if (!m_current_node->isInActiveGroup()) {
|
||||
if (!current_node_->isInActiveGroup()) {
|
||||
return nullptr;
|
||||
}
|
||||
/* do not calculate previews of hidden nodes */
|
||||
if (m_current_node->getbNode()->flag & NODE_HIDDEN) {
|
||||
if (current_node_->getbNode()->flag & NODE_HIDDEN) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bNodeInstanceHash *previews = m_context->getPreviewHash();
|
||||
bNodeInstanceHash *previews = context_->getPreviewHash();
|
||||
if (previews) {
|
||||
PreviewOperation *operation = new PreviewOperation(m_context->getViewSettings(),
|
||||
m_context->getDisplaySettings(),
|
||||
m_current_node->getbNode()->preview_xsize,
|
||||
m_current_node->getbNode()->preview_ysize);
|
||||
operation->setbNodeTree(m_context->getbNodeTree());
|
||||
operation->verifyPreview(previews, m_current_node->getInstanceKey());
|
||||
PreviewOperation *operation = new PreviewOperation(context_->getViewSettings(),
|
||||
context_->getDisplaySettings(),
|
||||
current_node_->getbNode()->preview_xsize,
|
||||
current_node_->getbNode()->preview_ysize);
|
||||
operation->setbNodeTree(context_->getbNodeTree());
|
||||
operation->verifyPreview(previews, current_node_->getInstanceKey());
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -270,18 +270,18 @@ void NodeOperationBuilder::addNodeInputPreview(NodeInput *input)
|
||||
|
||||
void NodeOperationBuilder::registerViewer(ViewerOperation *viewer)
|
||||
{
|
||||
if (m_active_viewer) {
|
||||
if (m_current_node->isInActiveGroup()) {
|
||||
if (active_viewer_) {
|
||||
if (current_node_->isInActiveGroup()) {
|
||||
/* deactivate previous viewer */
|
||||
m_active_viewer->setActive(false);
|
||||
active_viewer_->setActive(false);
|
||||
|
||||
m_active_viewer = viewer;
|
||||
active_viewer_ = viewer;
|
||||
viewer->setActive(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_current_node->getbNodeTree() == m_context->getbNodeTree()) {
|
||||
m_active_viewer = viewer;
|
||||
if (current_node_->getbNodeTree() == context_->getbNodeTree()) {
|
||||
active_viewer_ = viewer;
|
||||
viewer->setActive(true);
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ void NodeOperationBuilder::registerViewer(ViewerOperation *viewer)
|
||||
void NodeOperationBuilder::add_datatype_conversions()
|
||||
{
|
||||
Vector<Link> convert_links;
|
||||
for (const Link &link : m_links) {
|
||||
for (const Link &link : links_) {
|
||||
/* proxy operations can skip data type conversion */
|
||||
NodeOperation *from_op = &link.from()->getOperation();
|
||||
NodeOperation *to_op = &link.to()->getOperation();
|
||||
@@ -322,10 +322,10 @@ void NodeOperationBuilder::add_datatype_conversions()
|
||||
void NodeOperationBuilder::add_operation_input_constants()
|
||||
{
|
||||
/* NOTE: unconnected inputs cached first to avoid modifying
|
||||
* m_operations while iterating over it
|
||||
* operations_ while iterating over it
|
||||
*/
|
||||
Vector<NodeOperationInput *> pending_inputs;
|
||||
for (NodeOperation *op : m_operations) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
for (int k = 0; k < op->getNumberOfInputSockets(); ++k) {
|
||||
NodeOperationInput *input = op->getInputSocket(k);
|
||||
if (!input->isConnected()) {
|
||||
@@ -334,7 +334,7 @@ void NodeOperationBuilder::add_operation_input_constants()
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
|
||||
void NodeOperationBuilder::resolve_proxies()
|
||||
{
|
||||
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! */
|
||||
if (link.from()->getOperation().get_flags().is_proxy_operation &&
|
||||
!link.to()->getOperation().get_flags().is_proxy_operation) {
|
||||
@@ -423,16 +423,16 @@ void NodeOperationBuilder::determine_canvases()
|
||||
{
|
||||
/* Determine all canvas areas of the operations. */
|
||||
const rcti &preferred_area = COM_AREA_NONE;
|
||||
for (NodeOperation *op : m_operations) {
|
||||
if (op->isOutputOperation(m_context->isRendering()) && !op->get_flags().is_preview_operation) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
if (op->isOutputOperation(context_->isRendering()) && !op->get_flags().is_preview_operation) {
|
||||
rcti canvas = COM_AREA_NONE;
|
||||
op->determine_canvas(preferred_area, canvas);
|
||||
op->set_canvas(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
for (NodeOperation *op : m_operations) {
|
||||
if (op->isOutputOperation(m_context->isRendering()) && op->get_flags().is_preview_operation) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
if (op->isOutputOperation(context_->isRendering()) && op->get_flags().is_preview_operation) {
|
||||
rcti canvas = COM_AREA_NONE;
|
||||
op->determine_canvas(preferred_area, canvas);
|
||||
op->set_canvas(canvas);
|
||||
@@ -442,7 +442,7 @@ void NodeOperationBuilder::determine_canvases()
|
||||
/* Convert operation canvases when needed. */
|
||||
{
|
||||
Vector<Link> convert_links;
|
||||
for (const Link &link : m_links) {
|
||||
for (const Link &link : links_) {
|
||||
if (link.to()->getResizeMode() != ResizeMode::None) {
|
||||
const rcti &from_canvas = link.from()->getOperation().get_canvas();
|
||||
const rcti &to_canvas = link.to()->getOperation().get_canvas();
|
||||
@@ -485,7 +485,7 @@ void NodeOperationBuilder::merge_equal_operations()
|
||||
bool check_for_next_merge = true;
|
||||
while (check_for_next_merge) {
|
||||
/* 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. */
|
||||
std::sort(hashes.begin(), hashes.end());
|
||||
@@ -507,7 +507,7 @@ void NodeOperationBuilder::merge_equal_operations()
|
||||
void NodeOperationBuilder::merge_equal_operations(NodeOperation *from, NodeOperation *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;
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ Vector<NodeOperationInput *> NodeOperationBuilder::cache_output_links(
|
||||
NodeOperationOutput *output) const
|
||||
{
|
||||
Vector<NodeOperationInput *> inputs;
|
||||
for (const Link &link : m_links) {
|
||||
for (const Link &link : links_) {
|
||||
if (link.from() == output) {
|
||||
inputs.append(link.to());
|
||||
}
|
||||
@@ -526,7 +526,7 @@ Vector<NodeOperationInput *> NodeOperationBuilder::cache_output_links(
|
||||
WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation(
|
||||
NodeOperationOutput *output) const
|
||||
{
|
||||
for (const Link &link : m_links) {
|
||||
for (const Link &link : links_) {
|
||||
if (link.from() == output) {
|
||||
NodeOperation &op = link.to()->getOperation();
|
||||
if (op.get_flags().is_write_buffer_operation) {
|
||||
@@ -557,7 +557,7 @@ void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/,
|
||||
WriteBufferOperation *writeoperation = find_attached_write_buffer_operation(output);
|
||||
if (!writeoperation) {
|
||||
writeoperation = new WriteBufferOperation(output->getDataType());
|
||||
writeoperation->setbNodeTree(m_context->getbNodeTree());
|
||||
writeoperation->setbNodeTree(context_->getbNodeTree());
|
||||
addOperation(writeoperation);
|
||||
|
||||
addLink(output, writeoperation->getInputSocket(0));
|
||||
@@ -600,7 +600,7 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
|
||||
/* if no write buffer operation exists yet, create a new one */
|
||||
if (!writeOperation) {
|
||||
writeOperation = new WriteBufferOperation(operation->getOutputSocket()->getDataType());
|
||||
writeOperation->setbNodeTree(m_context->getbNodeTree());
|
||||
writeOperation->setbNodeTree(context_->getbNodeTree());
|
||||
addOperation(writeOperation);
|
||||
|
||||
addLink(output, writeOperation->getInputSocket(0));
|
||||
@@ -628,10 +628,10 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
|
||||
void NodeOperationBuilder::add_complex_operation_buffers()
|
||||
{
|
||||
/* 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;
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
for (NodeOperation *operation : operations_) {
|
||||
if (operation->get_flags().complex) {
|
||||
complex_ops.append(operation);
|
||||
}
|
||||
@@ -677,16 +677,16 @@ static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *
|
||||
void NodeOperationBuilder::prune_operations()
|
||||
{
|
||||
Tags reachable;
|
||||
for (NodeOperation *op : m_operations) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
/* output operations are primary executed operations */
|
||||
if (op->isOutputOperation(m_context->isRendering())) {
|
||||
if (op->isOutputOperation(context_->isRendering())) {
|
||||
find_reachable_operations_recursive(reachable, op);
|
||||
}
|
||||
}
|
||||
|
||||
/* delete unreachable operations */
|
||||
Vector<NodeOperation *> reachable_ops;
|
||||
for (NodeOperation *op : m_operations) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
if (reachable.find(op) != reachable.end()) {
|
||||
reachable_ops.append(op);
|
||||
}
|
||||
@@ -695,7 +695,7 @@ void NodeOperationBuilder::prune_operations()
|
||||
}
|
||||
}
|
||||
/* finally replace the operations list with the pruned list */
|
||||
m_operations = reachable_ops;
|
||||
operations_ = reachable_ops;
|
||||
}
|
||||
|
||||
/* topological (depth-first) sorting of operations */
|
||||
@@ -721,14 +721,14 @@ static void sort_operations_recursive(Vector<NodeOperation *> &sorted,
|
||||
void NodeOperationBuilder::sort_operations()
|
||||
{
|
||||
Vector<NodeOperation *> sorted;
|
||||
sorted.reserve(m_operations.size());
|
||||
sorted.reserve(operations_.size());
|
||||
Tags visited;
|
||||
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
for (NodeOperation *operation : operations_) {
|
||||
sort_operations_recursive(sorted, visited, operation);
|
||||
}
|
||||
|
||||
m_operations = sorted;
|
||||
operations_ = sorted;
|
||||
}
|
||||
|
||||
static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group)
|
||||
@@ -753,8 +753,8 @@ static void add_group_operations_recursive(Tags &visited, NodeOperation *op, Exe
|
||||
|
||||
ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op)
|
||||
{
|
||||
ExecutionGroup *group = new ExecutionGroup(m_groups.size());
|
||||
m_groups.append(group);
|
||||
ExecutionGroup *group = new ExecutionGroup(groups_.size());
|
||||
groups_.append(group);
|
||||
|
||||
Tags visited;
|
||||
add_group_operations_recursive(visited, op, group);
|
||||
@@ -764,8 +764,8 @@ ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op)
|
||||
|
||||
void NodeOperationBuilder::group_operations()
|
||||
{
|
||||
for (NodeOperation *op : m_operations) {
|
||||
if (op->isOutputOperation(m_context->isRendering())) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
if (op->isOutputOperation(context_->isRendering())) {
|
||||
ExecutionGroup *group = make_group(op);
|
||||
group->setOutputExecutionGroup(true);
|
||||
}
|
||||
@@ -786,7 +786,7 @@ void NodeOperationBuilder::group_operations()
|
||||
void NodeOperationBuilder::save_graphviz(StringRefNull name)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
exec_system_->set_operations(m_operations, m_groups);
|
||||
exec_system_->set_operations(operations_, groups_);
|
||||
DebugInfo::graphviz(exec_system_, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,45 +46,45 @@ class NodeOperationBuilder {
|
||||
public:
|
||||
class Link {
|
||||
private:
|
||||
NodeOperationOutput *m_from;
|
||||
NodeOperationInput *m_to;
|
||||
NodeOperationOutput *from_;
|
||||
NodeOperationInput *to_;
|
||||
|
||||
public:
|
||||
Link(NodeOperationOutput *from, NodeOperationInput *to) : m_from(from), m_to(to)
|
||||
Link(NodeOperationOutput *from, NodeOperationInput *to) : from_(from), to_(to)
|
||||
{
|
||||
}
|
||||
|
||||
NodeOperationOutput *from() const
|
||||
{
|
||||
return m_from;
|
||||
return from_;
|
||||
}
|
||||
NodeOperationInput *to() const
|
||||
{
|
||||
return m_to;
|
||||
return to_;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
const CompositorContext *m_context;
|
||||
NodeGraph m_graph;
|
||||
const CompositorContext *context_;
|
||||
NodeGraph graph_;
|
||||
ExecutionSystem *exec_system_;
|
||||
|
||||
Vector<NodeOperation *> m_operations;
|
||||
Vector<Link> m_links;
|
||||
Vector<ExecutionGroup *> m_groups;
|
||||
Vector<NodeOperation *> operations_;
|
||||
Vector<Link> links_;
|
||||
Vector<ExecutionGroup *> groups_;
|
||||
|
||||
/** Maps operation inputs to node inputs */
|
||||
Map<NodeOperationInput *, NodeInput *> m_input_map;
|
||||
Map<NodeOperationInput *, NodeInput *> input_map_;
|
||||
/** 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
|
||||
* Only one operation can occupy this place at a time,
|
||||
* to avoid race conditions
|
||||
*/
|
||||
ViewerOperation *m_active_viewer;
|
||||
ViewerOperation *active_viewer_;
|
||||
|
||||
public:
|
||||
NodeOperationBuilder(const CompositorContext *context,
|
||||
@@ -93,7 +93,7 @@ class NodeOperationBuilder {
|
||||
|
||||
const CompositorContext &context() const
|
||||
{
|
||||
return *m_context;
|
||||
return *context_;
|
||||
}
|
||||
|
||||
void convertToOperations(ExecutionSystem *system);
|
||||
@@ -120,17 +120,17 @@ class NodeOperationBuilder {
|
||||
/** The currently active viewer output operation */
|
||||
ViewerOperation *active_viewer() const
|
||||
{
|
||||
return m_active_viewer;
|
||||
return active_viewer_;
|
||||
}
|
||||
|
||||
const Vector<NodeOperation *> &get_operations() const
|
||||
{
|
||||
return m_operations;
|
||||
return operations_;
|
||||
}
|
||||
|
||||
const Vector<Link> &get_links() const
|
||||
{
|
||||
return m_links;
|
||||
return links_;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -42,30 +42,30 @@ OpenCLDevice::OpenCLDevice(cl_context context,
|
||||
cl_program program,
|
||||
cl_int vendorId)
|
||||
{
|
||||
m_device = device;
|
||||
m_context = context;
|
||||
m_program = program;
|
||||
m_queue = nullptr;
|
||||
m_vendorID = vendorId;
|
||||
device_ = device;
|
||||
context_ = context;
|
||||
program_ = program;
|
||||
queue_ = nullptr;
|
||||
vendorID_ = vendorId;
|
||||
|
||||
cl_int error;
|
||||
m_queue = clCreateCommandQueue(m_context, m_device, 0, &error);
|
||||
queue_ = clCreateCommandQueue(context_, device_, 0, &error);
|
||||
}
|
||||
|
||||
OpenCLDevice::OpenCLDevice(OpenCLDevice &&other) noexcept
|
||||
: m_context(other.m_context),
|
||||
m_device(other.m_device),
|
||||
m_program(other.m_program),
|
||||
m_queue(other.m_queue),
|
||||
m_vendorID(other.m_vendorID)
|
||||
: context_(other.context_),
|
||||
device_(other.device_),
|
||||
program_(other.program_),
|
||||
queue_(other.queue_),
|
||||
vendorID_(other.vendorID_)
|
||||
{
|
||||
other.m_queue = nullptr;
|
||||
other.queue_ = nullptr;
|
||||
}
|
||||
|
||||
OpenCLDevice::~OpenCLDevice()
|
||||
{
|
||||
if (m_queue) {
|
||||
clReleaseCommandQueue(m_queue);
|
||||
if (queue_) {
|
||||
clReleaseCommandQueue(queue_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
|
||||
const cl_image_format *imageFormat = determineImageFormat(result);
|
||||
|
||||
cl_mem clBuffer = clCreateImage2D(m_context,
|
||||
cl_mem clBuffer = clCreateImage2D(context_,
|
||||
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||
imageFormat,
|
||||
result->getWidth(),
|
||||
@@ -206,7 +206,7 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemo
|
||||
(size_t)outputMemoryBuffer->getHeight(),
|
||||
};
|
||||
|
||||
error = clEnqueueNDRangeKernel(m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
error = clEnqueueNDRangeKernel(queue_, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
@@ -226,7 +226,7 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel,
|
||||
size_t size[2];
|
||||
cl_int2 offset;
|
||||
|
||||
if (m_vendorID == NVIDIA) {
|
||||
if (vendorID_ == NVIDIA) {
|
||||
localSize = 32;
|
||||
}
|
||||
|
||||
@@ -254,11 +254,11 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel,
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
error = clEnqueueNDRangeKernel(
|
||||
m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
queue_, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
clFlush(m_queue);
|
||||
clFlush(queue_);
|
||||
if (operation->isBraked()) {
|
||||
breaked = false;
|
||||
}
|
||||
@@ -270,7 +270,7 @@ cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname,
|
||||
std::list<cl_kernel> *clKernelsToCleanUp)
|
||||
{
|
||||
cl_int error;
|
||||
cl_kernel kernel = clCreateKernel(m_program, kernelname, &error);
|
||||
cl_kernel kernel = clCreateKernel(program_, kernelname, &error);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
|
||||
@@ -43,27 +43,27 @@ class OpenCLDevice : public Device {
|
||||
/**
|
||||
* \brief opencl context
|
||||
*/
|
||||
cl_context m_context;
|
||||
cl_context context_;
|
||||
|
||||
/**
|
||||
* \brief opencl device
|
||||
*/
|
||||
cl_device_id m_device;
|
||||
cl_device_id device_;
|
||||
|
||||
/**
|
||||
* \brief opencl program
|
||||
*/
|
||||
cl_program m_program;
|
||||
cl_program program_;
|
||||
|
||||
/**
|
||||
* \brief opencl command queue
|
||||
*/
|
||||
cl_command_queue m_queue;
|
||||
cl_command_queue queue_;
|
||||
|
||||
/**
|
||||
* \brief opencl vendor ID
|
||||
*/
|
||||
cl_int m_vendorID;
|
||||
cl_int vendorID_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -93,12 +93,12 @@ class OpenCLDevice : public Device {
|
||||
|
||||
cl_context getContext()
|
||||
{
|
||||
return m_context;
|
||||
return context_;
|
||||
}
|
||||
|
||||
cl_command_queue getQueue()
|
||||
{
|
||||
return m_queue;
|
||||
return queue_;
|
||||
}
|
||||
|
||||
cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace blender::compositor {
|
||||
|
||||
SingleThreadedOperation::SingleThreadedOperation()
|
||||
{
|
||||
m_cachedInstance = nullptr;
|
||||
cachedInstance_ = nullptr;
|
||||
flags.complex = true;
|
||||
flags.single_threaded = true;
|
||||
}
|
||||
@@ -34,30 +34,30 @@ void SingleThreadedOperation::initExecution()
|
||||
|
||||
void SingleThreadedOperation::executePixel(float output[4], int x, int y, void * /*data*/)
|
||||
{
|
||||
m_cachedInstance->readNoCheck(output, x, y);
|
||||
cachedInstance_->readNoCheck(output, x, y);
|
||||
}
|
||||
|
||||
void SingleThreadedOperation::deinitExecution()
|
||||
{
|
||||
deinitMutex();
|
||||
if (m_cachedInstance) {
|
||||
delete m_cachedInstance;
|
||||
m_cachedInstance = nullptr;
|
||||
if (cachedInstance_) {
|
||||
delete cachedInstance_;
|
||||
cachedInstance_ = nullptr;
|
||||
}
|
||||
}
|
||||
void *SingleThreadedOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
if (m_cachedInstance) {
|
||||
return m_cachedInstance;
|
||||
if (cachedInstance_) {
|
||||
return cachedInstance_;
|
||||
}
|
||||
|
||||
lockMutex();
|
||||
if (m_cachedInstance == nullptr) {
|
||||
if (cachedInstance_ == nullptr) {
|
||||
//
|
||||
m_cachedInstance = createMemoryBuffer(rect);
|
||||
cachedInstance_ = createMemoryBuffer(rect);
|
||||
}
|
||||
unlockMutex();
|
||||
return m_cachedInstance;
|
||||
return cachedInstance_;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -24,12 +24,12 @@ namespace blender::compositor {
|
||||
|
||||
class SingleThreadedOperation : public NodeOperation {
|
||||
private:
|
||||
MemoryBuffer *m_cachedInstance;
|
||||
MemoryBuffer *cachedInstance_;
|
||||
|
||||
protected:
|
||||
inline bool isCached()
|
||||
{
|
||||
return m_cachedInstance != nullptr;
|
||||
return cachedInstance_ != nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace blender::compositor {
|
||||
DilateErodeNode::DilateErodeNode(bNode *editorNode) : Node(editorNode)
|
||||
{
|
||||
/* initialize node data */
|
||||
NodeBlurData *data = &m_alpha_blur;
|
||||
NodeBlurData *data = &alpha_blur_;
|
||||
memset(data, 0, sizeof(NodeBlurData));
|
||||
data->filtertype = R_FILTER_GAUSS;
|
||||
|
||||
@@ -86,7 +86,7 @@ void DilateErodeNode::convertToOperations(NodeConverter &converter,
|
||||
eCompositorQuality quality = context.getQuality();
|
||||
|
||||
GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
|
||||
operationx->setData(&m_alpha_blur);
|
||||
operationx->setData(&alpha_blur_);
|
||||
operationx->setQuality(quality);
|
||||
operationx->setFalloff(PROP_SMOOTH);
|
||||
converter.addOperation(operationx);
|
||||
@@ -96,7 +96,7 @@ void DilateErodeNode::convertToOperations(NodeConverter &converter,
|
||||
// yet
|
||||
|
||||
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
|
||||
operationy->setData(&m_alpha_blur);
|
||||
operationy->setData(&alpha_blur_);
|
||||
operationy->setQuality(quality);
|
||||
operationy->setFalloff(PROP_SMOOTH);
|
||||
converter.addOperation(operationy);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace blender::compositor {
|
||||
*/
|
||||
class DilateErodeNode : public Node {
|
||||
/** only used for blurring alpha, since the dilate/erode node doesn't have this. */
|
||||
NodeBlurData m_alpha_blur;
|
||||
NodeBlurData alpha_blur_;
|
||||
|
||||
public:
|
||||
DilateErodeNode(bNode *editorNode);
|
||||
|
||||
@@ -26,7 +26,7 @@ SocketProxyNode::SocketProxyNode(bNode *editorNode,
|
||||
bNodeSocket *editorInput,
|
||||
bNodeSocket *editorOutput,
|
||||
bool use_conversion)
|
||||
: Node(editorNode, false), m_use_conversion(use_conversion)
|
||||
: Node(editorNode, false), use_conversion_(use_conversion)
|
||||
{
|
||||
DataType dt;
|
||||
|
||||
@@ -52,7 +52,7 @@ SocketProxyNode::SocketProxyNode(bNode *editorNode,
|
||||
void SocketProxyNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
NodeOperationOutput *proxy_output = converter.addInputProxy(getInputSocket(0), m_use_conversion);
|
||||
NodeOperationOutput *proxy_output = converter.addInputProxy(getInputSocket(0), use_conversion_);
|
||||
converter.mapOutputSocket(getOutputSocket(), proxy_output);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,16 +37,16 @@ class SocketProxyNode : public Node {
|
||||
|
||||
bool getUseConversion() const
|
||||
{
|
||||
return m_use_conversion;
|
||||
return use_conversion_;
|
||||
}
|
||||
void setUseConversion(bool use_conversion)
|
||||
{
|
||||
m_use_conversion = use_conversion;
|
||||
use_conversion_ = use_conversion;
|
||||
}
|
||||
|
||||
private:
|
||||
/** If true, the proxy will convert input and output data to/from the proxy socket types. */
|
||||
bool m_use_conversion;
|
||||
bool use_conversion_;
|
||||
};
|
||||
|
||||
class SocketBufferNode : public Node {
|
||||
|
||||
@@ -34,9 +34,9 @@ void AlphaOverKeyOperation::executePixelSampled(float output[4],
|
||||
float inputOverColor[4];
|
||||
float value[4];
|
||||
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
|
||||
inputValueOperation_->readSampled(value, x, y, sampler);
|
||||
inputColor1Operation_->readSampled(inputColor1, x, y, sampler);
|
||||
inputColor2Operation_->readSampled(inputOverColor, x, y, sampler);
|
||||
|
||||
if (inputOverColor[3] <= 0.0f) {
|
||||
copy_v4_v4(output, inputColor1);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace blender::compositor {
|
||||
|
||||
AlphaOverMixedOperation::AlphaOverMixedOperation()
|
||||
{
|
||||
m_x = 0.0f;
|
||||
x_ = 0.0f;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ void AlphaOverMixedOperation::executePixelSampled(float output[4],
|
||||
float inputOverColor[4];
|
||||
float value[4];
|
||||
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
|
||||
inputValueOperation_->readSampled(value, x, y, sampler);
|
||||
inputColor1Operation_->readSampled(inputColor1, x, y, sampler);
|
||||
inputColor2Operation_->readSampled(inputOverColor, x, y, sampler);
|
||||
|
||||
if (inputOverColor[3] <= 0.0f) {
|
||||
copy_v4_v4(output, inputColor1);
|
||||
@@ -46,7 +46,7 @@ void AlphaOverMixedOperation::executePixelSampled(float output[4],
|
||||
copy_v4_v4(output, inputOverColor);
|
||||
}
|
||||
else {
|
||||
float addfac = 1.0f - m_x + inputOverColor[3] * m_x;
|
||||
float addfac = 1.0f - x_ + inputOverColor[3] * x_;
|
||||
float premul = value[0] * addfac;
|
||||
float mul = 1.0f - value[0] * inputOverColor[3];
|
||||
|
||||
@@ -71,7 +71,7 @@ void AlphaOverMixedOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
copy_v4_v4(p.out, over_color);
|
||||
}
|
||||
else {
|
||||
const float addfac = 1.0f - m_x + over_color[3] * m_x;
|
||||
const float addfac = 1.0f - x_ + over_color[3] * x_;
|
||||
const float premul = value * addfac;
|
||||
const float mul = 1.0f - value * over_color[3];
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace blender::compositor {
|
||||
*/
|
||||
class AlphaOverMixedOperation : public MixBaseOperation {
|
||||
private:
|
||||
float m_x;
|
||||
float x_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ class AlphaOverMixedOperation : public MixBaseOperation {
|
||||
|
||||
void setX(float x)
|
||||
{
|
||||
m_x = x;
|
||||
x_ = x;
|
||||
}
|
||||
|
||||
void update_memory_buffer_row(PixelCursor &p) override;
|
||||
|
||||
@@ -34,9 +34,9 @@ void AlphaOverPremultiplyOperation::executePixelSampled(float output[4],
|
||||
float inputOverColor[4];
|
||||
float value[4];
|
||||
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
|
||||
inputValueOperation_->readSampled(value, x, y, sampler);
|
||||
inputColor1Operation_->readSampled(inputColor1, x, y, sampler);
|
||||
inputColor2Operation_->readSampled(inputOverColor, x, y, sampler);
|
||||
|
||||
/* Zero alpha values should still permit an add of RGB data */
|
||||
if (inputOverColor[3] < 0.0f) {
|
||||
|
||||
@@ -112,13 +112,13 @@ AntiAliasOperation::AntiAliasOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
m_valueReader = nullptr;
|
||||
valueReader_ = nullptr;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
|
||||
void AntiAliasOperation::initExecution()
|
||||
{
|
||||
m_valueReader = this->getInputSocketReader(0);
|
||||
valueReader_ = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void AntiAliasOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
@@ -175,7 +175,7 @@ void AntiAliasOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
|
||||
void AntiAliasOperation::deinitExecution()
|
||||
{
|
||||
m_valueReader = nullptr;
|
||||
valueReader_ = nullptr;
|
||||
}
|
||||
|
||||
bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
|
||||
@@ -33,7 +33,7 @@ class AntiAliasOperation : public MultiThreadedOperation {
|
||||
/**
|
||||
* \brief Cached reference to the reader
|
||||
*/
|
||||
SocketReader *m_valueReader;
|
||||
SocketReader *valueReader_;
|
||||
|
||||
public:
|
||||
AntiAliasOperation();
|
||||
|
||||
@@ -27,14 +27,14 @@ BilateralBlurOperation::BilateralBlurOperation()
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
|
||||
m_inputColorProgram = nullptr;
|
||||
m_inputDeterminatorProgram = nullptr;
|
||||
inputColorProgram_ = nullptr;
|
||||
inputDeterminatorProgram_ = nullptr;
|
||||
}
|
||||
|
||||
void BilateralBlurOperation::initExecution()
|
||||
{
|
||||
m_inputColorProgram = getInputSocketReader(0);
|
||||
m_inputDeterminatorProgram = getInputSocketReader(1);
|
||||
inputColorProgram_ = getInputSocketReader(0);
|
||||
inputDeterminatorProgram_ = getInputSocketReader(1);
|
||||
QualityStepHelper::initExecution(COM_QH_INCREASE);
|
||||
}
|
||||
|
||||
@@ -47,14 +47,14 @@ void BilateralBlurOperation::executePixel(float output[4], int x, int y, void *d
|
||||
float tempColor[4];
|
||||
float blurColor[4];
|
||||
float blurDivider;
|
||||
float space = m_space;
|
||||
float sigmacolor = m_data->sigma_color;
|
||||
float space = space_;
|
||||
float sigmacolor = data_->sigma_color;
|
||||
int minx = floor(x - space);
|
||||
int maxx = ceil(x + space);
|
||||
int miny = floor(y - space);
|
||||
int maxy = ceil(y + space);
|
||||
float deltaColor;
|
||||
m_inputDeterminatorProgram->read(determinatorReferenceColor, x, y, data);
|
||||
inputDeterminatorProgram_->read(determinatorReferenceColor, x, y, data);
|
||||
|
||||
zero_v4(blurColor);
|
||||
blurDivider = 0.0f;
|
||||
@@ -65,14 +65,14 @@ void BilateralBlurOperation::executePixel(float output[4], int x, int y, void *d
|
||||
for (int yi = miny; yi < maxy; yi += QualityStepHelper::getStep()) {
|
||||
for (int xi = minx; xi < maxx; xi += QualityStepHelper::getStep()) {
|
||||
/* Read determinator. */
|
||||
m_inputDeterminatorProgram->read(determinator, xi, yi, data);
|
||||
inputDeterminatorProgram_->read(determinator, xi, yi, data);
|
||||
deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) +
|
||||
fabsf(determinatorReferenceColor[1] - determinator[1]) +
|
||||
/* Do not take the alpha channel into account. */
|
||||
fabsf(determinatorReferenceColor[2] - determinator[2]));
|
||||
if (deltaColor < sigmacolor) {
|
||||
/* Add this to the blur. */
|
||||
m_inputColorProgram->read(tempColor, xi, yi, data);
|
||||
inputColorProgram_->read(tempColor, xi, yi, data);
|
||||
add_v4_v4(blurColor, tempColor);
|
||||
blurDivider += 1.0f;
|
||||
}
|
||||
@@ -92,8 +92,8 @@ void BilateralBlurOperation::executePixel(float output[4], int x, int y, void *d
|
||||
|
||||
void BilateralBlurOperation::deinitExecution()
|
||||
{
|
||||
m_inputColorProgram = nullptr;
|
||||
m_inputDeterminatorProgram = nullptr;
|
||||
inputColorProgram_ = nullptr;
|
||||
inputDeterminatorProgram_ = nullptr;
|
||||
}
|
||||
|
||||
bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -101,7 +101,7 @@ bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
rcti *output)
|
||||
{
|
||||
rcti newInput;
|
||||
int add = ceil(m_space) + 1;
|
||||
int add = ceil(space_) + 1;
|
||||
|
||||
newInput.xmax = input->xmax + (add);
|
||||
newInput.xmin = input->xmin - (add);
|
||||
@@ -115,7 +115,7 @@ void BilateralBlurOperation::get_area_of_interest(const int UNUSED(input_idx),
|
||||
const rcti &output_area,
|
||||
rcti &r_input_area)
|
||||
{
|
||||
const int add = ceil(m_space) + 1;
|
||||
const int add = ceil(space_) + 1;
|
||||
|
||||
r_input_area.xmax = output_area.xmax + (add);
|
||||
r_input_area.xmin = output_area.xmin - (add);
|
||||
@@ -174,10 +174,10 @@ void BilateralBlurOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
{
|
||||
PixelCursor p = {};
|
||||
p.step = QualityStepHelper::getStep();
|
||||
p.sigma_color = m_data->sigma_color;
|
||||
p.sigma_color = data_->sigma_color;
|
||||
p.input_color = inputs[0];
|
||||
p.input_determinator = inputs[1];
|
||||
const float space = m_space;
|
||||
const float space = space_;
|
||||
for (int y = area.ymin; y < area.ymax; y++) {
|
||||
p.out = output->get_elem(area.xmin, y);
|
||||
/* This will be used as the reference color for the determinator. */
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace blender::compositor {
|
||||
|
||||
class BilateralBlurOperation : public MultiThreadedOperation, public QualityStepHelper {
|
||||
private:
|
||||
SocketReader *m_inputColorProgram;
|
||||
SocketReader *m_inputDeterminatorProgram;
|
||||
NodeBilateralBlurData *m_data;
|
||||
float m_space;
|
||||
SocketReader *inputColorProgram_;
|
||||
SocketReader *inputDeterminatorProgram_;
|
||||
NodeBilateralBlurData *data_;
|
||||
float space_;
|
||||
|
||||
public:
|
||||
BilateralBlurOperation();
|
||||
@@ -54,8 +54,8 @@ class BilateralBlurOperation : public MultiThreadedOperation, public QualityStep
|
||||
|
||||
void setData(NodeBilateralBlurData *data)
|
||||
{
|
||||
m_data = data;
|
||||
m_space = data->sigma_space + data->iter;
|
||||
data_ = data;
|
||||
space_ = data->sigma_space + data->iter;
|
||||
}
|
||||
|
||||
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
|
||||
|
||||
@@ -30,11 +30,11 @@ BlurBaseOperation::BlurBaseOperation(DataType data_type)
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(data_type);
|
||||
this->flags.complex = true;
|
||||
m_inputProgram = nullptr;
|
||||
memset(&m_data, 0, sizeof(NodeBlurData));
|
||||
m_size = 1.0f;
|
||||
m_sizeavailable = false;
|
||||
m_extend_bounds = false;
|
||||
inputProgram_ = nullptr;
|
||||
memset(&data_, 0, sizeof(NodeBlurData));
|
||||
size_ = 1.0f;
|
||||
sizeavailable_ = false;
|
||||
extend_bounds_ = false;
|
||||
use_variable_size_ = false;
|
||||
}
|
||||
|
||||
@@ -44,32 +44,32 @@ void BlurBaseOperation::init_data()
|
||||
updateSize();
|
||||
}
|
||||
|
||||
m_data.image_in_width = this->getWidth();
|
||||
m_data.image_in_height = this->getHeight();
|
||||
if (m_data.relative) {
|
||||
data_.image_in_width = this->getWidth();
|
||||
data_.image_in_height = this->getHeight();
|
||||
if (data_.relative) {
|
||||
int sizex, sizey;
|
||||
switch (m_data.aspect) {
|
||||
switch (data_.aspect) {
|
||||
case CMP_NODE_BLUR_ASPECT_Y:
|
||||
sizex = sizey = m_data.image_in_width;
|
||||
sizex = sizey = data_.image_in_width;
|
||||
break;
|
||||
case CMP_NODE_BLUR_ASPECT_X:
|
||||
sizex = sizey = m_data.image_in_height;
|
||||
sizex = sizey = data_.image_in_height;
|
||||
break;
|
||||
default:
|
||||
BLI_assert(m_data.aspect == CMP_NODE_BLUR_ASPECT_NONE);
|
||||
sizex = m_data.image_in_width;
|
||||
sizey = m_data.image_in_height;
|
||||
BLI_assert(data_.aspect == CMP_NODE_BLUR_ASPECT_NONE);
|
||||
sizex = data_.image_in_width;
|
||||
sizey = data_.image_in_height;
|
||||
break;
|
||||
}
|
||||
m_data.sizex = round_fl_to_int(m_data.percentx * 0.01f * sizex);
|
||||
m_data.sizey = round_fl_to_int(m_data.percenty * 0.01f * sizey);
|
||||
data_.sizex = round_fl_to_int(data_.percentx * 0.01f * sizex);
|
||||
data_.sizey = round_fl_to_int(data_.percenty * 0.01f * sizey);
|
||||
}
|
||||
}
|
||||
|
||||
void BlurBaseOperation::initExecution()
|
||||
{
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputSize = this->getInputSocketReader(1);
|
||||
inputProgram_ = this->getInputSocketReader(0);
|
||||
inputSize_ = this->getInputSocketReader(1);
|
||||
|
||||
QualityStepHelper::initExecution(COM_QH_MULTIPLY);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ float *BlurBaseOperation::make_gausstab(float rad, int size)
|
||||
sum = 0.0f;
|
||||
float fac = (rad > 0.0f ? 1.0f / rad : 0.0f);
|
||||
for (i = -size; i <= size; i++) {
|
||||
val = RE_filter_value(m_data.filtertype, (float)i * fac);
|
||||
val = RE_filter_value(data_.filtertype, (float)i * fac);
|
||||
sum += val;
|
||||
gausstab[i + size] = val;
|
||||
}
|
||||
@@ -165,29 +165,29 @@ float *BlurBaseOperation::make_dist_fac_inverse(float rad, int size, int falloff
|
||||
|
||||
void BlurBaseOperation::deinitExecution()
|
||||
{
|
||||
m_inputProgram = nullptr;
|
||||
m_inputSize = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
inputSize_ = nullptr;
|
||||
}
|
||||
|
||||
void BlurBaseOperation::setData(const NodeBlurData *data)
|
||||
{
|
||||
memcpy(&m_data, data, sizeof(NodeBlurData));
|
||||
memcpy(&data_, data, sizeof(NodeBlurData));
|
||||
}
|
||||
|
||||
int BlurBaseOperation::get_blur_size(eDimension dim) const
|
||||
{
|
||||
switch (dim) {
|
||||
case eDimension::X:
|
||||
return m_data.sizex;
|
||||
return data_.sizex;
|
||||
case eDimension::Y:
|
||||
return m_data.sizey;
|
||||
return data_.sizey;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void BlurBaseOperation::updateSize()
|
||||
{
|
||||
if (m_sizeavailable || use_variable_size_) {
|
||||
if (sizeavailable_ || use_variable_size_) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -195,23 +195,23 @@ void BlurBaseOperation::updateSize()
|
||||
case eExecutionModel::Tiled: {
|
||||
float result[4];
|
||||
this->getInputSocketReader(1)->readSampled(result, 0, 0, PixelSampler::Nearest);
|
||||
m_size = result[0];
|
||||
size_ = result[0];
|
||||
break;
|
||||
}
|
||||
case eExecutionModel::FullFrame: {
|
||||
NodeOperation *size_input = get_input_operation(SIZE_INPUT_INDEX);
|
||||
if (size_input->get_flags().is_constant_operation) {
|
||||
m_size = *static_cast<ConstantOperation *>(size_input)->get_constant_elem();
|
||||
size_ = *static_cast<ConstantOperation *>(size_input)->get_constant_elem();
|
||||
} /* Else use default. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_sizeavailable = true;
|
||||
sizeavailable_ = true;
|
||||
}
|
||||
|
||||
void BlurBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
if (!m_extend_bounds) {
|
||||
if (!extend_bounds_) {
|
||||
NodeOperation::determine_canvas(preferred_area, r_area);
|
||||
return;
|
||||
}
|
||||
@@ -219,8 +219,8 @@ void BlurBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_are
|
||||
switch (execution_model_) {
|
||||
case eExecutionModel::Tiled: {
|
||||
NodeOperation::determine_canvas(preferred_area, r_area);
|
||||
r_area.xmax += 2 * m_size * m_data.sizex;
|
||||
r_area.ymax += 2 * m_size * m_data.sizey;
|
||||
r_area.xmax += 2 * size_ * data_.sizex;
|
||||
r_area.ymax += 2 * size_ * data_.sizey;
|
||||
break;
|
||||
}
|
||||
case eExecutionModel::FullFrame: {
|
||||
@@ -229,8 +229,8 @@ void BlurBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_are
|
||||
* operations. */
|
||||
set_determined_canvas_modifier([=](rcti &canvas) {
|
||||
/* Rounding to even prevents jiggling in backdrop while switching size values. */
|
||||
canvas.xmax += round_to_even(2 * m_size * m_data.sizex);
|
||||
canvas.ymax += round_to_even(2 * m_size * m_data.sizey);
|
||||
canvas.xmax += round_to_even(2 * size_ * data_.sizex);
|
||||
canvas.ymax += round_to_even(2 * size_ * data_.sizey);
|
||||
});
|
||||
NodeOperation::determine_canvas(preferred_area, r_area);
|
||||
break;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace blender::compositor {
|
||||
|
||||
class BlurBaseOperation : public MultiThreadedOperation, public QualityStepHelper {
|
||||
private:
|
||||
bool m_extend_bounds;
|
||||
bool extend_bounds_;
|
||||
|
||||
protected:
|
||||
static constexpr int IMAGE_INPUT_INDEX = 0;
|
||||
@@ -48,12 +48,12 @@ class BlurBaseOperation : public MultiThreadedOperation, public QualityStepHelpe
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputProgram;
|
||||
SocketReader *m_inputSize;
|
||||
NodeBlurData m_data;
|
||||
SocketReader *inputProgram_;
|
||||
SocketReader *inputSize_;
|
||||
NodeBlurData data_;
|
||||
|
||||
float m_size;
|
||||
bool m_sizeavailable;
|
||||
float size_;
|
||||
bool sizeavailable_;
|
||||
|
||||
/* Flags for inheriting classes. */
|
||||
bool use_variable_size_;
|
||||
@@ -74,13 +74,13 @@ class BlurBaseOperation : public MultiThreadedOperation, public QualityStepHelpe
|
||||
|
||||
void setSize(float size)
|
||||
{
|
||||
m_size = size;
|
||||
m_sizeavailable = true;
|
||||
size_ = size;
|
||||
sizeavailable_ = true;
|
||||
}
|
||||
|
||||
void setExtendBounds(bool extend_bounds)
|
||||
{
|
||||
m_extend_bounds = extend_bounds;
|
||||
extend_bounds_ = extend_bounds;
|
||||
}
|
||||
|
||||
int get_blur_size(eDimension dim) const;
|
||||
|
||||
@@ -39,13 +39,13 @@ BokehBlurOperation::BokehBlurOperation()
|
||||
flags.complex = true;
|
||||
flags.open_cl = true;
|
||||
|
||||
m_size = 1.0f;
|
||||
m_sizeavailable = false;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputBokehProgram = nullptr;
|
||||
m_inputBoundingBoxReader = nullptr;
|
||||
size_ = 1.0f;
|
||||
sizeavailable_ = false;
|
||||
inputProgram_ = nullptr;
|
||||
inputBokehProgram_ = nullptr;
|
||||
inputBoundingBoxReader_ = nullptr;
|
||||
|
||||
m_extend_bounds = false;
|
||||
extend_bounds_ = false;
|
||||
}
|
||||
|
||||
void BokehBlurOperation::init_data()
|
||||
@@ -60,15 +60,15 @@ void BokehBlurOperation::init_data()
|
||||
|
||||
const float dimension = MIN2(width, height);
|
||||
|
||||
m_bokehMidX = width / 2.0f;
|
||||
m_bokehMidY = height / 2.0f;
|
||||
m_bokehDimension = dimension / 2.0f;
|
||||
bokehMidX_ = width / 2.0f;
|
||||
bokehMidY_ = height / 2.0f;
|
||||
bokehDimension_ = dimension / 2.0f;
|
||||
}
|
||||
|
||||
void *BokehBlurOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
lockMutex();
|
||||
if (!m_sizeavailable) {
|
||||
if (!sizeavailable_) {
|
||||
updateSize();
|
||||
}
|
||||
void *buffer = getInputOperation(0)->initializeTileData(nullptr);
|
||||
@@ -80,9 +80,9 @@ void BokehBlurOperation::initExecution()
|
||||
{
|
||||
initMutex();
|
||||
|
||||
m_inputProgram = getInputSocketReader(0);
|
||||
m_inputBokehProgram = getInputSocketReader(1);
|
||||
m_inputBoundingBoxReader = getInputSocketReader(2);
|
||||
inputProgram_ = getInputSocketReader(0);
|
||||
inputBokehProgram_ = getInputSocketReader(1);
|
||||
inputBoundingBoxReader_ = getInputSocketReader(2);
|
||||
|
||||
QualityStepHelper::initExecution(COM_QH_INCREASE);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
float tempBoundingBox[4];
|
||||
float bokeh[4];
|
||||
|
||||
m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, PixelSampler::Nearest);
|
||||
inputBoundingBoxReader_->readSampled(tempBoundingBox, x, y, PixelSampler::Nearest);
|
||||
if (tempBoundingBox[0] > 0.0f) {
|
||||
float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
|
||||
@@ -103,11 +103,11 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
int bufferstartx = input_rect.xmin;
|
||||
int bufferstarty = input_rect.ymin;
|
||||
const float max_dim = MAX2(this->getWidth(), this->getHeight());
|
||||
int pixelSize = m_size * max_dim / 100.0f;
|
||||
int pixelSize = size_ * max_dim / 100.0f;
|
||||
zero_v4(color_accum);
|
||||
|
||||
if (pixelSize < 2) {
|
||||
m_inputProgram->readSampled(color_accum, x, y, PixelSampler::Nearest);
|
||||
inputProgram_->readSampled(color_accum, x, y, PixelSampler::Nearest);
|
||||
multiplier_accum[0] = 1.0f;
|
||||
multiplier_accum[1] = 1.0f;
|
||||
multiplier_accum[2] = 1.0f;
|
||||
@@ -125,14 +125,14 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
int step = getStep();
|
||||
int offsetadd = getOffsetAdd() * COM_DATA_TYPE_COLOR_CHANNELS;
|
||||
|
||||
float m = m_bokehDimension / pixelSize;
|
||||
float m = bokehDimension_ / pixelSize;
|
||||
for (int ny = miny; ny < maxy; ny += step) {
|
||||
int bufferindex = ((minx - bufferstartx) * COM_DATA_TYPE_COLOR_CHANNELS) +
|
||||
((ny - bufferstarty) * COM_DATA_TYPE_COLOR_CHANNELS * bufferwidth);
|
||||
for (int nx = minx; nx < maxx; nx += step) {
|
||||
float u = m_bokehMidX - (nx - x) * m;
|
||||
float v = m_bokehMidY - (ny - y) * m;
|
||||
m_inputBokehProgram->readSampled(bokeh, u, v, PixelSampler::Nearest);
|
||||
float u = bokehMidX_ - (nx - x) * m;
|
||||
float v = bokehMidY_ - (ny - y) * m;
|
||||
inputBokehProgram_->readSampled(bokeh, u, v, PixelSampler::Nearest);
|
||||
madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]);
|
||||
add_v4_v4(multiplier_accum, bokeh);
|
||||
bufferindex += offsetadd;
|
||||
@@ -144,16 +144,16 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
output[3] = color_accum[3] * (1.0f / multiplier_accum[3]);
|
||||
}
|
||||
else {
|
||||
m_inputProgram->readSampled(output, x, y, PixelSampler::Nearest);
|
||||
inputProgram_->readSampled(output, x, y, PixelSampler::Nearest);
|
||||
}
|
||||
}
|
||||
|
||||
void BokehBlurOperation::deinitExecution()
|
||||
{
|
||||
deinitMutex();
|
||||
m_inputProgram = nullptr;
|
||||
m_inputBokehProgram = nullptr;
|
||||
m_inputBoundingBoxReader = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
inputBokehProgram_ = nullptr;
|
||||
inputBoundingBoxReader_ = nullptr;
|
||||
}
|
||||
|
||||
bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -164,11 +164,11 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
rcti bokehInput;
|
||||
const float max_dim = MAX2(this->getWidth(), this->getHeight());
|
||||
|
||||
if (m_sizeavailable) {
|
||||
newInput.xmax = input->xmax + (m_size * max_dim / 100.0f);
|
||||
newInput.xmin = input->xmin - (m_size * max_dim / 100.0f);
|
||||
newInput.ymax = input->ymax + (m_size * max_dim / 100.0f);
|
||||
newInput.ymin = input->ymin - (m_size * max_dim / 100.0f);
|
||||
if (sizeavailable_) {
|
||||
newInput.xmax = input->xmax + (size_ * max_dim / 100.0f);
|
||||
newInput.xmin = input->xmin - (size_ * max_dim / 100.0f);
|
||||
newInput.ymax = input->ymax + (size_ * max_dim / 100.0f);
|
||||
newInput.ymin = input->ymin - (size_ * max_dim / 100.0f);
|
||||
}
|
||||
else {
|
||||
newInput.xmax = input->xmax + (10.0f * max_dim / 100.0f);
|
||||
@@ -193,7 +193,7 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
|
||||
return true;
|
||||
}
|
||||
if (!m_sizeavailable) {
|
||||
if (!sizeavailable_) {
|
||||
rcti sizeInput;
|
||||
sizeInput.xmin = 0;
|
||||
sizeInput.ymin = 0;
|
||||
@@ -215,19 +215,19 @@ void BokehBlurOperation::executeOpenCL(OpenCLDevice *device,
|
||||
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
|
||||
{
|
||||
cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", nullptr);
|
||||
if (!m_sizeavailable) {
|
||||
if (!sizeavailable_) {
|
||||
updateSize();
|
||||
}
|
||||
const float max_dim = MAX2(this->getWidth(), this->getHeight());
|
||||
cl_int radius = m_size * max_dim / 100.0f;
|
||||
cl_int radius = size_ * max_dim / 100.0f;
|
||||
cl_int step = this->getStep();
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, m_inputBoundingBoxReader);
|
||||
kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, inputBoundingBoxReader_);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, inputProgram_);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, m_inputBokehProgram);
|
||||
kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, inputBokehProgram_);
|
||||
device->COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer);
|
||||
device->COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer);
|
||||
clSetKernelArg(kernel, 6, sizeof(cl_int), &radius);
|
||||
@@ -239,7 +239,7 @@ void BokehBlurOperation::executeOpenCL(OpenCLDevice *device,
|
||||
|
||||
void BokehBlurOperation::updateSize()
|
||||
{
|
||||
if (m_sizeavailable) {
|
||||
if (sizeavailable_) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -247,25 +247,25 @@ void BokehBlurOperation::updateSize()
|
||||
case eExecutionModel::Tiled: {
|
||||
float result[4];
|
||||
this->getInputSocketReader(3)->readSampled(result, 0, 0, PixelSampler::Nearest);
|
||||
m_size = result[0];
|
||||
CLAMP(m_size, 0.0f, 10.0f);
|
||||
size_ = result[0];
|
||||
CLAMP(size_, 0.0f, 10.0f);
|
||||
break;
|
||||
}
|
||||
case eExecutionModel::FullFrame: {
|
||||
NodeOperation *size_input = get_input_operation(SIZE_INPUT_INDEX);
|
||||
if (size_input->get_flags().is_constant_operation) {
|
||||
m_size = *static_cast<ConstantOperation *>(size_input)->get_constant_elem();
|
||||
CLAMP(m_size, 0.0f, 10.0f);
|
||||
size_ = *static_cast<ConstantOperation *>(size_input)->get_constant_elem();
|
||||
CLAMP(size_, 0.0f, 10.0f);
|
||||
} /* Else use default. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_sizeavailable = true;
|
||||
sizeavailable_ = true;
|
||||
}
|
||||
|
||||
void BokehBlurOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
if (!m_extend_bounds) {
|
||||
if (!extend_bounds_) {
|
||||
NodeOperation::determine_canvas(preferred_area, r_area);
|
||||
return;
|
||||
}
|
||||
@@ -274,15 +274,15 @@ void BokehBlurOperation::determine_canvas(const rcti &preferred_area, rcti &r_ar
|
||||
case eExecutionModel::Tiled: {
|
||||
NodeOperation::determine_canvas(preferred_area, r_area);
|
||||
const float max_dim = MAX2(BLI_rcti_size_x(&r_area), BLI_rcti_size_y(&r_area));
|
||||
r_area.xmax += 2 * m_size * max_dim / 100.0f;
|
||||
r_area.ymax += 2 * m_size * max_dim / 100.0f;
|
||||
r_area.xmax += 2 * size_ * max_dim / 100.0f;
|
||||
r_area.ymax += 2 * size_ * max_dim / 100.0f;
|
||||
break;
|
||||
}
|
||||
case eExecutionModel::FullFrame: {
|
||||
set_determined_canvas_modifier([=](rcti &canvas) {
|
||||
const float max_dim = MAX2(BLI_rcti_size_x(&canvas), BLI_rcti_size_y(&canvas));
|
||||
/* Rounding to even prevents image jiggling in backdrop while switching size values. */
|
||||
float add_size = round_to_even(2 * m_size * max_dim / 100.0f);
|
||||
float add_size = round_to_even(2 * size_ * max_dim / 100.0f);
|
||||
canvas.xmax += add_size;
|
||||
canvas.ymax += add_size;
|
||||
});
|
||||
@@ -299,7 +299,7 @@ void BokehBlurOperation::get_area_of_interest(const int input_idx,
|
||||
switch (input_idx) {
|
||||
case IMAGE_INPUT_INDEX: {
|
||||
const float max_dim = MAX2(this->getWidth(), this->getHeight());
|
||||
const float add_size = m_size * max_dim / 100.0f;
|
||||
const float add_size = size_ * max_dim / 100.0f;
|
||||
r_input_area.xmin = output_area.xmin - add_size;
|
||||
r_input_area.xmax = output_area.xmax + add_size;
|
||||
r_input_area.ymin = output_area.ymin - add_size;
|
||||
@@ -326,8 +326,8 @@ void BokehBlurOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
const float max_dim = MAX2(this->getWidth(), this->getHeight());
|
||||
const int pixel_size = m_size * max_dim / 100.0f;
|
||||
const float m = m_bokehDimension / pixel_size;
|
||||
const int pixel_size = size_ * max_dim / 100.0f;
|
||||
const float m = bokehDimension_ / pixel_size;
|
||||
|
||||
const MemoryBuffer *image_input = inputs[IMAGE_INPUT_INDEX];
|
||||
const MemoryBuffer *bokeh_input = inputs[BOKEH_INPUT_INDEX];
|
||||
@@ -362,9 +362,9 @@ void BokehBlurOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const float *row_color = image_input->get_elem(minx, miny);
|
||||
for (int ny = miny; ny < maxy; ny += step, row_color += row_stride) {
|
||||
const float *color = row_color;
|
||||
const float v = m_bokehMidY - (ny - y) * m;
|
||||
const float v = bokehMidY_ - (ny - y) * m;
|
||||
for (int nx = minx; nx < maxx; nx += step, color += elem_stride) {
|
||||
const float u = m_bokehMidX - (nx - x) * m;
|
||||
const float u = bokehMidX_ - (nx - x) * m;
|
||||
float bokeh[4];
|
||||
bokeh_input->read_elem_checked(u, v, bokeh);
|
||||
madd_v4_v4v4(color_accum, bokeh, color);
|
||||
|
||||
@@ -25,17 +25,17 @@ namespace blender::compositor {
|
||||
|
||||
class BokehBlurOperation : public MultiThreadedOperation, public QualityStepHelper {
|
||||
private:
|
||||
SocketReader *m_inputProgram;
|
||||
SocketReader *m_inputBokehProgram;
|
||||
SocketReader *m_inputBoundingBoxReader;
|
||||
SocketReader *inputProgram_;
|
||||
SocketReader *inputBokehProgram_;
|
||||
SocketReader *inputBoundingBoxReader_;
|
||||
void updateSize();
|
||||
float m_size;
|
||||
bool m_sizeavailable;
|
||||
float size_;
|
||||
bool sizeavailable_;
|
||||
|
||||
float m_bokehMidX;
|
||||
float m_bokehMidY;
|
||||
float m_bokehDimension;
|
||||
bool m_extend_bounds;
|
||||
float bokehMidX_;
|
||||
float bokehMidY_;
|
||||
float bokehDimension_;
|
||||
bool extend_bounds_;
|
||||
|
||||
public:
|
||||
BokehBlurOperation();
|
||||
@@ -64,8 +64,8 @@ class BokehBlurOperation : public MultiThreadedOperation, public QualityStepHelp
|
||||
|
||||
void setSize(float size)
|
||||
{
|
||||
m_size = size;
|
||||
m_sizeavailable = true;
|
||||
size_ = size;
|
||||
sizeavailable_ = true;
|
||||
}
|
||||
|
||||
void executeOpenCL(OpenCLDevice *device,
|
||||
@@ -77,7 +77,7 @@ class BokehBlurOperation : public MultiThreadedOperation, public QualityStepHelp
|
||||
|
||||
void setExtendBounds(bool extend_bounds)
|
||||
{
|
||||
m_extend_bounds = extend_bounds;
|
||||
extend_bounds_ = extend_bounds;
|
||||
}
|
||||
|
||||
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
|
||||
|
||||
@@ -23,33 +23,33 @@ namespace blender::compositor {
|
||||
BokehImageOperation::BokehImageOperation()
|
||||
{
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_deleteData = false;
|
||||
deleteData_ = false;
|
||||
}
|
||||
void BokehImageOperation::initExecution()
|
||||
{
|
||||
m_center[0] = getWidth() / 2;
|
||||
m_center[1] = getHeight() / 2;
|
||||
m_inverseRounding = 1.0f - m_data->rounding;
|
||||
m_circularDistance = getWidth() / 2;
|
||||
m_flapRad = (float)(M_PI * 2) / m_data->flaps;
|
||||
m_flapRadAdd = m_data->angle;
|
||||
while (m_flapRadAdd < 0.0f) {
|
||||
m_flapRadAdd += (float)(M_PI * 2.0);
|
||||
center_[0] = getWidth() / 2;
|
||||
center_[1] = getHeight() / 2;
|
||||
inverseRounding_ = 1.0f - data_->rounding;
|
||||
circularDistance_ = getWidth() / 2;
|
||||
flapRad_ = (float)(M_PI * 2) / data_->flaps;
|
||||
flapRadAdd_ = data_->angle;
|
||||
while (flapRadAdd_ < 0.0f) {
|
||||
flapRadAdd_ += (float)(M_PI * 2.0);
|
||||
}
|
||||
while (m_flapRadAdd > (float)M_PI) {
|
||||
m_flapRadAdd -= (float)(M_PI * 2.0);
|
||||
while (flapRadAdd_ > (float)M_PI) {
|
||||
flapRadAdd_ -= (float)(M_PI * 2.0);
|
||||
}
|
||||
}
|
||||
void BokehImageOperation::detemineStartPointOfFlap(float r[2], int flapNumber, float distance)
|
||||
{
|
||||
r[0] = sinf(m_flapRad * flapNumber + m_flapRadAdd) * distance + m_center[0];
|
||||
r[1] = cosf(m_flapRad * flapNumber + m_flapRadAdd) * distance + m_center[1];
|
||||
r[0] = sinf(flapRad_ * flapNumber + flapRadAdd_) * distance + center_[0];
|
||||
r[1] = cosf(flapRad_ * flapNumber + flapRadAdd_) * distance + center_[1];
|
||||
}
|
||||
float BokehImageOperation::isInsideBokeh(float distance, float x, float y)
|
||||
{
|
||||
float insideBokeh = 0.0f;
|
||||
const float deltaX = x - m_center[0];
|
||||
const float deltaY = y - m_center[1];
|
||||
const float deltaX = x - center_[0];
|
||||
const float deltaY = y - center_[1];
|
||||
float closestPoint[2];
|
||||
float lineP1[2];
|
||||
float lineP2[2];
|
||||
@@ -57,25 +57,25 @@ float BokehImageOperation::isInsideBokeh(float distance, float x, float y)
|
||||
point[0] = x;
|
||||
point[1] = y;
|
||||
|
||||
const float distanceToCenter = len_v2v2(point, m_center);
|
||||
const float distanceToCenter = len_v2v2(point, center_);
|
||||
const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0));
|
||||
int flapNumber = (int)((bearing - m_flapRadAdd) / m_flapRad);
|
||||
int flapNumber = (int)((bearing - flapRadAdd_) / flapRad_);
|
||||
|
||||
detemineStartPointOfFlap(lineP1, flapNumber, distance);
|
||||
detemineStartPointOfFlap(lineP2, flapNumber + 1, distance);
|
||||
closest_to_line_v2(closestPoint, point, lineP1, lineP2);
|
||||
|
||||
const float distanceLineToCenter = len_v2v2(m_center, closestPoint);
|
||||
const float distanceRoundingToCenter = m_inverseRounding * distanceLineToCenter +
|
||||
m_data->rounding * distance;
|
||||
const float distanceLineToCenter = len_v2v2(center_, closestPoint);
|
||||
const float distanceRoundingToCenter = inverseRounding_ * distanceLineToCenter +
|
||||
data_->rounding * distance;
|
||||
|
||||
const float catadioptricDistanceToCenter = distanceRoundingToCenter * m_data->catadioptric;
|
||||
const float catadioptricDistanceToCenter = distanceRoundingToCenter * data_->catadioptric;
|
||||
if (distanceRoundingToCenter >= distanceToCenter &&
|
||||
catadioptricDistanceToCenter <= distanceToCenter) {
|
||||
if (distanceRoundingToCenter - distanceToCenter < 1.0f) {
|
||||
insideBokeh = (distanceRoundingToCenter - distanceToCenter);
|
||||
}
|
||||
else if (m_data->catadioptric != 0.0f &&
|
||||
else if (data_->catadioptric != 0.0f &&
|
||||
distanceToCenter - catadioptricDistanceToCenter < 1.0f) {
|
||||
insideBokeh = (distanceToCenter - catadioptricDistanceToCenter);
|
||||
}
|
||||
@@ -90,9 +90,9 @@ void BokehImageOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
float shift = m_data->lensshift;
|
||||
float shift = data_->lensshift;
|
||||
float shift2 = shift / 2.0f;
|
||||
float distance = m_circularDistance;
|
||||
float distance = circularDistance_;
|
||||
float insideBokehMax = isInsideBokeh(distance, x, y);
|
||||
float insideBokehMed = isInsideBokeh(distance - fabsf(shift2 * distance), x, y);
|
||||
float insideBokehMin = isInsideBokeh(distance - fabsf(shift * distance), x, y);
|
||||
@@ -113,9 +113,9 @@ void BokehImageOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> UNUSED(inputs))
|
||||
{
|
||||
const float shift = m_data->lensshift;
|
||||
const float shift = data_->lensshift;
|
||||
const float shift2 = shift / 2.0f;
|
||||
const float distance = m_circularDistance;
|
||||
const float distance = circularDistance_;
|
||||
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
|
||||
const float insideBokehMax = isInsideBokeh(distance, it.x, it.y);
|
||||
const float insideBokehMed = isInsideBokeh(distance - fabsf(shift2 * distance), it.x, it.y);
|
||||
@@ -136,10 +136,10 @@ void BokehImageOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
void BokehImageOperation::deinitExecution()
|
||||
{
|
||||
if (m_deleteData) {
|
||||
if (m_data) {
|
||||
delete m_data;
|
||||
m_data = nullptr;
|
||||
if (deleteData_) {
|
||||
if (data_) {
|
||||
delete data_;
|
||||
data_ = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,37 +54,37 @@ class BokehImageOperation : public MultiThreadedOperation {
|
||||
/**
|
||||
* \brief Settings of the bokeh image
|
||||
*/
|
||||
NodeBokehImage *m_data;
|
||||
NodeBokehImage *data_;
|
||||
|
||||
/**
|
||||
* \brief precalculate center of the image
|
||||
*/
|
||||
float m_center[2];
|
||||
float center_[2];
|
||||
|
||||
/**
|
||||
* \brief 1.0-rounding
|
||||
*/
|
||||
float m_inverseRounding;
|
||||
float inverseRounding_;
|
||||
|
||||
/**
|
||||
* \brief distance of a full circle lens
|
||||
*/
|
||||
float m_circularDistance;
|
||||
float circularDistance_;
|
||||
|
||||
/**
|
||||
* \brief radius when the first flap starts
|
||||
*/
|
||||
float m_flapRad;
|
||||
float flapRad_;
|
||||
|
||||
/**
|
||||
* \brief radians of a single flap
|
||||
*/
|
||||
float m_flapRadAdd;
|
||||
float flapRadAdd_;
|
||||
|
||||
/**
|
||||
* \brief should the m_data field by deleted when this operation is finished
|
||||
* \brief should the data_ field by deleted when this operation is finished
|
||||
*/
|
||||
bool m_deleteData;
|
||||
bool deleteData_;
|
||||
|
||||
/**
|
||||
* \brief determine the coordinate of a flap corner.
|
||||
@@ -136,7 +136,7 @@ class BokehImageOperation : public MultiThreadedOperation {
|
||||
*/
|
||||
void setData(NodeBokehImage *data)
|
||||
{
|
||||
m_data = data;
|
||||
data_ = data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +148,7 @@ class BokehImageOperation : public MultiThreadedOperation {
|
||||
*/
|
||||
void deleteDataOnFinish()
|
||||
{
|
||||
m_deleteData = true;
|
||||
deleteData_ = true;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -25,19 +25,19 @@ BoxMaskOperation::BoxMaskOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
m_inputMask = nullptr;
|
||||
m_inputValue = nullptr;
|
||||
m_cosine = 0.0f;
|
||||
m_sine = 0.0f;
|
||||
inputMask_ = nullptr;
|
||||
inputValue_ = nullptr;
|
||||
cosine_ = 0.0f;
|
||||
sine_ = 0.0f;
|
||||
}
|
||||
void BoxMaskOperation::initExecution()
|
||||
{
|
||||
m_inputMask = this->getInputSocketReader(0);
|
||||
m_inputValue = this->getInputSocketReader(1);
|
||||
const double rad = (double)m_data->rotation;
|
||||
m_cosine = cos(rad);
|
||||
m_sine = sin(rad);
|
||||
m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
|
||||
inputMask_ = this->getInputSocketReader(0);
|
||||
inputValue_ = this->getInputSocketReader(1);
|
||||
const double rad = (double)data_->rotation;
|
||||
cosine_ = cos(rad);
|
||||
sine_ = sin(rad);
|
||||
aspectRatio_ = ((float)this->getWidth()) / this->getHeight();
|
||||
}
|
||||
|
||||
void BoxMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
@@ -48,20 +48,20 @@ void BoxMaskOperation::executePixelSampled(float output[4], float x, float y, Pi
|
||||
float rx = x / this->getWidth();
|
||||
float ry = y / this->getHeight();
|
||||
|
||||
const float dy = (ry - m_data->y) / m_aspectRatio;
|
||||
const float dx = rx - m_data->x;
|
||||
rx = m_data->x + (m_cosine * dx + m_sine * dy);
|
||||
ry = m_data->y + (-m_sine * dx + m_cosine * dy);
|
||||
const float dy = (ry - data_->y) / aspectRatio_;
|
||||
const float dx = rx - data_->x;
|
||||
rx = data_->x + (cosine_ * dx + sine_ * dy);
|
||||
ry = data_->y + (-sine_ * dx + cosine_ * dy);
|
||||
|
||||
m_inputMask->readSampled(inputMask, x, y, sampler);
|
||||
m_inputValue->readSampled(inputValue, x, y, sampler);
|
||||
inputMask_->readSampled(inputMask, x, y, sampler);
|
||||
inputValue_->readSampled(inputValue, x, y, sampler);
|
||||
|
||||
float halfHeight = m_data->height / 2.0f;
|
||||
float halfWidth = m_data->width / 2.0f;
|
||||
bool inside = (rx > m_data->x - halfWidth && rx < m_data->x + halfWidth &&
|
||||
ry > m_data->y - halfHeight && ry < m_data->y + halfHeight);
|
||||
float halfHeight = data_->height / 2.0f;
|
||||
float halfWidth = data_->width / 2.0f;
|
||||
bool inside = (rx > data_->x - halfWidth && rx < data_->x + halfWidth &&
|
||||
ry > data_->y - halfHeight && ry < data_->y + halfHeight);
|
||||
|
||||
switch (m_maskType) {
|
||||
switch (maskType_) {
|
||||
case CMP_NODE_MASKTYPE_ADD:
|
||||
if (inside) {
|
||||
output[0] = MAX2(inputMask[0], inputValue[0]);
|
||||
@@ -108,7 +108,7 @@ void BoxMaskOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
MaskFunc mask_func;
|
||||
switch (m_maskType) {
|
||||
switch (maskType_) {
|
||||
case CMP_NODE_MASKTYPE_ADD:
|
||||
mask_func = [](const bool is_inside, const float *mask, const float *value) {
|
||||
return is_inside ? MAX2(mask[0], value[0]) : mask[0];
|
||||
@@ -143,18 +143,18 @@ void BoxMaskOperation::apply_mask(MemoryBuffer *output,
|
||||
{
|
||||
const float op_w = this->getWidth();
|
||||
const float op_h = this->getHeight();
|
||||
const float half_w = m_data->width / 2.0f;
|
||||
const float half_h = m_data->height / 2.0f;
|
||||
const float half_w = data_->width / 2.0f;
|
||||
const float half_h = data_->height / 2.0f;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
const float op_ry = it.y / op_h;
|
||||
const float dy = (op_ry - m_data->y) / m_aspectRatio;
|
||||
const float dy = (op_ry - data_->y) / aspectRatio_;
|
||||
const float op_rx = it.x / op_w;
|
||||
const float dx = op_rx - m_data->x;
|
||||
const float rx = m_data->x + (m_cosine * dx + m_sine * dy);
|
||||
const float ry = m_data->y + (-m_sine * dx + m_cosine * dy);
|
||||
const float dx = op_rx - data_->x;
|
||||
const float rx = data_->x + (cosine_ * dx + sine_ * dy);
|
||||
const float ry = data_->y + (-sine_ * dx + cosine_ * dy);
|
||||
|
||||
const bool inside = (rx > m_data->x - half_w && rx < m_data->x + half_w &&
|
||||
ry > m_data->y - half_h && ry < m_data->y + half_h);
|
||||
const bool inside = (rx > data_->x - half_w && rx < data_->x + half_w &&
|
||||
ry > data_->y - half_h && ry < data_->y + half_h);
|
||||
const float *mask = it.in(0);
|
||||
const float *value = it.in(1);
|
||||
*it.out = mask_func(inside, mask, value);
|
||||
@@ -163,8 +163,8 @@ void BoxMaskOperation::apply_mask(MemoryBuffer *output,
|
||||
|
||||
void BoxMaskOperation::deinitExecution()
|
||||
{
|
||||
m_inputMask = nullptr;
|
||||
m_inputValue = nullptr;
|
||||
inputMask_ = nullptr;
|
||||
inputValue_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -29,15 +29,15 @@ class BoxMaskOperation : public MultiThreadedOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputMask;
|
||||
SocketReader *m_inputValue;
|
||||
SocketReader *inputMask_;
|
||||
SocketReader *inputValue_;
|
||||
|
||||
float m_sine;
|
||||
float m_cosine;
|
||||
float m_aspectRatio;
|
||||
int m_maskType;
|
||||
float sine_;
|
||||
float cosine_;
|
||||
float aspectRatio_;
|
||||
int maskType_;
|
||||
|
||||
NodeBoxMask *m_data;
|
||||
NodeBoxMask *data_;
|
||||
|
||||
public:
|
||||
BoxMaskOperation();
|
||||
@@ -59,12 +59,12 @@ class BoxMaskOperation : public MultiThreadedOperation {
|
||||
|
||||
void setData(NodeBoxMask *data)
|
||||
{
|
||||
m_data = data;
|
||||
data_ = data;
|
||||
}
|
||||
|
||||
void setMaskType(int maskType)
|
||||
{
|
||||
m_maskType = maskType;
|
||||
maskType_ = maskType;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,21 +26,21 @@ BrightnessOperation::BrightnessOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_inputProgram = nullptr;
|
||||
m_use_premultiply = false;
|
||||
inputProgram_ = nullptr;
|
||||
use_premultiply_ = false;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void BrightnessOperation::setUsePremultiply(bool use_premultiply)
|
||||
{
|
||||
m_use_premultiply = use_premultiply;
|
||||
use_premultiply_ = use_premultiply;
|
||||
}
|
||||
|
||||
void BrightnessOperation::initExecution()
|
||||
{
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputBrightnessProgram = this->getInputSocketReader(1);
|
||||
m_inputContrastProgram = this->getInputSocketReader(2);
|
||||
inputProgram_ = this->getInputSocketReader(0);
|
||||
inputBrightnessProgram_ = this->getInputSocketReader(1);
|
||||
inputContrastProgram_ = this->getInputSocketReader(2);
|
||||
}
|
||||
|
||||
void BrightnessOperation::executePixelSampled(float output[4],
|
||||
@@ -52,9 +52,9 @@ void BrightnessOperation::executePixelSampled(float output[4],
|
||||
float a, b;
|
||||
float inputBrightness[4];
|
||||
float inputContrast[4];
|
||||
m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
m_inputBrightnessProgram->readSampled(inputBrightness, x, y, sampler);
|
||||
m_inputContrastProgram->readSampled(inputContrast, x, y, sampler);
|
||||
inputProgram_->readSampled(inputValue, x, y, sampler);
|
||||
inputBrightnessProgram_->readSampled(inputBrightness, x, y, sampler);
|
||||
inputContrastProgram_->readSampled(inputContrast, x, y, sampler);
|
||||
float brightness = inputBrightness[0];
|
||||
float contrast = inputContrast[0];
|
||||
brightness /= 100.0f;
|
||||
@@ -74,14 +74,14 @@ void BrightnessOperation::executePixelSampled(float output[4],
|
||||
a = max_ff(1.0f - delta * 2.0f, 0.0f);
|
||||
b = a * brightness + delta;
|
||||
}
|
||||
if (m_use_premultiply) {
|
||||
if (use_premultiply_) {
|
||||
premul_to_straight_v4(inputValue);
|
||||
}
|
||||
output[0] = a * inputValue[0] + b;
|
||||
output[1] = a * inputValue[1] + b;
|
||||
output[2] = a * inputValue[2] + b;
|
||||
output[3] = inputValue[3];
|
||||
if (m_use_premultiply) {
|
||||
if (use_premultiply_) {
|
||||
straight_to_premul_v4(output);
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ void BrightnessOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
b = a * brightness + delta;
|
||||
}
|
||||
const float *color;
|
||||
if (m_use_premultiply) {
|
||||
if (use_premultiply_) {
|
||||
premul_to_straight_v4_v4(tmp_color, in_color);
|
||||
color = tmp_color;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ void BrightnessOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
it.out[1] = a * color[1] + b;
|
||||
it.out[2] = a * color[2] + b;
|
||||
it.out[3] = color[3];
|
||||
if (m_use_premultiply) {
|
||||
if (use_premultiply_) {
|
||||
straight_to_premul_v4(it.out);
|
||||
}
|
||||
}
|
||||
@@ -132,9 +132,9 @@ void BrightnessOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
void BrightnessOperation::deinitExecution()
|
||||
{
|
||||
m_inputProgram = nullptr;
|
||||
m_inputBrightnessProgram = nullptr;
|
||||
m_inputContrastProgram = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
inputBrightnessProgram_ = nullptr;
|
||||
inputContrastProgram_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -27,11 +27,11 @@ class BrightnessOperation : public MultiThreadedOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputProgram;
|
||||
SocketReader *m_inputBrightnessProgram;
|
||||
SocketReader *m_inputContrastProgram;
|
||||
SocketReader *inputProgram_;
|
||||
SocketReader *inputBrightnessProgram_;
|
||||
SocketReader *inputContrastProgram_;
|
||||
|
||||
bool m_use_premultiply;
|
||||
bool use_premultiply_;
|
||||
|
||||
public:
|
||||
BrightnessOperation();
|
||||
|
||||
@@ -28,26 +28,26 @@ CalculateMeanOperation::CalculateMeanOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color, ResizeMode::Align);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
m_imageReader = nullptr;
|
||||
m_iscalculated = false;
|
||||
m_setting = 1;
|
||||
imageReader_ = nullptr;
|
||||
iscalculated_ = false;
|
||||
setting_ = 1;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
void CalculateMeanOperation::initExecution()
|
||||
{
|
||||
m_imageReader = this->getInputSocketReader(0);
|
||||
m_iscalculated = false;
|
||||
imageReader_ = this->getInputSocketReader(0);
|
||||
iscalculated_ = false;
|
||||
NodeOperation::initMutex();
|
||||
}
|
||||
|
||||
void CalculateMeanOperation::executePixel(float output[4], int /*x*/, int /*y*/, void * /*data*/)
|
||||
{
|
||||
output[0] = m_result;
|
||||
output[0] = result_;
|
||||
}
|
||||
|
||||
void CalculateMeanOperation::deinitExecution()
|
||||
{
|
||||
m_imageReader = nullptr;
|
||||
imageReader_ = nullptr;
|
||||
NodeOperation::deinitMutex();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
rcti *output)
|
||||
{
|
||||
rcti imageInput;
|
||||
if (m_iscalculated) {
|
||||
if (iscalculated_) {
|
||||
return false;
|
||||
}
|
||||
NodeOperation *operation = getInputOperation(0);
|
||||
@@ -73,10 +73,10 @@ bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
void *CalculateMeanOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
lockMutex();
|
||||
if (!m_iscalculated) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_imageReader->initializeTileData(rect);
|
||||
if (!iscalculated_) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)imageReader_->initializeTileData(rect);
|
||||
calculateMean(tile);
|
||||
m_iscalculated = true;
|
||||
iscalculated_ = true;
|
||||
}
|
||||
unlockMutex();
|
||||
return nullptr;
|
||||
@@ -84,7 +84,7 @@ void *CalculateMeanOperation::initializeTileData(rcti *rect)
|
||||
|
||||
void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
|
||||
{
|
||||
m_result = 0.0f;
|
||||
result_ = 0.0f;
|
||||
float *buffer = tile->getBuffer();
|
||||
int size = tile->getWidth() * tile->getHeight();
|
||||
int pixels = 0;
|
||||
@@ -93,7 +93,7 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
|
||||
if (buffer[offset + 3] > 0) {
|
||||
pixels++;
|
||||
|
||||
switch (m_setting) {
|
||||
switch (setting_) {
|
||||
case 1: {
|
||||
sum += IMB_colormanagement_get_luminance(&buffer[offset]);
|
||||
break;
|
||||
@@ -125,12 +125,12 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
|
||||
}
|
||||
}
|
||||
}
|
||||
m_result = sum / pixels;
|
||||
result_ = sum / pixels;
|
||||
}
|
||||
|
||||
void CalculateMeanOperation::setSetting(int setting)
|
||||
{
|
||||
m_setting = setting;
|
||||
setting_ = setting;
|
||||
switch (setting) {
|
||||
case 1: {
|
||||
setting_func_ = IMB_colormanagement_get_luminance;
|
||||
@@ -171,10 +171,10 @@ void CalculateMeanOperation::update_memory_buffer_started(MemoryBuffer *UNUSED(o
|
||||
const rcti &UNUSED(area),
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
if (!m_iscalculated) {
|
||||
if (!iscalculated_) {
|
||||
MemoryBuffer *input = inputs[0];
|
||||
m_result = calc_mean(input);
|
||||
m_iscalculated = true;
|
||||
result_ = calc_mean(input);
|
||||
iscalculated_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ void CalculateMeanOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> UNUSED(inputs))
|
||||
{
|
||||
output->fill(area, &m_result);
|
||||
output->fill(area, &result_);
|
||||
}
|
||||
|
||||
float CalculateMeanOperation::calc_mean(const MemoryBuffer *input)
|
||||
|
||||
@@ -39,11 +39,11 @@ class CalculateMeanOperation : public MultiThreadedOperation {
|
||||
/**
|
||||
* \brief Cached reference to the reader
|
||||
*/
|
||||
SocketReader *m_imageReader;
|
||||
SocketReader *imageReader_;
|
||||
|
||||
bool m_iscalculated;
|
||||
float m_result;
|
||||
int m_setting;
|
||||
bool iscalculated_;
|
||||
float result_;
|
||||
int setting_;
|
||||
std::function<float(const float *elem)> setting_func_;
|
||||
|
||||
public:
|
||||
|
||||
@@ -29,26 +29,26 @@ void CalculateStandardDeviationOperation::executePixel(float output[4],
|
||||
int /*y*/,
|
||||
void * /*data*/)
|
||||
{
|
||||
output[0] = m_standardDeviation;
|
||||
output[0] = standardDeviation_;
|
||||
}
|
||||
|
||||
void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
lockMutex();
|
||||
if (!m_iscalculated) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_imageReader->initializeTileData(rect);
|
||||
if (!iscalculated_) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)imageReader_->initializeTileData(rect);
|
||||
CalculateMeanOperation::calculateMean(tile);
|
||||
m_standardDeviation = 0.0f;
|
||||
standardDeviation_ = 0.0f;
|
||||
float *buffer = tile->getBuffer();
|
||||
int size = tile->getWidth() * tile->getHeight();
|
||||
int pixels = 0;
|
||||
float sum = 0.0f;
|
||||
float mean = m_result;
|
||||
float mean = result_;
|
||||
for (int i = 0, offset = 0; i < size; i++, offset += 4) {
|
||||
if (buffer[offset + 3] > 0) {
|
||||
pixels++;
|
||||
|
||||
switch (m_setting) {
|
||||
switch (setting_) {
|
||||
case 1: /* rgb combined */
|
||||
{
|
||||
float value = IMB_colormanagement_get_luminance(&buffer[offset]);
|
||||
@@ -89,8 +89,8 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
|
||||
}
|
||||
}
|
||||
}
|
||||
m_standardDeviation = sqrt(sum / (float)(pixels - 1));
|
||||
m_iscalculated = true;
|
||||
standardDeviation_ = sqrt(sum / (float)(pixels - 1));
|
||||
iscalculated_ = true;
|
||||
}
|
||||
unlockMutex();
|
||||
return nullptr;
|
||||
@@ -99,7 +99,7 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
|
||||
void CalculateStandardDeviationOperation::update_memory_buffer_started(
|
||||
MemoryBuffer *UNUSED(output), const rcti &UNUSED(area), Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
if (!m_iscalculated) {
|
||||
if (!iscalculated_) {
|
||||
const MemoryBuffer *input = inputs[0];
|
||||
const float mean = CalculateMeanOperation::calc_mean(input);
|
||||
|
||||
@@ -112,16 +112,16 @@ void CalculateStandardDeviationOperation::update_memory_buffer_started(
|
||||
join.sum += chunk.sum;
|
||||
join.num_pixels += chunk.num_pixels;
|
||||
});
|
||||
m_standardDeviation = total.num_pixels <= 1 ? 0.0f :
|
||||
standardDeviation_ = total.num_pixels <= 1 ? 0.0f :
|
||||
sqrt(total.sum / (float)(total.num_pixels - 1));
|
||||
m_iscalculated = true;
|
||||
iscalculated_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateStandardDeviationOperation::update_memory_buffer_partial(
|
||||
MemoryBuffer *output, const rcti &area, Span<MemoryBuffer *> UNUSED(inputs))
|
||||
{
|
||||
output->fill(area, &m_standardDeviation);
|
||||
output->fill(area, &standardDeviation_);
|
||||
}
|
||||
|
||||
using PixelsSum = CalculateMeanOperation::PixelsSum;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace blender::compositor {
|
||||
*/
|
||||
class CalculateStandardDeviationOperation : public CalculateMeanOperation {
|
||||
protected:
|
||||
float m_standardDeviation;
|
||||
float standardDeviation_;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -27,24 +27,24 @@ ChangeHSVOperation::ChangeHSVOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ChangeHSVOperation::initExecution()
|
||||
{
|
||||
m_inputOperation = getInputSocketReader(0);
|
||||
m_hueOperation = getInputSocketReader(1);
|
||||
m_saturationOperation = getInputSocketReader(2);
|
||||
m_valueOperation = getInputSocketReader(3);
|
||||
inputOperation_ = getInputSocketReader(0);
|
||||
hueOperation_ = getInputSocketReader(1);
|
||||
saturationOperation_ = getInputSocketReader(2);
|
||||
valueOperation_ = getInputSocketReader(3);
|
||||
}
|
||||
|
||||
void ChangeHSVOperation::deinitExecution()
|
||||
{
|
||||
m_inputOperation = nullptr;
|
||||
m_hueOperation = nullptr;
|
||||
m_saturationOperation = nullptr;
|
||||
m_valueOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
hueOperation_ = nullptr;
|
||||
saturationOperation_ = nullptr;
|
||||
valueOperation_ = nullptr;
|
||||
}
|
||||
|
||||
void ChangeHSVOperation::executePixelSampled(float output[4],
|
||||
@@ -55,10 +55,10 @@ void ChangeHSVOperation::executePixelSampled(float output[4],
|
||||
float inputColor1[4];
|
||||
float hue[4], saturation[4], value[4];
|
||||
|
||||
m_inputOperation->readSampled(inputColor1, x, y, sampler);
|
||||
m_hueOperation->readSampled(hue, x, y, sampler);
|
||||
m_saturationOperation->readSampled(saturation, x, y, sampler);
|
||||
m_valueOperation->readSampled(value, x, y, sampler);
|
||||
inputOperation_->readSampled(inputColor1, x, y, sampler);
|
||||
hueOperation_->readSampled(hue, x, y, sampler);
|
||||
saturationOperation_->readSampled(saturation, x, y, sampler);
|
||||
valueOperation_->readSampled(value, x, y, sampler);
|
||||
|
||||
output[0] = inputColor1[0] + (hue[0] - 0.5f);
|
||||
if (output[0] > 1.0f) {
|
||||
|
||||
@@ -28,10 +28,10 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ChangeHSVOperation : public MultiThreadedOperation {
|
||||
private:
|
||||
SocketReader *m_inputOperation;
|
||||
SocketReader *m_hueOperation;
|
||||
SocketReader *m_saturationOperation;
|
||||
SocketReader *m_valueOperation;
|
||||
SocketReader *inputOperation_;
|
||||
SocketReader *hueOperation_;
|
||||
SocketReader *saturationOperation_;
|
||||
SocketReader *valueOperation_;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -25,46 +25,46 @@ ChannelMatteOperation::ChannelMatteOperation()
|
||||
addInputSocket(DataType::Color);
|
||||
addOutputSocket(DataType::Value);
|
||||
|
||||
m_inputImageProgram = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ChannelMatteOperation::initExecution()
|
||||
{
|
||||
m_inputImageProgram = this->getInputSocketReader(0);
|
||||
inputImageProgram_ = this->getInputSocketReader(0);
|
||||
|
||||
m_limit_range = m_limit_max - m_limit_min;
|
||||
limit_range_ = limit_max_ - limit_min_;
|
||||
|
||||
switch (m_limit_method) {
|
||||
switch (limit_method_) {
|
||||
/* SINGLE */
|
||||
case 0: {
|
||||
/* 123 / RGB / HSV / YUV / YCC */
|
||||
const int matte_channel = m_matte_channel - 1;
|
||||
const int limit_channel = m_limit_channel - 1;
|
||||
m_ids[0] = matte_channel;
|
||||
m_ids[1] = limit_channel;
|
||||
m_ids[2] = limit_channel;
|
||||
const int matte_channel = matte_channel_ - 1;
|
||||
const int limit_channel = limit_channel_ - 1;
|
||||
ids_[0] = matte_channel;
|
||||
ids_[1] = limit_channel;
|
||||
ids_[2] = limit_channel;
|
||||
break;
|
||||
}
|
||||
/* MAX */
|
||||
case 1: {
|
||||
switch (m_matte_channel) {
|
||||
switch (matte_channel_) {
|
||||
case 1: {
|
||||
m_ids[0] = 0;
|
||||
m_ids[1] = 1;
|
||||
m_ids[2] = 2;
|
||||
ids_[0] = 0;
|
||||
ids_[1] = 1;
|
||||
ids_[2] = 2;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
m_ids[0] = 1;
|
||||
m_ids[1] = 0;
|
||||
m_ids[2] = 2;
|
||||
ids_[0] = 1;
|
||||
ids_[1] = 0;
|
||||
ids_[2] = 2;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
m_ids[0] = 2;
|
||||
m_ids[1] = 0;
|
||||
m_ids[2] = 1;
|
||||
ids_[0] = 2;
|
||||
ids_[1] = 0;
|
||||
ids_[2] = 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -79,7 +79,7 @@ void ChannelMatteOperation::initExecution()
|
||||
|
||||
void ChannelMatteOperation::deinitExecution()
|
||||
{
|
||||
m_inputImageProgram = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
}
|
||||
|
||||
void ChannelMatteOperation::executePixelSampled(float output[4],
|
||||
@@ -90,14 +90,14 @@ void ChannelMatteOperation::executePixelSampled(float output[4],
|
||||
float inColor[4];
|
||||
float alpha;
|
||||
|
||||
const float limit_max = m_limit_max;
|
||||
const float limit_min = m_limit_min;
|
||||
const float limit_range = m_limit_range;
|
||||
const float limit_max = limit_max_;
|
||||
const float limit_min = limit_min_;
|
||||
const float limit_range = limit_range_;
|
||||
|
||||
m_inputImageProgram->readSampled(inColor, x, y, sampler);
|
||||
inputImageProgram_->readSampled(inColor, x, y, sampler);
|
||||
|
||||
/* matte operation */
|
||||
alpha = inColor[m_ids[0]] - MAX2(inColor[m_ids[1]], inColor[m_ids[2]]);
|
||||
alpha = inColor[ids_[0]] - MAX2(inColor[ids_[1]], inColor[ids_[2]]);
|
||||
|
||||
/* flip because 0.0 is transparent, not 1.0 */
|
||||
alpha = 1.0f - alpha;
|
||||
@@ -129,20 +129,20 @@ void ChannelMatteOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const float *color = it.in(0);
|
||||
|
||||
/* Matte operation. */
|
||||
float alpha = color[m_ids[0]] - MAX2(color[m_ids[1]], color[m_ids[2]]);
|
||||
float alpha = color[ids_[0]] - MAX2(color[ids_[1]], color[ids_[2]]);
|
||||
|
||||
/* Flip because 0.0 is transparent, not 1.0. */
|
||||
alpha = 1.0f - alpha;
|
||||
|
||||
/* Test range. */
|
||||
if (alpha > m_limit_max) {
|
||||
if (alpha > limit_max_) {
|
||||
alpha = color[3]; /* Whatever it was prior. */
|
||||
}
|
||||
else if (alpha < m_limit_min) {
|
||||
else if (alpha < limit_min_) {
|
||||
alpha = 0.0f;
|
||||
}
|
||||
else { /* Blend. */
|
||||
alpha = (alpha - m_limit_min) / m_limit_range;
|
||||
alpha = (alpha - limit_min_) / limit_range_;
|
||||
}
|
||||
|
||||
/* Store matte(alpha) value in [0] to go with
|
||||
|
||||
@@ -28,16 +28,16 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ChannelMatteOperation : public MultiThreadedOperation {
|
||||
private:
|
||||
SocketReader *m_inputImageProgram;
|
||||
SocketReader *inputImageProgram_;
|
||||
|
||||
/* int m_color_space; */ /* node->custom1 */ /* UNUSED */ /* TODO ? */
|
||||
int m_matte_channel; /* node->custom2 */
|
||||
int m_limit_method; /* node->algorithm */
|
||||
int m_limit_channel; /* node->channel */
|
||||
float m_limit_max; /* node->storage->t1 */
|
||||
float m_limit_min; /* node->storage->t2 */
|
||||
/* int color_space_; */ /* node->custom1 */ /* UNUSED */ /* TODO ? */
|
||||
int matte_channel_; /* node->custom2 */
|
||||
int limit_method_; /* node->algorithm */
|
||||
int limit_channel_; /* node->channel */
|
||||
float limit_max_; /* node->storage->t1 */
|
||||
float limit_min_; /* node->storage->t2 */
|
||||
|
||||
float m_limit_range;
|
||||
float limit_range_;
|
||||
|
||||
/** ids to use for the operations (max and simple)
|
||||
* alpha = in[ids[0]] - MAX2(in[ids[1]], in[ids[2]])
|
||||
@@ -47,7 +47,7 @@ class ChannelMatteOperation : public MultiThreadedOperation {
|
||||
* ids[2] = ids[1]
|
||||
* alpha = in[ids[0]] - MAX2(in[ids[1]], in[ids[2]])
|
||||
*/
|
||||
int m_ids[3];
|
||||
int ids_[3];
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -65,11 +65,11 @@ class ChannelMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma, const int custom2)
|
||||
{
|
||||
m_limit_max = nodeChroma->t1;
|
||||
m_limit_min = nodeChroma->t2;
|
||||
m_limit_method = nodeChroma->algorithm;
|
||||
m_limit_channel = nodeChroma->channel;
|
||||
m_matte_channel = custom2;
|
||||
limit_max_ = nodeChroma->t1;
|
||||
limit_min_ = nodeChroma->t2;
|
||||
limit_method_ = nodeChroma->algorithm;
|
||||
limit_channel_ = nodeChroma->channel;
|
||||
matte_channel_ = custom2;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,21 +26,21 @@ ChromaMatteOperation::ChromaMatteOperation()
|
||||
addInputSocket(DataType::Color);
|
||||
addOutputSocket(DataType::Value);
|
||||
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputKeyProgram = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
inputKeyProgram_ = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ChromaMatteOperation::initExecution()
|
||||
{
|
||||
m_inputImageProgram = this->getInputSocketReader(0);
|
||||
m_inputKeyProgram = this->getInputSocketReader(1);
|
||||
inputImageProgram_ = this->getInputSocketReader(0);
|
||||
inputKeyProgram_ = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ChromaMatteOperation::deinitExecution()
|
||||
{
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputKeyProgram = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
inputKeyProgram_ = nullptr;
|
||||
}
|
||||
|
||||
void ChromaMatteOperation::executePixelSampled(float output[4],
|
||||
@@ -51,16 +51,16 @@ void ChromaMatteOperation::executePixelSampled(float output[4],
|
||||
float inKey[4];
|
||||
float inImage[4];
|
||||
|
||||
const float acceptance = m_settings->t1; /* in radians */
|
||||
const float cutoff = m_settings->t2; /* in radians */
|
||||
const float gain = m_settings->fstrength;
|
||||
const float acceptance = settings_->t1; /* in radians */
|
||||
const float cutoff = settings_->t2; /* in radians */
|
||||
const float gain = settings_->fstrength;
|
||||
|
||||
float x_angle, z_angle, alpha;
|
||||
float theta, beta;
|
||||
float kfg;
|
||||
|
||||
m_inputKeyProgram->readSampled(inKey, x, y, sampler);
|
||||
m_inputImageProgram->readSampled(inImage, x, y, sampler);
|
||||
inputKeyProgram_->readSampled(inKey, x, y, sampler);
|
||||
inputImageProgram_->readSampled(inImage, x, y, sampler);
|
||||
|
||||
/* Store matte(alpha) value in [0] to go with
|
||||
* #COM_SetAlphaMultiplyOperation and the Value output. */
|
||||
@@ -114,9 +114,9 @@ void ChromaMatteOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
const float acceptance = m_settings->t1; /* In radians. */
|
||||
const float cutoff = m_settings->t2; /* In radians. */
|
||||
const float gain = m_settings->fstrength;
|
||||
const float acceptance = settings_->t1; /* In radians. */
|
||||
const float cutoff = settings_->t2; /* In radians. */
|
||||
const float gain = settings_->fstrength;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
const float *in_image = it.in(0);
|
||||
const float *in_key = it.in(1);
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ChromaMatteOperation : public MultiThreadedOperation {
|
||||
private:
|
||||
NodeChroma *m_settings;
|
||||
SocketReader *m_inputImageProgram;
|
||||
SocketReader *m_inputKeyProgram;
|
||||
NodeChroma *settings_;
|
||||
SocketReader *inputImageProgram_;
|
||||
SocketReader *inputKeyProgram_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ class ChromaMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma)
|
||||
{
|
||||
m_settings = nodeChroma;
|
||||
settings_ = nodeChroma;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -37,16 +37,16 @@ ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColorOperation = nullptr;
|
||||
inputValueOperation_ = nullptr;
|
||||
inputColorOperation_ = nullptr;
|
||||
this->set_canvas_input_index(1);
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ColorBalanceASCCDLOperation::initExecution()
|
||||
{
|
||||
m_inputValueOperation = this->getInputSocketReader(0);
|
||||
m_inputColorOperation = this->getInputSocketReader(1);
|
||||
inputValueOperation_ = this->getInputSocketReader(0);
|
||||
inputColorOperation_ = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ColorBalanceASCCDLOperation::executePixelSampled(float output[4],
|
||||
@@ -57,19 +57,19 @@ void ColorBalanceASCCDLOperation::executePixelSampled(float output[4],
|
||||
float inputColor[4];
|
||||
float value[4];
|
||||
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_inputColorOperation->readSampled(inputColor, x, y, sampler);
|
||||
inputValueOperation_->readSampled(value, x, y, sampler);
|
||||
inputColorOperation_->readSampled(inputColor, x, y, sampler);
|
||||
|
||||
float fac = value[0];
|
||||
fac = MIN2(1.0f, fac);
|
||||
const float mfac = 1.0f - fac;
|
||||
|
||||
output[0] = mfac * inputColor[0] +
|
||||
fac * colorbalance_cdl(inputColor[0], m_offset[0], m_power[0], m_slope[0]);
|
||||
fac * colorbalance_cdl(inputColor[0], offset_[0], power_[0], slope_[0]);
|
||||
output[1] = mfac * inputColor[1] +
|
||||
fac * colorbalance_cdl(inputColor[1], m_offset[1], m_power[1], m_slope[1]);
|
||||
fac * colorbalance_cdl(inputColor[1], offset_[1], power_[1], slope_[1]);
|
||||
output[2] = mfac * inputColor[2] +
|
||||
fac * colorbalance_cdl(inputColor[2], m_offset[2], m_power[2], m_slope[2]);
|
||||
fac * colorbalance_cdl(inputColor[2], offset_[2], power_[2], slope_[2]);
|
||||
output[3] = inputColor[3];
|
||||
}
|
||||
|
||||
@@ -81,19 +81,19 @@ void ColorBalanceASCCDLOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
const float fac = MIN2(1.0f, in_factor[0]);
|
||||
const float fac_m = 1.0f - fac;
|
||||
p.out[0] = fac_m * in_color[0] +
|
||||
fac * colorbalance_cdl(in_color[0], m_offset[0], m_power[0], m_slope[0]);
|
||||
fac * colorbalance_cdl(in_color[0], offset_[0], power_[0], slope_[0]);
|
||||
p.out[1] = fac_m * in_color[1] +
|
||||
fac * colorbalance_cdl(in_color[1], m_offset[1], m_power[1], m_slope[1]);
|
||||
fac * colorbalance_cdl(in_color[1], offset_[1], power_[1], slope_[1]);
|
||||
p.out[2] = fac_m * in_color[2] +
|
||||
fac * colorbalance_cdl(in_color[2], m_offset[2], m_power[2], m_slope[2]);
|
||||
fac * colorbalance_cdl(in_color[2], offset_[2], power_[2], slope_[2]);
|
||||
p.out[3] = in_color[3];
|
||||
}
|
||||
}
|
||||
|
||||
void ColorBalanceASCCDLOperation::deinitExecution()
|
||||
{
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColorOperation = nullptr;
|
||||
inputValueOperation_ = nullptr;
|
||||
inputColorOperation_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -31,12 +31,12 @@ class ColorBalanceASCCDLOperation : public MultiThreadedRowOperation {
|
||||
/**
|
||||
* Prefetched reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputValueOperation;
|
||||
SocketReader *m_inputColorOperation;
|
||||
SocketReader *inputValueOperation_;
|
||||
SocketReader *inputColorOperation_;
|
||||
|
||||
float m_offset[3];
|
||||
float m_power[3];
|
||||
float m_slope[3];
|
||||
float offset_[3];
|
||||
float power_[3];
|
||||
float slope_[3];
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -61,15 +61,15 @@ class ColorBalanceASCCDLOperation : public MultiThreadedRowOperation {
|
||||
|
||||
void setOffset(float offset[3])
|
||||
{
|
||||
copy_v3_v3(m_offset, offset);
|
||||
copy_v3_v3(offset_, offset);
|
||||
}
|
||||
void setPower(float power[3])
|
||||
{
|
||||
copy_v3_v3(m_power, power);
|
||||
copy_v3_v3(power_, power);
|
||||
}
|
||||
void setSlope(float slope[3])
|
||||
{
|
||||
copy_v3_v3(m_slope, slope);
|
||||
copy_v3_v3(slope_, slope);
|
||||
}
|
||||
|
||||
void update_memory_buffer_row(PixelCursor &p) override;
|
||||
|
||||
@@ -42,16 +42,16 @@ ColorBalanceLGGOperation::ColorBalanceLGGOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColorOperation = nullptr;
|
||||
inputValueOperation_ = nullptr;
|
||||
inputColorOperation_ = nullptr;
|
||||
this->set_canvas_input_index(1);
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ColorBalanceLGGOperation::initExecution()
|
||||
{
|
||||
m_inputValueOperation = this->getInputSocketReader(0);
|
||||
m_inputColorOperation = this->getInputSocketReader(1);
|
||||
inputValueOperation_ = this->getInputSocketReader(0);
|
||||
inputColorOperation_ = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ColorBalanceLGGOperation::executePixelSampled(float output[4],
|
||||
@@ -62,19 +62,19 @@ void ColorBalanceLGGOperation::executePixelSampled(float output[4],
|
||||
float inputColor[4];
|
||||
float value[4];
|
||||
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_inputColorOperation->readSampled(inputColor, x, y, sampler);
|
||||
inputValueOperation_->readSampled(value, x, y, sampler);
|
||||
inputColorOperation_->readSampled(inputColor, x, y, sampler);
|
||||
|
||||
float fac = value[0];
|
||||
fac = MIN2(1.0f, fac);
|
||||
const float mfac = 1.0f - fac;
|
||||
|
||||
output[0] = mfac * inputColor[0] +
|
||||
fac * colorbalance_lgg(inputColor[0], m_lift[0], m_gamma_inv[0], m_gain[0]);
|
||||
fac * colorbalance_lgg(inputColor[0], lift_[0], gamma_inv_[0], gain_[0]);
|
||||
output[1] = mfac * inputColor[1] +
|
||||
fac * colorbalance_lgg(inputColor[1], m_lift[1], m_gamma_inv[1], m_gain[1]);
|
||||
fac * colorbalance_lgg(inputColor[1], lift_[1], gamma_inv_[1], gain_[1]);
|
||||
output[2] = mfac * inputColor[2] +
|
||||
fac * colorbalance_lgg(inputColor[2], m_lift[2], m_gamma_inv[2], m_gain[2]);
|
||||
fac * colorbalance_lgg(inputColor[2], lift_[2], gamma_inv_[2], gain_[2]);
|
||||
output[3] = inputColor[3];
|
||||
}
|
||||
|
||||
@@ -86,19 +86,19 @@ void ColorBalanceLGGOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
const float fac = MIN2(1.0f, in_factor[0]);
|
||||
const float fac_m = 1.0f - fac;
|
||||
p.out[0] = fac_m * in_color[0] +
|
||||
fac * colorbalance_lgg(in_color[0], m_lift[0], m_gamma_inv[0], m_gain[0]);
|
||||
fac * colorbalance_lgg(in_color[0], lift_[0], gamma_inv_[0], gain_[0]);
|
||||
p.out[1] = fac_m * in_color[1] +
|
||||
fac * colorbalance_lgg(in_color[1], m_lift[1], m_gamma_inv[1], m_gain[1]);
|
||||
fac * colorbalance_lgg(in_color[1], lift_[1], gamma_inv_[1], gain_[1]);
|
||||
p.out[2] = fac_m * in_color[2] +
|
||||
fac * colorbalance_lgg(in_color[2], m_lift[2], m_gamma_inv[2], m_gain[2]);
|
||||
fac * colorbalance_lgg(in_color[2], lift_[2], gamma_inv_[2], gain_[2]);
|
||||
p.out[3] = in_color[3];
|
||||
}
|
||||
}
|
||||
|
||||
void ColorBalanceLGGOperation::deinitExecution()
|
||||
{
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColorOperation = nullptr;
|
||||
inputValueOperation_ = nullptr;
|
||||
inputColorOperation_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -31,12 +31,12 @@ class ColorBalanceLGGOperation : public MultiThreadedRowOperation {
|
||||
/**
|
||||
* Prefetched reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputValueOperation;
|
||||
SocketReader *m_inputColorOperation;
|
||||
SocketReader *inputValueOperation_;
|
||||
SocketReader *inputColorOperation_;
|
||||
|
||||
float m_gain[3];
|
||||
float m_lift[3];
|
||||
float m_gamma_inv[3];
|
||||
float gain_[3];
|
||||
float lift_[3];
|
||||
float gamma_inv_[3];
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -61,15 +61,15 @@ class ColorBalanceLGGOperation : public MultiThreadedRowOperation {
|
||||
|
||||
void setGain(const float gain[3])
|
||||
{
|
||||
copy_v3_v3(m_gain, gain);
|
||||
copy_v3_v3(gain_, gain);
|
||||
}
|
||||
void setLift(const float lift[3])
|
||||
{
|
||||
copy_v3_v3(m_lift, lift);
|
||||
copy_v3_v3(lift_, lift);
|
||||
}
|
||||
void setGammaInv(const float gamma_inv[3])
|
||||
{
|
||||
copy_v3_v3(m_gamma_inv, gamma_inv);
|
||||
copy_v3_v3(gamma_inv_, gamma_inv);
|
||||
}
|
||||
|
||||
void update_memory_buffer_row(PixelCursor &p) override;
|
||||
|
||||
@@ -27,17 +27,17 @@ ColorCorrectionOperation::ColorCorrectionOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_inputImage = nullptr;
|
||||
m_inputMask = nullptr;
|
||||
m_redChannelEnabled = true;
|
||||
m_greenChannelEnabled = true;
|
||||
m_blueChannelEnabled = true;
|
||||
inputImage_ = nullptr;
|
||||
inputMask_ = nullptr;
|
||||
redChannelEnabled_ = true;
|
||||
greenChannelEnabled_ = true;
|
||||
blueChannelEnabled_ = true;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
void ColorCorrectionOperation::initExecution()
|
||||
{
|
||||
m_inputImage = this->getInputSocketReader(0);
|
||||
m_inputMask = this->getInputSocketReader(1);
|
||||
inputImage_ = this->getInputSocketReader(0);
|
||||
inputMask_ = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
/* Calculate x^y if the function is defined. Otherwise return the given fallback value. */
|
||||
@@ -56,15 +56,15 @@ void ColorCorrectionOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputImageColor[4];
|
||||
float inputMask[4];
|
||||
m_inputImage->readSampled(inputImageColor, x, y, sampler);
|
||||
m_inputMask->readSampled(inputMask, x, y, sampler);
|
||||
inputImage_->readSampled(inputImageColor, x, y, sampler);
|
||||
inputMask_->readSampled(inputMask, x, y, sampler);
|
||||
|
||||
float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f;
|
||||
float contrast = m_data->master.contrast;
|
||||
float saturation = m_data->master.saturation;
|
||||
float gamma = m_data->master.gamma;
|
||||
float gain = m_data->master.gain;
|
||||
float lift = m_data->master.lift;
|
||||
float contrast = data_->master.contrast;
|
||||
float saturation = data_->master.saturation;
|
||||
float gamma = data_->master.gamma;
|
||||
float gain = data_->master.gain;
|
||||
float lift = data_->master.lift;
|
||||
float r, g, b;
|
||||
|
||||
float value = inputMask[0];
|
||||
@@ -76,18 +76,18 @@ void ColorCorrectionOperation::executePixelSampled(float output[4],
|
||||
float levelHighlights = 0.0;
|
||||
#define MARGIN 0.10f
|
||||
#define MARGIN_DIV (0.5f / MARGIN)
|
||||
if (level < m_data->startmidtones - MARGIN) {
|
||||
if (level < data_->startmidtones - MARGIN) {
|
||||
levelShadows = 1.0f;
|
||||
}
|
||||
else if (level < m_data->startmidtones + MARGIN) {
|
||||
levelMidtones = ((level - m_data->startmidtones) * MARGIN_DIV) + 0.5f;
|
||||
else if (level < data_->startmidtones + MARGIN) {
|
||||
levelMidtones = ((level - data_->startmidtones) * MARGIN_DIV) + 0.5f;
|
||||
levelShadows = 1.0f - levelMidtones;
|
||||
}
|
||||
else if (level < m_data->endmidtones - MARGIN) {
|
||||
else if (level < data_->endmidtones - MARGIN) {
|
||||
levelMidtones = 1.0f;
|
||||
}
|
||||
else if (level < m_data->endmidtones + MARGIN) {
|
||||
levelHighlights = ((level - m_data->endmidtones) * MARGIN_DIV) + 0.5f;
|
||||
else if (level < data_->endmidtones + MARGIN) {
|
||||
levelHighlights = ((level - data_->endmidtones) * MARGIN_DIV) + 0.5f;
|
||||
levelMidtones = 1.0f - levelHighlights;
|
||||
}
|
||||
else {
|
||||
@@ -95,18 +95,18 @@ void ColorCorrectionOperation::executePixelSampled(float output[4],
|
||||
}
|
||||
#undef MARGIN
|
||||
#undef MARGIN_DIV
|
||||
contrast *= (levelShadows * m_data->shadows.contrast) +
|
||||
(levelMidtones * m_data->midtones.contrast) +
|
||||
(levelHighlights * m_data->highlights.contrast);
|
||||
saturation *= (levelShadows * m_data->shadows.saturation) +
|
||||
(levelMidtones * m_data->midtones.saturation) +
|
||||
(levelHighlights * m_data->highlights.saturation);
|
||||
gamma *= (levelShadows * m_data->shadows.gamma) + (levelMidtones * m_data->midtones.gamma) +
|
||||
(levelHighlights * m_data->highlights.gamma);
|
||||
gain *= (levelShadows * m_data->shadows.gain) + (levelMidtones * m_data->midtones.gain) +
|
||||
(levelHighlights * m_data->highlights.gain);
|
||||
lift += (levelShadows * m_data->shadows.lift) + (levelMidtones * m_data->midtones.lift) +
|
||||
(levelHighlights * m_data->highlights.lift);
|
||||
contrast *= (levelShadows * data_->shadows.contrast) +
|
||||
(levelMidtones * data_->midtones.contrast) +
|
||||
(levelHighlights * data_->highlights.contrast);
|
||||
saturation *= (levelShadows * data_->shadows.saturation) +
|
||||
(levelMidtones * data_->midtones.saturation) +
|
||||
(levelHighlights * data_->highlights.saturation);
|
||||
gamma *= (levelShadows * data_->shadows.gamma) + (levelMidtones * data_->midtones.gamma) +
|
||||
(levelHighlights * data_->highlights.gamma);
|
||||
gain *= (levelShadows * data_->shadows.gain) + (levelMidtones * data_->midtones.gain) +
|
||||
(levelHighlights * data_->highlights.gain);
|
||||
lift += (levelShadows * data_->shadows.lift) + (levelMidtones * data_->midtones.lift) +
|
||||
(levelHighlights * data_->highlights.lift);
|
||||
|
||||
float invgamma = 1.0f / gamma;
|
||||
float luma = IMB_colormanagement_get_luminance(inputImageColor);
|
||||
@@ -133,19 +133,19 @@ void ColorCorrectionOperation::executePixelSampled(float output[4],
|
||||
g = mvalue * inputImageColor[1] + value * g;
|
||||
b = mvalue * inputImageColor[2] + value * b;
|
||||
|
||||
if (m_redChannelEnabled) {
|
||||
if (redChannelEnabled_) {
|
||||
output[0] = r;
|
||||
}
|
||||
else {
|
||||
output[0] = inputImageColor[0];
|
||||
}
|
||||
if (m_greenChannelEnabled) {
|
||||
if (greenChannelEnabled_) {
|
||||
output[1] = g;
|
||||
}
|
||||
else {
|
||||
output[1] = inputImageColor[1];
|
||||
}
|
||||
if (m_blueChannelEnabled) {
|
||||
if (blueChannelEnabled_) {
|
||||
output[2] = b;
|
||||
}
|
||||
else {
|
||||
@@ -166,40 +166,40 @@ void ColorCorrectionOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
float level_highlights = 0.0f;
|
||||
constexpr float MARGIN = 0.10f;
|
||||
constexpr float MARGIN_DIV = 0.5f / MARGIN;
|
||||
if (level < m_data->startmidtones - MARGIN) {
|
||||
if (level < data_->startmidtones - MARGIN) {
|
||||
level_shadows = 1.0f;
|
||||
}
|
||||
else if (level < m_data->startmidtones + MARGIN) {
|
||||
level_midtones = ((level - m_data->startmidtones) * MARGIN_DIV) + 0.5f;
|
||||
else if (level < data_->startmidtones + MARGIN) {
|
||||
level_midtones = ((level - data_->startmidtones) * MARGIN_DIV) + 0.5f;
|
||||
level_shadows = 1.0f - level_midtones;
|
||||
}
|
||||
else if (level < m_data->endmidtones - MARGIN) {
|
||||
else if (level < data_->endmidtones - MARGIN) {
|
||||
level_midtones = 1.0f;
|
||||
}
|
||||
else if (level < m_data->endmidtones + MARGIN) {
|
||||
level_highlights = ((level - m_data->endmidtones) * MARGIN_DIV) + 0.5f;
|
||||
else if (level < data_->endmidtones + MARGIN) {
|
||||
level_highlights = ((level - data_->endmidtones) * MARGIN_DIV) + 0.5f;
|
||||
level_midtones = 1.0f - level_highlights;
|
||||
}
|
||||
else {
|
||||
level_highlights = 1.0f;
|
||||
}
|
||||
float contrast = m_data->master.contrast;
|
||||
float saturation = m_data->master.saturation;
|
||||
float gamma = m_data->master.gamma;
|
||||
float gain = m_data->master.gain;
|
||||
float lift = m_data->master.lift;
|
||||
contrast *= level_shadows * m_data->shadows.contrast +
|
||||
level_midtones * m_data->midtones.contrast +
|
||||
level_highlights * m_data->highlights.contrast;
|
||||
saturation *= level_shadows * m_data->shadows.saturation +
|
||||
level_midtones * m_data->midtones.saturation +
|
||||
level_highlights * m_data->highlights.saturation;
|
||||
gamma *= level_shadows * m_data->shadows.gamma + level_midtones * m_data->midtones.gamma +
|
||||
level_highlights * m_data->highlights.gamma;
|
||||
gain *= level_shadows * m_data->shadows.gain + level_midtones * m_data->midtones.gain +
|
||||
level_highlights * m_data->highlights.gain;
|
||||
lift += level_shadows * m_data->shadows.lift + level_midtones * m_data->midtones.lift +
|
||||
level_highlights * m_data->highlights.lift;
|
||||
float contrast = data_->master.contrast;
|
||||
float saturation = data_->master.saturation;
|
||||
float gamma = data_->master.gamma;
|
||||
float gain = data_->master.gain;
|
||||
float lift = data_->master.lift;
|
||||
contrast *= level_shadows * data_->shadows.contrast +
|
||||
level_midtones * data_->midtones.contrast +
|
||||
level_highlights * data_->highlights.contrast;
|
||||
saturation *= level_shadows * data_->shadows.saturation +
|
||||
level_midtones * data_->midtones.saturation +
|
||||
level_highlights * data_->highlights.saturation;
|
||||
gamma *= level_shadows * data_->shadows.gamma + level_midtones * data_->midtones.gamma +
|
||||
level_highlights * data_->highlights.gamma;
|
||||
gain *= level_shadows * data_->shadows.gain + level_midtones * data_->midtones.gain +
|
||||
level_highlights * data_->highlights.gain;
|
||||
lift += level_shadows * data_->shadows.lift + level_midtones * data_->midtones.lift +
|
||||
level_highlights * data_->highlights.lift;
|
||||
|
||||
const float inv_gamma = 1.0f / gamma;
|
||||
const float luma = IMB_colormanagement_get_luminance(in_color);
|
||||
@@ -219,22 +219,22 @@ void ColorCorrectionOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
|
||||
/* Mix with mask. */
|
||||
const float value = MIN2(1.0f, in_mask[0]);
|
||||
const float m_value = 1.0f - value;
|
||||
r = m_value * in_color[0] + value * r;
|
||||
g = m_value * in_color[1] + value * g;
|
||||
b = m_value * in_color[2] + value * b;
|
||||
const float value_ = 1.0f - value;
|
||||
r = value_ * in_color[0] + value * r;
|
||||
g = value_ * in_color[1] + value * g;
|
||||
b = value_ * in_color[2] + value * b;
|
||||
|
||||
p.out[0] = m_redChannelEnabled ? r : in_color[0];
|
||||
p.out[1] = m_greenChannelEnabled ? g : in_color[1];
|
||||
p.out[2] = m_blueChannelEnabled ? b : in_color[2];
|
||||
p.out[0] = redChannelEnabled_ ? r : in_color[0];
|
||||
p.out[1] = greenChannelEnabled_ ? g : in_color[1];
|
||||
p.out[2] = blueChannelEnabled_ ? b : in_color[2];
|
||||
p.out[3] = in_color[3];
|
||||
}
|
||||
}
|
||||
|
||||
void ColorCorrectionOperation::deinitExecution()
|
||||
{
|
||||
m_inputImage = nullptr;
|
||||
m_inputMask = nullptr;
|
||||
inputImage_ = nullptr;
|
||||
inputMask_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -27,13 +27,13 @@ class ColorCorrectionOperation : public MultiThreadedRowOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputImage;
|
||||
SocketReader *m_inputMask;
|
||||
NodeColorCorrection *m_data;
|
||||
SocketReader *inputImage_;
|
||||
SocketReader *inputMask_;
|
||||
NodeColorCorrection *data_;
|
||||
|
||||
bool m_redChannelEnabled;
|
||||
bool m_greenChannelEnabled;
|
||||
bool m_blueChannelEnabled;
|
||||
bool redChannelEnabled_;
|
||||
bool greenChannelEnabled_;
|
||||
bool blueChannelEnabled_;
|
||||
|
||||
public:
|
||||
ColorCorrectionOperation();
|
||||
@@ -55,19 +55,19 @@ class ColorCorrectionOperation : public MultiThreadedRowOperation {
|
||||
|
||||
void setData(NodeColorCorrection *data)
|
||||
{
|
||||
m_data = data;
|
||||
data_ = data;
|
||||
}
|
||||
void setRedChannelEnabled(bool enabled)
|
||||
{
|
||||
m_redChannelEnabled = enabled;
|
||||
redChannelEnabled_ = enabled;
|
||||
}
|
||||
void setGreenChannelEnabled(bool enabled)
|
||||
{
|
||||
m_greenChannelEnabled = enabled;
|
||||
greenChannelEnabled_ = enabled;
|
||||
}
|
||||
void setBlueChannelEnabled(bool enabled)
|
||||
{
|
||||
m_blueChannelEnabled = enabled;
|
||||
blueChannelEnabled_ = enabled;
|
||||
}
|
||||
|
||||
void update_memory_buffer_row(PixelCursor &p) override;
|
||||
|
||||
@@ -30,22 +30,22 @@ ColorCurveOperation::ColorCurveOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
m_inputFacProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputBlackProgram = nullptr;
|
||||
m_inputWhiteProgram = nullptr;
|
||||
inputFacProgram_ = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
inputBlackProgram_ = nullptr;
|
||||
inputWhiteProgram_ = nullptr;
|
||||
|
||||
this->set_canvas_input_index(1);
|
||||
}
|
||||
void ColorCurveOperation::initExecution()
|
||||
{
|
||||
CurveBaseOperation::initExecution();
|
||||
m_inputFacProgram = this->getInputSocketReader(0);
|
||||
m_inputImageProgram = this->getInputSocketReader(1);
|
||||
m_inputBlackProgram = this->getInputSocketReader(2);
|
||||
m_inputWhiteProgram = this->getInputSocketReader(3);
|
||||
inputFacProgram_ = this->getInputSocketReader(0);
|
||||
inputImageProgram_ = this->getInputSocketReader(1);
|
||||
inputBlackProgram_ = this->getInputSocketReader(2);
|
||||
inputWhiteProgram_ = this->getInputSocketReader(3);
|
||||
|
||||
BKE_curvemapping_premultiply(m_curveMapping, 0);
|
||||
BKE_curvemapping_premultiply(curveMapping_, 0);
|
||||
}
|
||||
|
||||
void ColorCurveOperation::executePixelSampled(float output[4],
|
||||
@@ -53,7 +53,7 @@ void ColorCurveOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler sampler)
|
||||
{
|
||||
CurveMapping *cumap = m_curveMapping;
|
||||
CurveMapping *cumap = curveMapping_;
|
||||
|
||||
float fac[4];
|
||||
float image[4];
|
||||
@@ -63,15 +63,15 @@ void ColorCurveOperation::executePixelSampled(float output[4],
|
||||
float white[4];
|
||||
float bwmul[3];
|
||||
|
||||
m_inputBlackProgram->readSampled(black, x, y, sampler);
|
||||
m_inputWhiteProgram->readSampled(white, x, y, sampler);
|
||||
inputBlackProgram_->readSampled(black, x, y, sampler);
|
||||
inputWhiteProgram_->readSampled(white, x, y, sampler);
|
||||
|
||||
/* get our own local bwmul value,
|
||||
* since we can't be threadsafe and use cumap->bwmul & friends */
|
||||
BKE_curvemapping_set_black_white_ex(black, white, bwmul);
|
||||
|
||||
m_inputFacProgram->readSampled(fac, x, y, sampler);
|
||||
m_inputImageProgram->readSampled(image, x, y, sampler);
|
||||
inputFacProgram_->readSampled(fac, x, y, sampler);
|
||||
inputImageProgram_->readSampled(image, x, y, sampler);
|
||||
|
||||
if (*fac >= 1.0f) {
|
||||
BKE_curvemapping_evaluate_premulRGBF_ex(cumap, output, image, black, bwmul);
|
||||
@@ -90,17 +90,17 @@ void ColorCurveOperation::executePixelSampled(float output[4],
|
||||
void ColorCurveOperation::deinitExecution()
|
||||
{
|
||||
CurveBaseOperation::deinitExecution();
|
||||
m_inputFacProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputBlackProgram = nullptr;
|
||||
m_inputWhiteProgram = nullptr;
|
||||
inputFacProgram_ = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
inputBlackProgram_ = nullptr;
|
||||
inputWhiteProgram_ = nullptr;
|
||||
}
|
||||
|
||||
void ColorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
CurveMapping *cumap = m_curveMapping;
|
||||
CurveMapping *cumap = curveMapping_;
|
||||
float bwmul[3];
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
/* Local versions of `cumap->black` and `cumap->white`. */
|
||||
@@ -134,20 +134,20 @@ ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
m_inputFacProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
inputFacProgram_ = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
|
||||
this->set_canvas_input_index(1);
|
||||
}
|
||||
void ConstantLevelColorCurveOperation::initExecution()
|
||||
{
|
||||
CurveBaseOperation::initExecution();
|
||||
m_inputFacProgram = this->getInputSocketReader(0);
|
||||
m_inputImageProgram = this->getInputSocketReader(1);
|
||||
inputFacProgram_ = this->getInputSocketReader(0);
|
||||
inputImageProgram_ = this->getInputSocketReader(1);
|
||||
|
||||
BKE_curvemapping_premultiply(m_curveMapping, 0);
|
||||
BKE_curvemapping_premultiply(curveMapping_, 0);
|
||||
|
||||
BKE_curvemapping_set_black_white(m_curveMapping, m_black, m_white);
|
||||
BKE_curvemapping_set_black_white(curveMapping_, black_, white_);
|
||||
}
|
||||
|
||||
void ConstantLevelColorCurveOperation::executePixelSampled(float output[4],
|
||||
@@ -158,18 +158,18 @@ void ConstantLevelColorCurveOperation::executePixelSampled(float output[4],
|
||||
float fac[4];
|
||||
float image[4];
|
||||
|
||||
m_inputFacProgram->readSampled(fac, x, y, sampler);
|
||||
m_inputImageProgram->readSampled(image, x, y, sampler);
|
||||
inputFacProgram_->readSampled(fac, x, y, sampler);
|
||||
inputImageProgram_->readSampled(image, x, y, sampler);
|
||||
|
||||
if (*fac >= 1.0f) {
|
||||
BKE_curvemapping_evaluate_premulRGBF(m_curveMapping, output, image);
|
||||
BKE_curvemapping_evaluate_premulRGBF(curveMapping_, output, image);
|
||||
}
|
||||
else if (*fac <= 0.0f) {
|
||||
copy_v3_v3(output, image);
|
||||
}
|
||||
else {
|
||||
float col[4];
|
||||
BKE_curvemapping_evaluate_premulRGBF(m_curveMapping, col, image);
|
||||
BKE_curvemapping_evaluate_premulRGBF(curveMapping_, col, image);
|
||||
interp_v3_v3v3(output, image, col, *fac);
|
||||
}
|
||||
output[3] = image[3];
|
||||
@@ -178,15 +178,15 @@ void ConstantLevelColorCurveOperation::executePixelSampled(float output[4],
|
||||
void ConstantLevelColorCurveOperation::deinitExecution()
|
||||
{
|
||||
CurveBaseOperation::deinitExecution();
|
||||
m_inputFacProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
inputFacProgram_ = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
}
|
||||
|
||||
void ConstantLevelColorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
CurveMapping *cumap = m_curveMapping;
|
||||
CurveMapping *cumap = curveMapping_;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
const float fac = *it.in(0);
|
||||
const float *image = it.in(1);
|
||||
|
||||
@@ -27,10 +27,10 @@ class ColorCurveOperation : public CurveBaseOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputFacProgram;
|
||||
SocketReader *m_inputImageProgram;
|
||||
SocketReader *m_inputBlackProgram;
|
||||
SocketReader *m_inputWhiteProgram;
|
||||
SocketReader *inputFacProgram_;
|
||||
SocketReader *inputImageProgram_;
|
||||
SocketReader *inputBlackProgram_;
|
||||
SocketReader *inputWhiteProgram_;
|
||||
|
||||
public:
|
||||
ColorCurveOperation();
|
||||
@@ -60,10 +60,10 @@ class ConstantLevelColorCurveOperation : public CurveBaseOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputFacProgram;
|
||||
SocketReader *m_inputImageProgram;
|
||||
float m_black[3];
|
||||
float m_white[3];
|
||||
SocketReader *inputFacProgram_;
|
||||
SocketReader *inputImageProgram_;
|
||||
float black_[3];
|
||||
float white_[3];
|
||||
|
||||
public:
|
||||
ConstantLevelColorCurveOperation();
|
||||
@@ -85,11 +85,11 @@ class ConstantLevelColorCurveOperation : public CurveBaseOperation {
|
||||
|
||||
void setBlackLevel(float black[3])
|
||||
{
|
||||
copy_v3_v3(m_black, black);
|
||||
copy_v3_v3(black_, black);
|
||||
}
|
||||
void setWhiteLevel(float white[3])
|
||||
{
|
||||
copy_v3_v3(m_white, white);
|
||||
copy_v3_v3(white_, white);
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -25,14 +25,14 @@ ExposureOperation::ExposureOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_inputProgram = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ExposureOperation::initExecution()
|
||||
{
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputExposureProgram = this->getInputSocketReader(1);
|
||||
inputProgram_ = this->getInputSocketReader(0);
|
||||
inputExposureProgram_ = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ExposureOperation::executePixelSampled(float output[4],
|
||||
@@ -42,8 +42,8 @@ void ExposureOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue[4];
|
||||
float inputExposure[4];
|
||||
m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
m_inputExposureProgram->readSampled(inputExposure, x, y, sampler);
|
||||
inputProgram_->readSampled(inputValue, x, y, sampler);
|
||||
inputExposureProgram_->readSampled(inputExposure, x, y, sampler);
|
||||
const float exposure = pow(2, inputExposure[0]);
|
||||
|
||||
output[0] = inputValue[0] * exposure;
|
||||
@@ -68,8 +68,8 @@ void ExposureOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
|
||||
void ExposureOperation::deinitExecution()
|
||||
{
|
||||
m_inputProgram = nullptr;
|
||||
m_inputExposureProgram = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
inputExposureProgram_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -27,8 +27,8 @@ class ExposureOperation : public MultiThreadedRowOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputProgram;
|
||||
SocketReader *m_inputExposureProgram;
|
||||
SocketReader *inputProgram_;
|
||||
SocketReader *inputExposureProgram_;
|
||||
|
||||
public:
|
||||
ExposureOperation();
|
||||
|
||||
@@ -26,21 +26,21 @@ ColorMatteOperation::ColorMatteOperation()
|
||||
addInputSocket(DataType::Color);
|
||||
addOutputSocket(DataType::Value);
|
||||
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputKeyProgram = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
inputKeyProgram_ = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ColorMatteOperation::initExecution()
|
||||
{
|
||||
m_inputImageProgram = this->getInputSocketReader(0);
|
||||
m_inputKeyProgram = this->getInputSocketReader(1);
|
||||
inputImageProgram_ = this->getInputSocketReader(0);
|
||||
inputKeyProgram_ = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ColorMatteOperation::deinitExecution()
|
||||
{
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputKeyProgram = nullptr;
|
||||
inputImageProgram_ = nullptr;
|
||||
inputKeyProgram_ = nullptr;
|
||||
}
|
||||
|
||||
void ColorMatteOperation::executePixelSampled(float output[4],
|
||||
@@ -51,14 +51,14 @@ void ColorMatteOperation::executePixelSampled(float output[4],
|
||||
float inColor[4];
|
||||
float inKey[4];
|
||||
|
||||
const float hue = m_settings->t1;
|
||||
const float sat = m_settings->t2;
|
||||
const float val = m_settings->t3;
|
||||
const float hue = settings_->t1;
|
||||
const float sat = settings_->t2;
|
||||
const float val = settings_->t3;
|
||||
|
||||
float h_wrap;
|
||||
|
||||
m_inputImageProgram->readSampled(inColor, x, y, sampler);
|
||||
m_inputKeyProgram->readSampled(inKey, x, y, sampler);
|
||||
inputImageProgram_->readSampled(inColor, x, y, sampler);
|
||||
inputKeyProgram_->readSampled(inKey, x, y, sampler);
|
||||
|
||||
/* Store matte(alpha) value in [0] to go with
|
||||
* COM_SetAlphaMultiplyOperation and the Value output.
|
||||
@@ -86,9 +86,9 @@ void ColorMatteOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
const float hue = m_settings->t1;
|
||||
const float sat = m_settings->t2;
|
||||
const float val = m_settings->t3;
|
||||
const float hue = settings_->t1;
|
||||
const float sat = settings_->t2;
|
||||
const float val = settings_->t3;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
const float *in_color = it.in(0);
|
||||
const float *in_key = it.in(1);
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorMatteOperation : public MultiThreadedOperation {
|
||||
private:
|
||||
NodeChroma *m_settings;
|
||||
SocketReader *m_inputImageProgram;
|
||||
SocketReader *m_inputKeyProgram;
|
||||
NodeChroma *settings_;
|
||||
SocketReader *inputImageProgram_;
|
||||
SocketReader *inputKeyProgram_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ class ColorMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma)
|
||||
{
|
||||
m_settings = nodeChroma;
|
||||
settings_ = nodeChroma;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -27,13 +27,13 @@ ColorRampOperation::ColorRampOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
m_inputProgram = nullptr;
|
||||
m_colorBand = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
colorBand_ = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
void ColorRampOperation::initExecution()
|
||||
{
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
inputProgram_ = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void ColorRampOperation::executePixelSampled(float output[4],
|
||||
@@ -43,13 +43,13 @@ void ColorRampOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float values[4];
|
||||
|
||||
m_inputProgram->readSampled(values, x, y, sampler);
|
||||
BKE_colorband_evaluate(m_colorBand, values[0], output);
|
||||
inputProgram_->readSampled(values, x, y, sampler);
|
||||
BKE_colorband_evaluate(colorBand_, values[0], output);
|
||||
}
|
||||
|
||||
void ColorRampOperation::deinitExecution()
|
||||
{
|
||||
m_inputProgram = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
}
|
||||
|
||||
void ColorRampOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -57,7 +57,7 @@ void ColorRampOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
BKE_colorband_evaluate(m_colorBand, *it.in(0), it.out);
|
||||
BKE_colorband_evaluate(colorBand_, *it.in(0), it.out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ class ColorRampOperation : public MultiThreadedOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputProgram;
|
||||
ColorBand *m_colorBand;
|
||||
SocketReader *inputProgram_;
|
||||
ColorBand *colorBand_;
|
||||
|
||||
public:
|
||||
ColorRampOperation();
|
||||
@@ -51,7 +51,7 @@ class ColorRampOperation : public MultiThreadedOperation {
|
||||
|
||||
void setColorBand(ColorBand *colorBand)
|
||||
{
|
||||
m_colorBand = colorBand;
|
||||
colorBand_ = colorBand;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -27,60 +27,60 @@ ColorSpillOperation::ColorSpillOperation()
|
||||
addInputSocket(DataType::Value);
|
||||
addOutputSocket(DataType::Color);
|
||||
|
||||
m_inputImageReader = nullptr;
|
||||
m_inputFacReader = nullptr;
|
||||
m_spillChannel = 1; /* GREEN */
|
||||
m_spillMethod = 0;
|
||||
inputImageReader_ = nullptr;
|
||||
inputFacReader_ = nullptr;
|
||||
spillChannel_ = 1; /* GREEN */
|
||||
spillMethod_ = 0;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ColorSpillOperation::initExecution()
|
||||
{
|
||||
m_inputImageReader = this->getInputSocketReader(0);
|
||||
m_inputFacReader = this->getInputSocketReader(1);
|
||||
if (m_spillChannel == 0) {
|
||||
m_rmut = -1.0f;
|
||||
m_gmut = 1.0f;
|
||||
m_bmut = 1.0f;
|
||||
m_channel2 = 1;
|
||||
m_channel3 = 2;
|
||||
if (m_settings->unspill == 0) {
|
||||
m_settings->uspillr = 1.0f;
|
||||
m_settings->uspillg = 0.0f;
|
||||
m_settings->uspillb = 0.0f;
|
||||
inputImageReader_ = this->getInputSocketReader(0);
|
||||
inputFacReader_ = this->getInputSocketReader(1);
|
||||
if (spillChannel_ == 0) {
|
||||
rmut_ = -1.0f;
|
||||
gmut_ = 1.0f;
|
||||
bmut_ = 1.0f;
|
||||
channel2_ = 1;
|
||||
channel3_ = 2;
|
||||
if (settings_->unspill == 0) {
|
||||
settings_->uspillr = 1.0f;
|
||||
settings_->uspillg = 0.0f;
|
||||
settings_->uspillb = 0.0f;
|
||||
}
|
||||
}
|
||||
else if (m_spillChannel == 1) {
|
||||
m_rmut = 1.0f;
|
||||
m_gmut = -1.0f;
|
||||
m_bmut = 1.0f;
|
||||
m_channel2 = 0;
|
||||
m_channel3 = 2;
|
||||
if (m_settings->unspill == 0) {
|
||||
m_settings->uspillr = 0.0f;
|
||||
m_settings->uspillg = 1.0f;
|
||||
m_settings->uspillb = 0.0f;
|
||||
else if (spillChannel_ == 1) {
|
||||
rmut_ = 1.0f;
|
||||
gmut_ = -1.0f;
|
||||
bmut_ = 1.0f;
|
||||
channel2_ = 0;
|
||||
channel3_ = 2;
|
||||
if (settings_->unspill == 0) {
|
||||
settings_->uspillr = 0.0f;
|
||||
settings_->uspillg = 1.0f;
|
||||
settings_->uspillb = 0.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_rmut = 1.0f;
|
||||
m_gmut = 1.0f;
|
||||
m_bmut = -1.0f;
|
||||
rmut_ = 1.0f;
|
||||
gmut_ = 1.0f;
|
||||
bmut_ = -1.0f;
|
||||
|
||||
m_channel2 = 0;
|
||||
m_channel3 = 1;
|
||||
if (m_settings->unspill == 0) {
|
||||
m_settings->uspillr = 0.0f;
|
||||
m_settings->uspillg = 0.0f;
|
||||
m_settings->uspillb = 1.0f;
|
||||
channel2_ = 0;
|
||||
channel3_ = 1;
|
||||
if (settings_->unspill == 0) {
|
||||
settings_->uspillr = 0.0f;
|
||||
settings_->uspillg = 0.0f;
|
||||
settings_->uspillb = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpillOperation::deinitExecution()
|
||||
{
|
||||
m_inputImageReader = nullptr;
|
||||
m_inputFacReader = nullptr;
|
||||
inputImageReader_ = nullptr;
|
||||
inputFacReader_ = nullptr;
|
||||
}
|
||||
|
||||
void ColorSpillOperation::executePixelSampled(float output[4],
|
||||
@@ -90,25 +90,25 @@ void ColorSpillOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float fac[4];
|
||||
float input[4];
|
||||
m_inputFacReader->readSampled(fac, x, y, sampler);
|
||||
m_inputImageReader->readSampled(input, x, y, sampler);
|
||||
inputFacReader_->readSampled(fac, x, y, sampler);
|
||||
inputImageReader_->readSampled(input, x, y, sampler);
|
||||
float rfac = MIN2(1.0f, fac[0]);
|
||||
float map;
|
||||
|
||||
switch (m_spillMethod) {
|
||||
switch (spillMethod_) {
|
||||
case 0: /* simple */
|
||||
map = rfac * (input[m_spillChannel] - (m_settings->limscale * input[m_settings->limchan]));
|
||||
map = rfac * (input[spillChannel_] - (settings_->limscale * input[settings_->limchan]));
|
||||
break;
|
||||
default: /* average */
|
||||
map = rfac * (input[m_spillChannel] -
|
||||
(m_settings->limscale * AVG(input[m_channel2], input[m_channel3])));
|
||||
map = rfac * (input[spillChannel_] -
|
||||
(settings_->limscale * AVG(input[channel2_], input[channel3_])));
|
||||
break;
|
||||
}
|
||||
|
||||
if (map > 0.0f) {
|
||||
output[0] = input[0] + m_rmut * (m_settings->uspillr * map);
|
||||
output[1] = input[1] + m_gmut * (m_settings->uspillg * map);
|
||||
output[2] = input[2] + m_bmut * (m_settings->uspillb * map);
|
||||
output[0] = input[0] + rmut_ * (settings_->uspillr * map);
|
||||
output[1] = input[1] + gmut_ * (settings_->uspillg * map);
|
||||
output[2] = input[2] + bmut_ * (settings_->uspillb * map);
|
||||
output[3] = input[3];
|
||||
}
|
||||
else {
|
||||
@@ -125,21 +125,20 @@ void ColorSpillOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const float factor = MIN2(1.0f, *it.in(1));
|
||||
|
||||
float map;
|
||||
switch (m_spillMethod) {
|
||||
switch (spillMethod_) {
|
||||
case 0: /* simple */
|
||||
map = factor *
|
||||
(color[m_spillChannel] - (m_settings->limscale * color[m_settings->limchan]));
|
||||
map = factor * (color[spillChannel_] - (settings_->limscale * color[settings_->limchan]));
|
||||
break;
|
||||
default: /* average */
|
||||
map = factor * (color[m_spillChannel] -
|
||||
(m_settings->limscale * AVG(color[m_channel2], color[m_channel3])));
|
||||
map = factor * (color[spillChannel_] -
|
||||
(settings_->limscale * AVG(color[channel2_], color[channel3_])));
|
||||
break;
|
||||
}
|
||||
|
||||
if (map > 0.0f) {
|
||||
it.out[0] = color[0] + m_rmut * (m_settings->uspillr * map);
|
||||
it.out[1] = color[1] + m_gmut * (m_settings->uspillg * map);
|
||||
it.out[2] = color[2] + m_bmut * (m_settings->uspillb * map);
|
||||
it.out[0] = color[0] + rmut_ * (settings_->uspillr * map);
|
||||
it.out[1] = color[1] + gmut_ * (settings_->uspillg * map);
|
||||
it.out[2] = color[2] + bmut_ * (settings_->uspillb * map);
|
||||
it.out[3] = color[3];
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -28,14 +28,14 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorSpillOperation : public MultiThreadedOperation {
|
||||
protected:
|
||||
NodeColorspill *m_settings;
|
||||
SocketReader *m_inputImageReader;
|
||||
SocketReader *m_inputFacReader;
|
||||
int m_spillChannel;
|
||||
int m_spillMethod;
|
||||
int m_channel2;
|
||||
int m_channel3;
|
||||
float m_rmut, m_gmut, m_bmut;
|
||||
NodeColorspill *settings_;
|
||||
SocketReader *inputImageReader_;
|
||||
SocketReader *inputFacReader_;
|
||||
int spillChannel_;
|
||||
int spillMethod_;
|
||||
int channel2_;
|
||||
int channel3_;
|
||||
float rmut_, gmut_, bmut_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -53,15 +53,15 @@ class ColorSpillOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeColorspill *nodeColorSpill)
|
||||
{
|
||||
m_settings = nodeColorSpill;
|
||||
settings_ = nodeColorSpill;
|
||||
}
|
||||
void setSpillChannel(int channel)
|
||||
{
|
||||
m_spillChannel = channel;
|
||||
spillChannel_ = channel;
|
||||
}
|
||||
void setSpillMethod(int method)
|
||||
{
|
||||
m_spillMethod = method;
|
||||
spillMethod_ = method;
|
||||
}
|
||||
|
||||
float calculateMapValue(float fac, float *input);
|
||||
|
||||
@@ -32,71 +32,71 @@ CompositorOperation::CompositorOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
|
||||
this->setRenderData(nullptr);
|
||||
m_outputBuffer = nullptr;
|
||||
m_depthBuffer = nullptr;
|
||||
m_imageInput = nullptr;
|
||||
m_alphaInput = nullptr;
|
||||
m_depthInput = nullptr;
|
||||
outputBuffer_ = nullptr;
|
||||
depthBuffer_ = nullptr;
|
||||
imageInput_ = nullptr;
|
||||
alphaInput_ = nullptr;
|
||||
depthInput_ = nullptr;
|
||||
|
||||
m_useAlphaInput = false;
|
||||
m_active = false;
|
||||
useAlphaInput_ = false;
|
||||
active_ = false;
|
||||
|
||||
m_scene = nullptr;
|
||||
m_sceneName[0] = '\0';
|
||||
m_viewName = nullptr;
|
||||
scene_ = nullptr;
|
||||
sceneName_[0] = '\0';
|
||||
viewName_ = nullptr;
|
||||
|
||||
flags.use_render_border = true;
|
||||
}
|
||||
|
||||
void CompositorOperation::initExecution()
|
||||
{
|
||||
if (!m_active) {
|
||||
if (!active_) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* When initializing the tree during initial load the width and height can be zero. */
|
||||
m_imageInput = getInputSocketReader(0);
|
||||
m_alphaInput = getInputSocketReader(1);
|
||||
m_depthInput = getInputSocketReader(2);
|
||||
imageInput_ = getInputSocketReader(0);
|
||||
alphaInput_ = getInputSocketReader(1);
|
||||
depthInput_ = getInputSocketReader(2);
|
||||
if (this->getWidth() * this->getHeight() != 0) {
|
||||
m_outputBuffer = (float *)MEM_callocN(sizeof(float[4]) * this->getWidth() * this->getHeight(),
|
||||
outputBuffer_ = (float *)MEM_callocN(sizeof(float[4]) * this->getWidth() * this->getHeight(),
|
||||
"CompositorOperation");
|
||||
}
|
||||
if (m_depthInput != nullptr) {
|
||||
m_depthBuffer = (float *)MEM_callocN(sizeof(float) * this->getWidth() * this->getHeight(),
|
||||
if (depthInput_ != nullptr) {
|
||||
depthBuffer_ = (float *)MEM_callocN(sizeof(float) * this->getWidth() * this->getHeight(),
|
||||
"CompositorOperation");
|
||||
}
|
||||
}
|
||||
|
||||
void CompositorOperation::deinitExecution()
|
||||
{
|
||||
if (!m_active) {
|
||||
if (!active_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isBraked()) {
|
||||
Render *re = RE_GetSceneRender(m_scene);
|
||||
Render *re = RE_GetSceneRender(scene_);
|
||||
RenderResult *rr = RE_AcquireResultWrite(re);
|
||||
|
||||
if (rr) {
|
||||
RenderView *rv = RE_RenderViewGetByName(rr, m_viewName);
|
||||
RenderView *rv = RE_RenderViewGetByName(rr, viewName_);
|
||||
|
||||
if (rv->rectf != nullptr) {
|
||||
MEM_freeN(rv->rectf);
|
||||
}
|
||||
rv->rectf = m_outputBuffer;
|
||||
rv->rectf = outputBuffer_;
|
||||
if (rv->rectz != nullptr) {
|
||||
MEM_freeN(rv->rectz);
|
||||
}
|
||||
rv->rectz = m_depthBuffer;
|
||||
rv->rectz = depthBuffer_;
|
||||
rr->have_combined = true;
|
||||
}
|
||||
else {
|
||||
if (m_outputBuffer) {
|
||||
MEM_freeN(m_outputBuffer);
|
||||
if (outputBuffer_) {
|
||||
MEM_freeN(outputBuffer_);
|
||||
}
|
||||
if (m_depthBuffer) {
|
||||
MEM_freeN(m_depthBuffer);
|
||||
if (depthBuffer_) {
|
||||
MEM_freeN(depthBuffer_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,26 +113,26 @@ void CompositorOperation::deinitExecution()
|
||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||
}
|
||||
else {
|
||||
if (m_outputBuffer) {
|
||||
MEM_freeN(m_outputBuffer);
|
||||
if (outputBuffer_) {
|
||||
MEM_freeN(outputBuffer_);
|
||||
}
|
||||
if (m_depthBuffer) {
|
||||
MEM_freeN(m_depthBuffer);
|
||||
if (depthBuffer_) {
|
||||
MEM_freeN(depthBuffer_);
|
||||
}
|
||||
}
|
||||
|
||||
m_outputBuffer = nullptr;
|
||||
m_depthBuffer = nullptr;
|
||||
m_imageInput = nullptr;
|
||||
m_alphaInput = nullptr;
|
||||
m_depthInput = nullptr;
|
||||
outputBuffer_ = nullptr;
|
||||
depthBuffer_ = nullptr;
|
||||
imageInput_ = nullptr;
|
||||
alphaInput_ = nullptr;
|
||||
depthInput_ = nullptr;
|
||||
}
|
||||
|
||||
void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
{
|
||||
float color[8]; // 7 is enough
|
||||
float *buffer = m_outputBuffer;
|
||||
float *zbuffer = m_depthBuffer;
|
||||
float *buffer = outputBuffer_;
|
||||
float *zbuffer = depthBuffer_;
|
||||
|
||||
if (!buffer) {
|
||||
return;
|
||||
@@ -150,7 +150,7 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
int dx = 0, dy = 0;
|
||||
|
||||
#if 0
|
||||
const RenderData *rd = m_rd;
|
||||
const RenderData *rd = rd_;
|
||||
|
||||
if (rd->mode & R_BORDER && rd->mode & R_CROP) {
|
||||
/**
|
||||
@@ -192,14 +192,14 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
for (x = x1; x < x2 && (!breaked); x++) {
|
||||
int input_x = x + dx, input_y = y + dy;
|
||||
|
||||
m_imageInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
|
||||
if (m_useAlphaInput) {
|
||||
m_alphaInput->readSampled(&(color[3]), input_x, input_y, PixelSampler::Nearest);
|
||||
imageInput_->readSampled(color, input_x, input_y, PixelSampler::Nearest);
|
||||
if (useAlphaInput_) {
|
||||
alphaInput_->readSampled(&(color[3]), input_x, input_y, PixelSampler::Nearest);
|
||||
}
|
||||
|
||||
copy_v4_v4(buffer + offset4, color);
|
||||
|
||||
m_depthInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
|
||||
depthInput_->readSampled(color, input_x, input_y, PixelSampler::Nearest);
|
||||
zbuffer[offset] = color[0];
|
||||
offset4 += COM_DATA_TYPE_COLOR_CHANNELS;
|
||||
offset++;
|
||||
@@ -216,26 +216,26 @@ void CompositorOperation::update_memory_buffer_partial(MemoryBuffer *UNUSED(outp
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
if (!m_outputBuffer) {
|
||||
if (!outputBuffer_) {
|
||||
return;
|
||||
}
|
||||
MemoryBuffer output_buf(m_outputBuffer, COM_DATA_TYPE_COLOR_CHANNELS, getWidth(), getHeight());
|
||||
MemoryBuffer output_buf(outputBuffer_, COM_DATA_TYPE_COLOR_CHANNELS, getWidth(), getHeight());
|
||||
output_buf.copy_from(inputs[0], area);
|
||||
if (m_useAlphaInput) {
|
||||
if (useAlphaInput_) {
|
||||
output_buf.copy_from(inputs[1], area, 0, COM_DATA_TYPE_VALUE_CHANNELS, 3);
|
||||
}
|
||||
MemoryBuffer depth_buf(m_depthBuffer, COM_DATA_TYPE_VALUE_CHANNELS, getWidth(), getHeight());
|
||||
MemoryBuffer depth_buf(depthBuffer_, COM_DATA_TYPE_VALUE_CHANNELS, getWidth(), getHeight());
|
||||
depth_buf.copy_from(inputs[2], area);
|
||||
}
|
||||
|
||||
void CompositorOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area)
|
||||
{
|
||||
int width = m_rd->xsch * m_rd->size / 100;
|
||||
int height = m_rd->ysch * m_rd->size / 100;
|
||||
int width = rd_->xsch * rd_->size / 100;
|
||||
int height = rd_->ysch * rd_->size / 100;
|
||||
|
||||
/* Check actual render resolution with cropping it may differ with cropped border.rendering
|
||||
* Fix for T31777 Border Crop gives black (easy). */
|
||||
Render *re = RE_GetSceneRender(m_scene);
|
||||
Render *re = RE_GetSceneRender(scene_);
|
||||
if (re) {
|
||||
RenderResult *rr = RE_AcquireResultRead(re);
|
||||
if (rr) {
|
||||
|
||||
@@ -29,79 +29,79 @@ namespace blender::compositor {
|
||||
*/
|
||||
class CompositorOperation : public MultiThreadedOperation {
|
||||
private:
|
||||
const struct Scene *m_scene;
|
||||
const struct Scene *scene_;
|
||||
/**
|
||||
* \brief Scene name, used for getting the render output, includes 'SC' prefix.
|
||||
*/
|
||||
char m_sceneName[MAX_ID_NAME];
|
||||
char sceneName_[MAX_ID_NAME];
|
||||
|
||||
/**
|
||||
* \brief local reference to the scene
|
||||
*/
|
||||
const RenderData *m_rd;
|
||||
const RenderData *rd_;
|
||||
|
||||
/**
|
||||
* \brief reference to the output float buffer
|
||||
*/
|
||||
float *m_outputBuffer;
|
||||
float *outputBuffer_;
|
||||
|
||||
/**
|
||||
* \brief reference to the output depth float buffer
|
||||
*/
|
||||
float *m_depthBuffer;
|
||||
float *depthBuffer_;
|
||||
|
||||
/**
|
||||
* \brief local reference to the input image operation
|
||||
*/
|
||||
SocketReader *m_imageInput;
|
||||
SocketReader *imageInput_;
|
||||
|
||||
/**
|
||||
* \brief local reference to the input alpha operation
|
||||
*/
|
||||
SocketReader *m_alphaInput;
|
||||
SocketReader *alphaInput_;
|
||||
|
||||
/**
|
||||
* \brief local reference to the depth operation
|
||||
*/
|
||||
SocketReader *m_depthInput;
|
||||
SocketReader *depthInput_;
|
||||
|
||||
/**
|
||||
* \brief Ignore any alpha input
|
||||
*/
|
||||
bool m_useAlphaInput;
|
||||
bool useAlphaInput_;
|
||||
|
||||
/**
|
||||
* \brief operation is active for calculating final compo result
|
||||
*/
|
||||
bool m_active;
|
||||
bool active_;
|
||||
|
||||
/**
|
||||
* \brief View name, used for multiview
|
||||
*/
|
||||
const char *m_viewName;
|
||||
const char *viewName_;
|
||||
|
||||
public:
|
||||
CompositorOperation();
|
||||
bool isActiveCompositorOutput() const
|
||||
{
|
||||
return m_active;
|
||||
return active_;
|
||||
}
|
||||
void executeRegion(rcti *rect, unsigned int tileNumber) override;
|
||||
void setScene(const struct Scene *scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
scene_ = scene;
|
||||
}
|
||||
void setSceneName(const char *sceneName)
|
||||
{
|
||||
BLI_strncpy(m_sceneName, sceneName, sizeof(m_sceneName));
|
||||
BLI_strncpy(sceneName_, sceneName, sizeof(sceneName_));
|
||||
}
|
||||
void setViewName(const char *viewName)
|
||||
{
|
||||
m_viewName = viewName;
|
||||
viewName_ = viewName;
|
||||
}
|
||||
void setRenderData(const RenderData *rd)
|
||||
{
|
||||
m_rd = rd;
|
||||
rd_ = rd;
|
||||
}
|
||||
bool isOutputOperation(bool /*rendering*/) const override
|
||||
{
|
||||
@@ -116,11 +116,11 @@ class CompositorOperation : public MultiThreadedOperation {
|
||||
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
|
||||
void setUseAlphaInput(bool value)
|
||||
{
|
||||
m_useAlphaInput = value;
|
||||
useAlphaInput_ = value;
|
||||
}
|
||||
void setActive(bool active)
|
||||
{
|
||||
m_active = active;
|
||||
active_ = active;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,13 +26,13 @@ ConvertColorProfileOperation::ConvertColorProfileOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_inputOperation = nullptr;
|
||||
m_predivided = false;
|
||||
inputOperation_ = nullptr;
|
||||
predivided_ = false;
|
||||
}
|
||||
|
||||
void ConvertColorProfileOperation::initExecution()
|
||||
{
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
inputOperation_ = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void ConvertColorProfileOperation::executePixelSampled(float output[4],
|
||||
@@ -41,14 +41,13 @@ void ConvertColorProfileOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float color[4];
|
||||
m_inputOperation->readSampled(color, x, y, sampler);
|
||||
IMB_buffer_float_from_float(
|
||||
output, color, 4, m_toProfile, m_fromProfile, m_predivided, 1, 1, 0, 0);
|
||||
inputOperation_->readSampled(color, x, y, sampler);
|
||||
IMB_buffer_float_from_float(output, color, 4, toProfile_, fromProfile_, predivided_, 1, 1, 0, 0);
|
||||
}
|
||||
|
||||
void ConvertColorProfileOperation::deinitExecution()
|
||||
{
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -31,22 +31,22 @@ class ConvertColorProfileOperation : public NodeOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputOperation;
|
||||
SocketReader *inputOperation_;
|
||||
|
||||
/**
|
||||
* \brief color profile where to convert from
|
||||
*/
|
||||
int m_fromProfile;
|
||||
int fromProfile_;
|
||||
|
||||
/**
|
||||
* \brief color profile where to convert to
|
||||
*/
|
||||
int m_toProfile;
|
||||
int toProfile_;
|
||||
|
||||
/**
|
||||
* \brief is color predivided
|
||||
*/
|
||||
bool m_predivided;
|
||||
bool predivided_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -71,15 +71,15 @@ class ConvertColorProfileOperation : public NodeOperation {
|
||||
|
||||
void setFromColorProfile(int colorProfile)
|
||||
{
|
||||
m_fromProfile = colorProfile;
|
||||
fromProfile_ = colorProfile;
|
||||
}
|
||||
void setToColorProfile(int colorProfile)
|
||||
{
|
||||
m_toProfile = colorProfile;
|
||||
toProfile_ = colorProfile;
|
||||
}
|
||||
void setPredivided(bool predivided)
|
||||
{
|
||||
m_predivided = predivided;
|
||||
predivided_ = predivided;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,19 +26,19 @@ ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
m_inputOperation = nullptr;
|
||||
m_fStop = 128.0f;
|
||||
m_cameraObject = nullptr;
|
||||
m_maxRadius = 32.0f;
|
||||
m_blurPostOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
fStop_ = 128.0f;
|
||||
cameraObject_ = nullptr;
|
||||
maxRadius_ = 32.0f;
|
||||
blurPostOperation_ = nullptr;
|
||||
}
|
||||
|
||||
float ConvertDepthToRadiusOperation::determineFocalDistance()
|
||||
{
|
||||
if (m_cameraObject && m_cameraObject->type == OB_CAMERA) {
|
||||
Camera *camera = (Camera *)m_cameraObject->data;
|
||||
m_cam_lens = camera->lens;
|
||||
return BKE_camera_object_dof_distance(m_cameraObject);
|
||||
if (cameraObject_ && cameraObject_->type == OB_CAMERA) {
|
||||
Camera *camera = (Camera *)cameraObject_->data;
|
||||
cam_lens_ = camera->lens;
|
||||
return BKE_camera_object_dof_distance(cameraObject_);
|
||||
}
|
||||
|
||||
return 10.0f;
|
||||
@@ -49,27 +49,27 @@ void ConvertDepthToRadiusOperation::initExecution()
|
||||
float cam_sensor = DEFAULT_SENSOR_WIDTH;
|
||||
Camera *camera = nullptr;
|
||||
|
||||
if (m_cameraObject && m_cameraObject->type == OB_CAMERA) {
|
||||
camera = (Camera *)m_cameraObject->data;
|
||||
if (cameraObject_ && cameraObject_->type == OB_CAMERA) {
|
||||
camera = (Camera *)cameraObject_->data;
|
||||
cam_sensor = BKE_camera_sensor_size(camera->sensor_fit, camera->sensor_x, camera->sensor_y);
|
||||
}
|
||||
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
inputOperation_ = this->getInputSocketReader(0);
|
||||
float focalDistance = determineFocalDistance();
|
||||
if (focalDistance == 0.0f) {
|
||||
focalDistance = 1e10f; /* If the DOF is 0.0 then set it to be far away. */
|
||||
}
|
||||
m_inverseFocalDistance = 1.0f / focalDistance;
|
||||
m_aspect = (this->getWidth() > this->getHeight()) ?
|
||||
inverseFocalDistance_ = 1.0f / focalDistance;
|
||||
aspect_ = (this->getWidth() > this->getHeight()) ?
|
||||
(this->getHeight() / (float)this->getWidth()) :
|
||||
(this->getWidth() / (float)this->getHeight());
|
||||
m_aperture = 0.5f * (m_cam_lens / (m_aspect * cam_sensor)) / m_fStop;
|
||||
aperture_ = 0.5f * (cam_lens_ / (aspect_ * cam_sensor)) / fStop_;
|
||||
const float minsz = MIN2(getWidth(), getHeight());
|
||||
m_dof_sp = minsz / ((cam_sensor / 2.0f) /
|
||||
m_cam_lens); /* <- == `aspect * MIN2(img->x, img->y) / tan(0.5f * fov)` */
|
||||
dof_sp_ = minsz / ((cam_sensor / 2.0f) /
|
||||
cam_lens_); /* <- == `aspect * MIN2(img->x, img->y) / tan(0.5f * fov)` */
|
||||
|
||||
if (m_blurPostOperation) {
|
||||
m_blurPostOperation->setSigma(MIN2(m_aperture * 128.0f, m_maxRadius));
|
||||
if (blurPostOperation_) {
|
||||
blurPostOperation_->setSigma(MIN2(aperture_ * 128.0f, maxRadius_));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
|
||||
float inputValue[4];
|
||||
float z;
|
||||
float radius;
|
||||
m_inputOperation->readSampled(inputValue, x, y, sampler);
|
||||
inputOperation_->readSampled(inputValue, x, y, sampler);
|
||||
z = inputValue[0];
|
||||
if (z != 0.0f) {
|
||||
float iZ = (1.0f / z);
|
||||
@@ -92,14 +92,14 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
|
||||
/* Scale crad back to original maximum and blend. */
|
||||
crad->rect[px] = bcrad + wts->rect[px] * (scf * crad->rect[px] - bcrad);
|
||||
#endif
|
||||
radius = 0.5f * fabsf(m_aperture * (m_dof_sp * (m_inverseFocalDistance - iZ) - 1.0f));
|
||||
radius = 0.5f * fabsf(aperture_ * (dof_sp_ * (inverseFocalDistance_ - iZ) - 1.0f));
|
||||
/* 'bug' T6615, limit minimum radius to 1 pixel,
|
||||
* not really a solution, but somewhat mitigates the problem. */
|
||||
if (radius < 0.0f) {
|
||||
radius = 0.0f;
|
||||
}
|
||||
if (radius > m_maxRadius) {
|
||||
radius = m_maxRadius;
|
||||
if (radius > maxRadius_) {
|
||||
radius = maxRadius_;
|
||||
}
|
||||
output[0] = radius;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
|
||||
|
||||
void ConvertDepthToRadiusOperation::deinitExecution()
|
||||
{
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
}
|
||||
|
||||
void ConvertDepthToRadiusOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -133,10 +133,10 @@ void ConvertDepthToRadiusOperation::update_memory_buffer_partial(MemoryBuffer *o
|
||||
* `crad->rect[px] = bcrad + wts->rect[px] * (scf * crad->rect[px] - bcrad);` */
|
||||
#endif
|
||||
const float radius = 0.5f *
|
||||
fabsf(m_aperture * (m_dof_sp * (m_inverseFocalDistance - inv_z) - 1.0f));
|
||||
fabsf(aperture_ * (dof_sp_ * (inverseFocalDistance_ - inv_z) - 1.0f));
|
||||
/* Bug T6615, limit minimum radius to 1 pixel,
|
||||
* not really a solution, but somewhat mitigates the problem. */
|
||||
*it.out = CLAMPIS(radius, 0.0f, m_maxRadius);
|
||||
*it.out = CLAMPIS(radius, 0.0f, maxRadius_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,17 +33,17 @@ class ConvertDepthToRadiusOperation : public MultiThreadedOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
SocketReader *m_inputOperation;
|
||||
float m_fStop;
|
||||
float m_aspect;
|
||||
float m_maxRadius;
|
||||
float m_inverseFocalDistance;
|
||||
float m_aperture;
|
||||
float m_cam_lens;
|
||||
float m_dof_sp;
|
||||
Object *m_cameraObject;
|
||||
SocketReader *inputOperation_;
|
||||
float fStop_;
|
||||
float aspect_;
|
||||
float maxRadius_;
|
||||
float inverseFocalDistance_;
|
||||
float aperture_;
|
||||
float cam_lens_;
|
||||
float dof_sp_;
|
||||
Object *cameraObject_;
|
||||
|
||||
FastGaussianBlurValueOperation *m_blurPostOperation;
|
||||
FastGaussianBlurValueOperation *blurPostOperation_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -68,20 +68,20 @@ class ConvertDepthToRadiusOperation : public MultiThreadedOperation {
|
||||
|
||||
void setfStop(float fStop)
|
||||
{
|
||||
m_fStop = fStop;
|
||||
fStop_ = fStop;
|
||||
}
|
||||
void setMaxRadius(float maxRadius)
|
||||
{
|
||||
m_maxRadius = maxRadius;
|
||||
maxRadius_ = maxRadius;
|
||||
}
|
||||
void setCameraObject(Object *camera)
|
||||
{
|
||||
m_cameraObject = camera;
|
||||
cameraObject_ = camera;
|
||||
}
|
||||
float determineFocalDistance();
|
||||
void setPostBlur(FastGaussianBlurValueOperation *operation)
|
||||
{
|
||||
m_blurPostOperation = operation;
|
||||
blurPostOperation_ = operation;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,18 +26,18 @@ namespace blender::compositor {
|
||||
|
||||
ConvertBaseOperation::ConvertBaseOperation()
|
||||
{
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ConvertBaseOperation::initExecution()
|
||||
{
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
inputOperation_ = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void ConvertBaseOperation::deinitExecution()
|
||||
{
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
}
|
||||
|
||||
void ConvertBaseOperation::hash_output_params()
|
||||
@@ -66,7 +66,7 @@ void ConvertValueToColorOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float value;
|
||||
m_inputOperation->readSampled(&value, x, y, sampler);
|
||||
inputOperation_->readSampled(&value, x, y, sampler);
|
||||
output[0] = output[1] = output[2] = value;
|
||||
output[3] = 1.0f;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ void ConvertColorToValueOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
inputOperation_->readSampled(inputColor, x, y, sampler);
|
||||
output[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ void ConvertColorToBWOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
inputOperation_->readSampled(inputColor, x, y, sampler);
|
||||
output[0] = IMB_colormanagement_get_luminance(inputColor);
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ void ConvertColorToVectorOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float color[4];
|
||||
m_inputOperation->readSampled(color, x, y, sampler);
|
||||
inputOperation_->readSampled(color, x, y, sampler);
|
||||
copy_v3_v3(output, color);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ void ConvertValueToVectorOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float value;
|
||||
m_inputOperation->readSampled(&value, x, y, sampler);
|
||||
inputOperation_->readSampled(&value, x, y, sampler);
|
||||
output[0] = output[1] = output[2] = value;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ void ConvertVectorToColorOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler sampler)
|
||||
{
|
||||
m_inputOperation->readSampled(output, x, y, sampler);
|
||||
inputOperation_->readSampled(output, x, y, sampler);
|
||||
output[3] = 1.0f;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ void ConvertVectorToValueOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float input[4];
|
||||
m_inputOperation->readSampled(input, x, y, sampler);
|
||||
inputOperation_->readSampled(input, x, y, sampler);
|
||||
output[0] = (input[0] + input[1] + input[2]) / 3.0f;
|
||||
}
|
||||
|
||||
@@ -243,14 +243,14 @@ void ConvertRGBToYCCOperation::setMode(int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case 0:
|
||||
m_mode = BLI_YCC_ITU_BT601;
|
||||
mode_ = BLI_YCC_ITU_BT601;
|
||||
break;
|
||||
case 2:
|
||||
m_mode = BLI_YCC_JFIF_0_255;
|
||||
mode_ = BLI_YCC_JFIF_0_255;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
m_mode = BLI_YCC_ITU_BT709;
|
||||
mode_ = BLI_YCC_ITU_BT709;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -263,9 +263,8 @@ void ConvertRGBToYCCOperation::executePixelSampled(float output[4],
|
||||
float inputColor[4];
|
||||
float color[3];
|
||||
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
rgb_to_ycc(
|
||||
inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], m_mode);
|
||||
inputOperation_->readSampled(inputColor, x, y, sampler);
|
||||
rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], mode_);
|
||||
|
||||
/* divided by 255 to normalize for viewing in */
|
||||
/* R,G,B --> Y,Cb,Cr */
|
||||
@@ -276,14 +275,14 @@ void ConvertRGBToYCCOperation::executePixelSampled(float output[4],
|
||||
void ConvertRGBToYCCOperation::hash_output_params()
|
||||
{
|
||||
ConvertBaseOperation::hash_output_params();
|
||||
hash_param(m_mode);
|
||||
hash_param(mode_);
|
||||
}
|
||||
|
||||
void ConvertRGBToYCCOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
||||
{
|
||||
for (; !it.is_end(); ++it) {
|
||||
const float *in = it.in(0);
|
||||
rgb_to_ycc(in[0], in[1], in[2], &it.out[0], &it.out[1], &it.out[2], m_mode);
|
||||
rgb_to_ycc(in[0], in[1], in[2], &it.out[0], &it.out[1], &it.out[2], mode_);
|
||||
|
||||
/* Normalize for viewing (#rgb_to_ycc returns 0-255 values). */
|
||||
mul_v3_fl(it.out, 1.0f / 255.0f);
|
||||
@@ -303,14 +302,14 @@ void ConvertYCCToRGBOperation::setMode(int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case 0:
|
||||
m_mode = BLI_YCC_ITU_BT601;
|
||||
mode_ = BLI_YCC_ITU_BT601;
|
||||
break;
|
||||
case 2:
|
||||
m_mode = BLI_YCC_JFIF_0_255;
|
||||
mode_ = BLI_YCC_JFIF_0_255;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
m_mode = BLI_YCC_ITU_BT709;
|
||||
mode_ = BLI_YCC_ITU_BT709;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -321,26 +320,21 @@ void ConvertYCCToRGBOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
inputOperation_->readSampled(inputColor, x, y, sampler);
|
||||
|
||||
/* need to un-normalize the data */
|
||||
/* R,G,B --> Y,Cb,Cr */
|
||||
mul_v3_fl(inputColor, 255.0f);
|
||||
|
||||
ycc_to_rgb(inputColor[0],
|
||||
inputColor[1],
|
||||
inputColor[2],
|
||||
&output[0],
|
||||
&output[1],
|
||||
&output[2],
|
||||
m_mode);
|
||||
ycc_to_rgb(
|
||||
inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2], mode_);
|
||||
output[3] = inputColor[3];
|
||||
}
|
||||
|
||||
void ConvertYCCToRGBOperation::hash_output_params()
|
||||
{
|
||||
ConvertBaseOperation::hash_output_params();
|
||||
hash_param(m_mode);
|
||||
hash_param(mode_);
|
||||
}
|
||||
|
||||
void ConvertYCCToRGBOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
|
||||
@@ -348,13 +342,8 @@ void ConvertYCCToRGBOperation::update_memory_buffer_partial(BuffersIterator<floa
|
||||
for (; !it.is_end(); ++it) {
|
||||
const float *in = it.in(0);
|
||||
/* Multiply by 255 to un-normalize (#ycc_to_rgb needs input values in 0-255 range). */
|
||||
ycc_to_rgb(in[0] * 255.0f,
|
||||
in[1] * 255.0f,
|
||||
in[2] * 255.0f,
|
||||
&it.out[0],
|
||||
&it.out[1],
|
||||
&it.out[2],
|
||||
m_mode);
|
||||
ycc_to_rgb(
|
||||
in[0] * 255.0f, in[1] * 255.0f, in[2] * 255.0f, &it.out[0], &it.out[1], &it.out[2], mode_);
|
||||
it.out[3] = in[3];
|
||||
}
|
||||
}
|
||||
@@ -373,7 +362,7 @@ void ConvertRGBToYUVOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
inputOperation_->readSampled(inputColor, x, y, sampler);
|
||||
rgb_to_yuv(inputColor[0],
|
||||
inputColor[1],
|
||||
inputColor[2],
|
||||
@@ -407,7 +396,7 @@ void ConvertYUVToRGBOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
inputOperation_->readSampled(inputColor, x, y, sampler);
|
||||
yuv_to_rgb(inputColor[0],
|
||||
inputColor[1],
|
||||
inputColor[2],
|
||||
@@ -441,7 +430,7 @@ void ConvertRGBToHSVOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
inputOperation_->readSampled(inputColor, x, y, sampler);
|
||||
rgb_to_hsv_v(inputColor, output);
|
||||
output[3] = inputColor[3];
|
||||
}
|
||||
@@ -469,7 +458,7 @@ void ConvertHSVToRGBOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
inputOperation_->readSampled(inputColor, x, y, sampler);
|
||||
hsv_to_rgb_v(inputColor, output);
|
||||
output[0] = max_ff(output[0], 0.0f);
|
||||
output[1] = max_ff(output[1], 0.0f);
|
||||
@@ -503,7 +492,7 @@ void ConvertPremulToStraightOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
ColorSceneLinear4f<eAlpha::Premultiplied> input;
|
||||
m_inputOperation->readSampled(input, x, y, sampler);
|
||||
inputOperation_->readSampled(input, x, y, sampler);
|
||||
ColorSceneLinear4f<eAlpha::Straight> converted = input.unpremultiply_alpha();
|
||||
copy_v4_v4(output, converted);
|
||||
}
|
||||
@@ -529,7 +518,7 @@ void ConvertStraightToPremulOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
ColorSceneLinear4f<eAlpha::Straight> input;
|
||||
m_inputOperation->readSampled(input, x, y, sampler);
|
||||
inputOperation_->readSampled(input, x, y, sampler);
|
||||
ColorSceneLinear4f<eAlpha::Premultiplied> converted = input.premultiply_alpha();
|
||||
copy_v4_v4(output, converted);
|
||||
}
|
||||
@@ -547,16 +536,16 @@ SeparateChannelOperation::SeparateChannelOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
}
|
||||
void SeparateChannelOperation::initExecution()
|
||||
{
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
inputOperation_ = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void SeparateChannelOperation::deinitExecution()
|
||||
{
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
}
|
||||
|
||||
void SeparateChannelOperation::executePixelSampled(float output[4],
|
||||
@@ -565,8 +554,8 @@ void SeparateChannelOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float input[4];
|
||||
m_inputOperation->readSampled(input, x, y, sampler);
|
||||
output[0] = input[m_channel];
|
||||
inputOperation_->readSampled(input, x, y, sampler);
|
||||
output[0] = input[channel_];
|
||||
}
|
||||
|
||||
void SeparateChannelOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -574,7 +563,7 @@ void SeparateChannelOperation::update_memory_buffer_partial(MemoryBuffer *output
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
it.out[0] = it.in(0)[m_channel];
|
||||
it.out[0] = it.in(0)[channel_];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,26 +577,26 @@ CombineChannelsOperation::CombineChannelsOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->set_canvas_input_index(0);
|
||||
m_inputChannel1Operation = nullptr;
|
||||
m_inputChannel2Operation = nullptr;
|
||||
m_inputChannel3Operation = nullptr;
|
||||
m_inputChannel4Operation = nullptr;
|
||||
inputChannel1Operation_ = nullptr;
|
||||
inputChannel2Operation_ = nullptr;
|
||||
inputChannel3Operation_ = nullptr;
|
||||
inputChannel4Operation_ = nullptr;
|
||||
}
|
||||
|
||||
void CombineChannelsOperation::initExecution()
|
||||
{
|
||||
m_inputChannel1Operation = this->getInputSocketReader(0);
|
||||
m_inputChannel2Operation = this->getInputSocketReader(1);
|
||||
m_inputChannel3Operation = this->getInputSocketReader(2);
|
||||
m_inputChannel4Operation = this->getInputSocketReader(3);
|
||||
inputChannel1Operation_ = this->getInputSocketReader(0);
|
||||
inputChannel2Operation_ = this->getInputSocketReader(1);
|
||||
inputChannel3Operation_ = this->getInputSocketReader(2);
|
||||
inputChannel4Operation_ = this->getInputSocketReader(3);
|
||||
}
|
||||
|
||||
void CombineChannelsOperation::deinitExecution()
|
||||
{
|
||||
m_inputChannel1Operation = nullptr;
|
||||
m_inputChannel2Operation = nullptr;
|
||||
m_inputChannel3Operation = nullptr;
|
||||
m_inputChannel4Operation = nullptr;
|
||||
inputChannel1Operation_ = nullptr;
|
||||
inputChannel2Operation_ = nullptr;
|
||||
inputChannel3Operation_ = nullptr;
|
||||
inputChannel4Operation_ = nullptr;
|
||||
}
|
||||
|
||||
void CombineChannelsOperation::executePixelSampled(float output[4],
|
||||
@@ -616,20 +605,20 @@ void CombineChannelsOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float input[4];
|
||||
if (m_inputChannel1Operation) {
|
||||
m_inputChannel1Operation->readSampled(input, x, y, sampler);
|
||||
if (inputChannel1Operation_) {
|
||||
inputChannel1Operation_->readSampled(input, x, y, sampler);
|
||||
output[0] = input[0];
|
||||
}
|
||||
if (m_inputChannel2Operation) {
|
||||
m_inputChannel2Operation->readSampled(input, x, y, sampler);
|
||||
if (inputChannel2Operation_) {
|
||||
inputChannel2Operation_->readSampled(input, x, y, sampler);
|
||||
output[1] = input[0];
|
||||
}
|
||||
if (m_inputChannel3Operation) {
|
||||
m_inputChannel3Operation->readSampled(input, x, y, sampler);
|
||||
if (inputChannel3Operation_) {
|
||||
inputChannel3Operation_->readSampled(input, x, y, sampler);
|
||||
output[2] = input[0];
|
||||
}
|
||||
if (m_inputChannel4Operation) {
|
||||
m_inputChannel4Operation->readSampled(input, x, y, sampler);
|
||||
if (inputChannel4Operation_) {
|
||||
inputChannel4Operation_->readSampled(input, x, y, sampler);
|
||||
output[3] = input[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace blender::compositor {
|
||||
|
||||
class ConvertBaseOperation : public MultiThreadedOperation {
|
||||
protected:
|
||||
SocketReader *m_inputOperation;
|
||||
SocketReader *inputOperation_;
|
||||
|
||||
public:
|
||||
ConvertBaseOperation();
|
||||
@@ -114,7 +114,7 @@ class ConvertVectorToValueOperation : public ConvertBaseOperation {
|
||||
class ConvertRGBToYCCOperation : public ConvertBaseOperation {
|
||||
private:
|
||||
/** YCbCr mode (Jpeg, ITU601, ITU709) */
|
||||
int m_mode;
|
||||
int mode_;
|
||||
|
||||
public:
|
||||
ConvertRGBToYCCOperation();
|
||||
@@ -132,7 +132,7 @@ class ConvertRGBToYCCOperation : public ConvertBaseOperation {
|
||||
class ConvertYCCToRGBOperation : public ConvertBaseOperation {
|
||||
private:
|
||||
/** YCbCr mode (Jpeg, ITU601, ITU709) */
|
||||
int m_mode;
|
||||
int mode_;
|
||||
|
||||
public:
|
||||
ConvertYCCToRGBOperation();
|
||||
@@ -209,8 +209,8 @@ class ConvertStraightToPremulOperation : public ConvertBaseOperation {
|
||||
|
||||
class SeparateChannelOperation : public MultiThreadedOperation {
|
||||
private:
|
||||
SocketReader *m_inputOperation;
|
||||
int m_channel;
|
||||
SocketReader *inputOperation_;
|
||||
int channel_;
|
||||
|
||||
public:
|
||||
SeparateChannelOperation();
|
||||
@@ -221,7 +221,7 @@ class SeparateChannelOperation : public MultiThreadedOperation {
|
||||
|
||||
void setChannel(int channel)
|
||||
{
|
||||
m_channel = channel;
|
||||
channel_ = channel;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -231,10 +231,10 @@ class SeparateChannelOperation : public MultiThreadedOperation {
|
||||
|
||||
class CombineChannelsOperation : public MultiThreadedOperation {
|
||||
private:
|
||||
SocketReader *m_inputChannel1Operation;
|
||||
SocketReader *m_inputChannel2Operation;
|
||||
SocketReader *m_inputChannel3Operation;
|
||||
SocketReader *m_inputChannel4Operation;
|
||||
SocketReader *inputChannel1Operation_;
|
||||
SocketReader *inputChannel2Operation_;
|
||||
SocketReader *inputChannel3Operation_;
|
||||
SocketReader *inputChannel4Operation_;
|
||||
|
||||
public:
|
||||
CombineChannelsOperation();
|
||||
|
||||
@@ -38,44 +38,44 @@ void ConvolutionEdgeFilterOperation::executePixel(float output[4], int x, int y,
|
||||
CLAMP(y3, 0, getHeight() - 1);
|
||||
|
||||
float value[4];
|
||||
m_inputValueOperation->read(value, x2, y2, nullptr);
|
||||
inputValueOperation_->read(value, x2, y2, nullptr);
|
||||
float mval = 1.0f - value[0];
|
||||
|
||||
m_inputOperation->read(in1, x1, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[0]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[0]);
|
||||
inputOperation_->read(in1, x1, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, filter_[0]);
|
||||
madd_v3_v3fl(res2, in1, filter_[0]);
|
||||
|
||||
m_inputOperation->read(in1, x2, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[1]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[3]);
|
||||
inputOperation_->read(in1, x2, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, filter_[1]);
|
||||
madd_v3_v3fl(res2, in1, filter_[3]);
|
||||
|
||||
m_inputOperation->read(in1, x3, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[2]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[6]);
|
||||
inputOperation_->read(in1, x3, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, filter_[2]);
|
||||
madd_v3_v3fl(res2, in1, filter_[6]);
|
||||
|
||||
m_inputOperation->read(in1, x1, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[3]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[1]);
|
||||
inputOperation_->read(in1, x1, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in1, filter_[3]);
|
||||
madd_v3_v3fl(res2, in1, filter_[1]);
|
||||
|
||||
m_inputOperation->read(in2, x2, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in2, m_filter[4]);
|
||||
madd_v3_v3fl(res2, in2, m_filter[4]);
|
||||
inputOperation_->read(in2, x2, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in2, filter_[4]);
|
||||
madd_v3_v3fl(res2, in2, filter_[4]);
|
||||
|
||||
m_inputOperation->read(in1, x3, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[5]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[7]);
|
||||
inputOperation_->read(in1, x3, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in1, filter_[5]);
|
||||
madd_v3_v3fl(res2, in1, filter_[7]);
|
||||
|
||||
m_inputOperation->read(in1, x1, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[6]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[2]);
|
||||
inputOperation_->read(in1, x1, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, filter_[6]);
|
||||
madd_v3_v3fl(res2, in1, filter_[2]);
|
||||
|
||||
m_inputOperation->read(in1, x2, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[7]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[5]);
|
||||
inputOperation_->read(in1, x2, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, filter_[7]);
|
||||
madd_v3_v3fl(res2, in1, filter_[5]);
|
||||
|
||||
m_inputOperation->read(in1, x3, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[8]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[8]);
|
||||
inputOperation_->read(in1, x3, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, filter_[8]);
|
||||
madd_v3_v3fl(res2, in1, filter_[8]);
|
||||
|
||||
output[0] = sqrt(res1[0] * res1[0] + res2[0] * res2[0]);
|
||||
output[1] = sqrt(res1[1] * res1[1] + res2[1] * res2[1]);
|
||||
@@ -112,44 +112,44 @@ void ConvolutionEdgeFilterOperation::update_memory_buffer_partial(MemoryBuffer *
|
||||
float res2[4] = {0};
|
||||
|
||||
const float *color = center_color + down_offset + left_offset;
|
||||
madd_v3_v3fl(res1, color, m_filter[0]);
|
||||
madd_v3_v3fl(res1, color, filter_[0]);
|
||||
copy_v3_v3(res2, res1);
|
||||
|
||||
color = center_color + down_offset;
|
||||
madd_v3_v3fl(res1, color, m_filter[1]);
|
||||
madd_v3_v3fl(res2, color, m_filter[3]);
|
||||
madd_v3_v3fl(res1, color, filter_[1]);
|
||||
madd_v3_v3fl(res2, color, filter_[3]);
|
||||
|
||||
color = center_color + down_offset + right_offset;
|
||||
madd_v3_v3fl(res1, color, m_filter[2]);
|
||||
madd_v3_v3fl(res2, color, m_filter[6]);
|
||||
madd_v3_v3fl(res1, color, filter_[2]);
|
||||
madd_v3_v3fl(res2, color, filter_[6]);
|
||||
|
||||
color = center_color + left_offset;
|
||||
madd_v3_v3fl(res1, color, m_filter[3]);
|
||||
madd_v3_v3fl(res2, color, m_filter[1]);
|
||||
madd_v3_v3fl(res1, color, filter_[3]);
|
||||
madd_v3_v3fl(res2, color, filter_[1]);
|
||||
|
||||
{
|
||||
float rgb_filtered[3];
|
||||
mul_v3_v3fl(rgb_filtered, center_color, m_filter[4]);
|
||||
mul_v3_v3fl(rgb_filtered, center_color, filter_[4]);
|
||||
add_v3_v3(res1, rgb_filtered);
|
||||
add_v3_v3(res2, rgb_filtered);
|
||||
}
|
||||
|
||||
color = center_color + right_offset;
|
||||
madd_v3_v3fl(res1, color, m_filter[5]);
|
||||
madd_v3_v3fl(res2, color, m_filter[7]);
|
||||
madd_v3_v3fl(res1, color, filter_[5]);
|
||||
madd_v3_v3fl(res2, color, filter_[7]);
|
||||
|
||||
color = center_color + up_offset + left_offset;
|
||||
madd_v3_v3fl(res1, color, m_filter[6]);
|
||||
madd_v3_v3fl(res2, color, m_filter[2]);
|
||||
madd_v3_v3fl(res1, color, filter_[6]);
|
||||
madd_v3_v3fl(res2, color, filter_[2]);
|
||||
|
||||
color = center_color + up_offset;
|
||||
madd_v3_v3fl(res1, color, m_filter[7]);
|
||||
madd_v3_v3fl(res2, color, m_filter[5]);
|
||||
madd_v3_v3fl(res1, color, filter_[7]);
|
||||
madd_v3_v3fl(res2, color, filter_[5]);
|
||||
|
||||
{
|
||||
color = center_color + up_offset + right_offset;
|
||||
float rgb_filtered[3];
|
||||
mul_v3_v3fl(rgb_filtered, color, m_filter[8]);
|
||||
mul_v3_v3fl(rgb_filtered, color, filter_[8]);
|
||||
add_v3_v3(res1, rgb_filtered);
|
||||
add_v3_v3(res2, rgb_filtered);
|
||||
}
|
||||
@@ -159,10 +159,10 @@ void ConvolutionEdgeFilterOperation::update_memory_buffer_partial(MemoryBuffer *
|
||||
it.out[2] = sqrt(res1[2] * res1[2] + res2[2] * res2[2]);
|
||||
|
||||
const float factor = *it.in(FACTOR_INPUT_INDEX);
|
||||
const float m_factor = 1.0f - factor;
|
||||
it.out[0] = it.out[0] * factor + center_color[0] * m_factor;
|
||||
it.out[1] = it.out[1] * factor + center_color[1] * m_factor;
|
||||
it.out[2] = it.out[2] * factor + center_color[2] * m_factor;
|
||||
const float factor_ = 1.0f - factor;
|
||||
it.out[0] = it.out[0] * factor + center_color[0] * factor_;
|
||||
it.out[1] = it.out[1] * factor + center_color[1] * factor_;
|
||||
it.out[2] = it.out[2] * factor + center_color[2] * factor_;
|
||||
|
||||
it.out[3] = center_color[3];
|
||||
|
||||
|
||||
@@ -26,35 +26,35 @@ ConvolutionFilterOperation::ConvolutionFilterOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->set_canvas_input_index(0);
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
void ConvolutionFilterOperation::initExecution()
|
||||
{
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputValueOperation = this->getInputSocketReader(1);
|
||||
inputOperation_ = this->getInputSocketReader(0);
|
||||
inputValueOperation_ = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ConvolutionFilterOperation::set3x3Filter(
|
||||
float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9)
|
||||
{
|
||||
m_filter[0] = f1;
|
||||
m_filter[1] = f2;
|
||||
m_filter[2] = f3;
|
||||
m_filter[3] = f4;
|
||||
m_filter[4] = f5;
|
||||
m_filter[5] = f6;
|
||||
m_filter[6] = f7;
|
||||
m_filter[7] = f8;
|
||||
m_filter[8] = f9;
|
||||
m_filterHeight = 3;
|
||||
m_filterWidth = 3;
|
||||
filter_[0] = f1;
|
||||
filter_[1] = f2;
|
||||
filter_[2] = f3;
|
||||
filter_[3] = f4;
|
||||
filter_[4] = f5;
|
||||
filter_[5] = f6;
|
||||
filter_[6] = f7;
|
||||
filter_[7] = f8;
|
||||
filter_[8] = f9;
|
||||
filterHeight_ = 3;
|
||||
filterWidth_ = 3;
|
||||
}
|
||||
|
||||
void ConvolutionFilterOperation::deinitExecution()
|
||||
{
|
||||
m_inputOperation = nullptr;
|
||||
m_inputValueOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
inputValueOperation_ = nullptr;
|
||||
}
|
||||
|
||||
void ConvolutionFilterOperation::executePixel(float output[4], int x, int y, void * /*data*/)
|
||||
@@ -74,28 +74,28 @@ void ConvolutionFilterOperation::executePixel(float output[4], int x, int y, voi
|
||||
CLAMP(y2, 0, getHeight() - 1);
|
||||
CLAMP(y3, 0, getHeight() - 1);
|
||||
float value[4];
|
||||
m_inputValueOperation->read(value, x2, y2, nullptr);
|
||||
inputValueOperation_->read(value, x2, y2, nullptr);
|
||||
const float mval = 1.0f - value[0];
|
||||
|
||||
zero_v4(output);
|
||||
m_inputOperation->read(in1, x1, y1, nullptr);
|
||||
madd_v4_v4fl(output, in1, m_filter[0]);
|
||||
m_inputOperation->read(in1, x2, y1, nullptr);
|
||||
madd_v4_v4fl(output, in1, m_filter[1]);
|
||||
m_inputOperation->read(in1, x3, y1, nullptr);
|
||||
madd_v4_v4fl(output, in1, m_filter[2]);
|
||||
m_inputOperation->read(in1, x1, y2, nullptr);
|
||||
madd_v4_v4fl(output, in1, m_filter[3]);
|
||||
m_inputOperation->read(in2, x2, y2, nullptr);
|
||||
madd_v4_v4fl(output, in2, m_filter[4]);
|
||||
m_inputOperation->read(in1, x3, y2, nullptr);
|
||||
madd_v4_v4fl(output, in1, m_filter[5]);
|
||||
m_inputOperation->read(in1, x1, y3, nullptr);
|
||||
madd_v4_v4fl(output, in1, m_filter[6]);
|
||||
m_inputOperation->read(in1, x2, y3, nullptr);
|
||||
madd_v4_v4fl(output, in1, m_filter[7]);
|
||||
m_inputOperation->read(in1, x3, y3, nullptr);
|
||||
madd_v4_v4fl(output, in1, m_filter[8]);
|
||||
inputOperation_->read(in1, x1, y1, nullptr);
|
||||
madd_v4_v4fl(output, in1, filter_[0]);
|
||||
inputOperation_->read(in1, x2, y1, nullptr);
|
||||
madd_v4_v4fl(output, in1, filter_[1]);
|
||||
inputOperation_->read(in1, x3, y1, nullptr);
|
||||
madd_v4_v4fl(output, in1, filter_[2]);
|
||||
inputOperation_->read(in1, x1, y2, nullptr);
|
||||
madd_v4_v4fl(output, in1, filter_[3]);
|
||||
inputOperation_->read(in2, x2, y2, nullptr);
|
||||
madd_v4_v4fl(output, in2, filter_[4]);
|
||||
inputOperation_->read(in1, x3, y2, nullptr);
|
||||
madd_v4_v4fl(output, in1, filter_[5]);
|
||||
inputOperation_->read(in1, x1, y3, nullptr);
|
||||
madd_v4_v4fl(output, in1, filter_[6]);
|
||||
inputOperation_->read(in1, x2, y3, nullptr);
|
||||
madd_v4_v4fl(output, in1, filter_[7]);
|
||||
inputOperation_->read(in1, x3, y3, nullptr);
|
||||
madd_v4_v4fl(output, in1, filter_[8]);
|
||||
|
||||
output[0] = output[0] * value[0] + in2[0] * mval;
|
||||
output[1] = output[1] * value[0] + in2[1] * mval;
|
||||
@@ -113,8 +113,8 @@ bool ConvolutionFilterOperation::determineDependingAreaOfInterest(
|
||||
rcti *input, ReadBufferOperation *readOperation, rcti *output)
|
||||
{
|
||||
rcti newInput;
|
||||
int addx = (m_filterWidth - 1) / 2 + 1;
|
||||
int addy = (m_filterHeight - 1) / 2 + 1;
|
||||
int addx = (filterWidth_ - 1) / 2 + 1;
|
||||
int addy = (filterHeight_ - 1) / 2 + 1;
|
||||
newInput.xmax = input->xmax + addx;
|
||||
newInput.xmin = input->xmin - addx;
|
||||
newInput.ymax = input->ymax + addy;
|
||||
@@ -129,8 +129,8 @@ void ConvolutionFilterOperation::get_area_of_interest(const int input_idx,
|
||||
{
|
||||
switch (input_idx) {
|
||||
case IMAGE_INPUT_INDEX: {
|
||||
const int add_x = (m_filterWidth - 1) / 2 + 1;
|
||||
const int add_y = (m_filterHeight - 1) / 2 + 1;
|
||||
const int add_x = (filterWidth_ - 1) / 2 + 1;
|
||||
const int add_y = (filterHeight_ - 1) / 2 + 1;
|
||||
r_input_area.xmin = output_area.xmin - add_x;
|
||||
r_input_area.xmax = output_area.xmax + add_x;
|
||||
r_input_area.ymin = output_area.ymin - add_y;
|
||||
@@ -159,22 +159,22 @@ void ConvolutionFilterOperation::update_memory_buffer_partial(MemoryBuffer *outp
|
||||
|
||||
const float *center_color = it.in(IMAGE_INPUT_INDEX);
|
||||
zero_v4(it.out);
|
||||
madd_v4_v4fl(it.out, center_color + down_offset + left_offset, m_filter[0]);
|
||||
madd_v4_v4fl(it.out, center_color + down_offset, m_filter[1]);
|
||||
madd_v4_v4fl(it.out, center_color + down_offset + right_offset, m_filter[2]);
|
||||
madd_v4_v4fl(it.out, center_color + left_offset, m_filter[3]);
|
||||
madd_v4_v4fl(it.out, center_color, m_filter[4]);
|
||||
madd_v4_v4fl(it.out, center_color + right_offset, m_filter[5]);
|
||||
madd_v4_v4fl(it.out, center_color + up_offset + left_offset, m_filter[6]);
|
||||
madd_v4_v4fl(it.out, center_color + up_offset, m_filter[7]);
|
||||
madd_v4_v4fl(it.out, center_color + up_offset + right_offset, m_filter[8]);
|
||||
madd_v4_v4fl(it.out, center_color + down_offset + left_offset, filter_[0]);
|
||||
madd_v4_v4fl(it.out, center_color + down_offset, filter_[1]);
|
||||
madd_v4_v4fl(it.out, center_color + down_offset + right_offset, filter_[2]);
|
||||
madd_v4_v4fl(it.out, center_color + left_offset, filter_[3]);
|
||||
madd_v4_v4fl(it.out, center_color, filter_[4]);
|
||||
madd_v4_v4fl(it.out, center_color + right_offset, filter_[5]);
|
||||
madd_v4_v4fl(it.out, center_color + up_offset + left_offset, filter_[6]);
|
||||
madd_v4_v4fl(it.out, center_color + up_offset, filter_[7]);
|
||||
madd_v4_v4fl(it.out, center_color + up_offset + right_offset, filter_[8]);
|
||||
|
||||
const float factor = *it.in(FACTOR_INPUT_INDEX);
|
||||
const float m_factor = 1.0f - factor;
|
||||
it.out[0] = it.out[0] * factor + center_color[0] * m_factor;
|
||||
it.out[1] = it.out[1] * factor + center_color[1] * m_factor;
|
||||
it.out[2] = it.out[2] * factor + center_color[2] * m_factor;
|
||||
it.out[3] = it.out[3] * factor + center_color[3] * m_factor;
|
||||
const float factor_ = 1.0f - factor;
|
||||
it.out[0] = it.out[0] * factor + center_color[0] * factor_;
|
||||
it.out[1] = it.out[1] * factor + center_color[1] * factor_;
|
||||
it.out[2] = it.out[2] * factor + center_color[2] * factor_;
|
||||
it.out[3] = it.out[3] * factor + center_color[3] * factor_;
|
||||
|
||||
/* Make sure we don't return negative color. */
|
||||
CLAMP4_MIN(it.out, 0.0f);
|
||||
|
||||
@@ -28,13 +28,13 @@ class ConvolutionFilterOperation : public MultiThreadedOperation {
|
||||
static constexpr int FACTOR_INPUT_INDEX = 1;
|
||||
|
||||
private:
|
||||
int m_filterWidth;
|
||||
int m_filterHeight;
|
||||
int filterWidth_;
|
||||
int filterHeight_;
|
||||
|
||||
protected:
|
||||
SocketReader *m_inputOperation;
|
||||
SocketReader *m_inputValueOperation;
|
||||
float m_filter[9];
|
||||
SocketReader *inputOperation_;
|
||||
SocketReader *inputValueOperation_;
|
||||
float filter_[9];
|
||||
|
||||
public:
|
||||
ConvolutionFilterOperation();
|
||||
|
||||
@@ -24,8 +24,8 @@ CropBaseOperation::CropBaseOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color, ResizeMode::Align);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_inputOperation = nullptr;
|
||||
m_settings = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
settings_ = nullptr;
|
||||
}
|
||||
|
||||
void CropBaseOperation::updateArea()
|
||||
@@ -33,10 +33,10 @@ void CropBaseOperation::updateArea()
|
||||
SocketReader *inputReference = this->getInputSocketReader(0);
|
||||
float width = inputReference->getWidth();
|
||||
float height = inputReference->getHeight();
|
||||
NodeTwoXYs local_settings = *m_settings;
|
||||
NodeTwoXYs local_settings = *settings_;
|
||||
|
||||
if (width > 0.0f && height > 0.0f) {
|
||||
if (m_relative) {
|
||||
if (relative_) {
|
||||
local_settings.x1 = width * local_settings.fac_x1;
|
||||
local_settings.x2 = width * local_settings.fac_x2;
|
||||
local_settings.y1 = height * local_settings.fac_y1;
|
||||
@@ -55,28 +55,28 @@ void CropBaseOperation::updateArea()
|
||||
local_settings.y2 = height - 1;
|
||||
}
|
||||
|
||||
m_xmax = MAX2(local_settings.x1, local_settings.x2) + 1;
|
||||
m_xmin = MIN2(local_settings.x1, local_settings.x2);
|
||||
m_ymax = MAX2(local_settings.y1, local_settings.y2) + 1;
|
||||
m_ymin = MIN2(local_settings.y1, local_settings.y2);
|
||||
xmax_ = MAX2(local_settings.x1, local_settings.x2) + 1;
|
||||
xmin_ = MIN2(local_settings.x1, local_settings.x2);
|
||||
ymax_ = MAX2(local_settings.y1, local_settings.y2) + 1;
|
||||
ymin_ = MIN2(local_settings.y1, local_settings.y2);
|
||||
}
|
||||
else {
|
||||
m_xmax = 0;
|
||||
m_xmin = 0;
|
||||
m_ymax = 0;
|
||||
m_ymin = 0;
|
||||
xmax_ = 0;
|
||||
xmin_ = 0;
|
||||
ymax_ = 0;
|
||||
ymin_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CropBaseOperation::initExecution()
|
||||
{
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
inputOperation_ = this->getInputSocketReader(0);
|
||||
updateArea();
|
||||
}
|
||||
|
||||
void CropBaseOperation::deinitExecution()
|
||||
{
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
}
|
||||
|
||||
CropOperation::CropOperation() : CropBaseOperation()
|
||||
@@ -86,8 +86,8 @@ CropOperation::CropOperation() : CropBaseOperation()
|
||||
|
||||
void CropOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
{
|
||||
if ((x < m_xmax && x >= m_xmin) && (y < m_ymax && y >= m_ymin)) {
|
||||
m_inputOperation->readSampled(output, x, y, sampler);
|
||||
if ((x < xmax_ && x >= xmin_) && (y < ymax_ && y >= ymin_)) {
|
||||
inputOperation_->readSampled(output, x, y, sampler);
|
||||
}
|
||||
else {
|
||||
zero_v4(output);
|
||||
@@ -99,7 +99,7 @@ void CropOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
rcti crop_area;
|
||||
BLI_rcti_init(&crop_area, m_xmin, m_xmax, m_ymin, m_ymax);
|
||||
BLI_rcti_init(&crop_area, xmin_, xmax_, ymin_, ymax_);
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
if (BLI_rcti_isect_pt(&crop_area, it.x, it.y)) {
|
||||
copy_v4_v4(it.out, it.in(0));
|
||||
@@ -121,10 +121,10 @@ bool CropImageOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
newInput.xmax = input->xmax + m_xmin;
|
||||
newInput.xmin = input->xmin + m_xmin;
|
||||
newInput.ymax = input->ymax + m_ymin;
|
||||
newInput.ymin = input->ymin + m_ymin;
|
||||
newInput.xmax = input->xmax + xmin_;
|
||||
newInput.xmin = input->xmin + xmin_;
|
||||
newInput.ymax = input->ymax + ymin_;
|
||||
newInput.ymin = input->ymin + ymin_;
|
||||
|
||||
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
|
||||
}
|
||||
@@ -135,18 +135,18 @@ void CropImageOperation::get_area_of_interest(const int input_idx,
|
||||
{
|
||||
BLI_assert(input_idx == 0);
|
||||
UNUSED_VARS_NDEBUG(input_idx);
|
||||
r_input_area.xmax = output_area.xmax + m_xmin;
|
||||
r_input_area.xmin = output_area.xmin + m_xmin;
|
||||
r_input_area.ymax = output_area.ymax + m_ymin;
|
||||
r_input_area.ymin = output_area.ymin + m_ymin;
|
||||
r_input_area.xmax = output_area.xmax + xmin_;
|
||||
r_input_area.xmin = output_area.xmin + xmin_;
|
||||
r_input_area.ymax = output_area.ymax + ymin_;
|
||||
r_input_area.ymin = output_area.ymin + ymin_;
|
||||
}
|
||||
|
||||
void CropImageOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
NodeOperation::determine_canvas(preferred_area, r_area);
|
||||
updateArea();
|
||||
r_area.xmax = r_area.xmin + (m_xmax - m_xmin);
|
||||
r_area.ymax = r_area.ymin + (m_ymax - m_ymin);
|
||||
r_area.xmax = r_area.xmin + (xmax_ - xmin_);
|
||||
r_area.ymax = r_area.ymin + (ymax_ - ymin_);
|
||||
}
|
||||
|
||||
void CropImageOperation::executePixelSampled(float output[4],
|
||||
@@ -155,7 +155,7 @@ void CropImageOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
|
||||
m_inputOperation->readSampled(output, (x + m_xmin), (y + m_ymin), sampler);
|
||||
inputOperation_->readSampled(output, (x + xmin_), (y + ymin_), sampler);
|
||||
}
|
||||
else {
|
||||
zero_v4(output);
|
||||
@@ -171,7 +171,7 @@ void CropImageOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const MemoryBuffer *input = inputs[0];
|
||||
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
|
||||
if (BLI_rcti_isect_pt(&op_area, it.x, it.y)) {
|
||||
input->read_elem_checked(it.x + m_xmin, it.y + m_ymin, it.out);
|
||||
input->read_elem_checked(it.x + xmin_, it.y + ymin_, it.out);
|
||||
}
|
||||
else {
|
||||
zero_v4(it.out);
|
||||
|
||||
@@ -24,13 +24,13 @@ namespace blender::compositor {
|
||||
|
||||
class CropBaseOperation : public MultiThreadedOperation {
|
||||
protected:
|
||||
SocketReader *m_inputOperation;
|
||||
NodeTwoXYs *m_settings;
|
||||
bool m_relative;
|
||||
int m_xmax;
|
||||
int m_xmin;
|
||||
int m_ymax;
|
||||
int m_ymin;
|
||||
SocketReader *inputOperation_;
|
||||
NodeTwoXYs *settings_;
|
||||
bool relative_;
|
||||
int xmax_;
|
||||
int xmin_;
|
||||
int ymax_;
|
||||
int ymin_;
|
||||
|
||||
void updateArea();
|
||||
|
||||
@@ -40,11 +40,11 @@ class CropBaseOperation : public MultiThreadedOperation {
|
||||
void deinitExecution() override;
|
||||
void setCropSettings(NodeTwoXYs *settings)
|
||||
{
|
||||
m_settings = settings;
|
||||
settings_ = settings;
|
||||
}
|
||||
void setRelative(bool rel)
|
||||
{
|
||||
m_relative = rel;
|
||||
relative_ = rel;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void CryptomatteOperation::initExecution()
|
||||
void CryptomatteOperation::addObjectIndex(float objectIndex)
|
||||
{
|
||||
if (objectIndex != 0.0f) {
|
||||
m_objectIndex.append(objectIndex);
|
||||
objectIndex_.append(objectIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ void CryptomatteOperation::executePixel(float output[4], int x, int y, void *dat
|
||||
output[1] = ((float)(m3hash << 8) / (float)UINT32_MAX);
|
||||
output[2] = ((float)(m3hash << 16) / (float)UINT32_MAX);
|
||||
}
|
||||
for (float hash : m_objectIndex) {
|
||||
for (float hash : objectIndex_) {
|
||||
if (input[0] == hash) {
|
||||
output[3] += input[1];
|
||||
}
|
||||
@@ -89,7 +89,7 @@ void CryptomatteOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
it.out[1] = ((float)(m3hash << 8) / (float)UINT32_MAX);
|
||||
it.out[2] = ((float)(m3hash << 16) / (float)UINT32_MAX);
|
||||
}
|
||||
for (const float hash : m_objectIndex) {
|
||||
for (const float hash : objectIndex_) {
|
||||
if (input[0] == hash) {
|
||||
it.out[3] += input[1];
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace blender::compositor {
|
||||
|
||||
class CryptomatteOperation : public MultiThreadedOperation {
|
||||
private:
|
||||
Vector<float> m_objectIndex;
|
||||
Vector<float> objectIndex_;
|
||||
|
||||
public:
|
||||
Vector<SocketReader *> inputs;
|
||||
|
||||
@@ -24,37 +24,37 @@ namespace blender::compositor {
|
||||
|
||||
CurveBaseOperation::CurveBaseOperation()
|
||||
{
|
||||
m_curveMapping = nullptr;
|
||||
curveMapping_ = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
CurveBaseOperation::~CurveBaseOperation()
|
||||
{
|
||||
if (m_curveMapping) {
|
||||
BKE_curvemapping_free(m_curveMapping);
|
||||
m_curveMapping = nullptr;
|
||||
if (curveMapping_) {
|
||||
BKE_curvemapping_free(curveMapping_);
|
||||
curveMapping_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CurveBaseOperation::initExecution()
|
||||
{
|
||||
BKE_curvemapping_init(m_curveMapping);
|
||||
BKE_curvemapping_init(curveMapping_);
|
||||
}
|
||||
void CurveBaseOperation::deinitExecution()
|
||||
{
|
||||
if (m_curveMapping) {
|
||||
BKE_curvemapping_free(m_curveMapping);
|
||||
m_curveMapping = nullptr;
|
||||
if (curveMapping_) {
|
||||
BKE_curvemapping_free(curveMapping_);
|
||||
curveMapping_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CurveBaseOperation::setCurveMapping(CurveMapping *mapping)
|
||||
{
|
||||
/* duplicate the curve to avoid glitches while drawing, see bug T32374. */
|
||||
if (m_curveMapping) {
|
||||
BKE_curvemapping_free(m_curveMapping);
|
||||
if (curveMapping_) {
|
||||
BKE_curvemapping_free(curveMapping_);
|
||||
}
|
||||
m_curveMapping = BKE_curvemapping_copy(mapping);
|
||||
curveMapping_ = BKE_curvemapping_copy(mapping);
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -29,7 +29,7 @@ class CurveBaseOperation : public MultiThreadedOperation {
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
*/
|
||||
CurveMapping *m_curveMapping;
|
||||
CurveMapping *curveMapping_;
|
||||
|
||||
public:
|
||||
CurveBaseOperation();
|
||||
|
||||
@@ -160,21 +160,21 @@ DenoiseOperation::DenoiseOperation()
|
||||
this->addInputSocket(DataType::Vector);
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
m_settings = nullptr;
|
||||
settings_ = nullptr;
|
||||
}
|
||||
void DenoiseOperation::initExecution()
|
||||
{
|
||||
SingleThreadedOperation::initExecution();
|
||||
m_inputProgramColor = getInputSocketReader(0);
|
||||
m_inputProgramNormal = getInputSocketReader(1);
|
||||
m_inputProgramAlbedo = getInputSocketReader(2);
|
||||
inputProgramColor_ = getInputSocketReader(0);
|
||||
inputProgramNormal_ = getInputSocketReader(1);
|
||||
inputProgramAlbedo_ = getInputSocketReader(2);
|
||||
}
|
||||
|
||||
void DenoiseOperation::deinitExecution()
|
||||
{
|
||||
m_inputProgramColor = nullptr;
|
||||
m_inputProgramNormal = nullptr;
|
||||
m_inputProgramAlbedo = nullptr;
|
||||
inputProgramColor_ = nullptr;
|
||||
inputProgramNormal_ = nullptr;
|
||||
inputProgramAlbedo_ = nullptr;
|
||||
SingleThreadedOperation::deinitExecution();
|
||||
}
|
||||
|
||||
@@ -192,23 +192,23 @@ static bool are_guiding_passes_noise_free(NodeDenoise *settings)
|
||||
|
||||
void DenoiseOperation::hash_output_params()
|
||||
{
|
||||
if (m_settings) {
|
||||
hash_params((int)m_settings->hdr, are_guiding_passes_noise_free(m_settings));
|
||||
if (settings_) {
|
||||
hash_params((int)settings_->hdr, are_guiding_passes_noise_free(settings_));
|
||||
}
|
||||
}
|
||||
|
||||
MemoryBuffer *DenoiseOperation::createMemoryBuffer(rcti *rect2)
|
||||
{
|
||||
MemoryBuffer *tileColor = (MemoryBuffer *)m_inputProgramColor->initializeTileData(rect2);
|
||||
MemoryBuffer *tileNormal = (MemoryBuffer *)m_inputProgramNormal->initializeTileData(rect2);
|
||||
MemoryBuffer *tileAlbedo = (MemoryBuffer *)m_inputProgramAlbedo->initializeTileData(rect2);
|
||||
MemoryBuffer *tileColor = (MemoryBuffer *)inputProgramColor_->initializeTileData(rect2);
|
||||
MemoryBuffer *tileNormal = (MemoryBuffer *)inputProgramNormal_->initializeTileData(rect2);
|
||||
MemoryBuffer *tileAlbedo = (MemoryBuffer *)inputProgramAlbedo_->initializeTileData(rect2);
|
||||
rcti rect;
|
||||
rect.xmin = 0;
|
||||
rect.ymin = 0;
|
||||
rect.xmax = getWidth();
|
||||
rect.ymax = getHeight();
|
||||
MemoryBuffer *result = new MemoryBuffer(DataType::Color, rect);
|
||||
this->generateDenoise(result, tileColor, tileNormal, tileAlbedo, m_settings);
|
||||
this->generateDenoise(result, tileColor, tileNormal, tileAlbedo, settings_);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ void DenoiseOperation::update_memory_buffer(MemoryBuffer *output,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
if (!output_rendered_) {
|
||||
this->generateDenoise(output, inputs[0], inputs[1], inputs[2], m_settings);
|
||||
this->generateDenoise(output, inputs[0], inputs[1], inputs[2], settings_);
|
||||
output_rendered_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,14 +45,14 @@ class DenoiseOperation : public DenoiseBaseOperation {
|
||||
/**
|
||||
* \brief Cached reference to the input programs
|
||||
*/
|
||||
SocketReader *m_inputProgramColor;
|
||||
SocketReader *m_inputProgramAlbedo;
|
||||
SocketReader *m_inputProgramNormal;
|
||||
SocketReader *inputProgramColor_;
|
||||
SocketReader *inputProgramAlbedo_;
|
||||
SocketReader *inputProgramNormal_;
|
||||
|
||||
/**
|
||||
* \brief settings of the denoise node.
|
||||
*/
|
||||
NodeDenoise *m_settings;
|
||||
NodeDenoise *settings_;
|
||||
|
||||
public:
|
||||
DenoiseOperation();
|
||||
@@ -68,7 +68,7 @@ class DenoiseOperation : public DenoiseBaseOperation {
|
||||
|
||||
void setDenoiseSettings(NodeDenoise *settings)
|
||||
{
|
||||
m_settings = settings;
|
||||
settings_ = settings;
|
||||
}
|
||||
|
||||
void update_memory_buffer(MemoryBuffer *output,
|
||||
|
||||
@@ -28,19 +28,19 @@ DespeckleOperation::DespeckleOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->set_canvas_input_index(0);
|
||||
m_inputOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
void DespeckleOperation::initExecution()
|
||||
{
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputValueOperation = this->getInputSocketReader(1);
|
||||
inputOperation_ = this->getInputSocketReader(0);
|
||||
inputValueOperation_ = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void DespeckleOperation::deinitExecution()
|
||||
{
|
||||
m_inputOperation = nullptr;
|
||||
m_inputValueOperation = nullptr;
|
||||
inputOperation_ = nullptr;
|
||||
inputValueOperation_ = nullptr;
|
||||
}
|
||||
|
||||
BLI_INLINE int color_diff(const float a[3], const float b[3], const float threshold)
|
||||
@@ -69,10 +69,10 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
|
||||
CLAMP(y2, 0, getHeight() - 1);
|
||||
CLAMP(y3, 0, getHeight() - 1);
|
||||
float value[4];
|
||||
m_inputValueOperation->read(value, x2, y2, nullptr);
|
||||
inputValueOperation_->read(value, x2, y2, nullptr);
|
||||
// const float mval = 1.0f - value[0];
|
||||
|
||||
m_inputOperation->read(color_org, x2, y2, nullptr);
|
||||
inputOperation_->read(color_org, x2, y2, nullptr);
|
||||
|
||||
#define TOT_DIV_ONE 1.0f
|
||||
#define TOT_DIV_CNR (float)M_SQRT1_2
|
||||
@@ -82,7 +82,7 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
|
||||
#define COLOR_ADD(fac) \
|
||||
{ \
|
||||
madd_v4_v4fl(color_mid, in1, fac); \
|
||||
if (color_diff(in1, color_org, m_threshold)) { \
|
||||
if (color_diff(in1, color_org, threshold_)) { \
|
||||
w += fac; \
|
||||
madd_v4_v4fl(color_mid_ok, in1, fac); \
|
||||
} \
|
||||
@@ -91,34 +91,34 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
|
||||
zero_v4(color_mid);
|
||||
zero_v4(color_mid_ok);
|
||||
|
||||
m_inputOperation->read(in1, x1, y1, nullptr);
|
||||
inputOperation_->read(in1, x1, y1, nullptr);
|
||||
COLOR_ADD(TOT_DIV_CNR)
|
||||
m_inputOperation->read(in1, x2, y1, nullptr);
|
||||
inputOperation_->read(in1, x2, y1, nullptr);
|
||||
COLOR_ADD(TOT_DIV_ONE)
|
||||
m_inputOperation->read(in1, x3, y1, nullptr);
|
||||
inputOperation_->read(in1, x3, y1, nullptr);
|
||||
COLOR_ADD(TOT_DIV_CNR)
|
||||
m_inputOperation->read(in1, x1, y2, nullptr);
|
||||
inputOperation_->read(in1, x1, y2, nullptr);
|
||||
COLOR_ADD(TOT_DIV_ONE)
|
||||
|
||||
#if 0
|
||||
m_inputOperation->read(in2, x2, y2, nullptr);
|
||||
madd_v4_v4fl(color_mid, in2, m_filter[4]);
|
||||
inputOperation_->read(in2, x2, y2, nullptr);
|
||||
madd_v4_v4fl(color_mid, in2, filter_[4]);
|
||||
#endif
|
||||
|
||||
m_inputOperation->read(in1, x3, y2, nullptr);
|
||||
inputOperation_->read(in1, x3, y2, nullptr);
|
||||
COLOR_ADD(TOT_DIV_ONE)
|
||||
m_inputOperation->read(in1, x1, y3, nullptr);
|
||||
inputOperation_->read(in1, x1, y3, nullptr);
|
||||
COLOR_ADD(TOT_DIV_CNR)
|
||||
m_inputOperation->read(in1, x2, y3, nullptr);
|
||||
inputOperation_->read(in1, x2, y3, nullptr);
|
||||
COLOR_ADD(TOT_DIV_ONE)
|
||||
m_inputOperation->read(in1, x3, y3, nullptr);
|
||||
inputOperation_->read(in1, x3, y3, nullptr);
|
||||
COLOR_ADD(TOT_DIV_CNR)
|
||||
|
||||
mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
|
||||
// mul_v4_fl(color_mid, 1.0f / w);
|
||||
|
||||
if ((w != 0.0f) && ((w / WTOT) > (m_threshold_neighbor)) &&
|
||||
color_diff(color_mid, color_org, m_threshold)) {
|
||||
if ((w != 0.0f) && ((w / WTOT) > (threshold_neighbor_)) &&
|
||||
color_diff(color_mid, color_org, threshold_)) {
|
||||
mul_v4_fl(color_mid_ok, 1.0f / w);
|
||||
interp_v4_v4v4(output, color_org, color_mid_ok, value[0]);
|
||||
}
|
||||
@@ -137,8 +137,8 @@ bool DespeckleOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
rcti *output)
|
||||
{
|
||||
rcti newInput;
|
||||
int addx = 2; //(m_filterWidth - 1) / 2 + 1;
|
||||
int addy = 2; //(m_filterHeight - 1) / 2 + 1;
|
||||
int addx = 2; //(filterWidth_ - 1) / 2 + 1;
|
||||
int addy = 2; //(filterHeight_ - 1) / 2 + 1;
|
||||
newInput.xmax = input->xmax + addx;
|
||||
newInput.xmin = input->xmin - addx;
|
||||
newInput.ymax = input->ymax + addy;
|
||||
@@ -153,8 +153,8 @@ void DespeckleOperation::get_area_of_interest(const int input_idx,
|
||||
{
|
||||
switch (input_idx) {
|
||||
case IMAGE_INPUT_INDEX: {
|
||||
const int add_x = 2; //(m_filterWidth - 1) / 2 + 1;
|
||||
const int add_y = 2; //(m_filterHeight - 1) / 2 + 1;
|
||||
const int add_x = 2; //(filterWidth_ - 1) / 2 + 1;
|
||||
const int add_y = 2; //(filterHeight_ - 1) / 2 + 1;
|
||||
r_input_area.xmin = output_area.xmin - add_x;
|
||||
r_input_area.xmax = output_area.xmax + add_x;
|
||||
r_input_area.ymin = output_area.ymin - add_y;
|
||||
@@ -197,7 +197,7 @@ void DespeckleOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
#define COLOR_ADD(fac) \
|
||||
{ \
|
||||
madd_v4_v4fl(color_mid, in1, fac); \
|
||||
if (color_diff(in1, color_org, m_threshold)) { \
|
||||
if (color_diff(in1, color_org, threshold_)) { \
|
||||
w += fac; \
|
||||
madd_v4_v4fl(color_mid_ok, in1, fac); \
|
||||
} \
|
||||
@@ -217,7 +217,7 @@ void DespeckleOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
#if 0
|
||||
const float* in2 = image->get_elem(x2, y2);
|
||||
madd_v4_v4fl(color_mid, in2, m_filter[4]);
|
||||
madd_v4_v4fl(color_mid, in2, filter_[4]);
|
||||
#endif
|
||||
|
||||
in1 = image->get_elem(x3, y2);
|
||||
@@ -232,8 +232,8 @@ void DespeckleOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
|
||||
// mul_v4_fl(color_mid, 1.0f / w);
|
||||
|
||||
if ((w != 0.0f) && ((w / WTOT) > (m_threshold_neighbor)) &&
|
||||
color_diff(color_mid, color_org, m_threshold)) {
|
||||
if ((w != 0.0f) && ((w / WTOT) > (threshold_neighbor_)) &&
|
||||
color_diff(color_mid, color_org, threshold_)) {
|
||||
const float factor = *it.in(FACTOR_INPUT_INDEX);
|
||||
mul_v4_fl(color_mid_ok, 1.0f / w);
|
||||
interp_v4_v4v4(it.out, color_org, color_mid_ok, factor);
|
||||
|
||||
@@ -27,15 +27,15 @@ class DespeckleOperation : public MultiThreadedOperation {
|
||||
constexpr static int IMAGE_INPUT_INDEX = 0;
|
||||
constexpr static int FACTOR_INPUT_INDEX = 1;
|
||||
|
||||
float m_threshold;
|
||||
float m_threshold_neighbor;
|
||||
float threshold_;
|
||||
float threshold_neighbor_;
|
||||
|
||||
// int m_filterWidth;
|
||||
// int m_filterHeight;
|
||||
// int filterWidth_;
|
||||
// int filterHeight_;
|
||||
|
||||
protected:
|
||||
SocketReader *m_inputOperation;
|
||||
SocketReader *m_inputValueOperation;
|
||||
SocketReader *inputOperation_;
|
||||
SocketReader *inputValueOperation_;
|
||||
|
||||
public:
|
||||
DespeckleOperation();
|
||||
@@ -46,11 +46,11 @@ class DespeckleOperation : public MultiThreadedOperation {
|
||||
|
||||
void setThreshold(float threshold)
|
||||
{
|
||||
m_threshold = threshold;
|
||||
threshold_ = threshold;
|
||||
}
|
||||
void setThresholdNeighbor(float threshold)
|
||||
{
|
||||
m_threshold_neighbor = threshold;
|
||||
threshold_neighbor_ = threshold;
|
||||
}
|
||||
|
||||
void initExecution() override;
|
||||
|
||||
@@ -26,20 +26,20 @@ DifferenceMatteOperation::DifferenceMatteOperation()
|
||||
addInputSocket(DataType::Color);
|
||||
addOutputSocket(DataType::Value);
|
||||
|
||||
m_inputImage1Program = nullptr;
|
||||
m_inputImage2Program = nullptr;
|
||||
inputImage1Program_ = nullptr;
|
||||
inputImage2Program_ = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void DifferenceMatteOperation::initExecution()
|
||||
{
|
||||
m_inputImage1Program = this->getInputSocketReader(0);
|
||||
m_inputImage2Program = this->getInputSocketReader(1);
|
||||
inputImage1Program_ = this->getInputSocketReader(0);
|
||||
inputImage2Program_ = this->getInputSocketReader(1);
|
||||
}
|
||||
void DifferenceMatteOperation::deinitExecution()
|
||||
{
|
||||
m_inputImage1Program = nullptr;
|
||||
m_inputImage2Program = nullptr;
|
||||
inputImage1Program_ = nullptr;
|
||||
inputImage2Program_ = nullptr;
|
||||
}
|
||||
|
||||
void DifferenceMatteOperation::executePixelSampled(float output[4],
|
||||
@@ -50,13 +50,13 @@ void DifferenceMatteOperation::executePixelSampled(float output[4],
|
||||
float inColor1[4];
|
||||
float inColor2[4];
|
||||
|
||||
const float tolerance = m_settings->t1;
|
||||
const float falloff = m_settings->t2;
|
||||
const float tolerance = settings_->t1;
|
||||
const float falloff = settings_->t2;
|
||||
float difference;
|
||||
float alpha;
|
||||
|
||||
m_inputImage1Program->readSampled(inColor1, x, y, sampler);
|
||||
m_inputImage2Program->readSampled(inColor2, x, y, sampler);
|
||||
inputImage1Program_->readSampled(inColor1, x, y, sampler);
|
||||
inputImage2Program_->readSampled(inColor2, x, y, sampler);
|
||||
|
||||
difference = (fabsf(inColor2[0] - inColor1[0]) + fabsf(inColor2[1] - inColor1[1]) +
|
||||
fabsf(inColor2[2] - inColor1[2]));
|
||||
@@ -100,8 +100,8 @@ void DifferenceMatteOperation::update_memory_buffer_partial(MemoryBuffer *output
|
||||
/* Average together the distances. */
|
||||
difference = difference / 3.0f;
|
||||
|
||||
const float tolerance = m_settings->t1;
|
||||
const float falloff = m_settings->t2;
|
||||
const float tolerance = settings_->t1;
|
||||
const float falloff = settings_->t2;
|
||||
|
||||
/* Make 100% transparent. */
|
||||
if (difference <= tolerance) {
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class DifferenceMatteOperation : public MultiThreadedOperation {
|
||||
private:
|
||||
NodeChroma *m_settings;
|
||||
SocketReader *m_inputImage1Program;
|
||||
SocketReader *m_inputImage2Program;
|
||||
NodeChroma *settings_;
|
||||
SocketReader *inputImage1Program_;
|
||||
SocketReader *inputImage2Program_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ class DifferenceMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma)
|
||||
{
|
||||
m_settings = nodeChroma;
|
||||
settings_ = nodeChroma;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -27,58 +27,58 @@ DilateErodeThresholdOperation::DilateErodeThresholdOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->flags.complex = true;
|
||||
m_inputProgram = nullptr;
|
||||
m_inset = 0.0f;
|
||||
m__switch = 0.5f;
|
||||
m_distance = 0.0f;
|
||||
inputProgram_ = nullptr;
|
||||
inset_ = 0.0f;
|
||||
switch_ = 0.5f;
|
||||
distance_ = 0.0f;
|
||||
}
|
||||
|
||||
void DilateErodeThresholdOperation::init_data()
|
||||
{
|
||||
if (m_distance < 0.0f) {
|
||||
m_scope = -m_distance + m_inset;
|
||||
if (distance_ < 0.0f) {
|
||||
scope_ = -distance_ + inset_;
|
||||
}
|
||||
else {
|
||||
if (m_inset * 2 > m_distance) {
|
||||
m_scope = MAX2(m_inset * 2 - m_distance, m_distance);
|
||||
if (inset_ * 2 > distance_) {
|
||||
scope_ = MAX2(inset_ * 2 - distance_, distance_);
|
||||
}
|
||||
else {
|
||||
m_scope = m_distance;
|
||||
scope_ = distance_;
|
||||
}
|
||||
}
|
||||
if (m_scope < 3) {
|
||||
m_scope = 3;
|
||||
if (scope_ < 3) {
|
||||
scope_ = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void DilateErodeThresholdOperation::initExecution()
|
||||
{
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
inputProgram_ = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void *DilateErodeThresholdOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
void *buffer = m_inputProgram->initializeTileData(nullptr);
|
||||
void *buffer = inputProgram_->initializeTileData(nullptr);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
float inputValue[4];
|
||||
const float sw = m__switch;
|
||||
const float distance = m_distance;
|
||||
const float sw = switch_;
|
||||
const float distance = distance_;
|
||||
float pixelvalue;
|
||||
const float rd = m_scope * m_scope;
|
||||
const float inset = m_inset;
|
||||
const float rd = scope_ * scope_;
|
||||
const float inset = inset_;
|
||||
float mindist = rd * 2;
|
||||
|
||||
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
|
||||
float *buffer = inputBuffer->getBuffer();
|
||||
const rcti &input_rect = inputBuffer->get_rect();
|
||||
const int minx = MAX2(x - m_scope, input_rect.xmin);
|
||||
const int miny = MAX2(y - m_scope, input_rect.ymin);
|
||||
const int maxx = MIN2(x + m_scope, input_rect.xmax);
|
||||
const int maxy = MIN2(y + m_scope, input_rect.ymax);
|
||||
const int minx = MAX2(x - scope_, input_rect.xmin);
|
||||
const int miny = MAX2(y - scope_, input_rect.ymin);
|
||||
const int maxx = MIN2(x + scope_, input_rect.xmax);
|
||||
const int maxy = MIN2(y + scope_, input_rect.ymax);
|
||||
const int bufferWidth = inputBuffer->getWidth();
|
||||
int offset;
|
||||
|
||||
@@ -146,7 +146,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
|
||||
|
||||
void DilateErodeThresholdOperation::deinitExecution()
|
||||
{
|
||||
m_inputProgram = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
}
|
||||
|
||||
bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(
|
||||
@@ -154,10 +154,10 @@ bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
newInput.xmax = input->xmax + m_scope;
|
||||
newInput.xmin = input->xmin - m_scope;
|
||||
newInput.ymax = input->ymax + m_scope;
|
||||
newInput.ymin = input->ymin - m_scope;
|
||||
newInput.xmax = input->xmax + scope_;
|
||||
newInput.xmin = input->xmin - scope_;
|
||||
newInput.ymax = input->ymax + scope_;
|
||||
newInput.ymin = input->ymin - scope_;
|
||||
|
||||
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
|
||||
}
|
||||
@@ -168,10 +168,10 @@ void DilateErodeThresholdOperation::get_area_of_interest(const int input_idx,
|
||||
{
|
||||
BLI_assert(input_idx == 0);
|
||||
UNUSED_VARS_NDEBUG(input_idx);
|
||||
r_input_area.xmin = output_area.xmin - m_scope;
|
||||
r_input_area.xmax = output_area.xmax + m_scope;
|
||||
r_input_area.ymin = output_area.ymin - m_scope;
|
||||
r_input_area.ymax = output_area.ymax + m_scope;
|
||||
r_input_area.xmin = output_area.xmin - scope_;
|
||||
r_input_area.xmax = output_area.xmax + scope_;
|
||||
r_input_area.ymin = output_area.ymin - scope_;
|
||||
r_input_area.ymax = output_area.ymax + scope_;
|
||||
}
|
||||
|
||||
struct DilateErodeThresholdOperation::PixelData {
|
||||
@@ -222,21 +222,21 @@ void DilateErodeThresholdOperation::update_memory_buffer_partial(MemoryBuffer *o
|
||||
{
|
||||
const MemoryBuffer *input = inputs[0];
|
||||
const rcti &input_rect = input->get_rect();
|
||||
const float rd = m_scope * m_scope;
|
||||
const float inset = m_inset;
|
||||
const float rd = scope_ * scope_;
|
||||
const float inset = inset_;
|
||||
|
||||
PixelData p;
|
||||
p.sw = m__switch;
|
||||
p.sw = switch_;
|
||||
p.distance = rd * 2;
|
||||
p.elem_stride = input->elem_stride;
|
||||
p.row_stride = input->row_stride;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
p.x = it.x;
|
||||
p.y = it.y;
|
||||
p.xmin = MAX2(p.x - m_scope, input_rect.xmin);
|
||||
p.ymin = MAX2(p.y - m_scope, input_rect.ymin);
|
||||
p.xmax = MIN2(p.x + m_scope, input_rect.xmax);
|
||||
p.ymax = MIN2(p.y + m_scope, input_rect.ymax);
|
||||
p.xmin = MAX2(p.x - scope_, input_rect.xmin);
|
||||
p.ymin = MAX2(p.y - scope_, input_rect.ymin);
|
||||
p.xmax = MIN2(p.x + scope_, input_rect.xmax);
|
||||
p.ymax = MIN2(p.y + scope_, input_rect.ymax);
|
||||
p.elem = it.in(0);
|
||||
|
||||
float pixel_value;
|
||||
@@ -247,8 +247,8 @@ void DilateErodeThresholdOperation::update_memory_buffer_partial(MemoryBuffer *o
|
||||
pixel_value = sqrtf(get_min_distance<std::greater>(p));
|
||||
}
|
||||
|
||||
if (m_distance > 0.0f) {
|
||||
const float delta = m_distance - pixel_value;
|
||||
if (distance_ > 0.0f) {
|
||||
const float delta = distance_ - pixel_value;
|
||||
if (delta >= 0.0f) {
|
||||
*it.out = delta >= inset ? 1.0f : delta / inset;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ void DilateErodeThresholdOperation::update_memory_buffer_partial(MemoryBuffer *o
|
||||
}
|
||||
}
|
||||
else {
|
||||
const float delta = -m_distance + pixel_value;
|
||||
const float delta = -distance_ + pixel_value;
|
||||
if (delta < 0.0f) {
|
||||
*it.out = delta < -inset ? 1.0f : (-delta) / inset;
|
||||
}
|
||||
@@ -273,43 +273,43 @@ DilateDistanceOperation::DilateDistanceOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
m_inputProgram = nullptr;
|
||||
m_distance = 0.0f;
|
||||
inputProgram_ = nullptr;
|
||||
distance_ = 0.0f;
|
||||
flags.complex = true;
|
||||
flags.open_cl = true;
|
||||
}
|
||||
|
||||
void DilateDistanceOperation::init_data()
|
||||
{
|
||||
m_scope = m_distance;
|
||||
if (m_scope < 3) {
|
||||
m_scope = 3;
|
||||
scope_ = distance_;
|
||||
if (scope_ < 3) {
|
||||
scope_ = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void DilateDistanceOperation::initExecution()
|
||||
{
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
inputProgram_ = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void *DilateDistanceOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
void *buffer = m_inputProgram->initializeTileData(nullptr);
|
||||
void *buffer = inputProgram_->initializeTileData(nullptr);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
const float distance = m_distance;
|
||||
const float distance = distance_;
|
||||
const float mindist = distance * distance;
|
||||
|
||||
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
|
||||
float *buffer = inputBuffer->getBuffer();
|
||||
const rcti &input_rect = inputBuffer->get_rect();
|
||||
const int minx = MAX2(x - m_scope, input_rect.xmin);
|
||||
const int miny = MAX2(y - m_scope, input_rect.ymin);
|
||||
const int maxx = MIN2(x + m_scope, input_rect.xmax);
|
||||
const int maxy = MIN2(y + m_scope, input_rect.ymax);
|
||||
const int minx = MAX2(x - scope_, input_rect.xmin);
|
||||
const int miny = MAX2(y - scope_, input_rect.ymin);
|
||||
const int maxx = MIN2(x + scope_, input_rect.xmax);
|
||||
const int maxy = MIN2(y + scope_, input_rect.ymax);
|
||||
const int bufferWidth = inputBuffer->getWidth();
|
||||
int offset;
|
||||
|
||||
@@ -332,7 +332,7 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *
|
||||
|
||||
void DilateDistanceOperation::deinitExecution()
|
||||
{
|
||||
m_inputProgram = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
}
|
||||
|
||||
bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -341,10 +341,10 @@ bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
newInput.xmax = input->xmax + m_scope;
|
||||
newInput.xmin = input->xmin - m_scope;
|
||||
newInput.ymax = input->ymax + m_scope;
|
||||
newInput.ymin = input->ymin - m_scope;
|
||||
newInput.xmax = input->xmax + scope_;
|
||||
newInput.xmin = input->xmin - scope_;
|
||||
newInput.ymax = input->ymax + scope_;
|
||||
newInput.ymin = input->ymin - scope_;
|
||||
|
||||
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
|
||||
}
|
||||
@@ -358,11 +358,11 @@ void DilateDistanceOperation::executeOpenCL(OpenCLDevice *device,
|
||||
{
|
||||
cl_kernel dilateKernel = device->COM_clCreateKernel("dilateKernel", nullptr);
|
||||
|
||||
cl_int distanceSquared = m_distance * m_distance;
|
||||
cl_int scope = m_scope;
|
||||
cl_int distanceSquared = distance_ * distance_;
|
||||
cl_int scope = scope_;
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, inputProgram_);
|
||||
device->COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer);
|
||||
device->COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer);
|
||||
clSetKernelArg(dilateKernel, 4, sizeof(cl_int), &scope);
|
||||
@@ -377,10 +377,10 @@ void DilateDistanceOperation::get_area_of_interest(const int input_idx,
|
||||
{
|
||||
BLI_assert(input_idx == 0);
|
||||
UNUSED_VARS_NDEBUG(input_idx);
|
||||
r_input_area.xmin = output_area.xmin - m_scope;
|
||||
r_input_area.xmax = output_area.xmax + m_scope;
|
||||
r_input_area.ymin = output_area.ymin - m_scope;
|
||||
r_input_area.ymax = output_area.ymax + m_scope;
|
||||
r_input_area.xmin = output_area.xmin - scope_;
|
||||
r_input_area.xmax = output_area.xmax + scope_;
|
||||
r_input_area.ymin = output_area.ymin - scope_;
|
||||
r_input_area.ymax = output_area.ymax + scope_;
|
||||
}
|
||||
|
||||
struct DilateDistanceOperation::PixelData {
|
||||
@@ -450,7 +450,7 @@ void DilateDistanceOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
PixelData p(inputs[0], m_distance, m_scope);
|
||||
PixelData p(inputs[0], distance_, scope_);
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
p.update(it);
|
||||
*it.out = get_distance_value<std::greater>(p, 0.0f);
|
||||
@@ -465,16 +465,16 @@ ErodeDistanceOperation::ErodeDistanceOperation() : DilateDistanceOperation()
|
||||
|
||||
void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
const float distance = m_distance;
|
||||
const float distance = distance_;
|
||||
const float mindist = distance * distance;
|
||||
|
||||
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
|
||||
float *buffer = inputBuffer->getBuffer();
|
||||
const rcti &input_rect = inputBuffer->get_rect();
|
||||
const int minx = MAX2(x - m_scope, input_rect.xmin);
|
||||
const int miny = MAX2(y - m_scope, input_rect.ymin);
|
||||
const int maxx = MIN2(x + m_scope, input_rect.xmax);
|
||||
const int maxy = MIN2(y + m_scope, input_rect.ymax);
|
||||
const int minx = MAX2(x - scope_, input_rect.xmin);
|
||||
const int miny = MAX2(y - scope_, input_rect.ymin);
|
||||
const int maxx = MIN2(x + scope_, input_rect.xmax);
|
||||
const int maxy = MIN2(y + scope_, input_rect.ymax);
|
||||
const int bufferWidth = inputBuffer->getWidth();
|
||||
int offset;
|
||||
|
||||
@@ -504,11 +504,11 @@ void ErodeDistanceOperation::executeOpenCL(OpenCLDevice *device,
|
||||
{
|
||||
cl_kernel erodeKernel = device->COM_clCreateKernel("erodeKernel", nullptr);
|
||||
|
||||
cl_int distanceSquared = m_distance * m_distance;
|
||||
cl_int scope = m_scope;
|
||||
cl_int distanceSquared = distance_ * distance_;
|
||||
cl_int scope = scope_;
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, inputProgram_);
|
||||
device->COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer);
|
||||
device->COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer);
|
||||
clSetKernelArg(erodeKernel, 4, sizeof(cl_int), &scope);
|
||||
@@ -521,7 +521,7 @@ void ErodeDistanceOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
PixelData p(inputs[0], m_distance, m_scope);
|
||||
PixelData p(inputs[0], distance_, scope_);
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
p.update(it);
|
||||
*it.out = get_distance_value<std::less>(p, 1.0f);
|
||||
@@ -534,11 +534,11 @@ DilateStepOperation::DilateStepOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->flags.complex = true;
|
||||
m_inputProgram = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
}
|
||||
void DilateStepOperation::initExecution()
|
||||
{
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
inputProgram_ = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
/* Small helper to pass data from initializeTileData to executePixel. */
|
||||
@@ -563,13 +563,13 @@ static tile_info *create_cache(int xmin, int xmax, int ymin, int ymax)
|
||||
|
||||
void *DilateStepOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_inputProgram->initializeTileData(nullptr);
|
||||
MemoryBuffer *tile = (MemoryBuffer *)inputProgram_->initializeTileData(nullptr);
|
||||
int x, y, i;
|
||||
int width = tile->getWidth();
|
||||
int height = tile->getHeight();
|
||||
float *buffer = tile->getBuffer();
|
||||
|
||||
int half_window = m_iterations;
|
||||
int half_window = iterations_;
|
||||
int window = half_window * 2 + 1;
|
||||
|
||||
int xmin = MAX2(0, rect->xmin - half_window);
|
||||
@@ -661,7 +661,7 @@ void DilateStepOperation::executePixel(float output[4], int x, int y, void *data
|
||||
|
||||
void DilateStepOperation::deinitExecution()
|
||||
{
|
||||
m_inputProgram = nullptr;
|
||||
inputProgram_ = nullptr;
|
||||
}
|
||||
|
||||
void DilateStepOperation::deinitializeTileData(rcti * /*rect*/, void *data)
|
||||
@@ -676,7 +676,7 @@ bool DilateStepOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
rcti *output)
|
||||
{
|
||||
rcti newInput;
|
||||
int it = m_iterations;
|
||||
int it = iterations_;
|
||||
newInput.xmax = input->xmax + it;
|
||||
newInput.xmin = input->xmin - it;
|
||||
newInput.ymax = input->ymax + it;
|
||||
@@ -691,10 +691,10 @@ void DilateStepOperation::get_area_of_interest(const int input_idx,
|
||||
{
|
||||
BLI_assert(input_idx == 0);
|
||||
UNUSED_VARS_NDEBUG(input_idx);
|
||||
r_input_area.xmin = output_area.xmin - m_iterations;
|
||||
r_input_area.xmax = output_area.xmax + m_iterations;
|
||||
r_input_area.ymin = output_area.ymin - m_iterations;
|
||||
r_input_area.ymax = output_area.ymax + m_iterations;
|
||||
r_input_area.xmin = output_area.xmin - iterations_;
|
||||
r_input_area.xmax = output_area.xmax + iterations_;
|
||||
r_input_area.ymin = output_area.ymin - iterations_;
|
||||
r_input_area.ymax = output_area.ymax + iterations_;
|
||||
}
|
||||
|
||||
template<typename TCompareSelector>
|
||||
@@ -803,7 +803,7 @@ void DilateStepOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
step_update_memory_buffer<Max2Selector>(output, inputs[0], area, m_iterations, -FLT_MAX);
|
||||
step_update_memory_buffer<Max2Selector>(output, inputs[0], area, iterations_, -FLT_MAX);
|
||||
}
|
||||
|
||||
/* Erode step */
|
||||
@@ -814,13 +814,13 @@ ErodeStepOperation::ErodeStepOperation() : DilateStepOperation()
|
||||
|
||||
void *ErodeStepOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_inputProgram->initializeTileData(nullptr);
|
||||
MemoryBuffer *tile = (MemoryBuffer *)inputProgram_->initializeTileData(nullptr);
|
||||
int x, y, i;
|
||||
int width = tile->getWidth();
|
||||
int height = tile->getHeight();
|
||||
float *buffer = tile->getBuffer();
|
||||
|
||||
int half_window = m_iterations;
|
||||
int half_window = iterations_;
|
||||
int window = half_window * 2 + 1;
|
||||
|
||||
int xmin = MAX2(0, rect->xmin - half_window);
|
||||
@@ -913,7 +913,7 @@ void ErodeStepOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
step_update_memory_buffer<Min2Selector>(output, inputs[0], area, m_iterations, FLT_MAX);
|
||||
step_update_memory_buffer<Min2Selector>(output, inputs[0], area, iterations_, FLT_MAX);
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user