Cleanup: remove this-> for m_ prefixed members in Compositor
For cleaning old code style as new code usually omit it.
This commit is contained in:
@@ -22,14 +22,14 @@ namespace blender::compositor {
|
||||
|
||||
CompositorContext::CompositorContext()
|
||||
{
|
||||
this->m_scene = nullptr;
|
||||
this->m_rd = nullptr;
|
||||
this->m_quality = eCompositorQuality::High;
|
||||
this->m_hasActiveOpenCLDevices = false;
|
||||
this->m_fastCalculation = false;
|
||||
this->m_viewSettings = nullptr;
|
||||
this->m_displaySettings = nullptr;
|
||||
this->m_bnodetree = nullptr;
|
||||
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;
|
||||
}
|
||||
|
||||
int CompositorContext::getFramenumber() const
|
||||
|
||||
@@ -99,7 +99,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setRendering(bool rendering)
|
||||
{
|
||||
this->m_rendering = rendering;
|
||||
m_rendering = rendering;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ class CompositorContext {
|
||||
*/
|
||||
bool isRendering() const
|
||||
{
|
||||
return this->m_rendering;
|
||||
return m_rendering;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setRenderData(RenderData *rd)
|
||||
{
|
||||
this->m_rd = rd;
|
||||
m_rd = rd;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setbNodeTree(bNodeTree *bnodetree)
|
||||
{
|
||||
this->m_bnodetree = bnodetree;
|
||||
m_bnodetree = bnodetree;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ class CompositorContext {
|
||||
*/
|
||||
const bNodeTree *getbNodeTree() const
|
||||
{
|
||||
return this->m_bnodetree;
|
||||
return m_bnodetree;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ class CompositorContext {
|
||||
*/
|
||||
const RenderData *getRenderData() const
|
||||
{
|
||||
return this->m_rd;
|
||||
return m_rd;
|
||||
}
|
||||
|
||||
void setScene(Scene *scene)
|
||||
@@ -156,7 +156,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setPreviewHash(bNodeInstanceHash *previews)
|
||||
{
|
||||
this->m_previews = previews;
|
||||
m_previews = previews;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ class CompositorContext {
|
||||
*/
|
||||
bNodeInstanceHash *getPreviewHash() const
|
||||
{
|
||||
return this->m_previews;
|
||||
return m_previews;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +172,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setViewSettings(const ColorManagedViewSettings *viewSettings)
|
||||
{
|
||||
this->m_viewSettings = viewSettings;
|
||||
m_viewSettings = viewSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +180,7 @@ class CompositorContext {
|
||||
*/
|
||||
const ColorManagedViewSettings *getViewSettings() const
|
||||
{
|
||||
return this->m_viewSettings;
|
||||
return m_viewSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings)
|
||||
{
|
||||
this->m_displaySettings = displaySettings;
|
||||
m_displaySettings = displaySettings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +196,7 @@ class CompositorContext {
|
||||
*/
|
||||
const ColorManagedDisplaySettings *getDisplaySettings() const
|
||||
{
|
||||
return this->m_displaySettings;
|
||||
return m_displaySettings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setQuality(eCompositorQuality quality)
|
||||
{
|
||||
this->m_quality = quality;
|
||||
m_quality = quality;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +212,7 @@ class CompositorContext {
|
||||
*/
|
||||
eCompositorQuality getQuality() const
|
||||
{
|
||||
return this->m_quality;
|
||||
return m_quality;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +225,7 @@ class CompositorContext {
|
||||
*/
|
||||
bool getHasActiveOpenCLDevices() const
|
||||
{
|
||||
return this->m_hasActiveOpenCLDevices;
|
||||
return m_hasActiveOpenCLDevices;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +233,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices)
|
||||
{
|
||||
this->m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices;
|
||||
m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices;
|
||||
}
|
||||
|
||||
/** Whether it has a view with a specific name and not the default one. */
|
||||
@@ -247,7 +247,7 @@ class CompositorContext {
|
||||
*/
|
||||
const char *getViewName() const
|
||||
{
|
||||
return this->m_viewName;
|
||||
return m_viewName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,7 +255,7 @@ class CompositorContext {
|
||||
*/
|
||||
void setViewName(const char *viewName)
|
||||
{
|
||||
this->m_viewName = viewName;
|
||||
m_viewName = viewName;
|
||||
}
|
||||
|
||||
int getChunksize() const
|
||||
@@ -265,11 +265,11 @@ class CompositorContext {
|
||||
|
||||
void setFastCalculation(bool fastCalculation)
|
||||
{
|
||||
this->m_fastCalculation = fastCalculation;
|
||||
m_fastCalculation = fastCalculation;
|
||||
}
|
||||
bool isFastCalculation() const
|
||||
{
|
||||
return this->m_fastCalculation;
|
||||
return m_fastCalculation;
|
||||
}
|
||||
bool isGroupnodeBufferEnabled() const
|
||||
{
|
||||
|
||||
@@ -56,16 +56,16 @@ std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags)
|
||||
ExecutionGroup::ExecutionGroup(int id)
|
||||
{
|
||||
m_id = id;
|
||||
this->m_bTree = nullptr;
|
||||
this->m_height = 0;
|
||||
this->m_width = 0;
|
||||
this->m_max_read_buffer_offset = 0;
|
||||
this->m_x_chunks_len = 0;
|
||||
this->m_y_chunks_len = 0;
|
||||
this->m_chunks_len = 0;
|
||||
this->m_chunks_finished = 0;
|
||||
BLI_rcti_init(&this->m_viewerBorder, 0, 0, 0, 0);
|
||||
this->m_executionStartTime = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ExecutionGroup &execution_group)
|
||||
@@ -139,8 +139,8 @@ NodeOperation *ExecutionGroup::getOutputOperation() const
|
||||
void ExecutionGroup::init_work_packages()
|
||||
{
|
||||
m_work_packages.clear();
|
||||
if (this->m_chunks_len != 0) {
|
||||
m_work_packages.resize(this->m_chunks_len);
|
||||
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;
|
||||
@@ -157,12 +157,12 @@ void ExecutionGroup::init_read_buffer_operations()
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
if (operation->get_flags().is_read_buffer_operation) {
|
||||
ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation);
|
||||
this->m_read_operations.append(readOperation);
|
||||
m_read_operations.append(readOperation);
|
||||
max_offset = MAX2(max_offset, readOperation->getOffset());
|
||||
}
|
||||
}
|
||||
max_offset++;
|
||||
this->m_max_read_buffer_offset = max_offset;
|
||||
m_max_read_buffer_offset = max_offset;
|
||||
}
|
||||
|
||||
void ExecutionGroup::initExecution()
|
||||
@@ -175,11 +175,11 @@ void ExecutionGroup::initExecution()
|
||||
void ExecutionGroup::deinitExecution()
|
||||
{
|
||||
m_work_packages.clear();
|
||||
this->m_chunks_len = 0;
|
||||
this->m_x_chunks_len = 0;
|
||||
this->m_y_chunks_len = 0;
|
||||
this->m_read_operations.clear();
|
||||
this->m_bTree = nullptr;
|
||||
m_chunks_len = 0;
|
||||
m_x_chunks_len = 0;
|
||||
m_y_chunks_len = 0;
|
||||
m_read_operations.clear();
|
||||
m_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(&this->m_viewerBorder, 0, this->m_width, 0, this->m_height);
|
||||
BLI_rcti_init(&m_viewerBorder, 0, m_width, 0, m_height);
|
||||
}
|
||||
|
||||
void ExecutionGroup::init_number_of_chunks()
|
||||
{
|
||||
if (this->m_flags.single_threaded) {
|
||||
this->m_x_chunks_len = 1;
|
||||
this->m_y_chunks_len = 1;
|
||||
this->m_chunks_len = 1;
|
||||
if (m_flags.single_threaded) {
|
||||
m_x_chunks_len = 1;
|
||||
m_y_chunks_len = 1;
|
||||
m_chunks_len = 1;
|
||||
}
|
||||
else {
|
||||
const float chunkSizef = this->m_chunkSize;
|
||||
const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
|
||||
this->m_x_chunks_len = ceil(border_width / chunkSizef);
|
||||
this->m_y_chunks_len = ceil(border_height / chunkSizef);
|
||||
this->m_chunks_len = this->m_x_chunks_len * this->m_y_chunks_len;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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 < this->m_chunks_len; chunk_index++) {
|
||||
for (int chunk_index = 0; chunk_index < m_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(&this->m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
|
||||
const int border_width = BLI_rcti_size_x(&m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&m_viewerBorder);
|
||||
int index;
|
||||
switch (order_type) {
|
||||
case ChunkOrdering::Random: {
|
||||
@@ -242,16 +242,16 @@ 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 < this->m_chunks_len; index++) {
|
||||
for (index = 0; index < m_chunks_len; index++) {
|
||||
const WorkPackage &work_package = m_work_packages[index];
|
||||
chunk_orders[index].index = index;
|
||||
chunk_orders[index].x = work_package.rect.xmin - this->m_viewerBorder.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - this->m_viewerBorder.ymin;
|
||||
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].update_distance(&hotspot, 1);
|
||||
}
|
||||
|
||||
std::sort(&chunk_orders[0], &chunk_orders[this->m_chunks_len - 1]);
|
||||
for (index = 0; index < this->m_chunks_len; index++) {
|
||||
std::sort(&chunk_orders[0], &chunk_orders[m_chunks_len - 1]);
|
||||
for (index = 0; index < m_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 = this->m_chunks_len / COM_RULE_OF_THIRDS_DIVIDER;
|
||||
float addition = m_chunks_len / COM_RULE_OF_THIRDS_DIVIDER;
|
||||
|
||||
ChunkOrderHotspot hotspots[9]{
|
||||
ChunkOrderHotspot(mx, my, addition * 0),
|
||||
@@ -279,17 +279,17 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
};
|
||||
|
||||
blender::Array<ChunkOrder> chunk_orders(m_chunks_len);
|
||||
for (index = 0; index < this->m_chunks_len; index++) {
|
||||
for (index = 0; index < m_chunks_len; index++) {
|
||||
const WorkPackage &work_package = m_work_packages[index];
|
||||
chunk_orders[index].index = index;
|
||||
chunk_orders[index].x = work_package.rect.xmin - this->m_viewerBorder.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - this->m_viewerBorder.ymin;
|
||||
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].update_distance(hotspots, 9);
|
||||
}
|
||||
|
||||
std::sort(&chunk_orders[0], &chunk_orders[this->m_chunks_len]);
|
||||
std::sort(&chunk_orders[0], &chunk_orders[m_chunks_len]);
|
||||
|
||||
for (index = 0; index < this->m_chunks_len; index++) {
|
||||
for (index = 0; index < m_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 (this->m_width == 0 || this->m_height == 0) {
|
||||
if (m_width == 0 || m_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 (this->m_chunks_len == 0) {
|
||||
if (m_chunks_len == 0) {
|
||||
return;
|
||||
} /** \note Early break out. */
|
||||
unsigned int chunk_index;
|
||||
|
||||
this->m_executionStartTime = PIL_check_seconds_timer();
|
||||
m_executionStartTime = PIL_check_seconds_timer();
|
||||
|
||||
this->m_chunks_finished = 0;
|
||||
this->m_bTree = bTree;
|
||||
m_chunks_finished = 0;
|
||||
m_bTree = bTree;
|
||||
|
||||
blender::Array<unsigned int> chunk_order = get_execution_order();
|
||||
|
||||
@@ -341,12 +341,11 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
|
||||
finished = true;
|
||||
int numberEvaluated = 0;
|
||||
|
||||
for (int index = startIndex;
|
||||
index < this->m_chunks_len && numberEvaluated < maxNumberEvaluated;
|
||||
for (int index = startIndex; index < m_chunks_len && numberEvaluated < maxNumberEvaluated;
|
||||
index++) {
|
||||
chunk_index = chunk_order[index];
|
||||
int yChunk = chunk_index / this->m_x_chunks_len;
|
||||
int xChunk = chunk_index - (yChunk * this->m_x_chunks_len);
|
||||
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];
|
||||
switch (work_package.state) {
|
||||
case eWorkPackageState::NotScheduled: {
|
||||
@@ -389,7 +388,7 @@ MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber)
|
||||
WorkPackage &work_package = m_work_packages[chunkNumber];
|
||||
|
||||
MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN(
|
||||
sizeof(MemoryBuffer *) * this->m_max_read_buffer_offset, __func__);
|
||||
sizeof(MemoryBuffer *) * m_max_read_buffer_offset, __func__);
|
||||
rcti output;
|
||||
for (ReadBufferOperation *readOperation : m_read_operations) {
|
||||
MemoryProxy *memoryProxy = readOperation->getMemoryProxy();
|
||||
@@ -417,9 +416,9 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo
|
||||
work_package.state = eWorkPackageState::Executed;
|
||||
}
|
||||
|
||||
atomic_add_and_fetch_u(&this->m_chunks_finished, 1);
|
||||
atomic_add_and_fetch_u(&m_chunks_finished, 1);
|
||||
if (memoryBuffers) {
|
||||
for (unsigned int index = 0; index < this->m_max_read_buffer_offset; index++) {
|
||||
for (unsigned int index = 0; index < m_max_read_buffer_offset; index++) {
|
||||
MemoryBuffer *buffer = memoryBuffers[index];
|
||||
if (buffer) {
|
||||
if (buffer->isTemporarily()) {
|
||||
@@ -430,19 +429,16 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo
|
||||
}
|
||||
MEM_freeN(memoryBuffers);
|
||||
}
|
||||
if (this->m_bTree) {
|
||||
if (m_bTree) {
|
||||
/* Status report is only performed for top level Execution Groups. */
|
||||
float progress = this->m_chunks_finished;
|
||||
progress /= this->m_chunks_len;
|
||||
this->m_bTree->progress(this->m_bTree->prh, progress);
|
||||
float progress = m_chunks_finished;
|
||||
progress /= m_chunks_len;
|
||||
m_bTree->progress(m_bTree->prh, progress);
|
||||
|
||||
char buf[128];
|
||||
BLI_snprintf(buf,
|
||||
sizeof(buf),
|
||||
TIP_("Compositing | Tile %u-%u"),
|
||||
this->m_chunks_finished,
|
||||
this->m_chunks_len);
|
||||
this->m_bTree->stats_draw(this->m_bTree->sdh, buf);
|
||||
BLI_snprintf(
|
||||
buf, sizeof(buf), TIP_("Compositing | Tile %u-%u"), m_chunks_finished, m_chunks_len);
|
||||
m_bTree->stats_draw(m_bTree->sdh, buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,30 +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(&this->m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
|
||||
const int border_width = BLI_rcti_size_x(&m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&m_viewerBorder);
|
||||
|
||||
if (this->m_flags.single_threaded) {
|
||||
BLI_rcti_init(
|
||||
r_rect, this->m_viewerBorder.xmin, border_width, this->m_viewerBorder.ymin, border_height);
|
||||
if (m_flags.single_threaded) {
|
||||
BLI_rcti_init(r_rect, m_viewerBorder.xmin, border_width, m_viewerBorder.ymin, border_height);
|
||||
}
|
||||
else {
|
||||
const unsigned int minx = xChunk * this->m_chunkSize + this->m_viewerBorder.xmin;
|
||||
const unsigned int miny = yChunk * this->m_chunkSize + this->m_viewerBorder.ymin;
|
||||
const unsigned int width = MIN2((unsigned int)this->m_viewerBorder.xmax, this->m_width);
|
||||
const unsigned int height = MIN2((unsigned int)this->m_viewerBorder.ymax, this->m_height);
|
||||
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);
|
||||
BLI_rcti_init(r_rect,
|
||||
MIN2(minx, this->m_width),
|
||||
MIN2(minx + this->m_chunkSize, width),
|
||||
MIN2(miny, this->m_height),
|
||||
MIN2(miny + this->m_chunkSize, height));
|
||||
MIN2(minx, m_width),
|
||||
MIN2(minx + m_chunkSize, width),
|
||||
MIN2(miny, m_height),
|
||||
MIN2(miny + m_chunkSize, height));
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionGroup::determineChunkRect(rcti *r_rect, const unsigned int chunkNumber) const
|
||||
{
|
||||
const unsigned int yChunk = chunkNumber / this->m_x_chunks_len;
|
||||
const unsigned int xChunk = chunkNumber - (yChunk * this->m_x_chunks_len);
|
||||
const unsigned int yChunk = chunkNumber / m_x_chunks_len;
|
||||
const unsigned int xChunk = chunkNumber - (yChunk * m_x_chunks_len);
|
||||
determineChunkRect(r_rect, xChunk, yChunk);
|
||||
}
|
||||
|
||||
@@ -492,7 +487,7 @@ MemoryBuffer *ExecutionGroup::allocateOutputBuffer(rcti &rect)
|
||||
|
||||
bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area)
|
||||
{
|
||||
if (this->m_flags.single_threaded) {
|
||||
if (m_flags.single_threaded) {
|
||||
return scheduleChunkWhenPossible(graph, 0, 0);
|
||||
}
|
||||
/* Find all chunks inside the rect
|
||||
@@ -540,15 +535,15 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph,
|
||||
const int chunk_x,
|
||||
const int chunk_y)
|
||||
{
|
||||
if (chunk_x < 0 || chunk_x >= (int)this->m_x_chunks_len) {
|
||||
if (chunk_x < 0 || chunk_x >= (int)m_x_chunks_len) {
|
||||
return true;
|
||||
}
|
||||
if (chunk_y < 0 || chunk_y >= (int)this->m_y_chunks_len) {
|
||||
if (chunk_y < 0 || chunk_y >= (int)m_y_chunks_len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check if chunk is already executed or scheduled and not yet executed. */
|
||||
const int chunk_index = chunk_y * this->m_x_chunks_len + chunk_x;
|
||||
const int chunk_index = chunk_y * m_x_chunks_len + chunk_x;
|
||||
WorkPackage &work_package = m_work_packages[chunk_index];
|
||||
if (work_package.state == eWorkPackageState::Executed) {
|
||||
return true;
|
||||
@@ -589,11 +584,8 @@ 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(&this->m_viewerBorder,
|
||||
xmin * this->m_width,
|
||||
xmax * this->m_width,
|
||||
ymin * this->m_height,
|
||||
ymax * this->m_height);
|
||||
BLI_rcti_init(
|
||||
&m_viewerBorder, xmin * m_width, xmax * m_width, ymin * m_height, ymax * m_height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,11 +593,8 @@ 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(&this->m_viewerBorder,
|
||||
xmin * this->m_width,
|
||||
xmax * this->m_width,
|
||||
ymin * this->m_height,
|
||||
ymax * this->m_height);
|
||||
BLI_rcti_init(
|
||||
&m_viewerBorder, xmin * m_width, xmax * m_width, ymin * m_height, ymax * m_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ class ExecutionGroup {
|
||||
*/
|
||||
void setOutputExecutionGroup(bool is_output)
|
||||
{
|
||||
this->m_flags.is_output = is_output;
|
||||
m_flags.is_output = is_output;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,8 +281,8 @@ class ExecutionGroup {
|
||||
*/
|
||||
void setResolution(unsigned int resolution[2])
|
||||
{
|
||||
this->m_width = resolution[0];
|
||||
this->m_height = resolution[1];
|
||||
m_width = resolution[0];
|
||||
m_height = resolution[1];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,7 +381,7 @@ class ExecutionGroup {
|
||||
|
||||
void setChunksize(int chunksize)
|
||||
{
|
||||
this->m_chunkSize = chunksize;
|
||||
m_chunkSize = chunksize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,25 +43,25 @@ ExecutionSystem::ExecutionSystem(RenderData *rd,
|
||||
const char *viewName)
|
||||
{
|
||||
num_work_threads_ = WorkScheduler::get_num_cpu_threads();
|
||||
this->m_context.setViewName(viewName);
|
||||
this->m_context.setScene(scene);
|
||||
this->m_context.setbNodeTree(editingtree);
|
||||
this->m_context.setPreviewHash(editingtree->previews);
|
||||
this->m_context.setFastCalculation(fastcalculation);
|
||||
m_context.setViewName(viewName);
|
||||
m_context.setScene(scene);
|
||||
m_context.setbNodeTree(editingtree);
|
||||
m_context.setPreviewHash(editingtree->previews);
|
||||
m_context.setFastCalculation(fastcalculation);
|
||||
/* initialize the CompositorContext */
|
||||
if (rendering) {
|
||||
this->m_context.setQuality((eCompositorQuality)editingtree->render_quality);
|
||||
m_context.setQuality((eCompositorQuality)editingtree->render_quality);
|
||||
}
|
||||
else {
|
||||
this->m_context.setQuality((eCompositorQuality)editingtree->edit_quality);
|
||||
m_context.setQuality((eCompositorQuality)editingtree->edit_quality);
|
||||
}
|
||||
this->m_context.setRendering(rendering);
|
||||
this->m_context.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() &&
|
||||
(editingtree->flag & NTREE_COM_OPENCL));
|
||||
m_context.setRendering(rendering);
|
||||
m_context.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() &&
|
||||
(editingtree->flag & NTREE_COM_OPENCL));
|
||||
|
||||
this->m_context.setRenderData(rd);
|
||||
this->m_context.setViewSettings(viewSettings);
|
||||
this->m_context.setDisplaySettings(displaySettings);
|
||||
m_context.setRenderData(rd);
|
||||
m_context.setViewSettings(viewSettings);
|
||||
m_context.setDisplaySettings(displaySettings);
|
||||
|
||||
BLI_mutex_init(&work_mutex_);
|
||||
BLI_condition_init(&work_finished_cond_);
|
||||
@@ -94,12 +94,12 @@ ExecutionSystem::~ExecutionSystem()
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
delete operation;
|
||||
}
|
||||
this->m_operations.clear();
|
||||
m_operations.clear();
|
||||
|
||||
for (ExecutionGroup *group : m_groups) {
|
||||
delete group;
|
||||
}
|
||||
this->m_groups.clear();
|
||||
m_groups.clear();
|
||||
}
|
||||
|
||||
void ExecutionSystem::set_operations(const Vector<NodeOperation *> &operations,
|
||||
|
||||
@@ -200,7 +200,7 @@ class ExecutionSystem {
|
||||
*/
|
||||
const CompositorContext &getContext() const
|
||||
{
|
||||
return this->m_context;
|
||||
return m_context;
|
||||
}
|
||||
|
||||
SharedOperationBuffers &get_active_buffers()
|
||||
|
||||
@@ -47,14 +47,14 @@ static rcti create_rect(const int width, const int height)
|
||||
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state)
|
||||
{
|
||||
m_rect = rect;
|
||||
this->m_is_a_single_elem = false;
|
||||
this->m_memoryProxy = memoryProxy;
|
||||
this->m_num_channels = COM_data_type_num_channels(memoryProxy->getDataType());
|
||||
this->m_buffer = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer");
|
||||
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");
|
||||
owns_data_ = true;
|
||||
this->m_state = state;
|
||||
this->m_datatype = memoryProxy->getDataType();
|
||||
m_state = state;
|
||||
m_datatype = memoryProxy->getDataType();
|
||||
|
||||
set_strides();
|
||||
}
|
||||
@@ -62,14 +62,14 @@ MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBuf
|
||||
MemoryBuffer::MemoryBuffer(DataType dataType, const rcti &rect, bool is_a_single_elem)
|
||||
{
|
||||
m_rect = rect;
|
||||
this->m_is_a_single_elem = is_a_single_elem;
|
||||
this->m_memoryProxy = nullptr;
|
||||
this->m_num_channels = COM_data_type_num_channels(dataType);
|
||||
this->m_buffer = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer");
|
||||
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");
|
||||
owns_data_ = true;
|
||||
this->m_state = MemoryBufferState::Temporary;
|
||||
this->m_datatype = dataType;
|
||||
m_state = MemoryBufferState::Temporary;
|
||||
m_datatype = dataType;
|
||||
|
||||
set_strides();
|
||||
}
|
||||
@@ -153,20 +153,20 @@ BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, c
|
||||
MemoryBuffer *MemoryBuffer::inflate() const
|
||||
{
|
||||
BLI_assert(is_a_single_elem());
|
||||
MemoryBuffer *inflated = new MemoryBuffer(this->m_datatype, this->m_rect, false);
|
||||
inflated->copy_from(this, this->m_rect);
|
||||
MemoryBuffer *inflated = new MemoryBuffer(m_datatype, m_rect, false);
|
||||
inflated->copy_from(this, m_rect);
|
||||
return inflated;
|
||||
}
|
||||
|
||||
float MemoryBuffer::get_max_value() const
|
||||
{
|
||||
float result = this->m_buffer[0];
|
||||
float result = m_buffer[0];
|
||||
const unsigned int size = this->buffer_len();
|
||||
unsigned int i;
|
||||
|
||||
const float *fp_src = this->m_buffer;
|
||||
const float *fp_src = m_buffer;
|
||||
|
||||
for (i = 0; i < size; i++, fp_src += this->m_num_channels) {
|
||||
for (i = 0; i < size; i++, fp_src += m_num_channels) {
|
||||
float value = *fp_src;
|
||||
if (value > result) {
|
||||
result = value;
|
||||
@@ -181,10 +181,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, &this->m_rect, &rect_clamp);
|
||||
BLI_rcti_isect(&rect, &m_rect, &rect_clamp);
|
||||
|
||||
if (!BLI_rcti_is_empty(&rect_clamp)) {
|
||||
MemoryBuffer temp_buffer(this->m_datatype, rect_clamp);
|
||||
MemoryBuffer temp_buffer(m_datatype, rect_clamp);
|
||||
temp_buffer.fill_from(*this);
|
||||
return temp_buffer.get_max_value();
|
||||
}
|
||||
@@ -195,9 +195,9 @@ float MemoryBuffer::get_max_value(const rcti &rect) const
|
||||
|
||||
MemoryBuffer::~MemoryBuffer()
|
||||
{
|
||||
if (this->m_buffer && owns_data_) {
|
||||
MEM_freeN(this->m_buffer);
|
||||
this->m_buffer = nullptr;
|
||||
if (m_buffer && owns_data_) {
|
||||
MEM_freeN(m_buffer);
|
||||
m_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,30 +398,28 @@ void MemoryBuffer::fill(const rcti &area,
|
||||
void MemoryBuffer::fill_from(const MemoryBuffer &src)
|
||||
{
|
||||
rcti overlap;
|
||||
overlap.xmin = MAX2(this->m_rect.xmin, src.m_rect.xmin);
|
||||
overlap.xmax = MIN2(this->m_rect.xmax, src.m_rect.xmax);
|
||||
overlap.ymin = MAX2(this->m_rect.ymin, src.m_rect.ymin);
|
||||
overlap.ymax = MIN2(this->m_rect.ymax, src.m_rect.ymax);
|
||||
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);
|
||||
copy_from(&src, overlap);
|
||||
}
|
||||
|
||||
void MemoryBuffer::writePixel(int x, int y, const float color[4])
|
||||
{
|
||||
if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin &&
|
||||
y < this->m_rect.ymax) {
|
||||
if (x >= m_rect.xmin && x < m_rect.xmax && y >= m_rect.ymin && y < m_rect.ymax) {
|
||||
const int offset = get_coords_offset(x, y);
|
||||
memcpy(&this->m_buffer[offset], color, sizeof(float) * this->m_num_channels);
|
||||
memcpy(&m_buffer[offset], color, sizeof(float) * m_num_channels);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryBuffer::addPixel(int x, int y, const float color[4])
|
||||
{
|
||||
if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin &&
|
||||
y < this->m_rect.ymax) {
|
||||
if (x >= m_rect.xmin && x < m_rect.xmax && y >= m_rect.ymin && y < m_rect.ymax) {
|
||||
const int offset = get_coords_offset(x, y);
|
||||
float *dst = &this->m_buffer[offset];
|
||||
float *dst = &m_buffer[offset];
|
||||
const float *src = color;
|
||||
for (int i = 0; i < this->m_num_channels; i++, dst++, src++) {
|
||||
for (int i = 0; i < m_num_channels; i++, dst++, src++) {
|
||||
*dst += *src;
|
||||
}
|
||||
}
|
||||
@@ -436,7 +434,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(this->m_datatype == DataType::Color);
|
||||
BLI_assert(m_datatype == DataType::Color);
|
||||
|
||||
const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}};
|
||||
|
||||
@@ -472,10 +470,10 @@ static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4]
|
||||
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) * this->m_num_channels);
|
||||
memcpy(result, m_buffer, sizeof(float) * m_num_channels);
|
||||
}
|
||||
else {
|
||||
BLI_assert(this->m_datatype == DataType::Color);
|
||||
BLI_assert(m_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
|
||||
|
||||
@@ -330,12 +330,12 @@ class MemoryBuffer {
|
||||
|
||||
uint8_t get_num_channels() const
|
||||
{
|
||||
return this->m_num_channels;
|
||||
return m_num_channels;
|
||||
}
|
||||
|
||||
uint8_t get_elem_bytes_len() const
|
||||
{
|
||||
return this->m_num_channels * sizeof(float);
|
||||
return m_num_channels * sizeof(float);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,13 +370,13 @@ class MemoryBuffer {
|
||||
*/
|
||||
float *getBuffer()
|
||||
{
|
||||
return this->m_buffer;
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
float *release_ownership_buffer()
|
||||
{
|
||||
owns_data_ = false;
|
||||
return this->m_buffer;
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
MemoryBuffer *inflate() const;
|
||||
@@ -494,15 +494,15 @@ class MemoryBuffer {
|
||||
bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < m_rect.ymin || y >= m_rect.ymax));
|
||||
if (clip_x || clip_y) {
|
||||
/* clip result outside rect is zero */
|
||||
memset(result, 0, this->m_num_channels * sizeof(float));
|
||||
memset(result, 0, m_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 = &this->m_buffer[offset];
|
||||
memcpy(result, buffer, sizeof(float) * this->m_num_channels);
|
||||
float *buffer = &m_buffer[offset];
|
||||
memcpy(result, buffer, sizeof(float) * m_num_channels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,11 +520,11 @@ class MemoryBuffer {
|
||||
const int offset = get_coords_offset(u, v);
|
||||
|
||||
BLI_assert(offset >= 0);
|
||||
BLI_assert(offset < this->buffer_len() * this->m_num_channels);
|
||||
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 = &this->m_buffer[offset];
|
||||
memcpy(result, buffer, sizeof(float) * this->m_num_channels);
|
||||
float *buffer = &m_buffer[offset];
|
||||
memcpy(result, buffer, sizeof(float) * m_num_channels);
|
||||
}
|
||||
|
||||
void writePixel(int x, int y, const float color[4]);
|
||||
@@ -540,18 +540,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, this->m_num_channels, 0.0f);
|
||||
copy_vn_fl(result, m_num_channels, 0.0f);
|
||||
return;
|
||||
}
|
||||
if (m_is_a_single_elem) {
|
||||
memcpy(result, m_buffer, sizeof(float) * this->m_num_channels);
|
||||
memcpy(result, m_buffer, sizeof(float) * m_num_channels);
|
||||
}
|
||||
else {
|
||||
BLI_bilinear_interpolation_wrap_fl(this->m_buffer,
|
||||
BLI_bilinear_interpolation_wrap_fl(m_buffer,
|
||||
result,
|
||||
getWidth(),
|
||||
getHeight(),
|
||||
this->m_num_channels,
|
||||
m_num_channels,
|
||||
u,
|
||||
v,
|
||||
extend_x == MemoryBufferExtend::Repeat,
|
||||
@@ -566,7 +566,7 @@ class MemoryBuffer {
|
||||
*/
|
||||
inline bool isTemporarily() const
|
||||
{
|
||||
return this->m_state == MemoryBufferState::Temporary;
|
||||
return m_state == MemoryBufferState::Temporary;
|
||||
}
|
||||
|
||||
void copy_from(const MemoryBuffer *src, const rcti &area);
|
||||
@@ -632,7 +632,7 @@ class MemoryBuffer {
|
||||
*/
|
||||
const rcti &get_rect() const
|
||||
{
|
||||
return this->m_rect;
|
||||
return m_rect;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -668,7 +668,7 @@ class MemoryBuffer {
|
||||
|
||||
void clear_elem(float *out) const
|
||||
{
|
||||
memset(out, 0, this->m_num_channels * sizeof(float));
|
||||
memset(out, 0, m_num_channels * sizeof(float));
|
||||
}
|
||||
|
||||
template<typename T> T get_relative_x(T x) const
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace blender::compositor {
|
||||
|
||||
MemoryProxy::MemoryProxy(DataType datatype)
|
||||
{
|
||||
this->m_writeBufferOperation = nullptr;
|
||||
this->m_executor = nullptr;
|
||||
this->m_datatype = datatype;
|
||||
m_writeBufferOperation = nullptr;
|
||||
m_executor = nullptr;
|
||||
m_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;
|
||||
|
||||
this->m_buffer = new MemoryBuffer(this, result, MemoryBufferState::Default);
|
||||
m_buffer = new MemoryBuffer(this, result, MemoryBufferState::Default);
|
||||
}
|
||||
|
||||
void MemoryProxy::free()
|
||||
{
|
||||
if (this->m_buffer) {
|
||||
delete this->m_buffer;
|
||||
this->m_buffer = nullptr;
|
||||
if (m_buffer) {
|
||||
delete m_buffer;
|
||||
m_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class MemoryProxy {
|
||||
*/
|
||||
void setExecutor(ExecutionGroup *executor)
|
||||
{
|
||||
this->m_executor = executor;
|
||||
m_executor = executor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ class MemoryProxy {
|
||||
*/
|
||||
ExecutionGroup *getExecutor() const
|
||||
{
|
||||
return this->m_executor;
|
||||
return m_executor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ class MemoryProxy {
|
||||
*/
|
||||
void setWriteBufferOperation(WriteBufferOperation *operation)
|
||||
{
|
||||
this->m_writeBufferOperation = operation;
|
||||
m_writeBufferOperation = operation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ class MemoryProxy {
|
||||
*/
|
||||
WriteBufferOperation *getWriteBufferOperation() const
|
||||
{
|
||||
return this->m_writeBufferOperation;
|
||||
return m_writeBufferOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,12 +112,12 @@ class MemoryProxy {
|
||||
*/
|
||||
inline MemoryBuffer *getBuffer()
|
||||
{
|
||||
return this->m_buffer;
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
inline DataType getDataType()
|
||||
{
|
||||
return this->m_datatype;
|
||||
return m_datatype;
|
||||
}
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
|
||||
@@ -97,7 +97,7 @@ class Node {
|
||||
*/
|
||||
void setbNode(bNode *node)
|
||||
{
|
||||
this->m_editorNode = node;
|
||||
m_editorNode = node;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ class Node {
|
||||
*/
|
||||
void setbNodeTree(bNodeTree *nodetree)
|
||||
{
|
||||
this->m_editorNodeTree = nodetree;
|
||||
m_editorNodeTree = nodetree;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +145,7 @@ class Node {
|
||||
*/
|
||||
void setIsInActiveGroup(bool value)
|
||||
{
|
||||
this->m_inActiveGroup = value;
|
||||
m_inActiveGroup = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ class Node {
|
||||
*/
|
||||
inline bool isInActiveGroup() const
|
||||
{
|
||||
return this->m_inActiveGroup;
|
||||
return m_inActiveGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,7 +222,7 @@ class NodeInput {
|
||||
|
||||
Node *getNode() const
|
||||
{
|
||||
return this->m_node;
|
||||
return m_node;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
@@ -230,7 +230,7 @@ class NodeInput {
|
||||
}
|
||||
bNodeSocket *getbNodeSocket() const
|
||||
{
|
||||
return this->m_editorSocket;
|
||||
return m_editorSocket;
|
||||
}
|
||||
|
||||
void setLink(NodeOutput *link);
|
||||
@@ -264,7 +264,7 @@ class NodeOutput {
|
||||
|
||||
Node *getNode() const
|
||||
{
|
||||
return this->m_node;
|
||||
return m_node;
|
||||
}
|
||||
DataType getDataType() const
|
||||
{
|
||||
@@ -272,7 +272,7 @@ class NodeOutput {
|
||||
}
|
||||
bNodeSocket *getbNodeSocket() const
|
||||
{
|
||||
return this->m_editorSocket;
|
||||
return m_editorSocket;
|
||||
}
|
||||
|
||||
float getEditorValueFloat();
|
||||
|
||||
@@ -34,7 +34,7 @@ NodeOperation::NodeOperation()
|
||||
{
|
||||
canvas_input_index_ = 0;
|
||||
canvas_ = COM_AREA_NONE;
|
||||
this->m_btree = nullptr;
|
||||
m_btree = nullptr;
|
||||
}
|
||||
|
||||
/** Get constant value when operation is constant, otherwise return default_value. */
|
||||
@@ -179,22 +179,22 @@ void NodeOperation::initExecution()
|
||||
|
||||
void NodeOperation::initMutex()
|
||||
{
|
||||
BLI_mutex_init(&this->m_mutex);
|
||||
BLI_mutex_init(&m_mutex);
|
||||
}
|
||||
|
||||
void NodeOperation::lockMutex()
|
||||
{
|
||||
BLI_mutex_lock(&this->m_mutex);
|
||||
BLI_mutex_lock(&m_mutex);
|
||||
}
|
||||
|
||||
void NodeOperation::unlockMutex()
|
||||
{
|
||||
BLI_mutex_unlock(&this->m_mutex);
|
||||
BLI_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
||||
void NodeOperation::deinitMutex()
|
||||
{
|
||||
BLI_mutex_end(&this->m_mutex);
|
||||
BLI_mutex_end(&m_mutex);
|
||||
}
|
||||
|
||||
void NodeOperation::deinitExecution()
|
||||
|
||||
@@ -125,11 +125,11 @@ class NodeOperationInput {
|
||||
|
||||
void setResizeMode(ResizeMode resizeMode)
|
||||
{
|
||||
this->m_resizeMode = resizeMode;
|
||||
m_resizeMode = resizeMode;
|
||||
}
|
||||
ResizeMode getResizeMode() const
|
||||
{
|
||||
return this->m_resizeMode;
|
||||
return m_resizeMode;
|
||||
}
|
||||
|
||||
SocketReader *getReader();
|
||||
@@ -442,7 +442,7 @@ class NodeOperation {
|
||||
|
||||
void setbNodeTree(const bNodeTree *tree)
|
||||
{
|
||||
this->m_btree = tree;
|
||||
m_btree = tree;
|
||||
}
|
||||
|
||||
void set_execution_system(ExecutionSystem *system)
|
||||
@@ -561,13 +561,13 @@ class NodeOperation {
|
||||
|
||||
inline bool isBraked() const
|
||||
{
|
||||
return this->m_btree->test_break(this->m_btree->tbh);
|
||||
return m_btree->test_break(m_btree->tbh);
|
||||
}
|
||||
|
||||
inline void updateDraw()
|
||||
{
|
||||
if (this->m_btree->update_draw) {
|
||||
this->m_btree->update_draw(this->m_btree->udh);
|
||||
if (m_btree->update_draw) {
|
||||
m_btree->update_draw(m_btree->udh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -753,7 +753,7 @@ static void add_group_operations_recursive(Tags &visited, NodeOperation *op, Exe
|
||||
|
||||
ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op)
|
||||
{
|
||||
ExecutionGroup *group = new ExecutionGroup(this->m_groups.size());
|
||||
ExecutionGroup *group = new ExecutionGroup(m_groups.size());
|
||||
m_groups.append(group);
|
||||
|
||||
Tags visited;
|
||||
|
||||
@@ -42,14 +42,14 @@ OpenCLDevice::OpenCLDevice(cl_context context,
|
||||
cl_program program,
|
||||
cl_int vendorId)
|
||||
{
|
||||
this->m_device = device;
|
||||
this->m_context = context;
|
||||
this->m_program = program;
|
||||
this->m_queue = nullptr;
|
||||
this->m_vendorID = vendorId;
|
||||
m_device = device;
|
||||
m_context = context;
|
||||
m_program = program;
|
||||
m_queue = nullptr;
|
||||
m_vendorID = vendorId;
|
||||
|
||||
cl_int error;
|
||||
this->m_queue = clCreateCommandQueue(this->m_context, this->m_device, 0, &error);
|
||||
m_queue = clCreateCommandQueue(m_context, m_device, 0, &error);
|
||||
}
|
||||
|
||||
OpenCLDevice::OpenCLDevice(OpenCLDevice &&other) noexcept
|
||||
@@ -64,8 +64,8 @@ OpenCLDevice::OpenCLDevice(OpenCLDevice &&other) noexcept
|
||||
|
||||
OpenCLDevice::~OpenCLDevice()
|
||||
{
|
||||
if (this->m_queue) {
|
||||
clReleaseCommandQueue(this->m_queue);
|
||||
if (m_queue) {
|
||||
clReleaseCommandQueue(m_queue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
|
||||
const cl_image_format *imageFormat = determineImageFormat(result);
|
||||
|
||||
cl_mem clBuffer = clCreateImage2D(this->m_context,
|
||||
cl_mem clBuffer = clCreateImage2D(m_context,
|
||||
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||
imageFormat,
|
||||
result->getWidth(),
|
||||
@@ -206,8 +206,7 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemo
|
||||
(size_t)outputMemoryBuffer->getHeight(),
|
||||
};
|
||||
|
||||
error = clEnqueueNDRangeKernel(
|
||||
this->m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
error = clEnqueueNDRangeKernel(m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
@@ -227,7 +226,7 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel,
|
||||
size_t size[2];
|
||||
cl_int2 offset;
|
||||
|
||||
if (this->m_vendorID == NVIDIA) {
|
||||
if (m_vendorID == NVIDIA) {
|
||||
localSize = 32;
|
||||
}
|
||||
|
||||
@@ -255,11 +254,11 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel,
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
error = clEnqueueNDRangeKernel(
|
||||
this->m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
clFlush(this->m_queue);
|
||||
clFlush(m_queue);
|
||||
if (operation->isBraked()) {
|
||||
breaked = false;
|
||||
}
|
||||
@@ -271,7 +270,7 @@ cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname,
|
||||
std::list<cl_kernel> *clKernelsToCleanUp)
|
||||
{
|
||||
cl_int error;
|
||||
cl_kernel kernel = clCreateKernel(this->m_program, kernelname, &error);
|
||||
cl_kernel kernel = clCreateKernel(m_program, kernelname, &error);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
|
||||
@@ -93,12 +93,12 @@ class OpenCLDevice : public Device {
|
||||
|
||||
cl_context getContext()
|
||||
{
|
||||
return this->m_context;
|
||||
return m_context;
|
||||
}
|
||||
|
||||
cl_command_queue getQueue()
|
||||
{
|
||||
return this->m_queue;
|
||||
return m_queue;
|
||||
}
|
||||
|
||||
cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace blender::compositor {
|
||||
|
||||
SingleThreadedOperation::SingleThreadedOperation()
|
||||
{
|
||||
this->m_cachedInstance = nullptr;
|
||||
m_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*/)
|
||||
{
|
||||
this->m_cachedInstance->readNoCheck(output, x, y);
|
||||
m_cachedInstance->readNoCheck(output, x, y);
|
||||
}
|
||||
|
||||
void SingleThreadedOperation::deinitExecution()
|
||||
{
|
||||
deinitMutex();
|
||||
if (this->m_cachedInstance) {
|
||||
delete this->m_cachedInstance;
|
||||
this->m_cachedInstance = nullptr;
|
||||
if (m_cachedInstance) {
|
||||
delete m_cachedInstance;
|
||||
m_cachedInstance = nullptr;
|
||||
}
|
||||
}
|
||||
void *SingleThreadedOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
if (this->m_cachedInstance) {
|
||||
return this->m_cachedInstance;
|
||||
if (m_cachedInstance) {
|
||||
return m_cachedInstance;
|
||||
}
|
||||
|
||||
lockMutex();
|
||||
if (this->m_cachedInstance == nullptr) {
|
||||
if (m_cachedInstance == nullptr) {
|
||||
//
|
||||
this->m_cachedInstance = createMemoryBuffer(rect);
|
||||
m_cachedInstance = createMemoryBuffer(rect);
|
||||
}
|
||||
unlockMutex();
|
||||
return this->m_cachedInstance;
|
||||
return m_cachedInstance;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -29,7 +29,7 @@ class SingleThreadedOperation : public NodeOperation {
|
||||
protected:
|
||||
inline bool isCached()
|
||||
{
|
||||
return this->m_cachedInstance != nullptr;
|
||||
return m_cachedInstance != nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -34,9 +34,9 @@ void AlphaOverKeyOperation::executePixelSampled(float output[4],
|
||||
float inputOverColor[4];
|
||||
float value[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_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()
|
||||
{
|
||||
this->m_x = 0.0f;
|
||||
m_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];
|
||||
|
||||
this->m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_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 - this->m_x + inputOverColor[3] * this->m_x;
|
||||
float addfac = 1.0f - m_x + inputOverColor[3] * m_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 - this->m_x + over_color[3] * this->m_x;
|
||||
const float addfac = 1.0f - m_x + over_color[3] * m_x;
|
||||
const float premul = value * addfac;
|
||||
const float mul = 1.0f - value * over_color[3];
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class AlphaOverMixedOperation : public MixBaseOperation {
|
||||
|
||||
void setX(float x)
|
||||
{
|
||||
this->m_x = x;
|
||||
m_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];
|
||||
|
||||
this->m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_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);
|
||||
this->m_valueReader = nullptr;
|
||||
m_valueReader = nullptr;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
|
||||
void AntiAliasOperation::initExecution()
|
||||
{
|
||||
this->m_valueReader = this->getInputSocketReader(0);
|
||||
m_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()
|
||||
{
|
||||
this->m_valueReader = nullptr;
|
||||
m_valueReader = nullptr;
|
||||
}
|
||||
|
||||
bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
|
||||
@@ -27,14 +27,14 @@ BilateralBlurOperation::BilateralBlurOperation()
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
|
||||
this->m_inputColorProgram = nullptr;
|
||||
this->m_inputDeterminatorProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
m_inputDeterminatorProgram = nullptr;
|
||||
}
|
||||
|
||||
void BilateralBlurOperation::initExecution()
|
||||
{
|
||||
this->m_inputColorProgram = getInputSocketReader(0);
|
||||
this->m_inputDeterminatorProgram = getInputSocketReader(1);
|
||||
m_inputColorProgram = getInputSocketReader(0);
|
||||
m_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 = this->m_space;
|
||||
float sigmacolor = this->m_data->sigma_color;
|
||||
float space = m_space;
|
||||
float sigmacolor = m_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;
|
||||
this->m_inputDeterminatorProgram->read(determinatorReferenceColor, x, y, data);
|
||||
m_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. */
|
||||
this->m_inputDeterminatorProgram->read(determinator, xi, yi, data);
|
||||
m_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. */
|
||||
this->m_inputColorProgram->read(tempColor, xi, yi, data);
|
||||
m_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()
|
||||
{
|
||||
this->m_inputColorProgram = nullptr;
|
||||
this->m_inputDeterminatorProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
m_inputDeterminatorProgram = nullptr;
|
||||
}
|
||||
|
||||
bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -101,7 +101,7 @@ bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
rcti *output)
|
||||
{
|
||||
rcti newInput;
|
||||
int add = ceil(this->m_space) + 1;
|
||||
int add = ceil(m_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(this->m_space) + 1;
|
||||
const int add = ceil(m_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 = this->m_data->sigma_color;
|
||||
p.sigma_color = m_data->sigma_color;
|
||||
p.input_color = inputs[0];
|
||||
p.input_determinator = inputs[1];
|
||||
const float space = this->m_space;
|
||||
const float space = m_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. */
|
||||
|
||||
@@ -54,8 +54,8 @@ class BilateralBlurOperation : public MultiThreadedOperation, public QualityStep
|
||||
|
||||
void setData(NodeBilateralBlurData *data)
|
||||
{
|
||||
this->m_data = data;
|
||||
this->m_space = data->sigma_space + data->iter;
|
||||
m_data = data;
|
||||
m_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;
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
memset(&m_data, 0, sizeof(NodeBlurData));
|
||||
this->m_size = 1.0f;
|
||||
this->m_sizeavailable = false;
|
||||
this->m_extend_bounds = false;
|
||||
m_size = 1.0f;
|
||||
m_sizeavailable = false;
|
||||
m_extend_bounds = false;
|
||||
use_variable_size_ = false;
|
||||
}
|
||||
|
||||
@@ -44,32 +44,32 @@ void BlurBaseOperation::init_data()
|
||||
updateSize();
|
||||
}
|
||||
|
||||
this->m_data.image_in_width = this->getWidth();
|
||||
this->m_data.image_in_height = this->getHeight();
|
||||
if (this->m_data.relative) {
|
||||
m_data.image_in_width = this->getWidth();
|
||||
m_data.image_in_height = this->getHeight();
|
||||
if (m_data.relative) {
|
||||
int sizex, sizey;
|
||||
switch (this->m_data.aspect) {
|
||||
switch (m_data.aspect) {
|
||||
case CMP_NODE_BLUR_ASPECT_Y:
|
||||
sizex = sizey = this->m_data.image_in_width;
|
||||
sizex = sizey = m_data.image_in_width;
|
||||
break;
|
||||
case CMP_NODE_BLUR_ASPECT_X:
|
||||
sizex = sizey = this->m_data.image_in_height;
|
||||
sizex = sizey = m_data.image_in_height;
|
||||
break;
|
||||
default:
|
||||
BLI_assert(this->m_data.aspect == CMP_NODE_BLUR_ASPECT_NONE);
|
||||
sizex = this->m_data.image_in_width;
|
||||
sizey = this->m_data.image_in_height;
|
||||
BLI_assert(m_data.aspect == CMP_NODE_BLUR_ASPECT_NONE);
|
||||
sizex = m_data.image_in_width;
|
||||
sizey = m_data.image_in_height;
|
||||
break;
|
||||
}
|
||||
this->m_data.sizex = round_fl_to_int(this->m_data.percentx * 0.01f * sizex);
|
||||
this->m_data.sizey = round_fl_to_int(this->m_data.percenty * 0.01f * sizey);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void BlurBaseOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
this->m_inputSize = this->getInputSocketReader(1);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
m_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(this->m_data.filtertype, (float)i * fac);
|
||||
val = RE_filter_value(m_data.filtertype, (float)i * fac);
|
||||
sum += val;
|
||||
gausstab[i + size] = val;
|
||||
}
|
||||
@@ -165,8 +165,8 @@ float *BlurBaseOperation::make_dist_fac_inverse(float rad, int size, int falloff
|
||||
|
||||
void BlurBaseOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputSize = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputSize = nullptr;
|
||||
}
|
||||
|
||||
void BlurBaseOperation::setData(const NodeBlurData *data)
|
||||
@@ -187,7 +187,7 @@ int BlurBaseOperation::get_blur_size(eDimension dim) const
|
||||
|
||||
void BlurBaseOperation::updateSize()
|
||||
{
|
||||
if (this->m_sizeavailable || use_variable_size_) {
|
||||
if (m_sizeavailable || use_variable_size_) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ void BlurBaseOperation::updateSize()
|
||||
case eExecutionModel::Tiled: {
|
||||
float result[4];
|
||||
this->getInputSocketReader(1)->readSampled(result, 0, 0, PixelSampler::Nearest);
|
||||
this->m_size = result[0];
|
||||
m_size = result[0];
|
||||
break;
|
||||
}
|
||||
case eExecutionModel::FullFrame: {
|
||||
@@ -206,7 +206,7 @@ void BlurBaseOperation::updateSize()
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->m_sizeavailable = true;
|
||||
m_sizeavailable = true;
|
||||
}
|
||||
|
||||
void BlurBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
|
||||
@@ -74,13 +74,13 @@ class BlurBaseOperation : public MultiThreadedOperation, public QualityStepHelpe
|
||||
|
||||
void setSize(float size)
|
||||
{
|
||||
this->m_size = size;
|
||||
this->m_sizeavailable = true;
|
||||
m_size = size;
|
||||
m_sizeavailable = true;
|
||||
}
|
||||
|
||||
void setExtendBounds(bool extend_bounds)
|
||||
{
|
||||
this->m_extend_bounds = extend_bounds;
|
||||
m_extend_bounds = extend_bounds;
|
||||
}
|
||||
|
||||
int get_blur_size(eDimension dim) const;
|
||||
|
||||
@@ -39,13 +39,13 @@ BokehBlurOperation::BokehBlurOperation()
|
||||
flags.complex = true;
|
||||
flags.open_cl = true;
|
||||
|
||||
this->m_size = 1.0f;
|
||||
this->m_sizeavailable = false;
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputBokehProgram = nullptr;
|
||||
this->m_inputBoundingBoxReader = nullptr;
|
||||
m_size = 1.0f;
|
||||
m_sizeavailable = false;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputBokehProgram = nullptr;
|
||||
m_inputBoundingBoxReader = nullptr;
|
||||
|
||||
this->m_extend_bounds = false;
|
||||
m_extend_bounds = false;
|
||||
}
|
||||
|
||||
void BokehBlurOperation::init_data()
|
||||
@@ -68,7 +68,7 @@ void BokehBlurOperation::init_data()
|
||||
void *BokehBlurOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_sizeavailable) {
|
||||
if (!m_sizeavailable) {
|
||||
updateSize();
|
||||
}
|
||||
void *buffer = getInputOperation(0)->initializeTileData(nullptr);
|
||||
@@ -80,9 +80,9 @@ void BokehBlurOperation::initExecution()
|
||||
{
|
||||
initMutex();
|
||||
|
||||
this->m_inputProgram = getInputSocketReader(0);
|
||||
this->m_inputBokehProgram = getInputSocketReader(1);
|
||||
this->m_inputBoundingBoxReader = getInputSocketReader(2);
|
||||
m_inputProgram = getInputSocketReader(0);
|
||||
m_inputBokehProgram = getInputSocketReader(1);
|
||||
m_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];
|
||||
|
||||
this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, PixelSampler::Nearest);
|
||||
m_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 = this->m_size * max_dim / 100.0f;
|
||||
int pixelSize = m_size * max_dim / 100.0f;
|
||||
zero_v4(color_accum);
|
||||
|
||||
if (pixelSize < 2) {
|
||||
this->m_inputProgram->readSampled(color_accum, x, y, PixelSampler::Nearest);
|
||||
m_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 = this->m_bokehDimension / pixelSize;
|
||||
float m = 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 = this->m_bokehMidX - (nx - x) * m;
|
||||
float v = this->m_bokehMidY - (ny - y) * m;
|
||||
this->m_inputBokehProgram->readSampled(bokeh, u, v, PixelSampler::Nearest);
|
||||
float u = m_bokehMidX - (nx - x) * m;
|
||||
float v = m_bokehMidY - (ny - y) * m;
|
||||
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 {
|
||||
this->m_inputProgram->readSampled(output, x, y, PixelSampler::Nearest);
|
||||
m_inputProgram->readSampled(output, x, y, PixelSampler::Nearest);
|
||||
}
|
||||
}
|
||||
|
||||
void BokehBlurOperation::deinitExecution()
|
||||
{
|
||||
deinitMutex();
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputBokehProgram = nullptr;
|
||||
this->m_inputBoundingBoxReader = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputBokehProgram = nullptr;
|
||||
m_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 (this->m_sizeavailable) {
|
||||
newInput.xmax = input->xmax + (this->m_size * max_dim / 100.0f);
|
||||
newInput.xmin = input->xmin - (this->m_size * max_dim / 100.0f);
|
||||
newInput.ymax = input->ymax + (this->m_size * max_dim / 100.0f);
|
||||
newInput.ymin = input->ymin - (this->m_size * max_dim / 100.0f);
|
||||
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);
|
||||
}
|
||||
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 (!this->m_sizeavailable) {
|
||||
if (!m_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 (!this->m_sizeavailable) {
|
||||
if (!m_sizeavailable) {
|
||||
updateSize();
|
||||
}
|
||||
const float max_dim = MAX2(this->getWidth(), this->getHeight());
|
||||
cl_int radius = this->m_size * max_dim / 100.0f;
|
||||
cl_int radius = m_size * max_dim / 100.0f;
|
||||
cl_int step = this->getStep();
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBoundingBoxReader);
|
||||
kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, m_inputBoundingBoxReader);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
|
||||
kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
|
||||
kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, m_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 (this->m_sizeavailable) {
|
||||
if (m_sizeavailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -247,8 +247,8 @@ void BokehBlurOperation::updateSize()
|
||||
case eExecutionModel::Tiled: {
|
||||
float result[4];
|
||||
this->getInputSocketReader(3)->readSampled(result, 0, 0, PixelSampler::Nearest);
|
||||
this->m_size = result[0];
|
||||
CLAMP(this->m_size, 0.0f, 10.0f);
|
||||
m_size = result[0];
|
||||
CLAMP(m_size, 0.0f, 10.0f);
|
||||
break;
|
||||
}
|
||||
case eExecutionModel::FullFrame: {
|
||||
@@ -260,7 +260,7 @@ void BokehBlurOperation::updateSize()
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->m_sizeavailable = true;
|
||||
m_sizeavailable = true;
|
||||
}
|
||||
|
||||
void BokehBlurOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
@@ -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 * this->m_size * max_dim / 100.0f;
|
||||
r_area.ymax += 2 * this->m_size * max_dim / 100.0f;
|
||||
r_area.xmax += 2 * m_size * max_dim / 100.0f;
|
||||
r_area.ymax += 2 * m_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 * this->m_size * max_dim / 100.0f);
|
||||
float add_size = round_to_even(2 * m_size * max_dim / 100.0f);
|
||||
canvas.xmax += add_size;
|
||||
canvas.ymax += add_size;
|
||||
});
|
||||
|
||||
@@ -64,8 +64,8 @@ class BokehBlurOperation : public MultiThreadedOperation, public QualityStepHelp
|
||||
|
||||
void setSize(float size)
|
||||
{
|
||||
this->m_size = size;
|
||||
this->m_sizeavailable = true;
|
||||
m_size = size;
|
||||
m_sizeavailable = true;
|
||||
}
|
||||
|
||||
void executeOpenCL(OpenCLDevice *device,
|
||||
@@ -77,7 +77,7 @@ class BokehBlurOperation : public MultiThreadedOperation, public QualityStepHelp
|
||||
|
||||
void setExtendBounds(bool extend_bounds)
|
||||
{
|
||||
this->m_extend_bounds = extend_bounds;
|
||||
m_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);
|
||||
this->m_deleteData = false;
|
||||
m_deleteData = false;
|
||||
}
|
||||
void BokehImageOperation::initExecution()
|
||||
{
|
||||
this->m_center[0] = getWidth() / 2;
|
||||
this->m_center[1] = getHeight() / 2;
|
||||
this->m_inverseRounding = 1.0f - this->m_data->rounding;
|
||||
this->m_circularDistance = getWidth() / 2;
|
||||
this->m_flapRad = (float)(M_PI * 2) / this->m_data->flaps;
|
||||
this->m_flapRadAdd = this->m_data->angle;
|
||||
while (this->m_flapRadAdd < 0.0f) {
|
||||
this->m_flapRadAdd += (float)(M_PI * 2.0);
|
||||
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);
|
||||
}
|
||||
while (this->m_flapRadAdd > (float)M_PI) {
|
||||
this->m_flapRadAdd -= (float)(M_PI * 2.0);
|
||||
while (m_flapRadAdd > (float)M_PI) {
|
||||
m_flapRadAdd -= (float)(M_PI * 2.0);
|
||||
}
|
||||
}
|
||||
void BokehImageOperation::detemineStartPointOfFlap(float r[2], int flapNumber, float distance)
|
||||
{
|
||||
r[0] = sinf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_center[0];
|
||||
r[1] = cosf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_center[1];
|
||||
r[0] = sinf(m_flapRad * flapNumber + m_flapRadAdd) * distance + m_center[0];
|
||||
r[1] = cosf(m_flapRad * flapNumber + m_flapRadAdd) * distance + m_center[1];
|
||||
}
|
||||
float BokehImageOperation::isInsideBokeh(float distance, float x, float y)
|
||||
{
|
||||
float insideBokeh = 0.0f;
|
||||
const float deltaX = x - this->m_center[0];
|
||||
const float deltaY = y - this->m_center[1];
|
||||
const float deltaX = x - m_center[0];
|
||||
const float deltaY = y - m_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, this->m_center);
|
||||
const float distanceToCenter = len_v2v2(point, m_center);
|
||||
const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0));
|
||||
int flapNumber = (int)((bearing - this->m_flapRadAdd) / this->m_flapRad);
|
||||
int flapNumber = (int)((bearing - m_flapRadAdd) / m_flapRad);
|
||||
|
||||
detemineStartPointOfFlap(lineP1, flapNumber, distance);
|
||||
detemineStartPointOfFlap(lineP2, flapNumber + 1, distance);
|
||||
closest_to_line_v2(closestPoint, point, lineP1, lineP2);
|
||||
|
||||
const float distanceLineToCenter = len_v2v2(this->m_center, closestPoint);
|
||||
const float distanceRoundingToCenter = this->m_inverseRounding * distanceLineToCenter +
|
||||
this->m_data->rounding * distance;
|
||||
const float distanceLineToCenter = len_v2v2(m_center, closestPoint);
|
||||
const float distanceRoundingToCenter = m_inverseRounding * distanceLineToCenter +
|
||||
m_data->rounding * distance;
|
||||
|
||||
const float catadioptricDistanceToCenter = distanceRoundingToCenter * this->m_data->catadioptric;
|
||||
const float catadioptricDistanceToCenter = distanceRoundingToCenter * m_data->catadioptric;
|
||||
if (distanceRoundingToCenter >= distanceToCenter &&
|
||||
catadioptricDistanceToCenter <= distanceToCenter) {
|
||||
if (distanceRoundingToCenter - distanceToCenter < 1.0f) {
|
||||
insideBokeh = (distanceRoundingToCenter - distanceToCenter);
|
||||
}
|
||||
else if (this->m_data->catadioptric != 0.0f &&
|
||||
else if (m_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 = this->m_data->lensshift;
|
||||
float shift = m_data->lensshift;
|
||||
float shift2 = shift / 2.0f;
|
||||
float distance = this->m_circularDistance;
|
||||
float distance = m_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 = this->m_data->lensshift;
|
||||
const float shift = m_data->lensshift;
|
||||
const float shift2 = shift / 2.0f;
|
||||
const float distance = this->m_circularDistance;
|
||||
const float distance = m_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 (this->m_deleteData) {
|
||||
if (this->m_data) {
|
||||
delete this->m_data;
|
||||
this->m_data = nullptr;
|
||||
if (m_deleteData) {
|
||||
if (m_data) {
|
||||
delete m_data;
|
||||
m_data = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class BokehImageOperation : public MultiThreadedOperation {
|
||||
*/
|
||||
void setData(NodeBokehImage *data)
|
||||
{
|
||||
this->m_data = data;
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +148,7 @@ class BokehImageOperation : public MultiThreadedOperation {
|
||||
*/
|
||||
void deleteDataOnFinish()
|
||||
{
|
||||
this->m_deleteData = true;
|
||||
m_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);
|
||||
this->m_inputMask = nullptr;
|
||||
this->m_inputValue = nullptr;
|
||||
this->m_cosine = 0.0f;
|
||||
this->m_sine = 0.0f;
|
||||
m_inputMask = nullptr;
|
||||
m_inputValue = nullptr;
|
||||
m_cosine = 0.0f;
|
||||
m_sine = 0.0f;
|
||||
}
|
||||
void BoxMaskOperation::initExecution()
|
||||
{
|
||||
this->m_inputMask = this->getInputSocketReader(0);
|
||||
this->m_inputValue = this->getInputSocketReader(1);
|
||||
const double rad = (double)this->m_data->rotation;
|
||||
this->m_cosine = cos(rad);
|
||||
this->m_sine = sin(rad);
|
||||
this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
|
||||
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();
|
||||
}
|
||||
|
||||
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 - this->m_data->y) / this->m_aspectRatio;
|
||||
const float dx = rx - this->m_data->x;
|
||||
rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy);
|
||||
ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy);
|
||||
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);
|
||||
|
||||
this->m_inputMask->readSampled(inputMask, x, y, sampler);
|
||||
this->m_inputValue->readSampled(inputValue, x, y, sampler);
|
||||
m_inputMask->readSampled(inputMask, x, y, sampler);
|
||||
m_inputValue->readSampled(inputValue, x, y, sampler);
|
||||
|
||||
float halfHeight = this->m_data->height / 2.0f;
|
||||
float halfWidth = this->m_data->width / 2.0f;
|
||||
bool inside = (rx > this->m_data->x - halfWidth && rx < this->m_data->x + halfWidth &&
|
||||
ry > this->m_data->y - halfHeight && ry < this->m_data->y + halfHeight);
|
||||
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);
|
||||
|
||||
switch (this->m_maskType) {
|
||||
switch (m_maskType) {
|
||||
case CMP_NODE_MASKTYPE_ADD:
|
||||
if (inside) {
|
||||
output[0] = MAX2(inputMask[0], inputValue[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 = this->m_data->width / 2.0f;
|
||||
const float half_h = this->m_data->height / 2.0f;
|
||||
const float half_w = m_data->width / 2.0f;
|
||||
const float half_h = m_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 - this->m_data->y) / m_aspectRatio;
|
||||
const float dy = (op_ry - m_data->y) / m_aspectRatio;
|
||||
const float op_rx = it.x / op_w;
|
||||
const float dx = op_rx - this->m_data->x;
|
||||
const float rx = this->m_data->x + (m_cosine * dx + m_sine * dy);
|
||||
const float ry = this->m_data->y + (-m_sine * dx + m_cosine * dy);
|
||||
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 bool inside = (rx > this->m_data->x - half_w && rx < this->m_data->x + half_w &&
|
||||
ry > this->m_data->y - half_h && ry < this->m_data->y + half_h);
|
||||
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 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()
|
||||
{
|
||||
this->m_inputMask = nullptr;
|
||||
this->m_inputValue = nullptr;
|
||||
m_inputMask = nullptr;
|
||||
m_inputValue = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -59,12 +59,12 @@ class BoxMaskOperation : public MultiThreadedOperation {
|
||||
|
||||
void setData(NodeBoxMask *data)
|
||||
{
|
||||
this->m_data = data;
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
void setMaskType(int maskType)
|
||||
{
|
||||
this->m_maskType = maskType;
|
||||
m_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);
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_use_premultiply = false;
|
||||
m_inputProgram = nullptr;
|
||||
m_use_premultiply = false;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void BrightnessOperation::setUsePremultiply(bool use_premultiply)
|
||||
{
|
||||
this->m_use_premultiply = use_premultiply;
|
||||
m_use_premultiply = use_premultiply;
|
||||
}
|
||||
|
||||
void BrightnessOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
this->m_inputBrightnessProgram = this->getInputSocketReader(1);
|
||||
this->m_inputContrastProgram = this->getInputSocketReader(2);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputBrightnessProgram = this->getInputSocketReader(1);
|
||||
m_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];
|
||||
this->m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputBrightnessProgram->readSampled(inputBrightness, x, y, sampler);
|
||||
this->m_inputContrastProgram->readSampled(inputContrast, x, y, sampler);
|
||||
m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
m_inputBrightnessProgram->readSampled(inputBrightness, x, y, sampler);
|
||||
m_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 (this->m_use_premultiply) {
|
||||
if (m_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 (this->m_use_premultiply) {
|
||||
if (m_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 (this->m_use_premultiply) {
|
||||
if (m_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 (this->m_use_premultiply) {
|
||||
if (m_use_premultiply) {
|
||||
straight_to_premul_v4(it.out);
|
||||
}
|
||||
}
|
||||
@@ -132,9 +132,9 @@ void BrightnessOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
void BrightnessOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputBrightnessProgram = nullptr;
|
||||
this->m_inputContrastProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputBrightnessProgram = nullptr;
|
||||
m_inputContrastProgram = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -28,26 +28,26 @@ CalculateMeanOperation::CalculateMeanOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color, ResizeMode::Align);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_imageReader = nullptr;
|
||||
this->m_iscalculated = false;
|
||||
this->m_setting = 1;
|
||||
m_imageReader = nullptr;
|
||||
m_iscalculated = false;
|
||||
m_setting = 1;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
void CalculateMeanOperation::initExecution()
|
||||
{
|
||||
this->m_imageReader = this->getInputSocketReader(0);
|
||||
this->m_iscalculated = false;
|
||||
m_imageReader = this->getInputSocketReader(0);
|
||||
m_iscalculated = false;
|
||||
NodeOperation::initMutex();
|
||||
}
|
||||
|
||||
void CalculateMeanOperation::executePixel(float output[4], int /*x*/, int /*y*/, void * /*data*/)
|
||||
{
|
||||
output[0] = this->m_result;
|
||||
output[0] = m_result;
|
||||
}
|
||||
|
||||
void CalculateMeanOperation::deinitExecution()
|
||||
{
|
||||
this->m_imageReader = nullptr;
|
||||
m_imageReader = nullptr;
|
||||
NodeOperation::deinitMutex();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
rcti *output)
|
||||
{
|
||||
rcti imageInput;
|
||||
if (this->m_iscalculated) {
|
||||
if (m_iscalculated) {
|
||||
return false;
|
||||
}
|
||||
NodeOperation *operation = getInputOperation(0);
|
||||
@@ -73,10 +73,10 @@ bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
void *CalculateMeanOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_iscalculated) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
|
||||
if (!m_iscalculated) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_imageReader->initializeTileData(rect);
|
||||
calculateMean(tile);
|
||||
this->m_iscalculated = true;
|
||||
m_iscalculated = true;
|
||||
}
|
||||
unlockMutex();
|
||||
return nullptr;
|
||||
@@ -84,7 +84,7 @@ void *CalculateMeanOperation::initializeTileData(rcti *rect)
|
||||
|
||||
void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
|
||||
{
|
||||
this->m_result = 0.0f;
|
||||
m_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 (this->m_setting) {
|
||||
switch (m_setting) {
|
||||
case 1: {
|
||||
sum += IMB_colormanagement_get_luminance(&buffer[offset]);
|
||||
break;
|
||||
@@ -125,12 +125,12 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
|
||||
}
|
||||
}
|
||||
}
|
||||
this->m_result = sum / pixels;
|
||||
m_result = sum / pixels;
|
||||
}
|
||||
|
||||
void CalculateMeanOperation::setSetting(int setting)
|
||||
{
|
||||
this->m_setting = setting;
|
||||
m_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 (!this->m_iscalculated) {
|
||||
if (!m_iscalculated) {
|
||||
MemoryBuffer *input = inputs[0];
|
||||
m_result = calc_mean(input);
|
||||
this->m_iscalculated = true;
|
||||
m_iscalculated = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,26 +29,26 @@ void CalculateStandardDeviationOperation::executePixel(float output[4],
|
||||
int /*y*/,
|
||||
void * /*data*/)
|
||||
{
|
||||
output[0] = this->m_standardDeviation;
|
||||
output[0] = m_standardDeviation;
|
||||
}
|
||||
|
||||
void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_iscalculated) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
|
||||
if (!m_iscalculated) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_imageReader->initializeTileData(rect);
|
||||
CalculateMeanOperation::calculateMean(tile);
|
||||
this->m_standardDeviation = 0.0f;
|
||||
m_standardDeviation = 0.0f;
|
||||
float *buffer = tile->getBuffer();
|
||||
int size = tile->getWidth() * tile->getHeight();
|
||||
int pixels = 0;
|
||||
float sum = 0.0f;
|
||||
float mean = this->m_result;
|
||||
float mean = m_result;
|
||||
for (int i = 0, offset = 0; i < size; i++, offset += 4) {
|
||||
if (buffer[offset + 3] > 0) {
|
||||
pixels++;
|
||||
|
||||
switch (this->m_setting) {
|
||||
switch (m_setting) {
|
||||
case 1: /* rgb combined */
|
||||
{
|
||||
float value = IMB_colormanagement_get_luminance(&buffer[offset]);
|
||||
@@ -89,8 +89,8 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
|
||||
}
|
||||
}
|
||||
}
|
||||
this->m_standardDeviation = sqrt(sum / (float)(pixels - 1));
|
||||
this->m_iscalculated = true;
|
||||
m_standardDeviation = sqrt(sum / (float)(pixels - 1));
|
||||
m_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 (!this->m_iscalculated) {
|
||||
if (!m_iscalculated) {
|
||||
const MemoryBuffer *input = inputs[0];
|
||||
const float mean = CalculateMeanOperation::calc_mean(input);
|
||||
|
||||
@@ -112,10 +112,9 @@ void CalculateStandardDeviationOperation::update_memory_buffer_started(
|
||||
join.sum += chunk.sum;
|
||||
join.num_pixels += chunk.num_pixels;
|
||||
});
|
||||
this->m_standardDeviation = total.num_pixels <= 1 ?
|
||||
0.0f :
|
||||
sqrt(total.sum / (float)(total.num_pixels - 1));
|
||||
this->m_iscalculated = true;
|
||||
m_standardDeviation = total.num_pixels <= 1 ? 0.0f :
|
||||
sqrt(total.sum / (float)(total.num_pixels - 1));
|
||||
m_iscalculated = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,24 +27,24 @@ ChangeHSVOperation::ChangeHSVOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ChangeHSVOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = getInputSocketReader(0);
|
||||
this->m_hueOperation = getInputSocketReader(1);
|
||||
this->m_saturationOperation = getInputSocketReader(2);
|
||||
this->m_valueOperation = getInputSocketReader(3);
|
||||
m_inputOperation = getInputSocketReader(0);
|
||||
m_hueOperation = getInputSocketReader(1);
|
||||
m_saturationOperation = getInputSocketReader(2);
|
||||
m_valueOperation = getInputSocketReader(3);
|
||||
}
|
||||
|
||||
void ChangeHSVOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_hueOperation = nullptr;
|
||||
this->m_saturationOperation = nullptr;
|
||||
this->m_valueOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
m_hueOperation = nullptr;
|
||||
m_saturationOperation = nullptr;
|
||||
m_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];
|
||||
|
||||
this->m_inputOperation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_hueOperation->readSampled(hue, x, y, sampler);
|
||||
this->m_saturationOperation->readSampled(saturation, x, y, sampler);
|
||||
this->m_valueOperation->readSampled(value, x, y, sampler);
|
||||
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);
|
||||
|
||||
output[0] = inputColor1[0] + (hue[0] - 0.5f);
|
||||
if (output[0] > 1.0f) {
|
||||
|
||||
@@ -25,46 +25,46 @@ ChannelMatteOperation::ChannelMatteOperation()
|
||||
addInputSocket(DataType::Color);
|
||||
addOutputSocket(DataType::Value);
|
||||
|
||||
this->m_inputImageProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ChannelMatteOperation::initExecution()
|
||||
{
|
||||
this->m_inputImageProgram = this->getInputSocketReader(0);
|
||||
m_inputImageProgram = this->getInputSocketReader(0);
|
||||
|
||||
this->m_limit_range = this->m_limit_max - this->m_limit_min;
|
||||
m_limit_range = m_limit_max - m_limit_min;
|
||||
|
||||
switch (this->m_limit_method) {
|
||||
switch (m_limit_method) {
|
||||
/* SINGLE */
|
||||
case 0: {
|
||||
/* 123 / RGB / HSV / YUV / YCC */
|
||||
const int matte_channel = this->m_matte_channel - 1;
|
||||
const int limit_channel = this->m_limit_channel - 1;
|
||||
this->m_ids[0] = matte_channel;
|
||||
this->m_ids[1] = limit_channel;
|
||||
this->m_ids[2] = limit_channel;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
/* MAX */
|
||||
case 1: {
|
||||
switch (this->m_matte_channel) {
|
||||
switch (m_matte_channel) {
|
||||
case 1: {
|
||||
this->m_ids[0] = 0;
|
||||
this->m_ids[1] = 1;
|
||||
this->m_ids[2] = 2;
|
||||
m_ids[0] = 0;
|
||||
m_ids[1] = 1;
|
||||
m_ids[2] = 2;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
this->m_ids[0] = 1;
|
||||
this->m_ids[1] = 0;
|
||||
this->m_ids[2] = 2;
|
||||
m_ids[0] = 1;
|
||||
m_ids[1] = 0;
|
||||
m_ids[2] = 2;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
this->m_ids[0] = 2;
|
||||
this->m_ids[1] = 0;
|
||||
this->m_ids[2] = 1;
|
||||
m_ids[0] = 2;
|
||||
m_ids[1] = 0;
|
||||
m_ids[2] = 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -79,7 +79,7 @@ void ChannelMatteOperation::initExecution()
|
||||
|
||||
void ChannelMatteOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputImageProgram = nullptr;
|
||||
m_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 = this->m_limit_max;
|
||||
const float limit_min = this->m_limit_min;
|
||||
const float limit_range = this->m_limit_range;
|
||||
const float limit_max = m_limit_max;
|
||||
const float limit_min = m_limit_min;
|
||||
const float limit_range = m_limit_range;
|
||||
|
||||
this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
|
||||
m_inputImageProgram->readSampled(inColor, x, y, sampler);
|
||||
|
||||
/* matte operation */
|
||||
alpha = inColor[this->m_ids[0]] - MAX2(inColor[this->m_ids[1]], inColor[this->m_ids[2]]);
|
||||
alpha = inColor[m_ids[0]] - MAX2(inColor[m_ids[1]], inColor[m_ids[2]]);
|
||||
|
||||
/* flip because 0.0 is transparent, not 1.0 */
|
||||
alpha = 1.0f - alpha;
|
||||
@@ -129,7 +129,7 @@ void ChannelMatteOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const float *color = it.in(0);
|
||||
|
||||
/* Matte operation. */
|
||||
float alpha = color[this->m_ids[0]] - MAX2(color[this->m_ids[1]], color[this->m_ids[2]]);
|
||||
float alpha = color[m_ids[0]] - MAX2(color[m_ids[1]], color[m_ids[2]]);
|
||||
|
||||
/* Flip because 0.0 is transparent, not 1.0. */
|
||||
alpha = 1.0f - alpha;
|
||||
|
||||
@@ -65,11 +65,11 @@ class ChannelMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma, const int custom2)
|
||||
{
|
||||
this->m_limit_max = nodeChroma->t1;
|
||||
this->m_limit_min = nodeChroma->t2;
|
||||
this->m_limit_method = nodeChroma->algorithm;
|
||||
this->m_limit_channel = nodeChroma->channel;
|
||||
this->m_matte_channel = 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;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,21 +26,21 @@ ChromaMatteOperation::ChromaMatteOperation()
|
||||
addInputSocket(DataType::Color);
|
||||
addOutputSocket(DataType::Value);
|
||||
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputKeyProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputKeyProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ChromaMatteOperation::initExecution()
|
||||
{
|
||||
this->m_inputImageProgram = this->getInputSocketReader(0);
|
||||
this->m_inputKeyProgram = this->getInputSocketReader(1);
|
||||
m_inputImageProgram = this->getInputSocketReader(0);
|
||||
m_inputKeyProgram = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ChromaMatteOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputKeyProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_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 = this->m_settings->t1; /* in radians */
|
||||
const float cutoff = this->m_settings->t2; /* in radians */
|
||||
const float gain = this->m_settings->fstrength;
|
||||
const float acceptance = m_settings->t1; /* in radians */
|
||||
const float cutoff = m_settings->t2; /* in radians */
|
||||
const float gain = m_settings->fstrength;
|
||||
|
||||
float x_angle, z_angle, alpha;
|
||||
float theta, beta;
|
||||
float kfg;
|
||||
|
||||
this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
|
||||
this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
|
||||
m_inputKeyProgram->readSampled(inKey, x, y, sampler);
|
||||
m_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 = this->m_settings->t1; /* In radians. */
|
||||
const float cutoff = this->m_settings->t2; /* In radians. */
|
||||
const float gain = this->m_settings->fstrength;
|
||||
const float acceptance = m_settings->t1; /* In radians. */
|
||||
const float cutoff = m_settings->t2; /* In radians. */
|
||||
const float gain = m_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);
|
||||
|
||||
@@ -48,7 +48,7 @@ class ChromaMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma)
|
||||
{
|
||||
this->m_settings = nodeChroma;
|
||||
m_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);
|
||||
this->m_inputValueOperation = nullptr;
|
||||
this->m_inputColorOperation = nullptr;
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColorOperation = nullptr;
|
||||
this->set_canvas_input_index(1);
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ColorBalanceASCCDLOperation::initExecution()
|
||||
{
|
||||
this->m_inputValueOperation = this->getInputSocketReader(0);
|
||||
this->m_inputColorOperation = this->getInputSocketReader(1);
|
||||
m_inputValueOperation = this->getInputSocketReader(0);
|
||||
m_inputColorOperation = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ColorBalanceASCCDLOperation::executePixelSampled(float output[4],
|
||||
@@ -57,22 +57,19 @@ void ColorBalanceASCCDLOperation::executePixelSampled(float output[4],
|
||||
float inputColor[4];
|
||||
float value[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_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], this->m_offset[0], this->m_power[0], this->m_slope[0]);
|
||||
fac * colorbalance_cdl(inputColor[0], m_offset[0], m_power[0], m_slope[0]);
|
||||
output[1] = mfac * inputColor[1] +
|
||||
fac * colorbalance_cdl(
|
||||
inputColor[1], this->m_offset[1], this->m_power[1], this->m_slope[1]);
|
||||
fac * colorbalance_cdl(inputColor[1], m_offset[1], m_power[1], m_slope[1]);
|
||||
output[2] = mfac * inputColor[2] +
|
||||
fac * colorbalance_cdl(
|
||||
inputColor[2], this->m_offset[2], this->m_power[2], this->m_slope[2]);
|
||||
fac * colorbalance_cdl(inputColor[2], m_offset[2], m_power[2], m_slope[2]);
|
||||
output[3] = inputColor[3];
|
||||
}
|
||||
|
||||
@@ -95,8 +92,8 @@ void ColorBalanceASCCDLOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
|
||||
void ColorBalanceASCCDLOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputValueOperation = nullptr;
|
||||
this->m_inputColorOperation = nullptr;
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColorOperation = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -61,15 +61,15 @@ class ColorBalanceASCCDLOperation : public MultiThreadedRowOperation {
|
||||
|
||||
void setOffset(float offset[3])
|
||||
{
|
||||
copy_v3_v3(this->m_offset, offset);
|
||||
copy_v3_v3(m_offset, offset);
|
||||
}
|
||||
void setPower(float power[3])
|
||||
{
|
||||
copy_v3_v3(this->m_power, power);
|
||||
copy_v3_v3(m_power, power);
|
||||
}
|
||||
void setSlope(float slope[3])
|
||||
{
|
||||
copy_v3_v3(this->m_slope, slope);
|
||||
copy_v3_v3(m_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);
|
||||
this->m_inputValueOperation = nullptr;
|
||||
this->m_inputColorOperation = nullptr;
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColorOperation = nullptr;
|
||||
this->set_canvas_input_index(1);
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ColorBalanceLGGOperation::initExecution()
|
||||
{
|
||||
this->m_inputValueOperation = this->getInputSocketReader(0);
|
||||
this->m_inputColorOperation = this->getInputSocketReader(1);
|
||||
m_inputValueOperation = this->getInputSocketReader(0);
|
||||
m_inputColorOperation = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ColorBalanceLGGOperation::executePixelSampled(float output[4],
|
||||
@@ -62,22 +62,19 @@ void ColorBalanceLGGOperation::executePixelSampled(float output[4],
|
||||
float inputColor[4];
|
||||
float value[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(value, x, y, sampler);
|
||||
m_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], this->m_lift[0], this->m_gamma_inv[0], this->m_gain[0]);
|
||||
fac * colorbalance_lgg(inputColor[0], m_lift[0], m_gamma_inv[0], m_gain[0]);
|
||||
output[1] = mfac * inputColor[1] +
|
||||
fac * colorbalance_lgg(
|
||||
inputColor[1], this->m_lift[1], this->m_gamma_inv[1], this->m_gain[1]);
|
||||
fac * colorbalance_lgg(inputColor[1], m_lift[1], m_gamma_inv[1], m_gain[1]);
|
||||
output[2] = mfac * inputColor[2] +
|
||||
fac * colorbalance_lgg(
|
||||
inputColor[2], this->m_lift[2], this->m_gamma_inv[2], this->m_gain[2]);
|
||||
fac * colorbalance_lgg(inputColor[2], m_lift[2], m_gamma_inv[2], m_gain[2]);
|
||||
output[3] = inputColor[3];
|
||||
}
|
||||
|
||||
@@ -100,8 +97,8 @@ void ColorBalanceLGGOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
|
||||
void ColorBalanceLGGOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputValueOperation = nullptr;
|
||||
this->m_inputColorOperation = nullptr;
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColorOperation = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -61,15 +61,15 @@ class ColorBalanceLGGOperation : public MultiThreadedRowOperation {
|
||||
|
||||
void setGain(const float gain[3])
|
||||
{
|
||||
copy_v3_v3(this->m_gain, gain);
|
||||
copy_v3_v3(m_gain, gain);
|
||||
}
|
||||
void setLift(const float lift[3])
|
||||
{
|
||||
copy_v3_v3(this->m_lift, lift);
|
||||
copy_v3_v3(m_lift, lift);
|
||||
}
|
||||
void setGammaInv(const float gamma_inv[3])
|
||||
{
|
||||
copy_v3_v3(this->m_gamma_inv, gamma_inv);
|
||||
copy_v3_v3(m_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);
|
||||
this->m_inputImage = nullptr;
|
||||
this->m_inputMask = nullptr;
|
||||
this->m_redChannelEnabled = true;
|
||||
this->m_greenChannelEnabled = true;
|
||||
this->m_blueChannelEnabled = true;
|
||||
m_inputImage = nullptr;
|
||||
m_inputMask = nullptr;
|
||||
m_redChannelEnabled = true;
|
||||
m_greenChannelEnabled = true;
|
||||
m_blueChannelEnabled = true;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
void ColorCorrectionOperation::initExecution()
|
||||
{
|
||||
this->m_inputImage = this->getInputSocketReader(0);
|
||||
this->m_inputMask = this->getInputSocketReader(1);
|
||||
m_inputImage = this->getInputSocketReader(0);
|
||||
m_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];
|
||||
this->m_inputImage->readSampled(inputImageColor, x, y, sampler);
|
||||
this->m_inputMask->readSampled(inputMask, x, y, sampler);
|
||||
m_inputImage->readSampled(inputImageColor, x, y, sampler);
|
||||
m_inputMask->readSampled(inputMask, x, y, sampler);
|
||||
|
||||
float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f;
|
||||
float contrast = this->m_data->master.contrast;
|
||||
float saturation = this->m_data->master.saturation;
|
||||
float gamma = this->m_data->master.gamma;
|
||||
float gain = this->m_data->master.gain;
|
||||
float lift = this->m_data->master.lift;
|
||||
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 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 < this->m_data->startmidtones - MARGIN) {
|
||||
if (level < m_data->startmidtones - MARGIN) {
|
||||
levelShadows = 1.0f;
|
||||
}
|
||||
else if (level < this->m_data->startmidtones + MARGIN) {
|
||||
levelMidtones = ((level - this->m_data->startmidtones) * MARGIN_DIV) + 0.5f;
|
||||
else if (level < m_data->startmidtones + MARGIN) {
|
||||
levelMidtones = ((level - m_data->startmidtones) * MARGIN_DIV) + 0.5f;
|
||||
levelShadows = 1.0f - levelMidtones;
|
||||
}
|
||||
else if (level < this->m_data->endmidtones - MARGIN) {
|
||||
else if (level < m_data->endmidtones - MARGIN) {
|
||||
levelMidtones = 1.0f;
|
||||
}
|
||||
else if (level < this->m_data->endmidtones + MARGIN) {
|
||||
levelHighlights = ((level - this->m_data->endmidtones) * MARGIN_DIV) + 0.5f;
|
||||
else if (level < m_data->endmidtones + MARGIN) {
|
||||
levelHighlights = ((level - m_data->endmidtones) * MARGIN_DIV) + 0.5f;
|
||||
levelMidtones = 1.0f - levelHighlights;
|
||||
}
|
||||
else {
|
||||
@@ -95,21 +95,18 @@ void ColorCorrectionOperation::executePixelSampled(float output[4],
|
||||
}
|
||||
#undef MARGIN
|
||||
#undef MARGIN_DIV
|
||||
contrast *= (levelShadows * this->m_data->shadows.contrast) +
|
||||
(levelMidtones * this->m_data->midtones.contrast) +
|
||||
(levelHighlights * this->m_data->highlights.contrast);
|
||||
saturation *= (levelShadows * this->m_data->shadows.saturation) +
|
||||
(levelMidtones * this->m_data->midtones.saturation) +
|
||||
(levelHighlights * this->m_data->highlights.saturation);
|
||||
gamma *= (levelShadows * this->m_data->shadows.gamma) +
|
||||
(levelMidtones * this->m_data->midtones.gamma) +
|
||||
(levelHighlights * this->m_data->highlights.gamma);
|
||||
gain *= (levelShadows * this->m_data->shadows.gain) +
|
||||
(levelMidtones * this->m_data->midtones.gain) +
|
||||
(levelHighlights * this->m_data->highlights.gain);
|
||||
lift += (levelShadows * this->m_data->shadows.lift) +
|
||||
(levelMidtones * this->m_data->midtones.lift) +
|
||||
(levelHighlights * this->m_data->highlights.lift);
|
||||
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);
|
||||
|
||||
float invgamma = 1.0f / gamma;
|
||||
float luma = IMB_colormanagement_get_luminance(inputImageColor);
|
||||
@@ -136,19 +133,19 @@ void ColorCorrectionOperation::executePixelSampled(float output[4],
|
||||
g = mvalue * inputImageColor[1] + value * g;
|
||||
b = mvalue * inputImageColor[2] + value * b;
|
||||
|
||||
if (this->m_redChannelEnabled) {
|
||||
if (m_redChannelEnabled) {
|
||||
output[0] = r;
|
||||
}
|
||||
else {
|
||||
output[0] = inputImageColor[0];
|
||||
}
|
||||
if (this->m_greenChannelEnabled) {
|
||||
if (m_greenChannelEnabled) {
|
||||
output[1] = g;
|
||||
}
|
||||
else {
|
||||
output[1] = inputImageColor[1];
|
||||
}
|
||||
if (this->m_blueChannelEnabled) {
|
||||
if (m_blueChannelEnabled) {
|
||||
output[2] = b;
|
||||
}
|
||||
else {
|
||||
@@ -169,43 +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 < this->m_data->startmidtones - MARGIN) {
|
||||
if (level < m_data->startmidtones - MARGIN) {
|
||||
level_shadows = 1.0f;
|
||||
}
|
||||
else if (level < this->m_data->startmidtones + MARGIN) {
|
||||
level_midtones = ((level - this->m_data->startmidtones) * MARGIN_DIV) + 0.5f;
|
||||
else if (level < m_data->startmidtones + MARGIN) {
|
||||
level_midtones = ((level - m_data->startmidtones) * MARGIN_DIV) + 0.5f;
|
||||
level_shadows = 1.0f - level_midtones;
|
||||
}
|
||||
else if (level < this->m_data->endmidtones - MARGIN) {
|
||||
else if (level < m_data->endmidtones - MARGIN) {
|
||||
level_midtones = 1.0f;
|
||||
}
|
||||
else if (level < this->m_data->endmidtones + MARGIN) {
|
||||
level_highlights = ((level - this->m_data->endmidtones) * MARGIN_DIV) + 0.5f;
|
||||
else if (level < m_data->endmidtones + MARGIN) {
|
||||
level_highlights = ((level - m_data->endmidtones) * MARGIN_DIV) + 0.5f;
|
||||
level_midtones = 1.0f - level_highlights;
|
||||
}
|
||||
else {
|
||||
level_highlights = 1.0f;
|
||||
}
|
||||
float contrast = this->m_data->master.contrast;
|
||||
float saturation = this->m_data->master.saturation;
|
||||
float gamma = this->m_data->master.gamma;
|
||||
float gain = this->m_data->master.gain;
|
||||
float lift = this->m_data->master.lift;
|
||||
contrast *= level_shadows * this->m_data->shadows.contrast +
|
||||
level_midtones * this->m_data->midtones.contrast +
|
||||
level_highlights * this->m_data->highlights.contrast;
|
||||
saturation *= level_shadows * this->m_data->shadows.saturation +
|
||||
level_midtones * this->m_data->midtones.saturation +
|
||||
level_highlights * this->m_data->highlights.saturation;
|
||||
gamma *= level_shadows * this->m_data->shadows.gamma +
|
||||
level_midtones * this->m_data->midtones.gamma +
|
||||
level_highlights * this->m_data->highlights.gamma;
|
||||
gain *= level_shadows * this->m_data->shadows.gain +
|
||||
level_midtones * this->m_data->midtones.gain +
|
||||
level_highlights * this->m_data->highlights.gain;
|
||||
lift += level_shadows * this->m_data->shadows.lift +
|
||||
level_midtones * this->m_data->midtones.lift +
|
||||
level_highlights * this->m_data->highlights.lift;
|
||||
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;
|
||||
|
||||
const float inv_gamma = 1.0f / gamma;
|
||||
const float luma = IMB_colormanagement_get_luminance(in_color);
|
||||
@@ -239,8 +233,8 @@ void ColorCorrectionOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
|
||||
void ColorCorrectionOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputImage = nullptr;
|
||||
this->m_inputMask = nullptr;
|
||||
m_inputImage = nullptr;
|
||||
m_inputMask = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -55,19 +55,19 @@ class ColorCorrectionOperation : public MultiThreadedRowOperation {
|
||||
|
||||
void setData(NodeColorCorrection *data)
|
||||
{
|
||||
this->m_data = data;
|
||||
m_data = data;
|
||||
}
|
||||
void setRedChannelEnabled(bool enabled)
|
||||
{
|
||||
this->m_redChannelEnabled = enabled;
|
||||
m_redChannelEnabled = enabled;
|
||||
}
|
||||
void setGreenChannelEnabled(bool enabled)
|
||||
{
|
||||
this->m_greenChannelEnabled = enabled;
|
||||
m_greenChannelEnabled = enabled;
|
||||
}
|
||||
void setBlueChannelEnabled(bool enabled)
|
||||
{
|
||||
this->m_blueChannelEnabled = enabled;
|
||||
m_blueChannelEnabled = enabled;
|
||||
}
|
||||
|
||||
void update_memory_buffer_row(PixelCursor &p) override;
|
||||
|
||||
@@ -30,22 +30,22 @@ ColorCurveOperation::ColorCurveOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_inputFacProgram = nullptr;
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputBlackProgram = nullptr;
|
||||
this->m_inputWhiteProgram = nullptr;
|
||||
m_inputFacProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputBlackProgram = nullptr;
|
||||
m_inputWhiteProgram = nullptr;
|
||||
|
||||
this->set_canvas_input_index(1);
|
||||
}
|
||||
void ColorCurveOperation::initExecution()
|
||||
{
|
||||
CurveBaseOperation::initExecution();
|
||||
this->m_inputFacProgram = this->getInputSocketReader(0);
|
||||
this->m_inputImageProgram = this->getInputSocketReader(1);
|
||||
this->m_inputBlackProgram = this->getInputSocketReader(2);
|
||||
this->m_inputWhiteProgram = this->getInputSocketReader(3);
|
||||
m_inputFacProgram = this->getInputSocketReader(0);
|
||||
m_inputImageProgram = this->getInputSocketReader(1);
|
||||
m_inputBlackProgram = this->getInputSocketReader(2);
|
||||
m_inputWhiteProgram = this->getInputSocketReader(3);
|
||||
|
||||
BKE_curvemapping_premultiply(this->m_curveMapping, 0);
|
||||
BKE_curvemapping_premultiply(m_curveMapping, 0);
|
||||
}
|
||||
|
||||
void ColorCurveOperation::executePixelSampled(float output[4],
|
||||
@@ -53,7 +53,7 @@ void ColorCurveOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler sampler)
|
||||
{
|
||||
CurveMapping *cumap = this->m_curveMapping;
|
||||
CurveMapping *cumap = m_curveMapping;
|
||||
|
||||
float fac[4];
|
||||
float image[4];
|
||||
@@ -63,15 +63,15 @@ void ColorCurveOperation::executePixelSampled(float output[4],
|
||||
float white[4];
|
||||
float bwmul[3];
|
||||
|
||||
this->m_inputBlackProgram->readSampled(black, x, y, sampler);
|
||||
this->m_inputWhiteProgram->readSampled(white, x, y, sampler);
|
||||
m_inputBlackProgram->readSampled(black, x, y, sampler);
|
||||
m_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);
|
||||
|
||||
this->m_inputFacProgram->readSampled(fac, x, y, sampler);
|
||||
this->m_inputImageProgram->readSampled(image, x, y, sampler);
|
||||
m_inputFacProgram->readSampled(fac, x, y, sampler);
|
||||
m_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();
|
||||
this->m_inputFacProgram = nullptr;
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputBlackProgram = nullptr;
|
||||
this->m_inputWhiteProgram = nullptr;
|
||||
m_inputFacProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputBlackProgram = nullptr;
|
||||
m_inputWhiteProgram = nullptr;
|
||||
}
|
||||
|
||||
void ColorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
CurveMapping *cumap = this->m_curveMapping;
|
||||
CurveMapping *cumap = m_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);
|
||||
|
||||
this->m_inputFacProgram = nullptr;
|
||||
this->m_inputImageProgram = nullptr;
|
||||
m_inputFacProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
|
||||
this->set_canvas_input_index(1);
|
||||
}
|
||||
void ConstantLevelColorCurveOperation::initExecution()
|
||||
{
|
||||
CurveBaseOperation::initExecution();
|
||||
this->m_inputFacProgram = this->getInputSocketReader(0);
|
||||
this->m_inputImageProgram = this->getInputSocketReader(1);
|
||||
m_inputFacProgram = this->getInputSocketReader(0);
|
||||
m_inputImageProgram = this->getInputSocketReader(1);
|
||||
|
||||
BKE_curvemapping_premultiply(this->m_curveMapping, 0);
|
||||
BKE_curvemapping_premultiply(m_curveMapping, 0);
|
||||
|
||||
BKE_curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white);
|
||||
BKE_curvemapping_set_black_white(m_curveMapping, m_black, m_white);
|
||||
}
|
||||
|
||||
void ConstantLevelColorCurveOperation::executePixelSampled(float output[4],
|
||||
@@ -158,18 +158,18 @@ void ConstantLevelColorCurveOperation::executePixelSampled(float output[4],
|
||||
float fac[4];
|
||||
float image[4];
|
||||
|
||||
this->m_inputFacProgram->readSampled(fac, x, y, sampler);
|
||||
this->m_inputImageProgram->readSampled(image, x, y, sampler);
|
||||
m_inputFacProgram->readSampled(fac, x, y, sampler);
|
||||
m_inputImageProgram->readSampled(image, x, y, sampler);
|
||||
|
||||
if (*fac >= 1.0f) {
|
||||
BKE_curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image);
|
||||
BKE_curvemapping_evaluate_premulRGBF(m_curveMapping, output, image);
|
||||
}
|
||||
else if (*fac <= 0.0f) {
|
||||
copy_v3_v3(output, image);
|
||||
}
|
||||
else {
|
||||
float col[4];
|
||||
BKE_curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image);
|
||||
BKE_curvemapping_evaluate_premulRGBF(m_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();
|
||||
this->m_inputFacProgram = nullptr;
|
||||
this->m_inputImageProgram = nullptr;
|
||||
m_inputFacProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
}
|
||||
|
||||
void ConstantLevelColorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
CurveMapping *cumap = this->m_curveMapping;
|
||||
CurveMapping *cumap = m_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);
|
||||
|
||||
@@ -85,11 +85,11 @@ class ConstantLevelColorCurveOperation : public CurveBaseOperation {
|
||||
|
||||
void setBlackLevel(float black[3])
|
||||
{
|
||||
copy_v3_v3(this->m_black, black);
|
||||
copy_v3_v3(m_black, black);
|
||||
}
|
||||
void setWhiteLevel(float white[3])
|
||||
{
|
||||
copy_v3_v3(this->m_white, white);
|
||||
copy_v3_v3(m_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);
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ExposureOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
this->m_inputExposureProgram = this->getInputSocketReader(1);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
m_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];
|
||||
this->m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputExposureProgram->readSampled(inputExposure, x, y, sampler);
|
||||
m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
m_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()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputExposureProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputExposureProgram = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -26,21 +26,21 @@ ColorMatteOperation::ColorMatteOperation()
|
||||
addInputSocket(DataType::Color);
|
||||
addOutputSocket(DataType::Value);
|
||||
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputKeyProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputKeyProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ColorMatteOperation::initExecution()
|
||||
{
|
||||
this->m_inputImageProgram = this->getInputSocketReader(0);
|
||||
this->m_inputKeyProgram = this->getInputSocketReader(1);
|
||||
m_inputImageProgram = this->getInputSocketReader(0);
|
||||
m_inputKeyProgram = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void ColorMatteOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputKeyProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_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 = this->m_settings->t1;
|
||||
const float sat = this->m_settings->t2;
|
||||
const float val = this->m_settings->t3;
|
||||
const float hue = m_settings->t1;
|
||||
const float sat = m_settings->t2;
|
||||
const float val = m_settings->t3;
|
||||
|
||||
float h_wrap;
|
||||
|
||||
this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
|
||||
this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
|
||||
m_inputImageProgram->readSampled(inColor, x, y, sampler);
|
||||
m_inputKeyProgram->readSampled(inKey, x, y, sampler);
|
||||
|
||||
/* Store matte(alpha) value in [0] to go with
|
||||
* COM_SetAlphaMultiplyOperation and the Value output.
|
||||
|
||||
@@ -48,7 +48,7 @@ class ColorMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma)
|
||||
{
|
||||
this->m_settings = nodeChroma;
|
||||
m_settings = nodeChroma;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -27,13 +27,13 @@ ColorRampOperation::ColorRampOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_colorBand = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_colorBand = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
void ColorRampOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void ColorRampOperation::executePixelSampled(float output[4],
|
||||
@@ -43,13 +43,13 @@ void ColorRampOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float values[4];
|
||||
|
||||
this->m_inputProgram->readSampled(values, x, y, sampler);
|
||||
BKE_colorband_evaluate(this->m_colorBand, values[0], output);
|
||||
m_inputProgram->readSampled(values, x, y, sampler);
|
||||
BKE_colorband_evaluate(m_colorBand, values[0], output);
|
||||
}
|
||||
|
||||
void ColorRampOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
void ColorRampOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -51,7 +51,7 @@ class ColorRampOperation : public MultiThreadedOperation {
|
||||
|
||||
void setColorBand(ColorBand *colorBand)
|
||||
{
|
||||
this->m_colorBand = colorBand;
|
||||
m_colorBand = colorBand;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -27,60 +27,60 @@ ColorSpillOperation::ColorSpillOperation()
|
||||
addInputSocket(DataType::Value);
|
||||
addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_inputImageReader = nullptr;
|
||||
this->m_inputFacReader = nullptr;
|
||||
this->m_spillChannel = 1; /* GREEN */
|
||||
this->m_spillMethod = 0;
|
||||
m_inputImageReader = nullptr;
|
||||
m_inputFacReader = nullptr;
|
||||
m_spillChannel = 1; /* GREEN */
|
||||
m_spillMethod = 0;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ColorSpillOperation::initExecution()
|
||||
{
|
||||
this->m_inputImageReader = this->getInputSocketReader(0);
|
||||
this->m_inputFacReader = this->getInputSocketReader(1);
|
||||
if (this->m_spillChannel == 0) {
|
||||
this->m_rmut = -1.0f;
|
||||
this->m_gmut = 1.0f;
|
||||
this->m_bmut = 1.0f;
|
||||
this->m_channel2 = 1;
|
||||
this->m_channel3 = 2;
|
||||
if (this->m_settings->unspill == 0) {
|
||||
this->m_settings->uspillr = 1.0f;
|
||||
this->m_settings->uspillg = 0.0f;
|
||||
this->m_settings->uspillb = 0.0f;
|
||||
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;
|
||||
}
|
||||
}
|
||||
else if (this->m_spillChannel == 1) {
|
||||
this->m_rmut = 1.0f;
|
||||
this->m_gmut = -1.0f;
|
||||
this->m_bmut = 1.0f;
|
||||
this->m_channel2 = 0;
|
||||
this->m_channel3 = 2;
|
||||
if (this->m_settings->unspill == 0) {
|
||||
this->m_settings->uspillr = 0.0f;
|
||||
this->m_settings->uspillg = 1.0f;
|
||||
this->m_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 {
|
||||
this->m_rmut = 1.0f;
|
||||
this->m_gmut = 1.0f;
|
||||
this->m_bmut = -1.0f;
|
||||
m_rmut = 1.0f;
|
||||
m_gmut = 1.0f;
|
||||
m_bmut = -1.0f;
|
||||
|
||||
this->m_channel2 = 0;
|
||||
this->m_channel3 = 1;
|
||||
if (this->m_settings->unspill == 0) {
|
||||
this->m_settings->uspillr = 0.0f;
|
||||
this->m_settings->uspillg = 0.0f;
|
||||
this->m_settings->uspillb = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpillOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputImageReader = nullptr;
|
||||
this->m_inputFacReader = nullptr;
|
||||
m_inputImageReader = nullptr;
|
||||
m_inputFacReader = nullptr;
|
||||
}
|
||||
|
||||
void ColorSpillOperation::executePixelSampled(float output[4],
|
||||
@@ -90,27 +90,25 @@ void ColorSpillOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float fac[4];
|
||||
float input[4];
|
||||
this->m_inputFacReader->readSampled(fac, x, y, sampler);
|
||||
this->m_inputImageReader->readSampled(input, x, y, sampler);
|
||||
m_inputFacReader->readSampled(fac, x, y, sampler);
|
||||
m_inputImageReader->readSampled(input, x, y, sampler);
|
||||
float rfac = MIN2(1.0f, fac[0]);
|
||||
float map;
|
||||
|
||||
switch (this->m_spillMethod) {
|
||||
switch (m_spillMethod) {
|
||||
case 0: /* simple */
|
||||
map = rfac * (input[this->m_spillChannel] -
|
||||
(this->m_settings->limscale * input[this->m_settings->limchan]));
|
||||
map = rfac * (input[m_spillChannel] - (m_settings->limscale * input[m_settings->limchan]));
|
||||
break;
|
||||
default: /* average */
|
||||
map = rfac *
|
||||
(input[this->m_spillChannel] -
|
||||
(this->m_settings->limscale * AVG(input[this->m_channel2], input[this->m_channel3])));
|
||||
map = rfac * (input[m_spillChannel] -
|
||||
(m_settings->limscale * AVG(input[m_channel2], input[m_channel3])));
|
||||
break;
|
||||
}
|
||||
|
||||
if (map > 0.0f) {
|
||||
output[0] = input[0] + this->m_rmut * (this->m_settings->uspillr * map);
|
||||
output[1] = input[1] + this->m_gmut * (this->m_settings->uspillg * map);
|
||||
output[2] = input[2] + this->m_bmut * (this->m_settings->uspillb * map);
|
||||
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[3] = input[3];
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -53,15 +53,15 @@ class ColorSpillOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeColorspill *nodeColorSpill)
|
||||
{
|
||||
this->m_settings = nodeColorSpill;
|
||||
m_settings = nodeColorSpill;
|
||||
}
|
||||
void setSpillChannel(int channel)
|
||||
{
|
||||
this->m_spillChannel = channel;
|
||||
m_spillChannel = channel;
|
||||
}
|
||||
void setSpillMethod(int method)
|
||||
{
|
||||
this->m_spillMethod = method;
|
||||
m_spillMethod = method;
|
||||
}
|
||||
|
||||
float calculateMapValue(float fac, float *input);
|
||||
|
||||
@@ -32,71 +32,71 @@ CompositorOperation::CompositorOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
|
||||
this->setRenderData(nullptr);
|
||||
this->m_outputBuffer = nullptr;
|
||||
this->m_depthBuffer = nullptr;
|
||||
this->m_imageInput = nullptr;
|
||||
this->m_alphaInput = nullptr;
|
||||
this->m_depthInput = nullptr;
|
||||
m_outputBuffer = nullptr;
|
||||
m_depthBuffer = nullptr;
|
||||
m_imageInput = nullptr;
|
||||
m_alphaInput = nullptr;
|
||||
m_depthInput = nullptr;
|
||||
|
||||
this->m_useAlphaInput = false;
|
||||
this->m_active = false;
|
||||
m_useAlphaInput = false;
|
||||
m_active = false;
|
||||
|
||||
this->m_scene = nullptr;
|
||||
this->m_sceneName[0] = '\0';
|
||||
this->m_viewName = nullptr;
|
||||
m_scene = nullptr;
|
||||
m_sceneName[0] = '\0';
|
||||
m_viewName = nullptr;
|
||||
|
||||
flags.use_render_border = true;
|
||||
}
|
||||
|
||||
void CompositorOperation::initExecution()
|
||||
{
|
||||
if (!this->m_active) {
|
||||
if (!m_active) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* When initializing the tree during initial load the width and height can be zero. */
|
||||
this->m_imageInput = getInputSocketReader(0);
|
||||
this->m_alphaInput = getInputSocketReader(1);
|
||||
this->m_depthInput = getInputSocketReader(2);
|
||||
m_imageInput = getInputSocketReader(0);
|
||||
m_alphaInput = getInputSocketReader(1);
|
||||
m_depthInput = getInputSocketReader(2);
|
||||
if (this->getWidth() * this->getHeight() != 0) {
|
||||
this->m_outputBuffer = (float *)MEM_callocN(
|
||||
sizeof(float[4]) * this->getWidth() * this->getHeight(), "CompositorOperation");
|
||||
m_outputBuffer = (float *)MEM_callocN(sizeof(float[4]) * this->getWidth() * this->getHeight(),
|
||||
"CompositorOperation");
|
||||
}
|
||||
if (this->m_depthInput != nullptr) {
|
||||
this->m_depthBuffer = (float *)MEM_callocN(
|
||||
sizeof(float) * this->getWidth() * this->getHeight(), "CompositorOperation");
|
||||
if (m_depthInput != nullptr) {
|
||||
m_depthBuffer = (float *)MEM_callocN(sizeof(float) * this->getWidth() * this->getHeight(),
|
||||
"CompositorOperation");
|
||||
}
|
||||
}
|
||||
|
||||
void CompositorOperation::deinitExecution()
|
||||
{
|
||||
if (!this->m_active) {
|
||||
if (!m_active) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isBraked()) {
|
||||
Render *re = RE_GetSceneRender(this->m_scene);
|
||||
Render *re = RE_GetSceneRender(m_scene);
|
||||
RenderResult *rr = RE_AcquireResultWrite(re);
|
||||
|
||||
if (rr) {
|
||||
RenderView *rv = RE_RenderViewGetByName(rr, this->m_viewName);
|
||||
RenderView *rv = RE_RenderViewGetByName(rr, m_viewName);
|
||||
|
||||
if (rv->rectf != nullptr) {
|
||||
MEM_freeN(rv->rectf);
|
||||
}
|
||||
rv->rectf = this->m_outputBuffer;
|
||||
rv->rectf = m_outputBuffer;
|
||||
if (rv->rectz != nullptr) {
|
||||
MEM_freeN(rv->rectz);
|
||||
}
|
||||
rv->rectz = this->m_depthBuffer;
|
||||
rv->rectz = m_depthBuffer;
|
||||
rr->have_combined = true;
|
||||
}
|
||||
else {
|
||||
if (this->m_outputBuffer) {
|
||||
MEM_freeN(this->m_outputBuffer);
|
||||
if (m_outputBuffer) {
|
||||
MEM_freeN(m_outputBuffer);
|
||||
}
|
||||
if (this->m_depthBuffer) {
|
||||
MEM_freeN(this->m_depthBuffer);
|
||||
if (m_depthBuffer) {
|
||||
MEM_freeN(m_depthBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,26 +113,26 @@ void CompositorOperation::deinitExecution()
|
||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||
}
|
||||
else {
|
||||
if (this->m_outputBuffer) {
|
||||
MEM_freeN(this->m_outputBuffer);
|
||||
if (m_outputBuffer) {
|
||||
MEM_freeN(m_outputBuffer);
|
||||
}
|
||||
if (this->m_depthBuffer) {
|
||||
MEM_freeN(this->m_depthBuffer);
|
||||
if (m_depthBuffer) {
|
||||
MEM_freeN(m_depthBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
this->m_outputBuffer = nullptr;
|
||||
this->m_depthBuffer = nullptr;
|
||||
this->m_imageInput = nullptr;
|
||||
this->m_alphaInput = nullptr;
|
||||
this->m_depthInput = nullptr;
|
||||
m_outputBuffer = nullptr;
|
||||
m_depthBuffer = nullptr;
|
||||
m_imageInput = nullptr;
|
||||
m_alphaInput = nullptr;
|
||||
m_depthInput = nullptr;
|
||||
}
|
||||
|
||||
void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
{
|
||||
float color[8]; // 7 is enough
|
||||
float *buffer = this->m_outputBuffer;
|
||||
float *zbuffer = this->m_depthBuffer;
|
||||
float *buffer = m_outputBuffer;
|
||||
float *zbuffer = m_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 = this->m_rd;
|
||||
const RenderData *rd = m_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;
|
||||
|
||||
this->m_imageInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
|
||||
if (this->m_useAlphaInput) {
|
||||
this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, PixelSampler::Nearest);
|
||||
m_imageInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
|
||||
if (m_useAlphaInput) {
|
||||
m_alphaInput->readSampled(&(color[3]), input_x, input_y, PixelSampler::Nearest);
|
||||
}
|
||||
|
||||
copy_v4_v4(buffer + offset4, color);
|
||||
|
||||
this->m_depthInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
|
||||
m_depthInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
|
||||
zbuffer[offset] = color[0];
|
||||
offset4 += COM_DATA_TYPE_COLOR_CHANNELS;
|
||||
offset++;
|
||||
@@ -221,7 +221,7 @@ void CompositorOperation::update_memory_buffer_partial(MemoryBuffer *UNUSED(outp
|
||||
}
|
||||
MemoryBuffer output_buf(m_outputBuffer, COM_DATA_TYPE_COLOR_CHANNELS, getWidth(), getHeight());
|
||||
output_buf.copy_from(inputs[0], area);
|
||||
if (this->m_useAlphaInput) {
|
||||
if (m_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());
|
||||
@@ -230,12 +230,12 @@ void CompositorOperation::update_memory_buffer_partial(MemoryBuffer *UNUSED(outp
|
||||
|
||||
void CompositorOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area)
|
||||
{
|
||||
int width = this->m_rd->xsch * this->m_rd->size / 100;
|
||||
int height = this->m_rd->ysch * this->m_rd->size / 100;
|
||||
int width = m_rd->xsch * m_rd->size / 100;
|
||||
int height = m_rd->ysch * m_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(this->m_scene);
|
||||
Render *re = RE_GetSceneRender(m_scene);
|
||||
if (re) {
|
||||
RenderResult *rr = RE_AcquireResultRead(re);
|
||||
if (rr) {
|
||||
|
||||
@@ -84,7 +84,7 @@ class CompositorOperation : public MultiThreadedOperation {
|
||||
CompositorOperation();
|
||||
bool isActiveCompositorOutput() const
|
||||
{
|
||||
return this->m_active;
|
||||
return m_active;
|
||||
}
|
||||
void executeRegion(rcti *rect, unsigned int tileNumber) override;
|
||||
void setScene(const struct Scene *scene)
|
||||
@@ -93,15 +93,15 @@ class CompositorOperation : public MultiThreadedOperation {
|
||||
}
|
||||
void setSceneName(const char *sceneName)
|
||||
{
|
||||
BLI_strncpy(this->m_sceneName, sceneName, sizeof(this->m_sceneName));
|
||||
BLI_strncpy(m_sceneName, sceneName, sizeof(m_sceneName));
|
||||
}
|
||||
void setViewName(const char *viewName)
|
||||
{
|
||||
this->m_viewName = viewName;
|
||||
m_viewName = viewName;
|
||||
}
|
||||
void setRenderData(const RenderData *rd)
|
||||
{
|
||||
this->m_rd = rd;
|
||||
m_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)
|
||||
{
|
||||
this->m_useAlphaInput = value;
|
||||
m_useAlphaInput = value;
|
||||
}
|
||||
void setActive(bool active)
|
||||
{
|
||||
this->m_active = active;
|
||||
m_active = active;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,13 +26,13 @@ ConvertColorProfileOperation::ConvertColorProfileOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_predivided = false;
|
||||
m_inputOperation = nullptr;
|
||||
m_predivided = false;
|
||||
}
|
||||
|
||||
void ConvertColorProfileOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void ConvertColorProfileOperation::executePixelSampled(float output[4],
|
||||
@@ -41,14 +41,14 @@ void ConvertColorProfileOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float color[4];
|
||||
this->m_inputOperation->readSampled(color, x, y, sampler);
|
||||
m_inputOperation->readSampled(color, x, y, sampler);
|
||||
IMB_buffer_float_from_float(
|
||||
output, color, 4, this->m_toProfile, this->m_fromProfile, this->m_predivided, 1, 1, 0, 0);
|
||||
output, color, 4, m_toProfile, m_fromProfile, m_predivided, 1, 1, 0, 0);
|
||||
}
|
||||
|
||||
void ConvertColorProfileOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -71,15 +71,15 @@ class ConvertColorProfileOperation : public NodeOperation {
|
||||
|
||||
void setFromColorProfile(int colorProfile)
|
||||
{
|
||||
this->m_fromProfile = colorProfile;
|
||||
m_fromProfile = colorProfile;
|
||||
}
|
||||
void setToColorProfile(int colorProfile)
|
||||
{
|
||||
this->m_toProfile = colorProfile;
|
||||
m_toProfile = colorProfile;
|
||||
}
|
||||
void setPredivided(bool predivided)
|
||||
{
|
||||
this->m_predivided = predivided;
|
||||
m_predivided = predivided;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,19 +26,19 @@ ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_fStop = 128.0f;
|
||||
this->m_cameraObject = nullptr;
|
||||
this->m_maxRadius = 32.0f;
|
||||
this->m_blurPostOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
m_fStop = 128.0f;
|
||||
m_cameraObject = nullptr;
|
||||
m_maxRadius = 32.0f;
|
||||
m_blurPostOperation = nullptr;
|
||||
}
|
||||
|
||||
float ConvertDepthToRadiusOperation::determineFocalDistance()
|
||||
{
|
||||
if (this->m_cameraObject && this->m_cameraObject->type == OB_CAMERA) {
|
||||
Camera *camera = (Camera *)this->m_cameraObject->data;
|
||||
this->m_cam_lens = camera->lens;
|
||||
return BKE_camera_object_dof_distance(this->m_cameraObject);
|
||||
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);
|
||||
}
|
||||
|
||||
return 10.0f;
|
||||
@@ -49,28 +49,27 @@ void ConvertDepthToRadiusOperation::initExecution()
|
||||
float cam_sensor = DEFAULT_SENSOR_WIDTH;
|
||||
Camera *camera = nullptr;
|
||||
|
||||
if (this->m_cameraObject && this->m_cameraObject->type == OB_CAMERA) {
|
||||
camera = (Camera *)this->m_cameraObject->data;
|
||||
if (m_cameraObject && m_cameraObject->type == OB_CAMERA) {
|
||||
camera = (Camera *)m_cameraObject->data;
|
||||
cam_sensor = BKE_camera_sensor_size(camera->sensor_fit, camera->sensor_x, camera->sensor_y);
|
||||
}
|
||||
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
m_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. */
|
||||
}
|
||||
this->m_inverseFocalDistance = 1.0f / focalDistance;
|
||||
this->m_aspect = (this->getWidth() > this->getHeight()) ?
|
||||
(this->getHeight() / (float)this->getWidth()) :
|
||||
(this->getWidth() / (float)this->getHeight());
|
||||
this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * cam_sensor)) / this->m_fStop;
|
||||
m_inverseFocalDistance = 1.0f / focalDistance;
|
||||
m_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;
|
||||
const float minsz = MIN2(getWidth(), getHeight());
|
||||
this->m_dof_sp =
|
||||
minsz / ((cam_sensor / 2.0f) /
|
||||
this->m_cam_lens); /* <- == `aspect * MIN2(img->x, img->y) / tan(0.5f * fov)` */
|
||||
m_dof_sp = minsz / ((cam_sensor / 2.0f) /
|
||||
m_cam_lens); /* <- == `aspect * MIN2(img->x, img->y) / tan(0.5f * fov)` */
|
||||
|
||||
if (this->m_blurPostOperation) {
|
||||
m_blurPostOperation->setSigma(MIN2(m_aperture * 128.0f, this->m_maxRadius));
|
||||
if (m_blurPostOperation) {
|
||||
m_blurPostOperation->setSigma(MIN2(m_aperture * 128.0f, m_maxRadius));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +81,7 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
|
||||
float inputValue[4];
|
||||
float z;
|
||||
float radius;
|
||||
this->m_inputOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputOperation->readSampled(inputValue, x, y, sampler);
|
||||
z = inputValue[0];
|
||||
if (z != 0.0f) {
|
||||
float iZ = (1.0f / z);
|
||||
@@ -93,15 +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(this->m_aperture *
|
||||
(this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.0f));
|
||||
radius = 0.5f * fabsf(m_aperture * (m_dof_sp * (m_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 > this->m_maxRadius) {
|
||||
radius = this->m_maxRadius;
|
||||
if (radius > m_maxRadius) {
|
||||
radius = m_maxRadius;
|
||||
}
|
||||
output[0] = radius;
|
||||
}
|
||||
@@ -112,7 +110,7 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
|
||||
|
||||
void ConvertDepthToRadiusOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
|
||||
void ConvertDepthToRadiusOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -68,20 +68,20 @@ class ConvertDepthToRadiusOperation : public MultiThreadedOperation {
|
||||
|
||||
void setfStop(float fStop)
|
||||
{
|
||||
this->m_fStop = fStop;
|
||||
m_fStop = fStop;
|
||||
}
|
||||
void setMaxRadius(float maxRadius)
|
||||
{
|
||||
this->m_maxRadius = maxRadius;
|
||||
m_maxRadius = maxRadius;
|
||||
}
|
||||
void setCameraObject(Object *camera)
|
||||
{
|
||||
this->m_cameraObject = camera;
|
||||
m_cameraObject = camera;
|
||||
}
|
||||
float determineFocalDistance();
|
||||
void setPostBlur(FastGaussianBlurValueOperation *operation)
|
||||
{
|
||||
this->m_blurPostOperation = operation;
|
||||
m_blurPostOperation = operation;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,18 +26,18 @@ namespace blender::compositor {
|
||||
|
||||
ConvertBaseOperation::ConvertBaseOperation()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ConvertBaseOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void ConvertBaseOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
|
||||
void ConvertBaseOperation::hash_output_params()
|
||||
@@ -66,7 +66,7 @@ void ConvertValueToColorOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float value;
|
||||
this->m_inputOperation->readSampled(&value, x, y, sampler);
|
||||
m_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];
|
||||
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_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];
|
||||
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_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];
|
||||
this->m_inputOperation->readSampled(color, x, y, sampler);
|
||||
m_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;
|
||||
this->m_inputOperation->readSampled(&value, x, y, sampler);
|
||||
m_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)
|
||||
{
|
||||
this->m_inputOperation->readSampled(output, x, y, sampler);
|
||||
m_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];
|
||||
this->m_inputOperation->readSampled(input, x, y, sampler);
|
||||
m_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:
|
||||
this->m_mode = BLI_YCC_ITU_BT601;
|
||||
m_mode = BLI_YCC_ITU_BT601;
|
||||
break;
|
||||
case 2:
|
||||
this->m_mode = BLI_YCC_JFIF_0_255;
|
||||
m_mode = BLI_YCC_JFIF_0_255;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
this->m_mode = BLI_YCC_ITU_BT709;
|
||||
m_mode = BLI_YCC_ITU_BT709;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -263,9 +263,9 @@ void ConvertRGBToYCCOperation::executePixelSampled(float output[4],
|
||||
float inputColor[4];
|
||||
float color[3];
|
||||
|
||||
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
rgb_to_ycc(
|
||||
inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode);
|
||||
inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], m_mode);
|
||||
|
||||
/* divided by 255 to normalize for viewing in */
|
||||
/* R,G,B --> Y,Cb,Cr */
|
||||
@@ -283,7 +283,7 @@ void ConvertRGBToYCCOperation::update_memory_buffer_partial(BuffersIterator<floa
|
||||
{
|
||||
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], this->m_mode);
|
||||
rgb_to_ycc(in[0], in[1], in[2], &it.out[0], &it.out[1], &it.out[2], m_mode);
|
||||
|
||||
/* Normalize for viewing (#rgb_to_ycc returns 0-255 values). */
|
||||
mul_v3_fl(it.out, 1.0f / 255.0f);
|
||||
@@ -303,14 +303,14 @@ void ConvertYCCToRGBOperation::setMode(int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case 0:
|
||||
this->m_mode = BLI_YCC_ITU_BT601;
|
||||
m_mode = BLI_YCC_ITU_BT601;
|
||||
break;
|
||||
case 2:
|
||||
this->m_mode = BLI_YCC_JFIF_0_255;
|
||||
m_mode = BLI_YCC_JFIF_0_255;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
this->m_mode = BLI_YCC_ITU_BT709;
|
||||
m_mode = BLI_YCC_ITU_BT709;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ void ConvertYCCToRGBOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
|
||||
/* need to un-normalize the data */
|
||||
/* R,G,B --> Y,Cb,Cr */
|
||||
@@ -333,7 +333,7 @@ void ConvertYCCToRGBOperation::executePixelSampled(float output[4],
|
||||
&output[0],
|
||||
&output[1],
|
||||
&output[2],
|
||||
this->m_mode);
|
||||
m_mode);
|
||||
output[3] = inputColor[3];
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ void ConvertYCCToRGBOperation::update_memory_buffer_partial(BuffersIterator<floa
|
||||
&it.out[0],
|
||||
&it.out[1],
|
||||
&it.out[2],
|
||||
this->m_mode);
|
||||
m_mode);
|
||||
it.out[3] = in[3];
|
||||
}
|
||||
}
|
||||
@@ -373,7 +373,7 @@ void ConvertRGBToYUVOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
rgb_to_yuv(inputColor[0],
|
||||
inputColor[1],
|
||||
inputColor[2],
|
||||
@@ -407,7 +407,7 @@ void ConvertYUVToRGBOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
yuv_to_rgb(inputColor[0],
|
||||
inputColor[1],
|
||||
inputColor[2],
|
||||
@@ -441,7 +441,7 @@ void ConvertRGBToHSVOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
rgb_to_hsv_v(inputColor, output);
|
||||
output[3] = inputColor[3];
|
||||
}
|
||||
@@ -469,7 +469,7 @@ void ConvertHSVToRGBOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
|
||||
m_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 +503,7 @@ void ConvertPremulToStraightOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
ColorSceneLinear4f<eAlpha::Premultiplied> input;
|
||||
this->m_inputOperation->readSampled(input, x, y, sampler);
|
||||
m_inputOperation->readSampled(input, x, y, sampler);
|
||||
ColorSceneLinear4f<eAlpha::Straight> converted = input.unpremultiply_alpha();
|
||||
copy_v4_v4(output, converted);
|
||||
}
|
||||
@@ -529,7 +529,7 @@ void ConvertStraightToPremulOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
ColorSceneLinear4f<eAlpha::Straight> input;
|
||||
this->m_inputOperation->readSampled(input, x, y, sampler);
|
||||
m_inputOperation->readSampled(input, x, y, sampler);
|
||||
ColorSceneLinear4f<eAlpha::Premultiplied> converted = input.premultiply_alpha();
|
||||
copy_v4_v4(output, converted);
|
||||
}
|
||||
@@ -547,16 +547,16 @@ SeparateChannelOperation::SeparateChannelOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
void SeparateChannelOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void SeparateChannelOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
|
||||
void SeparateChannelOperation::executePixelSampled(float output[4],
|
||||
@@ -565,8 +565,8 @@ void SeparateChannelOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float input[4];
|
||||
this->m_inputOperation->readSampled(input, x, y, sampler);
|
||||
output[0] = input[this->m_channel];
|
||||
m_inputOperation->readSampled(input, x, y, sampler);
|
||||
output[0] = input[m_channel];
|
||||
}
|
||||
|
||||
void SeparateChannelOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -574,7 +574,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)[this->m_channel];
|
||||
it.out[0] = it.in(0)[m_channel];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,26 +588,26 @@ CombineChannelsOperation::CombineChannelsOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->set_canvas_input_index(0);
|
||||
this->m_inputChannel1Operation = nullptr;
|
||||
this->m_inputChannel2Operation = nullptr;
|
||||
this->m_inputChannel3Operation = nullptr;
|
||||
this->m_inputChannel4Operation = nullptr;
|
||||
m_inputChannel1Operation = nullptr;
|
||||
m_inputChannel2Operation = nullptr;
|
||||
m_inputChannel3Operation = nullptr;
|
||||
m_inputChannel4Operation = nullptr;
|
||||
}
|
||||
|
||||
void CombineChannelsOperation::initExecution()
|
||||
{
|
||||
this->m_inputChannel1Operation = this->getInputSocketReader(0);
|
||||
this->m_inputChannel2Operation = this->getInputSocketReader(1);
|
||||
this->m_inputChannel3Operation = this->getInputSocketReader(2);
|
||||
this->m_inputChannel4Operation = this->getInputSocketReader(3);
|
||||
m_inputChannel1Operation = this->getInputSocketReader(0);
|
||||
m_inputChannel2Operation = this->getInputSocketReader(1);
|
||||
m_inputChannel3Operation = this->getInputSocketReader(2);
|
||||
m_inputChannel4Operation = this->getInputSocketReader(3);
|
||||
}
|
||||
|
||||
void CombineChannelsOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputChannel1Operation = nullptr;
|
||||
this->m_inputChannel2Operation = nullptr;
|
||||
this->m_inputChannel3Operation = nullptr;
|
||||
this->m_inputChannel4Operation = nullptr;
|
||||
m_inputChannel1Operation = nullptr;
|
||||
m_inputChannel2Operation = nullptr;
|
||||
m_inputChannel3Operation = nullptr;
|
||||
m_inputChannel4Operation = nullptr;
|
||||
}
|
||||
|
||||
void CombineChannelsOperation::executePixelSampled(float output[4],
|
||||
@@ -616,20 +616,20 @@ void CombineChannelsOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float input[4];
|
||||
if (this->m_inputChannel1Operation) {
|
||||
this->m_inputChannel1Operation->readSampled(input, x, y, sampler);
|
||||
if (m_inputChannel1Operation) {
|
||||
m_inputChannel1Operation->readSampled(input, x, y, sampler);
|
||||
output[0] = input[0];
|
||||
}
|
||||
if (this->m_inputChannel2Operation) {
|
||||
this->m_inputChannel2Operation->readSampled(input, x, y, sampler);
|
||||
if (m_inputChannel2Operation) {
|
||||
m_inputChannel2Operation->readSampled(input, x, y, sampler);
|
||||
output[1] = input[0];
|
||||
}
|
||||
if (this->m_inputChannel3Operation) {
|
||||
this->m_inputChannel3Operation->readSampled(input, x, y, sampler);
|
||||
if (m_inputChannel3Operation) {
|
||||
m_inputChannel3Operation->readSampled(input, x, y, sampler);
|
||||
output[2] = input[0];
|
||||
}
|
||||
if (this->m_inputChannel4Operation) {
|
||||
this->m_inputChannel4Operation->readSampled(input, x, y, sampler);
|
||||
if (m_inputChannel4Operation) {
|
||||
m_inputChannel4Operation->readSampled(input, x, y, sampler);
|
||||
output[3] = input[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ class SeparateChannelOperation : public MultiThreadedOperation {
|
||||
|
||||
void setChannel(int channel)
|
||||
{
|
||||
this->m_channel = channel;
|
||||
m_channel = channel;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -38,44 +38,44 @@ void ConvolutionEdgeFilterOperation::executePixel(float output[4], int x, int y,
|
||||
CLAMP(y3, 0, getHeight() - 1);
|
||||
|
||||
float value[4];
|
||||
this->m_inputValueOperation->read(value, x2, y2, nullptr);
|
||||
m_inputValueOperation->read(value, x2, y2, nullptr);
|
||||
float mval = 1.0f - value[0];
|
||||
|
||||
this->m_inputOperation->read(in1, x1, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, this->m_filter[0]);
|
||||
madd_v3_v3fl(res2, in1, this->m_filter[0]);
|
||||
m_inputOperation->read(in1, x1, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[0]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[0]);
|
||||
|
||||
this->m_inputOperation->read(in1, x2, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, this->m_filter[1]);
|
||||
madd_v3_v3fl(res2, in1, this->m_filter[3]);
|
||||
m_inputOperation->read(in1, x2, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[1]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[3]);
|
||||
|
||||
this->m_inputOperation->read(in1, x3, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, this->m_filter[2]);
|
||||
madd_v3_v3fl(res2, in1, this->m_filter[6]);
|
||||
m_inputOperation->read(in1, x3, y1, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[2]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[6]);
|
||||
|
||||
this->m_inputOperation->read(in1, x1, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in1, this->m_filter[3]);
|
||||
madd_v3_v3fl(res2, in1, this->m_filter[1]);
|
||||
m_inputOperation->read(in1, x1, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[3]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[1]);
|
||||
|
||||
this->m_inputOperation->read(in2, x2, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in2, this->m_filter[4]);
|
||||
madd_v3_v3fl(res2, in2, this->m_filter[4]);
|
||||
m_inputOperation->read(in2, x2, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in2, m_filter[4]);
|
||||
madd_v3_v3fl(res2, in2, m_filter[4]);
|
||||
|
||||
this->m_inputOperation->read(in1, x3, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in1, this->m_filter[5]);
|
||||
madd_v3_v3fl(res2, in1, this->m_filter[7]);
|
||||
m_inputOperation->read(in1, x3, y2, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[5]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[7]);
|
||||
|
||||
this->m_inputOperation->read(in1, x1, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, this->m_filter[6]);
|
||||
madd_v3_v3fl(res2, in1, this->m_filter[2]);
|
||||
m_inputOperation->read(in1, x1, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[6]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[2]);
|
||||
|
||||
this->m_inputOperation->read(in1, x2, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, this->m_filter[7]);
|
||||
madd_v3_v3fl(res2, in1, this->m_filter[5]);
|
||||
m_inputOperation->read(in1, x2, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[7]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[5]);
|
||||
|
||||
this->m_inputOperation->read(in1, x3, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, this->m_filter[8]);
|
||||
madd_v3_v3fl(res2, in1, this->m_filter[8]);
|
||||
m_inputOperation->read(in1, x3, y3, nullptr);
|
||||
madd_v3_v3fl(res1, in1, m_filter[8]);
|
||||
madd_v3_v3fl(res2, in1, m_filter[8]);
|
||||
|
||||
output[0] = sqrt(res1[0] * res1[0] + res2[0] * res2[0]);
|
||||
output[1] = sqrt(res1[1] * res1[1] + res2[1] * res2[1]);
|
||||
|
||||
@@ -26,35 +26,35 @@ ConvolutionFilterOperation::ConvolutionFilterOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->set_canvas_input_index(0);
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
void ConvolutionFilterOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
this->m_inputValueOperation = this->getInputSocketReader(1);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
m_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)
|
||||
{
|
||||
this->m_filter[0] = f1;
|
||||
this->m_filter[1] = f2;
|
||||
this->m_filter[2] = f3;
|
||||
this->m_filter[3] = f4;
|
||||
this->m_filter[4] = f5;
|
||||
this->m_filter[5] = f6;
|
||||
this->m_filter[6] = f7;
|
||||
this->m_filter[7] = f8;
|
||||
this->m_filter[8] = f9;
|
||||
this->m_filterHeight = 3;
|
||||
this->m_filterWidth = 3;
|
||||
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;
|
||||
}
|
||||
|
||||
void ConvolutionFilterOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_inputValueOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
m_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];
|
||||
this->m_inputValueOperation->read(value, x2, y2, nullptr);
|
||||
m_inputValueOperation->read(value, x2, y2, nullptr);
|
||||
const float mval = 1.0f - value[0];
|
||||
|
||||
zero_v4(output);
|
||||
this->m_inputOperation->read(in1, x1, y1, nullptr);
|
||||
madd_v4_v4fl(output, in1, this->m_filter[0]);
|
||||
this->m_inputOperation->read(in1, x2, y1, nullptr);
|
||||
madd_v4_v4fl(output, in1, this->m_filter[1]);
|
||||
this->m_inputOperation->read(in1, x3, y1, nullptr);
|
||||
madd_v4_v4fl(output, in1, this->m_filter[2]);
|
||||
this->m_inputOperation->read(in1, x1, y2, nullptr);
|
||||
madd_v4_v4fl(output, in1, this->m_filter[3]);
|
||||
this->m_inputOperation->read(in2, x2, y2, nullptr);
|
||||
madd_v4_v4fl(output, in2, this->m_filter[4]);
|
||||
this->m_inputOperation->read(in1, x3, y2, nullptr);
|
||||
madd_v4_v4fl(output, in1, this->m_filter[5]);
|
||||
this->m_inputOperation->read(in1, x1, y3, nullptr);
|
||||
madd_v4_v4fl(output, in1, this->m_filter[6]);
|
||||
this->m_inputOperation->read(in1, x2, y3, nullptr);
|
||||
madd_v4_v4fl(output, in1, this->m_filter[7]);
|
||||
this->m_inputOperation->read(in1, x3, y3, nullptr);
|
||||
madd_v4_v4fl(output, in1, this->m_filter[8]);
|
||||
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]);
|
||||
|
||||
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 = (this->m_filterWidth - 1) / 2 + 1;
|
||||
int addy = (this->m_filterHeight - 1) / 2 + 1;
|
||||
int addx = (m_filterWidth - 1) / 2 + 1;
|
||||
int addy = (m_filterHeight - 1) / 2 + 1;
|
||||
newInput.xmax = input->xmax + addx;
|
||||
newInput.xmin = input->xmin - addx;
|
||||
newInput.ymax = input->ymax + addy;
|
||||
|
||||
@@ -24,8 +24,8 @@ CropBaseOperation::CropBaseOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color, ResizeMode::Align);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_settings = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
m_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 = *this->m_settings;
|
||||
NodeTwoXYs local_settings = *m_settings;
|
||||
|
||||
if (width > 0.0f && height > 0.0f) {
|
||||
if (this->m_relative) {
|
||||
if (m_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;
|
||||
}
|
||||
|
||||
this->m_xmax = MAX2(local_settings.x1, local_settings.x2) + 1;
|
||||
this->m_xmin = MIN2(local_settings.x1, local_settings.x2);
|
||||
this->m_ymax = MAX2(local_settings.y1, local_settings.y2) + 1;
|
||||
this->m_ymin = MIN2(local_settings.y1, local_settings.y2);
|
||||
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);
|
||||
}
|
||||
else {
|
||||
this->m_xmax = 0;
|
||||
this->m_xmin = 0;
|
||||
this->m_ymax = 0;
|
||||
this->m_ymin = 0;
|
||||
m_xmax = 0;
|
||||
m_xmin = 0;
|
||||
m_ymax = 0;
|
||||
m_ymin = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CropBaseOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
updateArea();
|
||||
}
|
||||
|
||||
void CropBaseOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_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 < this->m_xmax && x >= this->m_xmin) && (y < this->m_ymax && y >= this->m_ymin)) {
|
||||
this->m_inputOperation->readSampled(output, x, y, sampler);
|
||||
if ((x < m_xmax && x >= m_xmin) && (y < m_ymax && y >= m_ymin)) {
|
||||
m_inputOperation->readSampled(output, x, y, sampler);
|
||||
}
|
||||
else {
|
||||
zero_v4(output);
|
||||
@@ -121,10 +121,10 @@ bool CropImageOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
newInput.xmax = input->xmax + this->m_xmin;
|
||||
newInput.xmin = input->xmin + this->m_xmin;
|
||||
newInput.ymax = input->ymax + this->m_ymin;
|
||||
newInput.ymin = input->ymin + this->m_ymin;
|
||||
newInput.xmax = input->xmax + m_xmin;
|
||||
newInput.xmin = input->xmin + m_xmin;
|
||||
newInput.ymax = input->ymax + m_ymin;
|
||||
newInput.ymin = input->ymin + m_ymin;
|
||||
|
||||
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
|
||||
}
|
||||
@@ -135,10 +135,10 @@ 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 + this->m_xmin;
|
||||
r_input_area.xmin = output_area.xmin + this->m_xmin;
|
||||
r_input_area.ymax = output_area.ymax + this->m_ymin;
|
||||
r_input_area.ymin = output_area.ymin + this->m_ymin;
|
||||
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;
|
||||
}
|
||||
|
||||
void CropImageOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
@@ -155,7 +155,7 @@ void CropImageOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
|
||||
this->m_inputOperation->readSampled(output, (x + this->m_xmin), (y + this->m_ymin), sampler);
|
||||
m_inputOperation->readSampled(output, (x + m_xmin), (y + m_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 + this->m_xmin, it.y + this->m_ymin, it.out);
|
||||
input->read_elem_checked(it.x + m_xmin, it.y + m_ymin, it.out);
|
||||
}
|
||||
else {
|
||||
zero_v4(it.out);
|
||||
|
||||
@@ -40,11 +40,11 @@ class CropBaseOperation : public MultiThreadedOperation {
|
||||
void deinitExecution() override;
|
||||
void setCropSettings(NodeTwoXYs *settings)
|
||||
{
|
||||
this->m_settings = settings;
|
||||
m_settings = settings;
|
||||
}
|
||||
void setRelative(bool rel)
|
||||
{
|
||||
this->m_relative = rel;
|
||||
m_relative = rel;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -24,37 +24,37 @@ namespace blender::compositor {
|
||||
|
||||
CurveBaseOperation::CurveBaseOperation()
|
||||
{
|
||||
this->m_curveMapping = nullptr;
|
||||
m_curveMapping = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
CurveBaseOperation::~CurveBaseOperation()
|
||||
{
|
||||
if (this->m_curveMapping) {
|
||||
BKE_curvemapping_free(this->m_curveMapping);
|
||||
this->m_curveMapping = nullptr;
|
||||
if (m_curveMapping) {
|
||||
BKE_curvemapping_free(m_curveMapping);
|
||||
m_curveMapping = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CurveBaseOperation::initExecution()
|
||||
{
|
||||
BKE_curvemapping_init(this->m_curveMapping);
|
||||
BKE_curvemapping_init(m_curveMapping);
|
||||
}
|
||||
void CurveBaseOperation::deinitExecution()
|
||||
{
|
||||
if (this->m_curveMapping) {
|
||||
BKE_curvemapping_free(this->m_curveMapping);
|
||||
this->m_curveMapping = nullptr;
|
||||
if (m_curveMapping) {
|
||||
BKE_curvemapping_free(m_curveMapping);
|
||||
m_curveMapping = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CurveBaseOperation::setCurveMapping(CurveMapping *mapping)
|
||||
{
|
||||
/* duplicate the curve to avoid glitches while drawing, see bug T32374. */
|
||||
if (this->m_curveMapping) {
|
||||
BKE_curvemapping_free(this->m_curveMapping);
|
||||
if (m_curveMapping) {
|
||||
BKE_curvemapping_free(m_curveMapping);
|
||||
}
|
||||
this->m_curveMapping = BKE_curvemapping_copy(mapping);
|
||||
m_curveMapping = BKE_curvemapping_copy(mapping);
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -160,21 +160,21 @@ DenoiseOperation::DenoiseOperation()
|
||||
this->addInputSocket(DataType::Vector);
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_settings = nullptr;
|
||||
m_settings = nullptr;
|
||||
}
|
||||
void DenoiseOperation::initExecution()
|
||||
{
|
||||
SingleThreadedOperation::initExecution();
|
||||
this->m_inputProgramColor = getInputSocketReader(0);
|
||||
this->m_inputProgramNormal = getInputSocketReader(1);
|
||||
this->m_inputProgramAlbedo = getInputSocketReader(2);
|
||||
m_inputProgramColor = getInputSocketReader(0);
|
||||
m_inputProgramNormal = getInputSocketReader(1);
|
||||
m_inputProgramAlbedo = getInputSocketReader(2);
|
||||
}
|
||||
|
||||
void DenoiseOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgramColor = nullptr;
|
||||
this->m_inputProgramNormal = nullptr;
|
||||
this->m_inputProgramAlbedo = nullptr;
|
||||
m_inputProgramColor = nullptr;
|
||||
m_inputProgramNormal = nullptr;
|
||||
m_inputProgramAlbedo = nullptr;
|
||||
SingleThreadedOperation::deinitExecution();
|
||||
}
|
||||
|
||||
@@ -199,16 +199,16 @@ void DenoiseOperation::hash_output_params()
|
||||
|
||||
MemoryBuffer *DenoiseOperation::createMemoryBuffer(rcti *rect2)
|
||||
{
|
||||
MemoryBuffer *tileColor = (MemoryBuffer *)this->m_inputProgramColor->initializeTileData(rect2);
|
||||
MemoryBuffer *tileNormal = (MemoryBuffer *)this->m_inputProgramNormal->initializeTileData(rect2);
|
||||
MemoryBuffer *tileAlbedo = (MemoryBuffer *)this->m_inputProgramAlbedo->initializeTileData(rect2);
|
||||
MemoryBuffer *tileColor = (MemoryBuffer *)m_inputProgramColor->initializeTileData(rect2);
|
||||
MemoryBuffer *tileNormal = (MemoryBuffer *)m_inputProgramNormal->initializeTileData(rect2);
|
||||
MemoryBuffer *tileAlbedo = (MemoryBuffer *)m_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, this->m_settings);
|
||||
this->generateDenoise(result, tileColor, tileNormal, tileAlbedo, m_settings);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class DenoiseOperation : public DenoiseBaseOperation {
|
||||
|
||||
void setDenoiseSettings(NodeDenoise *settings)
|
||||
{
|
||||
this->m_settings = settings;
|
||||
m_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);
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
void DespeckleOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
this->m_inputValueOperation = this->getInputSocketReader(1);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputValueOperation = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void DespeckleOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_inputValueOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
m_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];
|
||||
this->m_inputValueOperation->read(value, x2, y2, nullptr);
|
||||
m_inputValueOperation->read(value, x2, y2, nullptr);
|
||||
// const float mval = 1.0f - value[0];
|
||||
|
||||
this->m_inputOperation->read(color_org, x2, y2, nullptr);
|
||||
m_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, this->m_threshold)) { \
|
||||
if (color_diff(in1, color_org, m_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);
|
||||
|
||||
this->m_inputOperation->read(in1, x1, y1, nullptr);
|
||||
m_inputOperation->read(in1, x1, y1, nullptr);
|
||||
COLOR_ADD(TOT_DIV_CNR)
|
||||
this->m_inputOperation->read(in1, x2, y1, nullptr);
|
||||
m_inputOperation->read(in1, x2, y1, nullptr);
|
||||
COLOR_ADD(TOT_DIV_ONE)
|
||||
this->m_inputOperation->read(in1, x3, y1, nullptr);
|
||||
m_inputOperation->read(in1, x3, y1, nullptr);
|
||||
COLOR_ADD(TOT_DIV_CNR)
|
||||
this->m_inputOperation->read(in1, x1, y2, nullptr);
|
||||
m_inputOperation->read(in1, x1, y2, nullptr);
|
||||
COLOR_ADD(TOT_DIV_ONE)
|
||||
|
||||
#if 0
|
||||
this->m_inputOperation->read(in2, x2, y2, nullptr);
|
||||
madd_v4_v4fl(color_mid, in2, this->m_filter[4]);
|
||||
m_inputOperation->read(in2, x2, y2, nullptr);
|
||||
madd_v4_v4fl(color_mid, in2, m_filter[4]);
|
||||
#endif
|
||||
|
||||
this->m_inputOperation->read(in1, x3, y2, nullptr);
|
||||
m_inputOperation->read(in1, x3, y2, nullptr);
|
||||
COLOR_ADD(TOT_DIV_ONE)
|
||||
this->m_inputOperation->read(in1, x1, y3, nullptr);
|
||||
m_inputOperation->read(in1, x1, y3, nullptr);
|
||||
COLOR_ADD(TOT_DIV_CNR)
|
||||
this->m_inputOperation->read(in1, x2, y3, nullptr);
|
||||
m_inputOperation->read(in1, x2, y3, nullptr);
|
||||
COLOR_ADD(TOT_DIV_ONE)
|
||||
this->m_inputOperation->read(in1, x3, y3, nullptr);
|
||||
m_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) > (this->m_threshold_neighbor)) &&
|
||||
color_diff(color_mid, color_org, this->m_threshold)) {
|
||||
if ((w != 0.0f) && ((w / WTOT) > (m_threshold_neighbor)) &&
|
||||
color_diff(color_mid, color_org, m_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; //(this->m_filterWidth - 1) / 2 + 1;
|
||||
int addy = 2; //(this->m_filterHeight - 1) / 2 + 1;
|
||||
int addx = 2; //(m_filterWidth - 1) / 2 + 1;
|
||||
int addy = 2; //(m_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; //(this->m_filterWidth - 1) / 2 + 1;
|
||||
const int add_y = 2; //(this->m_filterHeight - 1) / 2 + 1;
|
||||
const int add_x = 2; //(m_filterWidth - 1) / 2 + 1;
|
||||
const int add_y = 2; //(m_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;
|
||||
@@ -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, this->m_filter[4]);
|
||||
madd_v4_v4fl(color_mid, in2, m_filter[4]);
|
||||
#endif
|
||||
|
||||
in1 = image->get_elem(x3, y2);
|
||||
|
||||
@@ -46,11 +46,11 @@ class DespeckleOperation : public MultiThreadedOperation {
|
||||
|
||||
void setThreshold(float threshold)
|
||||
{
|
||||
this->m_threshold = threshold;
|
||||
m_threshold = threshold;
|
||||
}
|
||||
void setThresholdNeighbor(float threshold)
|
||||
{
|
||||
this->m_threshold_neighbor = threshold;
|
||||
m_threshold_neighbor = threshold;
|
||||
}
|
||||
|
||||
void initExecution() override;
|
||||
|
||||
@@ -26,20 +26,20 @@ DifferenceMatteOperation::DifferenceMatteOperation()
|
||||
addInputSocket(DataType::Color);
|
||||
addOutputSocket(DataType::Value);
|
||||
|
||||
this->m_inputImage1Program = nullptr;
|
||||
this->m_inputImage2Program = nullptr;
|
||||
m_inputImage1Program = nullptr;
|
||||
m_inputImage2Program = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void DifferenceMatteOperation::initExecution()
|
||||
{
|
||||
this->m_inputImage1Program = this->getInputSocketReader(0);
|
||||
this->m_inputImage2Program = this->getInputSocketReader(1);
|
||||
m_inputImage1Program = this->getInputSocketReader(0);
|
||||
m_inputImage2Program = this->getInputSocketReader(1);
|
||||
}
|
||||
void DifferenceMatteOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputImage1Program = nullptr;
|
||||
this->m_inputImage2Program = nullptr;
|
||||
m_inputImage1Program = nullptr;
|
||||
m_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 = this->m_settings->t1;
|
||||
const float falloff = this->m_settings->t2;
|
||||
const float tolerance = m_settings->t1;
|
||||
const float falloff = m_settings->t2;
|
||||
float difference;
|
||||
float alpha;
|
||||
|
||||
this->m_inputImage1Program->readSampled(inColor1, x, y, sampler);
|
||||
this->m_inputImage2Program->readSampled(inColor2, x, y, sampler);
|
||||
m_inputImage1Program->readSampled(inColor1, x, y, sampler);
|
||||
m_inputImage2Program->readSampled(inColor2, x, y, sampler);
|
||||
|
||||
difference = (fabsf(inColor2[0] - inColor1[0]) + fabsf(inColor2[1] - inColor1[1]) +
|
||||
fabsf(inColor2[2] - inColor1[2]));
|
||||
|
||||
@@ -48,7 +48,7 @@ class DifferenceMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma)
|
||||
{
|
||||
this->m_settings = nodeChroma;
|
||||
m_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;
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inset = 0.0f;
|
||||
this->m__switch = 0.5f;
|
||||
this->m_distance = 0.0f;
|
||||
m_inputProgram = nullptr;
|
||||
m_inset = 0.0f;
|
||||
m__switch = 0.5f;
|
||||
m_distance = 0.0f;
|
||||
}
|
||||
|
||||
void DilateErodeThresholdOperation::init_data()
|
||||
{
|
||||
if (this->m_distance < 0.0f) {
|
||||
this->m_scope = -this->m_distance + this->m_inset;
|
||||
if (m_distance < 0.0f) {
|
||||
m_scope = -m_distance + m_inset;
|
||||
}
|
||||
else {
|
||||
if (this->m_inset * 2 > this->m_distance) {
|
||||
this->m_scope = MAX2(this->m_inset * 2 - this->m_distance, this->m_distance);
|
||||
if (m_inset * 2 > m_distance) {
|
||||
m_scope = MAX2(m_inset * 2 - m_distance, m_distance);
|
||||
}
|
||||
else {
|
||||
this->m_scope = this->m_distance;
|
||||
m_scope = m_distance;
|
||||
}
|
||||
}
|
||||
if (this->m_scope < 3) {
|
||||
this->m_scope = 3;
|
||||
if (m_scope < 3) {
|
||||
m_scope = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void DilateErodeThresholdOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void *DilateErodeThresholdOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
void *buffer = this->m_inputProgram->initializeTileData(nullptr);
|
||||
void *buffer = m_inputProgram->initializeTileData(nullptr);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
float inputValue[4];
|
||||
const float sw = this->m__switch;
|
||||
const float distance = this->m_distance;
|
||||
const float sw = m__switch;
|
||||
const float distance = m_distance;
|
||||
float pixelvalue;
|
||||
const float rd = this->m_scope * this->m_scope;
|
||||
const float inset = this->m_inset;
|
||||
const float rd = m_scope * m_scope;
|
||||
const float inset = m_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 - this->m_scope, input_rect.xmin);
|
||||
const int miny = MAX2(y - this->m_scope, input_rect.ymin);
|
||||
const int maxx = MIN2(x + this->m_scope, input_rect.xmax);
|
||||
const int maxy = MIN2(y + this->m_scope, input_rect.ymax);
|
||||
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 bufferWidth = inputBuffer->getWidth();
|
||||
int offset;
|
||||
|
||||
@@ -146,7 +146,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
|
||||
|
||||
void DilateErodeThresholdOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(
|
||||
@@ -154,10 +154,10 @@ bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
newInput.xmax = input->xmax + this->m_scope;
|
||||
newInput.xmin = input->xmin - this->m_scope;
|
||||
newInput.ymax = input->ymax + this->m_scope;
|
||||
newInput.ymin = input->ymin - this->m_scope;
|
||||
newInput.xmax = input->xmax + m_scope;
|
||||
newInput.xmin = input->xmin - m_scope;
|
||||
newInput.ymax = input->ymax + m_scope;
|
||||
newInput.ymin = input->ymin - m_scope;
|
||||
|
||||
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
|
||||
}
|
||||
@@ -273,43 +273,43 @@ DilateDistanceOperation::DilateDistanceOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_distance = 0.0f;
|
||||
m_inputProgram = nullptr;
|
||||
m_distance = 0.0f;
|
||||
flags.complex = true;
|
||||
flags.open_cl = true;
|
||||
}
|
||||
|
||||
void DilateDistanceOperation::init_data()
|
||||
{
|
||||
this->m_scope = this->m_distance;
|
||||
if (this->m_scope < 3) {
|
||||
this->m_scope = 3;
|
||||
m_scope = m_distance;
|
||||
if (m_scope < 3) {
|
||||
m_scope = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void DilateDistanceOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void *DilateDistanceOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
void *buffer = this->m_inputProgram->initializeTileData(nullptr);
|
||||
void *buffer = m_inputProgram->initializeTileData(nullptr);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
const float distance = this->m_distance;
|
||||
const float distance = m_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 - this->m_scope, input_rect.xmin);
|
||||
const int miny = MAX2(y - this->m_scope, input_rect.ymin);
|
||||
const int maxx = MIN2(x + this->m_scope, input_rect.xmax);
|
||||
const int maxy = MIN2(y + this->m_scope, input_rect.ymax);
|
||||
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 bufferWidth = inputBuffer->getWidth();
|
||||
int offset;
|
||||
|
||||
@@ -332,7 +332,7 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *
|
||||
|
||||
void DilateDistanceOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -341,10 +341,10 @@ bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
newInput.xmax = input->xmax + this->m_scope;
|
||||
newInput.xmin = input->xmin - this->m_scope;
|
||||
newInput.ymax = input->ymax + this->m_scope;
|
||||
newInput.ymin = input->ymin - this->m_scope;
|
||||
newInput.xmax = input->xmax + m_scope;
|
||||
newInput.xmin = input->xmin - m_scope;
|
||||
newInput.ymax = input->ymax + m_scope;
|
||||
newInput.ymin = input->ymin - m_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 = this->m_distance * this->m_distance;
|
||||
cl_int scope = this->m_scope;
|
||||
cl_int distanceSquared = m_distance * m_distance;
|
||||
cl_int scope = m_scope;
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
|
||||
dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
device->COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer);
|
||||
device->COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer);
|
||||
clSetKernelArg(dilateKernel, 4, sizeof(cl_int), &scope);
|
||||
@@ -465,16 +465,16 @@ ErodeDistanceOperation::ErodeDistanceOperation() : DilateDistanceOperation()
|
||||
|
||||
void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
const float distance = this->m_distance;
|
||||
const float distance = m_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 - this->m_scope, input_rect.xmin);
|
||||
const int miny = MAX2(y - this->m_scope, input_rect.ymin);
|
||||
const int maxx = MIN2(x + this->m_scope, input_rect.xmax);
|
||||
const int maxy = MIN2(y + this->m_scope, input_rect.ymax);
|
||||
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 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 = this->m_distance * this->m_distance;
|
||||
cl_int scope = this->m_scope;
|
||||
cl_int distanceSquared = m_distance * m_distance;
|
||||
cl_int scope = m_scope;
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
|
||||
erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
device->COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer);
|
||||
device->COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer);
|
||||
clSetKernelArg(erodeKernel, 4, sizeof(cl_int), &scope);
|
||||
@@ -534,11 +534,11 @@ DilateStepOperation::DilateStepOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->flags.complex = true;
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
void DilateStepOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_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 *)this->m_inputProgram->initializeTileData(nullptr);
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_inputProgram->initializeTileData(nullptr);
|
||||
int x, y, i;
|
||||
int width = tile->getWidth();
|
||||
int height = tile->getHeight();
|
||||
float *buffer = tile->getBuffer();
|
||||
|
||||
int half_window = this->m_iterations;
|
||||
int half_window = m_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()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
void DilateStepOperation::deinitializeTileData(rcti * /*rect*/, void *data)
|
||||
@@ -676,7 +676,7 @@ bool DilateStepOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
rcti *output)
|
||||
{
|
||||
rcti newInput;
|
||||
int it = this->m_iterations;
|
||||
int it = m_iterations;
|
||||
newInput.xmax = input->xmax + it;
|
||||
newInput.xmin = input->xmin - it;
|
||||
newInput.ymax = input->ymax + it;
|
||||
@@ -814,13 +814,13 @@ ErodeStepOperation::ErodeStepOperation() : DilateStepOperation()
|
||||
|
||||
void *ErodeStepOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(nullptr);
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_inputProgram->initializeTileData(nullptr);
|
||||
int x, y, i;
|
||||
int width = tile->getWidth();
|
||||
int height = tile->getHeight();
|
||||
float *buffer = tile->getBuffer();
|
||||
|
||||
int half_window = this->m_iterations;
|
||||
int half_window = m_iterations;
|
||||
int window = half_window * 2 + 1;
|
||||
|
||||
int xmin = MAX2(0, rect->xmin - half_window);
|
||||
|
||||
@@ -64,15 +64,15 @@ class DilateErodeThresholdOperation : public MultiThreadedOperation {
|
||||
|
||||
void setDistance(float distance)
|
||||
{
|
||||
this->m_distance = distance;
|
||||
m_distance = distance;
|
||||
}
|
||||
void setSwitch(float sw)
|
||||
{
|
||||
this->m__switch = sw;
|
||||
m__switch = sw;
|
||||
}
|
||||
void setInset(float inset)
|
||||
{
|
||||
this->m_inset = inset;
|
||||
m_inset = inset;
|
||||
}
|
||||
|
||||
bool determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -119,7 +119,7 @@ class DilateDistanceOperation : public MultiThreadedOperation {
|
||||
|
||||
void setDistance(float distance)
|
||||
{
|
||||
this->m_distance = distance;
|
||||
m_distance = distance;
|
||||
}
|
||||
bool determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
@@ -190,7 +190,7 @@ class DilateStepOperation : public MultiThreadedOperation {
|
||||
|
||||
void setIterations(int iterations)
|
||||
{
|
||||
this->m_iterations = iterations;
|
||||
m_iterations = iterations;
|
||||
}
|
||||
|
||||
bool determineDependingAreaOfInterest(rcti *input,
|
||||
|
||||
@@ -27,20 +27,20 @@ DirectionalBlurOperation::DirectionalBlurOperation()
|
||||
this->addOutputSocket(DataType::Color);
|
||||
flags.complex = true;
|
||||
flags.open_cl = true;
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
void DirectionalBlurOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = getInputSocketReader(0);
|
||||
m_inputProgram = getInputSocketReader(0);
|
||||
QualityStepHelper::initExecution(COM_QH_INCREASE);
|
||||
const float angle = this->m_data->angle;
|
||||
const float zoom = this->m_data->zoom;
|
||||
const float spin = this->m_data->spin;
|
||||
const float iterations = this->m_data->iter;
|
||||
const float distance = this->m_data->distance;
|
||||
const float center_x = this->m_data->center_x;
|
||||
const float center_y = this->m_data->center_y;
|
||||
const float angle = m_data->angle;
|
||||
const float zoom = m_data->zoom;
|
||||
const float spin = m_data->spin;
|
||||
const float iterations = m_data->iter;
|
||||
const float distance = m_data->distance;
|
||||
const float center_x = m_data->center_x;
|
||||
const float center_y = m_data->center_y;
|
||||
const float width = getWidth();
|
||||
const float height = getHeight();
|
||||
|
||||
@@ -49,45 +49,45 @@ void DirectionalBlurOperation::initExecution()
|
||||
float D;
|
||||
|
||||
D = distance * sqrtf(width * width + height * height);
|
||||
this->m_center_x_pix = center_x * width;
|
||||
this->m_center_y_pix = center_y * height;
|
||||
m_center_x_pix = center_x * width;
|
||||
m_center_y_pix = center_y * height;
|
||||
|
||||
this->m_tx = itsc * D * cosf(a);
|
||||
this->m_ty = -itsc * D * sinf(a);
|
||||
this->m_sc = itsc * zoom;
|
||||
this->m_rot = itsc * spin;
|
||||
m_tx = itsc * D * cosf(a);
|
||||
m_ty = -itsc * D * sinf(a);
|
||||
m_sc = itsc * zoom;
|
||||
m_rot = itsc * spin;
|
||||
}
|
||||
|
||||
void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void * /*data*/)
|
||||
{
|
||||
const int iterations = pow(2.0f, this->m_data->iter);
|
||||
const int iterations = pow(2.0f, m_data->iter);
|
||||
float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
float col2[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
this->m_inputProgram->readSampled(col2, x, y, PixelSampler::Bilinear);
|
||||
float ltx = this->m_tx;
|
||||
float lty = this->m_ty;
|
||||
float lsc = this->m_sc;
|
||||
float lrot = this->m_rot;
|
||||
m_inputProgram->readSampled(col2, x, y, PixelSampler::Bilinear);
|
||||
float ltx = m_tx;
|
||||
float lty = m_ty;
|
||||
float lsc = m_sc;
|
||||
float lrot = m_rot;
|
||||
/* blur the image */
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
const float cs = cosf(lrot), ss = sinf(lrot);
|
||||
const float isc = 1.0f / (1.0f + lsc);
|
||||
|
||||
const float v = isc * (y - this->m_center_y_pix) + lty;
|
||||
const float u = isc * (x - this->m_center_x_pix) + ltx;
|
||||
const float v = isc * (y - m_center_y_pix) + lty;
|
||||
const float u = isc * (x - m_center_x_pix) + ltx;
|
||||
|
||||
this->m_inputProgram->readSampled(col,
|
||||
cs * u + ss * v + this->m_center_x_pix,
|
||||
cs * v - ss * u + this->m_center_y_pix,
|
||||
PixelSampler::Bilinear);
|
||||
m_inputProgram->readSampled(col,
|
||||
cs * u + ss * v + m_center_x_pix,
|
||||
cs * v - ss * u + m_center_y_pix,
|
||||
PixelSampler::Bilinear);
|
||||
|
||||
add_v4_v4(col2, col);
|
||||
|
||||
/* double transformations */
|
||||
ltx += this->m_tx;
|
||||
lty += this->m_ty;
|
||||
lrot += this->m_rot;
|
||||
lsc += this->m_sc;
|
||||
ltx += m_tx;
|
||||
lty += m_ty;
|
||||
lrot += m_rot;
|
||||
lsc += m_sc;
|
||||
}
|
||||
|
||||
mul_v4_v4fl(output, col2, 1.0f / (iterations + 1));
|
||||
@@ -102,14 +102,14 @@ void DirectionalBlurOperation::executeOpenCL(OpenCLDevice *device,
|
||||
{
|
||||
cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", nullptr);
|
||||
|
||||
cl_int iterations = pow(2.0f, this->m_data->iter);
|
||||
cl_float2 ltxy = {{this->m_tx, this->m_ty}};
|
||||
cl_float2 centerpix = {{this->m_center_x_pix, this->m_center_y_pix}};
|
||||
cl_float lsc = this->m_sc;
|
||||
cl_float lrot = this->m_rot;
|
||||
cl_int iterations = pow(2.0f, m_data->iter);
|
||||
cl_float2 ltxy = {{m_tx, m_ty}};
|
||||
cl_float2 centerpix = {{m_center_x_pix, m_center_y_pix}};
|
||||
cl_float lsc = m_sc;
|
||||
cl_float lrot = m_rot;
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
directionalBlurKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
|
||||
directionalBlurKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
device->COM_clAttachOutputMemoryBufferToKernelParameter(
|
||||
directionalBlurKernel, 1, clOutputBuffer);
|
||||
device->COM_clAttachMemoryBufferOffsetToKernelParameter(
|
||||
@@ -125,7 +125,7 @@ void DirectionalBlurOperation::executeOpenCL(OpenCLDevice *device,
|
||||
|
||||
void DirectionalBlurOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
bool DirectionalBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
@@ -156,7 +156,7 @@ void DirectionalBlurOperation::update_memory_buffer_partial(MemoryBuffer *output
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
const MemoryBuffer *input = inputs[0];
|
||||
const int iterations = pow(2.0f, this->m_data->iter);
|
||||
const int iterations = pow(2.0f, m_data->iter);
|
||||
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
|
||||
const int x = it.x;
|
||||
const int y = it.y;
|
||||
@@ -166,27 +166,27 @@ void DirectionalBlurOperation::update_memory_buffer_partial(MemoryBuffer *output
|
||||
/* Blur pixel. */
|
||||
/* TODO(manzanilla): Many values used on iterations can be calculated beforehand. Create a
|
||||
* table on operation initialization. */
|
||||
float ltx = this->m_tx;
|
||||
float lty = this->m_ty;
|
||||
float lsc = this->m_sc;
|
||||
float lrot = this->m_rot;
|
||||
float ltx = m_tx;
|
||||
float lty = m_ty;
|
||||
float lsc = m_sc;
|
||||
float lrot = m_rot;
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
const float cs = cosf(lrot), ss = sinf(lrot);
|
||||
const float isc = 1.0f / (1.0f + lsc);
|
||||
|
||||
const float v = isc * (y - this->m_center_y_pix) + lty;
|
||||
const float u = isc * (x - this->m_center_x_pix) + ltx;
|
||||
const float v = isc * (y - m_center_y_pix) + lty;
|
||||
const float u = isc * (x - m_center_x_pix) + ltx;
|
||||
|
||||
float color[4];
|
||||
input->read_elem_bilinear(
|
||||
cs * u + ss * v + this->m_center_x_pix, cs * v - ss * u + this->m_center_y_pix, color);
|
||||
cs * u + ss * v + m_center_x_pix, cs * v - ss * u + m_center_y_pix, color);
|
||||
add_v4_v4(color_accum, color);
|
||||
|
||||
/* Double transformations. */
|
||||
ltx += this->m_tx;
|
||||
lty += this->m_ty;
|
||||
lrot += this->m_rot;
|
||||
lsc += this->m_sc;
|
||||
ltx += m_tx;
|
||||
lty += m_ty;
|
||||
lrot += m_rot;
|
||||
lsc += m_sc;
|
||||
}
|
||||
|
||||
mul_v4_v4fl(it.out, color_accum, 1.0f / (iterations + 1));
|
||||
|
||||
@@ -56,7 +56,7 @@ class DirectionalBlurOperation : public MultiThreadedOperation, public QualitySt
|
||||
|
||||
void setData(NodeDBlurData *data)
|
||||
{
|
||||
this->m_data = data;
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
void executeOpenCL(OpenCLDevice *device,
|
||||
|
||||
@@ -29,12 +29,12 @@ DisplaceOperation::DisplaceOperation()
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
|
||||
this->m_inputColorProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
}
|
||||
|
||||
void DisplaceOperation::initExecution()
|
||||
{
|
||||
this->m_inputColorProgram = this->getInputSocketReader(0);
|
||||
m_inputColorProgram = this->getInputSocketReader(0);
|
||||
NodeOperation *vector = this->getInputSocketReader(1);
|
||||
NodeOperation *scale_x = this->getInputSocketReader(2);
|
||||
NodeOperation *scale_y = this->getInputSocketReader(3);
|
||||
@@ -50,8 +50,8 @@ void DisplaceOperation::initExecution()
|
||||
};
|
||||
}
|
||||
|
||||
this->m_width_x4 = this->getWidth() * 4;
|
||||
this->m_height_x4 = this->getHeight() * 4;
|
||||
m_width_x4 = this->getWidth() * 4;
|
||||
m_height_x4 = this->getHeight() * 4;
|
||||
input_vector_width_ = vector->getWidth();
|
||||
input_vector_height_ = vector->getHeight();
|
||||
}
|
||||
@@ -66,11 +66,11 @@ void DisplaceOperation::executePixelSampled(float output[4],
|
||||
|
||||
pixelTransform(xy, uv, deriv);
|
||||
if (is_zero_v2(deriv[0]) && is_zero_v2(deriv[1])) {
|
||||
this->m_inputColorProgram->readSampled(output, uv[0], uv[1], PixelSampler::Bilinear);
|
||||
m_inputColorProgram->readSampled(output, uv[0], uv[1], PixelSampler::Bilinear);
|
||||
}
|
||||
else {
|
||||
/* EWA filtering (without nearest it gets blurry with NO distortion) */
|
||||
this->m_inputColorProgram->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
|
||||
m_inputColorProgram->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ void DisplaceOperation::pixelTransform(const float xy[2], float r_uv[2], float r
|
||||
|
||||
void DisplaceOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputColorProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
vector_read_fn_ = nullptr;
|
||||
scale_x_read_fn_ = nullptr;
|
||||
scale_y_read_fn_ = nullptr;
|
||||
|
||||
@@ -28,21 +28,21 @@ DisplaceSimpleOperation::DisplaceSimpleOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_inputColorProgram = nullptr;
|
||||
this->m_inputVectorProgram = nullptr;
|
||||
this->m_inputScaleXProgram = nullptr;
|
||||
this->m_inputScaleYProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
m_inputVectorProgram = nullptr;
|
||||
m_inputScaleXProgram = nullptr;
|
||||
m_inputScaleYProgram = nullptr;
|
||||
}
|
||||
|
||||
void DisplaceSimpleOperation::initExecution()
|
||||
{
|
||||
this->m_inputColorProgram = this->getInputSocketReader(0);
|
||||
this->m_inputVectorProgram = this->getInputSocketReader(1);
|
||||
this->m_inputScaleXProgram = this->getInputSocketReader(2);
|
||||
this->m_inputScaleYProgram = this->getInputSocketReader(3);
|
||||
m_inputColorProgram = this->getInputSocketReader(0);
|
||||
m_inputVectorProgram = this->getInputSocketReader(1);
|
||||
m_inputScaleXProgram = this->getInputSocketReader(2);
|
||||
m_inputScaleYProgram = this->getInputSocketReader(3);
|
||||
|
||||
this->m_width_x4 = this->getWidth() * 4;
|
||||
this->m_height_x4 = this->getHeight() * 4;
|
||||
m_width_x4 = this->getWidth() * 4;
|
||||
m_height_x4 = this->getHeight() * 4;
|
||||
}
|
||||
|
||||
/* minimum distance (in pixels) a pixel has to be displaced
|
||||
@@ -60,17 +60,17 @@ void DisplaceSimpleOperation::executePixelSampled(float output[4],
|
||||
float p_dx, p_dy; /* main displacement in pixel space */
|
||||
float u, v;
|
||||
|
||||
this->m_inputScaleXProgram->readSampled(inScale, x, y, sampler);
|
||||
m_inputScaleXProgram->readSampled(inScale, x, y, sampler);
|
||||
float xs = inScale[0];
|
||||
this->m_inputScaleYProgram->readSampled(inScale, x, y, sampler);
|
||||
m_inputScaleYProgram->readSampled(inScale, x, y, sampler);
|
||||
float ys = inScale[0];
|
||||
|
||||
/* clamp x and y displacement to triple image resolution -
|
||||
* to prevent hangs from huge values mistakenly plugged in eg. z buffers */
|
||||
CLAMP(xs, -this->m_width_x4, this->m_width_x4);
|
||||
CLAMP(ys, -this->m_height_x4, this->m_height_x4);
|
||||
CLAMP(xs, -m_width_x4, m_width_x4);
|
||||
CLAMP(ys, -m_height_x4, m_height_x4);
|
||||
|
||||
this->m_inputVectorProgram->readSampled(inVector, x, y, sampler);
|
||||
m_inputVectorProgram->readSampled(inVector, x, y, sampler);
|
||||
p_dx = inVector[0] * xs;
|
||||
p_dy = inVector[1] * ys;
|
||||
|
||||
@@ -81,15 +81,15 @@ void DisplaceSimpleOperation::executePixelSampled(float output[4],
|
||||
CLAMP(u, 0.0f, this->getWidth() - 1.0f);
|
||||
CLAMP(v, 0.0f, this->getHeight() - 1.0f);
|
||||
|
||||
this->m_inputColorProgram->readSampled(output, u, v, sampler);
|
||||
m_inputColorProgram->readSampled(output, u, v, sampler);
|
||||
}
|
||||
|
||||
void DisplaceSimpleOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputColorProgram = nullptr;
|
||||
this->m_inputVectorProgram = nullptr;
|
||||
this->m_inputScaleXProgram = nullptr;
|
||||
this->m_inputScaleYProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
m_inputVectorProgram = nullptr;
|
||||
m_inputScaleXProgram = nullptr;
|
||||
m_inputScaleYProgram = nullptr;
|
||||
}
|
||||
|
||||
bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
|
||||
@@ -26,21 +26,21 @@ DistanceRGBMatteOperation::DistanceRGBMatteOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputKeyProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputKeyProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void DistanceRGBMatteOperation::initExecution()
|
||||
{
|
||||
this->m_inputImageProgram = this->getInputSocketReader(0);
|
||||
this->m_inputKeyProgram = this->getInputSocketReader(1);
|
||||
m_inputImageProgram = this->getInputSocketReader(0);
|
||||
m_inputKeyProgram = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void DistanceRGBMatteOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputKeyProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputKeyProgram = nullptr;
|
||||
}
|
||||
|
||||
float DistanceRGBMatteOperation::calculateDistance(const float key[4], const float image[4])
|
||||
@@ -56,14 +56,14 @@ void DistanceRGBMatteOperation::executePixelSampled(float output[4],
|
||||
float inKey[4];
|
||||
float inImage[4];
|
||||
|
||||
const float tolerance = this->m_settings->t1;
|
||||
const float falloff = this->m_settings->t2;
|
||||
const float tolerance = m_settings->t1;
|
||||
const float falloff = m_settings->t2;
|
||||
|
||||
float distance;
|
||||
float alpha;
|
||||
|
||||
this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
|
||||
this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
|
||||
m_inputKeyProgram->readSampled(inKey, x, y, sampler);
|
||||
m_inputImageProgram->readSampled(inImage, x, y, sampler);
|
||||
|
||||
distance = this->calculateDistance(inKey, inImage);
|
||||
|
||||
@@ -102,8 +102,8 @@ void DistanceRGBMatteOperation::update_memory_buffer_partial(MemoryBuffer *outpu
|
||||
const float *in_key = it.in(1);
|
||||
|
||||
float distance = this->calculateDistance(in_key, in_image);
|
||||
const float tolerance = this->m_settings->t1;
|
||||
const float falloff = this->m_settings->t2;
|
||||
const float tolerance = m_settings->t1;
|
||||
const float falloff = m_settings->t2;
|
||||
|
||||
/* Store matte(alpha) value in [0] to go with
|
||||
* COM_SetAlphaMultiplyOperation and the Value output.
|
||||
|
||||
@@ -50,7 +50,7 @@ class DistanceRGBMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma)
|
||||
{
|
||||
this->m_settings = nodeChroma;
|
||||
m_settings = nodeChroma;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,20 +26,20 @@ DotproductOperation::DotproductOperation()
|
||||
this->addInputSocket(DataType::Vector);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->set_canvas_input_index(0);
|
||||
this->m_input1Operation = nullptr;
|
||||
this->m_input2Operation = nullptr;
|
||||
m_input1Operation = nullptr;
|
||||
m_input2Operation = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
void DotproductOperation::initExecution()
|
||||
{
|
||||
this->m_input1Operation = this->getInputSocketReader(0);
|
||||
this->m_input2Operation = this->getInputSocketReader(1);
|
||||
m_input1Operation = this->getInputSocketReader(0);
|
||||
m_input2Operation = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void DotproductOperation::deinitExecution()
|
||||
{
|
||||
this->m_input1Operation = nullptr;
|
||||
this->m_input2Operation = nullptr;
|
||||
m_input1Operation = nullptr;
|
||||
m_input2Operation = nullptr;
|
||||
}
|
||||
|
||||
/** \todo current implementation is the inverse of a dot-product. not 'logically' correct
|
||||
@@ -51,8 +51,8 @@ void DotproductOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float input1[4];
|
||||
float input2[4];
|
||||
this->m_input1Operation->readSampled(input1, x, y, sampler);
|
||||
this->m_input2Operation->readSampled(input2, x, y, sampler);
|
||||
m_input1Operation->readSampled(input1, x, y, sampler);
|
||||
m_input2Operation->readSampled(input2, x, y, sampler);
|
||||
output[0] = -(input1[0] * input2[0] + input1[1] * input2[1] + input1[2] * input2[2]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1267,8 +1267,8 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float
|
||||
*
|
||||
* Each version has slightly different criteria for detecting an edge pixel.
|
||||
*/
|
||||
if (this->m_adjacentOnly) { /* If "adjacent only" inner edge mode is turned on. */
|
||||
if (this->m_keepInside) { /* If "keep inside" buffer edge mode is turned on. */
|
||||
if (m_adjacentOnly) { /* If "adjacent only" inner edge mode is turned on. */
|
||||
if (m_keepInside) { /* If "keep inside" buffer edge mode is turned on. */
|
||||
do_adjacentKeepBorders(t, rw, limask, lomask, lres, res, rsize);
|
||||
}
|
||||
else { /* "bleed out" buffer edge mode is turned on. */
|
||||
@@ -1281,8 +1281,8 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float
|
||||
/* Detect edges in all non-border pixels in the buffer. */
|
||||
do_adjacentEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz);
|
||||
}
|
||||
else { /* "all" inner edge mode is turned on. */
|
||||
if (this->m_keepInside) { /* If "keep inside" buffer edge mode is turned on. */
|
||||
else { /* "all" inner edge mode is turned on. */
|
||||
if (m_keepInside) { /* If "keep inside" buffer edge mode is turned on. */
|
||||
do_allKeepBorders(t, rw, limask, lomask, lres, res, rsize);
|
||||
}
|
||||
else { /* "bleed out" buffer edge mode is turned on. */
|
||||
@@ -1322,10 +1322,10 @@ DoubleEdgeMaskOperation::DoubleEdgeMaskOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_inputInnerMask = nullptr;
|
||||
this->m_inputOuterMask = nullptr;
|
||||
this->m_adjacentOnly = false;
|
||||
this->m_keepInside = false;
|
||||
m_inputInnerMask = nullptr;
|
||||
m_inputOuterMask = nullptr;
|
||||
m_adjacentOnly = false;
|
||||
m_keepInside = false;
|
||||
this->flags.complex = true;
|
||||
is_output_rendered_ = false;
|
||||
}
|
||||
@@ -1334,7 +1334,7 @@ bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
ReadBufferOperation *readOperation,
|
||||
rcti *output)
|
||||
{
|
||||
if (this->m_cachedInstance == nullptr) {
|
||||
if (m_cachedInstance == nullptr) {
|
||||
rcti newInput;
|
||||
newInput.xmax = this->getWidth();
|
||||
newInput.xmin = 0;
|
||||
@@ -1348,31 +1348,31 @@ bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
|
||||
void DoubleEdgeMaskOperation::initExecution()
|
||||
{
|
||||
this->m_inputInnerMask = this->getInputSocketReader(0);
|
||||
this->m_inputOuterMask = this->getInputSocketReader(1);
|
||||
m_inputInnerMask = this->getInputSocketReader(0);
|
||||
m_inputOuterMask = this->getInputSocketReader(1);
|
||||
initMutex();
|
||||
this->m_cachedInstance = nullptr;
|
||||
m_cachedInstance = nullptr;
|
||||
}
|
||||
|
||||
void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
if (this->m_cachedInstance) {
|
||||
return this->m_cachedInstance;
|
||||
if (m_cachedInstance) {
|
||||
return m_cachedInstance;
|
||||
}
|
||||
|
||||
lockMutex();
|
||||
if (this->m_cachedInstance == nullptr) {
|
||||
MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect);
|
||||
MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect);
|
||||
if (m_cachedInstance == nullptr) {
|
||||
MemoryBuffer *innerMask = (MemoryBuffer *)m_inputInnerMask->initializeTileData(rect);
|
||||
MemoryBuffer *outerMask = (MemoryBuffer *)m_inputOuterMask->initializeTileData(rect);
|
||||
float *data = (float *)MEM_mallocN(sizeof(float) * this->getWidth() * this->getHeight(),
|
||||
__func__);
|
||||
float *imask = innerMask->getBuffer();
|
||||
float *omask = outerMask->getBuffer();
|
||||
doDoubleEdgeMask(imask, omask, data);
|
||||
this->m_cachedInstance = data;
|
||||
m_cachedInstance = data;
|
||||
}
|
||||
unlockMutex();
|
||||
return this->m_cachedInstance;
|
||||
return m_cachedInstance;
|
||||
}
|
||||
void DoubleEdgeMaskOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
@@ -1383,12 +1383,12 @@ void DoubleEdgeMaskOperation::executePixel(float output[4], int x, int y, void *
|
||||
|
||||
void DoubleEdgeMaskOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputInnerMask = nullptr;
|
||||
this->m_inputOuterMask = nullptr;
|
||||
m_inputInnerMask = nullptr;
|
||||
m_inputOuterMask = nullptr;
|
||||
deinitMutex();
|
||||
if (this->m_cachedInstance) {
|
||||
MEM_freeN(this->m_cachedInstance);
|
||||
this->m_cachedInstance = nullptr;
|
||||
if (m_cachedInstance) {
|
||||
MEM_freeN(m_cachedInstance);
|
||||
m_cachedInstance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,11 +64,11 @@ class DoubleEdgeMaskOperation : public NodeOperation {
|
||||
|
||||
void setAdjecentOnly(bool adjacentOnly)
|
||||
{
|
||||
this->m_adjacentOnly = adjacentOnly;
|
||||
m_adjacentOnly = adjacentOnly;
|
||||
}
|
||||
void setKeepInside(bool keepInside)
|
||||
{
|
||||
this->m_keepInside = keepInside;
|
||||
m_keepInside = keepInside;
|
||||
}
|
||||
|
||||
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
|
||||
|
||||
@@ -25,19 +25,19 @@ EllipseMaskOperation::EllipseMaskOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_inputMask = nullptr;
|
||||
this->m_inputValue = nullptr;
|
||||
this->m_cosine = 0.0f;
|
||||
this->m_sine = 0.0f;
|
||||
m_inputMask = nullptr;
|
||||
m_inputValue = nullptr;
|
||||
m_cosine = 0.0f;
|
||||
m_sine = 0.0f;
|
||||
}
|
||||
void EllipseMaskOperation::initExecution()
|
||||
{
|
||||
this->m_inputMask = this->getInputSocketReader(0);
|
||||
this->m_inputValue = this->getInputSocketReader(1);
|
||||
const double rad = (double)this->m_data->rotation;
|
||||
this->m_cosine = cos(rad);
|
||||
this->m_sine = sin(rad);
|
||||
this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
|
||||
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();
|
||||
}
|
||||
|
||||
void EllipseMaskOperation::executePixelSampled(float output[4],
|
||||
@@ -51,26 +51,26 @@ void EllipseMaskOperation::executePixelSampled(float output[4],
|
||||
float rx = x / this->getWidth();
|
||||
float ry = y / this->getHeight();
|
||||
|
||||
const float dy = (ry - this->m_data->y) / this->m_aspectRatio;
|
||||
const float dx = rx - this->m_data->x;
|
||||
rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy);
|
||||
ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy);
|
||||
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);
|
||||
|
||||
this->m_inputMask->readSampled(inputMask, x, y, sampler);
|
||||
this->m_inputValue->readSampled(inputValue, x, y, sampler);
|
||||
m_inputMask->readSampled(inputMask, x, y, sampler);
|
||||
m_inputValue->readSampled(inputValue, x, y, sampler);
|
||||
|
||||
const float halfHeight = (this->m_data->height) / 2.0f;
|
||||
const float halfWidth = this->m_data->width / 2.0f;
|
||||
float sx = rx - this->m_data->x;
|
||||
const float halfHeight = (m_data->height) / 2.0f;
|
||||
const float halfWidth = m_data->width / 2.0f;
|
||||
float sx = rx - m_data->x;
|
||||
sx *= sx;
|
||||
const float tx = halfWidth * halfWidth;
|
||||
float sy = ry - this->m_data->y;
|
||||
float sy = ry - m_data->y;
|
||||
sy *= sy;
|
||||
const float ty = halfHeight * halfHeight;
|
||||
|
||||
bool inside = ((sx / tx) + (sy / ty)) < 1.0f;
|
||||
|
||||
switch (this->m_maskType) {
|
||||
switch (m_maskType) {
|
||||
case CMP_NODE_MASKTYPE_ADD:
|
||||
if (inside) {
|
||||
output[0] = MAX2(inputMask[0], inputValue[0]);
|
||||
@@ -154,24 +154,24 @@ void EllipseMaskOperation::apply_mask(MemoryBuffer *output,
|
||||
const MemoryBuffer *input_value = inputs[1];
|
||||
const float op_w = this->getWidth();
|
||||
const float op_h = this->getHeight();
|
||||
const float half_w = this->m_data->width / 2.0f;
|
||||
const float half_h = this->m_data->height / 2.0f;
|
||||
const float half_w = m_data->width / 2.0f;
|
||||
const float half_h = m_data->height / 2.0f;
|
||||
const float tx = half_w * half_w;
|
||||
const float ty = half_h * half_h;
|
||||
for (int y = area.ymin; y < area.ymax; y++) {
|
||||
const float op_ry = y / op_h;
|
||||
const float dy = (op_ry - this->m_data->y) / m_aspectRatio;
|
||||
const float dy = (op_ry - m_data->y) / m_aspectRatio;
|
||||
float *out = output->get_elem(area.xmin, y);
|
||||
const float *mask = input_mask->get_elem(area.xmin, y);
|
||||
const float *value = input_value->get_elem(area.xmin, y);
|
||||
for (int x = area.xmin; x < area.xmax; x++) {
|
||||
const float op_rx = x / op_w;
|
||||
const float dx = op_rx - this->m_data->x;
|
||||
const float rx = this->m_data->x + (m_cosine * dx + m_sine * dy);
|
||||
const float ry = this->m_data->y + (-m_sine * dx + m_cosine * dy);
|
||||
float sx = rx - this->m_data->x;
|
||||
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);
|
||||
float sx = rx - m_data->x;
|
||||
sx *= sx;
|
||||
float sy = ry - this->m_data->y;
|
||||
float sy = ry - m_data->y;
|
||||
sy *= sy;
|
||||
const bool inside = ((sx / tx) + (sy / ty)) < 1.0f;
|
||||
out[0] = mask_func(inside, mask, value);
|
||||
@@ -185,8 +185,8 @@ void EllipseMaskOperation::apply_mask(MemoryBuffer *output,
|
||||
|
||||
void EllipseMaskOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputMask = nullptr;
|
||||
this->m_inputValue = nullptr;
|
||||
m_inputMask = nullptr;
|
||||
m_inputValue = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -59,12 +59,12 @@ class EllipseMaskOperation : public MultiThreadedOperation {
|
||||
|
||||
void setData(NodeEllipseMask *data)
|
||||
{
|
||||
this->m_data = data;
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
void setMaskType(int maskType)
|
||||
{
|
||||
this->m_maskType = maskType;
|
||||
m_maskType = maskType;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace blender::compositor {
|
||||
|
||||
FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(DataType::Color)
|
||||
{
|
||||
this->m_iirgaus = nullptr;
|
||||
m_iirgaus = nullptr;
|
||||
}
|
||||
|
||||
void FastGaussianBlurOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
@@ -48,7 +48,7 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this->m_iirgaus) {
|
||||
if (m_iirgaus) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(
|
||||
void FastGaussianBlurOperation::init_data()
|
||||
{
|
||||
BlurBaseOperation::init_data();
|
||||
this->m_sx = this->m_data.sizex * this->m_size / 2.0f;
|
||||
this->m_sy = this->m_data.sizey * this->m_size / 2.0f;
|
||||
m_sx = m_data.sizex * m_size / 2.0f;
|
||||
m_sy = m_data.sizey * m_size / 2.0f;
|
||||
}
|
||||
|
||||
void FastGaussianBlurOperation::initExecution()
|
||||
@@ -75,9 +75,9 @@ void FastGaussianBlurOperation::initExecution()
|
||||
|
||||
void FastGaussianBlurOperation::deinitExecution()
|
||||
{
|
||||
if (this->m_iirgaus) {
|
||||
delete this->m_iirgaus;
|
||||
this->m_iirgaus = nullptr;
|
||||
if (m_iirgaus) {
|
||||
delete m_iirgaus;
|
||||
m_iirgaus = nullptr;
|
||||
}
|
||||
BlurBaseOperation::deinitMutex();
|
||||
}
|
||||
@@ -85,36 +85,36 @@ void FastGaussianBlurOperation::deinitExecution()
|
||||
void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_iirgaus) {
|
||||
MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
|
||||
if (!m_iirgaus) {
|
||||
MemoryBuffer *newBuf = (MemoryBuffer *)m_inputProgram->initializeTileData(rect);
|
||||
MemoryBuffer *copy = new MemoryBuffer(*newBuf);
|
||||
updateSize();
|
||||
|
||||
int c;
|
||||
this->m_sx = this->m_data.sizex * this->m_size / 2.0f;
|
||||
this->m_sy = this->m_data.sizey * this->m_size / 2.0f;
|
||||
m_sx = m_data.sizex * m_size / 2.0f;
|
||||
m_sy = m_data.sizey * m_size / 2.0f;
|
||||
|
||||
if ((this->m_sx == this->m_sy) && (this->m_sx > 0.0f)) {
|
||||
if ((m_sx == m_sy) && (m_sx > 0.0f)) {
|
||||
for (c = 0; c < COM_DATA_TYPE_COLOR_CHANNELS; c++) {
|
||||
IIR_gauss(copy, this->m_sx, c, 3);
|
||||
IIR_gauss(copy, m_sx, c, 3);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this->m_sx > 0.0f) {
|
||||
if (m_sx > 0.0f) {
|
||||
for (c = 0; c < COM_DATA_TYPE_COLOR_CHANNELS; c++) {
|
||||
IIR_gauss(copy, this->m_sx, c, 1);
|
||||
IIR_gauss(copy, m_sx, c, 1);
|
||||
}
|
||||
}
|
||||
if (this->m_sy > 0.0f) {
|
||||
if (m_sy > 0.0f) {
|
||||
for (c = 0; c < COM_DATA_TYPE_COLOR_CHANNELS; c++) {
|
||||
IIR_gauss(copy, this->m_sy, c, 2);
|
||||
IIR_gauss(copy, m_sy, c, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->m_iirgaus = copy;
|
||||
m_iirgaus = copy;
|
||||
}
|
||||
unlockMutex();
|
||||
return this->m_iirgaus;
|
||||
return m_iirgaus;
|
||||
}
|
||||
|
||||
void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
|
||||
@@ -294,20 +294,20 @@ void FastGaussianBlurOperation::update_memory_buffer_started(MemoryBuffer *outpu
|
||||
}
|
||||
image->copy_from(input, area);
|
||||
|
||||
if ((this->m_sx == this->m_sy) && (this->m_sx > 0.0f)) {
|
||||
if ((m_sx == m_sy) && (m_sx > 0.0f)) {
|
||||
for (const int c : IndexRange(COM_DATA_TYPE_COLOR_CHANNELS)) {
|
||||
IIR_gauss(image, this->m_sx, c, 3);
|
||||
IIR_gauss(image, m_sx, c, 3);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this->m_sx > 0.0f) {
|
||||
if (m_sx > 0.0f) {
|
||||
for (const int c : IndexRange(COM_DATA_TYPE_COLOR_CHANNELS)) {
|
||||
IIR_gauss(image, this->m_sx, c, 1);
|
||||
IIR_gauss(image, m_sx, c, 1);
|
||||
}
|
||||
}
|
||||
if (this->m_sy > 0.0f) {
|
||||
if (m_sy > 0.0f) {
|
||||
for (const int c : IndexRange(COM_DATA_TYPE_COLOR_CHANNELS)) {
|
||||
IIR_gauss(image, this->m_sy, c, 2);
|
||||
IIR_gauss(image, m_sy, c, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,10 +322,10 @@ FastGaussianBlurValueOperation::FastGaussianBlurValueOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_iirgaus = nullptr;
|
||||
this->m_inputprogram = nullptr;
|
||||
this->m_sigma = 1.0f;
|
||||
this->m_overlay = 0;
|
||||
m_iirgaus = nullptr;
|
||||
m_inputprogram = nullptr;
|
||||
m_sigma = 1.0f;
|
||||
m_overlay = 0;
|
||||
flags.complex = true;
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ bool FastGaussianBlurValueOperation::determineDependingAreaOfInterest(
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
if (this->m_iirgaus) {
|
||||
if (m_iirgaus) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -354,15 +354,15 @@ bool FastGaussianBlurValueOperation::determineDependingAreaOfInterest(
|
||||
|
||||
void FastGaussianBlurValueOperation::initExecution()
|
||||
{
|
||||
this->m_inputprogram = getInputSocketReader(0);
|
||||
m_inputprogram = getInputSocketReader(0);
|
||||
initMutex();
|
||||
}
|
||||
|
||||
void FastGaussianBlurValueOperation::deinitExecution()
|
||||
{
|
||||
if (this->m_iirgaus) {
|
||||
delete this->m_iirgaus;
|
||||
this->m_iirgaus = nullptr;
|
||||
if (m_iirgaus) {
|
||||
delete m_iirgaus;
|
||||
m_iirgaus = nullptr;
|
||||
}
|
||||
deinitMutex();
|
||||
}
|
||||
@@ -370,12 +370,12 @@ void FastGaussianBlurValueOperation::deinitExecution()
|
||||
void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_iirgaus) {
|
||||
MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputprogram->initializeTileData(rect);
|
||||
if (!m_iirgaus) {
|
||||
MemoryBuffer *newBuf = (MemoryBuffer *)m_inputprogram->initializeTileData(rect);
|
||||
MemoryBuffer *copy = new MemoryBuffer(*newBuf);
|
||||
FastGaussianBlurOperation::IIR_gauss(copy, this->m_sigma, 0, 3);
|
||||
FastGaussianBlurOperation::IIR_gauss(copy, m_sigma, 0, 3);
|
||||
|
||||
if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) {
|
||||
if (m_overlay == FAST_GAUSS_OVERLAY_MIN) {
|
||||
float *src = newBuf->getBuffer();
|
||||
float *dst = copy->getBuffer();
|
||||
for (int i = copy->getWidth() * copy->getHeight(); i != 0;
|
||||
@@ -385,7 +385,7 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this->m_overlay == FAST_GAUSS_OVERLAY_MAX) {
|
||||
else if (m_overlay == FAST_GAUSS_OVERLAY_MAX) {
|
||||
float *src = newBuf->getBuffer();
|
||||
float *dst = copy->getBuffer();
|
||||
for (int i = copy->getWidth() * copy->getHeight(); i != 0;
|
||||
@@ -396,10 +396,10 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect)
|
||||
}
|
||||
}
|
||||
|
||||
this->m_iirgaus = copy;
|
||||
m_iirgaus = copy;
|
||||
}
|
||||
unlockMutex();
|
||||
return this->m_iirgaus;
|
||||
return m_iirgaus;
|
||||
}
|
||||
|
||||
void FastGaussianBlurValueOperation::get_area_of_interest(const int UNUSED(input_idx),
|
||||
@@ -427,12 +427,12 @@ void FastGaussianBlurValueOperation::update_memory_buffer_partial(MemoryBuffer *
|
||||
{
|
||||
MemoryBuffer *image = inputs[0];
|
||||
BuffersIterator<float> it = output->iterate_with({image, m_iirgaus}, area);
|
||||
if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) {
|
||||
if (m_overlay == FAST_GAUSS_OVERLAY_MIN) {
|
||||
for (; !it.is_end(); ++it) {
|
||||
*it.out = MIN2(*it.in(0), *it.in(1));
|
||||
}
|
||||
}
|
||||
else if (this->m_overlay == FAST_GAUSS_OVERLAY_MAX) {
|
||||
else if (m_overlay == FAST_GAUSS_OVERLAY_MAX) {
|
||||
for (; !it.is_end(); ++it) {
|
||||
*it.out = MAX2(*it.in(0), *it.in(1));
|
||||
}
|
||||
|
||||
@@ -83,13 +83,13 @@ class FastGaussianBlurValueOperation : public MultiThreadedOperation {
|
||||
void initExecution() override;
|
||||
void setSigma(float sigma)
|
||||
{
|
||||
this->m_sigma = sigma;
|
||||
m_sigma = sigma;
|
||||
}
|
||||
|
||||
/* used for DOF blurring ZBuffer */
|
||||
void setOverlay(int overlay)
|
||||
{
|
||||
this->m_overlay = overlay;
|
||||
m_overlay = overlay;
|
||||
}
|
||||
|
||||
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
|
||||
|
||||
@@ -25,26 +25,26 @@ FlipOperation::FlipOperation()
|
||||
this->addInputSocket(DataType::Color, ResizeMode::None);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->set_canvas_input_index(0);
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_flipX = true;
|
||||
this->m_flipY = false;
|
||||
m_inputOperation = nullptr;
|
||||
m_flipX = true;
|
||||
m_flipY = false;
|
||||
}
|
||||
void FlipOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void FlipOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
|
||||
void FlipOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
{
|
||||
float nx = this->m_flipX ? ((int)this->getWidth() - 1) - x : x;
|
||||
float ny = this->m_flipY ? ((int)this->getHeight() - 1) - y : y;
|
||||
float nx = m_flipX ? ((int)this->getWidth() - 1) - x : x;
|
||||
float ny = m_flipY ? ((int)this->getHeight() - 1) - y : y;
|
||||
|
||||
this->m_inputOperation->readSampled(output, nx, ny, sampler);
|
||||
m_inputOperation->readSampled(output, nx, ny, sampler);
|
||||
}
|
||||
|
||||
bool FlipOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -53,7 +53,7 @@ bool FlipOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
if (this->m_flipX) {
|
||||
if (m_flipX) {
|
||||
const int w = (int)this->getWidth() - 1;
|
||||
newInput.xmax = (w - input->xmin) + 1;
|
||||
newInput.xmin = (w - input->xmax) - 1;
|
||||
@@ -62,7 +62,7 @@ bool FlipOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
newInput.xmin = input->xmin;
|
||||
newInput.xmax = input->xmax;
|
||||
}
|
||||
if (this->m_flipY) {
|
||||
if (m_flipY) {
|
||||
const int h = (int)this->getHeight() - 1;
|
||||
newInput.ymax = (h - input->ymin) + 1;
|
||||
newInput.ymin = (h - input->ymax) - 1;
|
||||
@@ -99,7 +99,7 @@ void FlipOperation::get_area_of_interest(const int input_idx,
|
||||
{
|
||||
BLI_assert(input_idx == 0);
|
||||
UNUSED_VARS_NDEBUG(input_idx);
|
||||
if (this->m_flipX) {
|
||||
if (m_flipX) {
|
||||
const int w = (int)this->getWidth() - 1;
|
||||
r_input_area.xmax = (w - output_area.xmin) + 1;
|
||||
r_input_area.xmin = (w - output_area.xmax) + 1;
|
||||
@@ -108,7 +108,7 @@ void FlipOperation::get_area_of_interest(const int input_idx,
|
||||
r_input_area.xmin = output_area.xmin;
|
||||
r_input_area.xmax = output_area.xmax;
|
||||
}
|
||||
if (this->m_flipY) {
|
||||
if (m_flipY) {
|
||||
const int h = (int)this->getHeight() - 1;
|
||||
r_input_area.ymax = (h - output_area.ymin) + 1;
|
||||
r_input_area.ymin = (h - output_area.ymax) + 1;
|
||||
@@ -127,8 +127,8 @@ void FlipOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const int input_offset_x = input_img->get_rect().xmin;
|
||||
const int input_offset_y = input_img->get_rect().ymin;
|
||||
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
|
||||
const int nx = this->m_flipX ? ((int)this->getWidth() - 1) - it.x : it.x;
|
||||
const int ny = this->m_flipY ? ((int)this->getHeight() - 1) - it.y : it.y;
|
||||
const int nx = m_flipX ? ((int)this->getWidth() - 1) - it.x : it.x;
|
||||
const int ny = m_flipY ? ((int)this->getHeight() - 1) - it.y : it.y;
|
||||
input_img->read_elem(input_offset_x + nx, input_offset_y + ny, it.out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ class FlipOperation : public MultiThreadedOperation {
|
||||
void deinitExecution() override;
|
||||
void setFlipX(bool flipX)
|
||||
{
|
||||
this->m_flipX = flipX;
|
||||
m_flipX = flipX;
|
||||
}
|
||||
void setFlipY(bool flipY)
|
||||
{
|
||||
this->m_flipY = flipY;
|
||||
m_flipY = flipY;
|
||||
}
|
||||
|
||||
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
|
||||
|
||||
@@ -24,12 +24,12 @@ GammaCorrectOperation::GammaCorrectOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
void GammaCorrectOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void GammaCorrectOperation::executePixelSampled(float output[4],
|
||||
@@ -38,7 +38,7 @@ void GammaCorrectOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
this->m_inputProgram->readSampled(inputColor, x, y, sampler);
|
||||
m_inputProgram->readSampled(inputColor, x, y, sampler);
|
||||
if (inputColor[3] > 0.0f) {
|
||||
inputColor[0] /= inputColor[3];
|
||||
inputColor[1] /= inputColor[3];
|
||||
@@ -88,19 +88,19 @@ void GammaCorrectOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
void GammaCorrectOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
GammaUncorrectOperation::GammaUncorrectOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
void GammaUncorrectOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void GammaUncorrectOperation::executePixelSampled(float output[4],
|
||||
@@ -109,7 +109,7 @@ void GammaUncorrectOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inputColor[4];
|
||||
this->m_inputProgram->readSampled(inputColor, x, y, sampler);
|
||||
m_inputProgram->readSampled(inputColor, x, y, sampler);
|
||||
|
||||
if (inputColor[3] > 0.0f) {
|
||||
inputColor[0] /= inputColor[3];
|
||||
@@ -158,7 +158,7 @@ void GammaUncorrectOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
void GammaUncorrectOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -25,14 +25,14 @@ GammaOperation::GammaOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputGammaProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputGammaProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
void GammaOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
this->m_inputGammaProgram = this->getInputSocketReader(1);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputGammaProgram = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void GammaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
@@ -40,8 +40,8 @@ void GammaOperation::executePixelSampled(float output[4], float x, float y, Pixe
|
||||
float inputValue[4];
|
||||
float inputGamma[4];
|
||||
|
||||
this->m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputGammaProgram->readSampled(inputGamma, x, y, sampler);
|
||||
m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
m_inputGammaProgram->readSampled(inputGamma, x, y, sampler);
|
||||
const float gamma = inputGamma[0];
|
||||
/* check for negative to avoid nan's */
|
||||
output[0] = inputValue[0] > 0.0f ? powf(inputValue[0], gamma) : inputValue[0];
|
||||
@@ -67,8 +67,8 @@ void GammaOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
|
||||
void GammaOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputGammaProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputGammaProgram = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace blender::compositor {
|
||||
GaussianAlphaBlurBaseOperation::GaussianAlphaBlurBaseOperation(eDimension dim)
|
||||
: BlurBaseOperation(DataType::Value)
|
||||
{
|
||||
this->m_gausstab = nullptr;
|
||||
this->m_filtersize = 0;
|
||||
this->m_falloff = -1; /* Intentionally invalid, so we can detect uninitialized values. */
|
||||
m_gausstab = nullptr;
|
||||
m_filtersize = 0;
|
||||
m_falloff = -1; /* Intentionally invalid, so we can detect uninitialized values. */
|
||||
dimension_ = dim;
|
||||
}
|
||||
|
||||
@@ -52,14 +52,14 @@ void GaussianAlphaBlurBaseOperation::deinitExecution()
|
||||
{
|
||||
BlurBaseOperation::deinitExecution();
|
||||
|
||||
if (this->m_gausstab) {
|
||||
MEM_freeN(this->m_gausstab);
|
||||
this->m_gausstab = nullptr;
|
||||
if (m_gausstab) {
|
||||
MEM_freeN(m_gausstab);
|
||||
m_gausstab = nullptr;
|
||||
}
|
||||
|
||||
if (this->m_distbuf_inv) {
|
||||
MEM_freeN(this->m_distbuf_inv);
|
||||
this->m_distbuf_inv = nullptr;
|
||||
if (m_distbuf_inv) {
|
||||
MEM_freeN(m_distbuf_inv);
|
||||
m_distbuf_inv = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,11 +51,11 @@ class GaussianAlphaBlurBaseOperation : public BlurBaseOperation {
|
||||
*/
|
||||
void setSubtract(bool subtract)
|
||||
{
|
||||
this->m_do_subtract = subtract;
|
||||
m_do_subtract = subtract;
|
||||
}
|
||||
void setFalloff(int falloff)
|
||||
{
|
||||
this->m_falloff = falloff;
|
||||
m_falloff = falloff;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation()
|
||||
void *GaussianAlphaXBlurOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_sizeavailable) {
|
||||
if (!m_sizeavailable) {
|
||||
updateGauss();
|
||||
}
|
||||
void *buffer = getInputOperation(0)->initializeTileData(nullptr);
|
||||
@@ -42,7 +42,7 @@ void GaussianAlphaXBlurOperation::initExecution()
|
||||
|
||||
initMutex();
|
||||
|
||||
if (this->m_sizeavailable && execution_model_ == eExecutionModel::Tiled) {
|
||||
if (m_sizeavailable && execution_model_ == eExecutionModel::Tiled) {
|
||||
float rad = max_ff(m_size * m_data.sizex, 0.0f);
|
||||
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
|
||||
|
||||
@@ -53,7 +53,7 @@ void GaussianAlphaXBlurOperation::initExecution()
|
||||
|
||||
void GaussianAlphaXBlurOperation::updateGauss()
|
||||
{
|
||||
if (this->m_gausstab == nullptr) {
|
||||
if (m_gausstab == nullptr) {
|
||||
updateSize();
|
||||
float rad = max_ff(m_size * m_data.sizex, 0.0f);
|
||||
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
|
||||
@@ -61,7 +61,7 @@ void GaussianAlphaXBlurOperation::updateGauss()
|
||||
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
}
|
||||
|
||||
if (this->m_distbuf_inv == nullptr) {
|
||||
if (m_distbuf_inv == nullptr) {
|
||||
updateSize();
|
||||
float rad = max_ff(m_size * m_data.sizex, 0.0f);
|
||||
rad = min_ff(rad, MAX_GAUSSTAB_RADIUS);
|
||||
@@ -78,7 +78,7 @@ BLI_INLINE float finv_test(const float f, const bool test)
|
||||
|
||||
void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
const bool do_invert = this->m_do_subtract;
|
||||
const bool do_invert = m_do_subtract;
|
||||
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
|
||||
float *buffer = inputBuffer->getBuffer();
|
||||
int bufferwidth = inputBuffer->getWidth();
|
||||
@@ -106,20 +106,20 @@ void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, vo
|
||||
float distfacinv_max = 1.0f; /* 0 to 1 */
|
||||
|
||||
for (int nx = xmin; nx < xmax; nx += step) {
|
||||
const int index = (nx - x) + this->m_filtersize;
|
||||
const int index = (nx - x) + m_filtersize;
|
||||
float value = finv_test(buffer[bufferindex], do_invert);
|
||||
float multiplier;
|
||||
|
||||
/* gauss */
|
||||
{
|
||||
multiplier = this->m_gausstab[index];
|
||||
multiplier = m_gausstab[index];
|
||||
alpha_accum += value * multiplier;
|
||||
multiplier_accum += multiplier;
|
||||
}
|
||||
|
||||
/* dilate - find most extreme color */
|
||||
if (value > value_max) {
|
||||
multiplier = this->m_distbuf_inv[index];
|
||||
multiplier = m_distbuf_inv[index];
|
||||
value *= multiplier;
|
||||
if (value > value_max) {
|
||||
value_max = value;
|
||||
@@ -139,14 +139,14 @@ void GaussianAlphaXBlurOperation::deinitExecution()
|
||||
{
|
||||
GaussianAlphaBlurBaseOperation::deinitExecution();
|
||||
|
||||
if (this->m_gausstab) {
|
||||
MEM_freeN(this->m_gausstab);
|
||||
this->m_gausstab = nullptr;
|
||||
if (m_gausstab) {
|
||||
MEM_freeN(m_gausstab);
|
||||
m_gausstab = nullptr;
|
||||
}
|
||||
|
||||
if (this->m_distbuf_inv) {
|
||||
MEM_freeN(this->m_distbuf_inv);
|
||||
this->m_distbuf_inv = nullptr;
|
||||
if (m_distbuf_inv) {
|
||||
MEM_freeN(m_distbuf_inv);
|
||||
m_distbuf_inv = nullptr;
|
||||
}
|
||||
|
||||
deinitMutex();
|
||||
@@ -170,9 +170,9 @@ bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (this->m_sizeavailable && this->m_gausstab != nullptr) {
|
||||
newInput.xmax = input->xmax + this->m_filtersize + 1;
|
||||
newInput.xmin = input->xmin - this->m_filtersize - 1;
|
||||
if (m_sizeavailable && m_gausstab != nullptr) {
|
||||
newInput.xmax = input->xmax + m_filtersize + 1;
|
||||
newInput.xmin = input->xmin - m_filtersize - 1;
|
||||
newInput.ymax = input->ymax;
|
||||
newInput.ymin = input->ymin;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation()
|
||||
void *GaussianAlphaYBlurOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_sizeavailable) {
|
||||
if (!m_sizeavailable) {
|
||||
updateGauss();
|
||||
}
|
||||
void *buffer = getInputOperation(0)->initializeTileData(nullptr);
|
||||
@@ -43,7 +43,7 @@ void GaussianAlphaYBlurOperation::initExecution()
|
||||
|
||||
initMutex();
|
||||
|
||||
if (this->m_sizeavailable && execution_model_ == eExecutionModel::Tiled) {
|
||||
if (m_sizeavailable && execution_model_ == eExecutionModel::Tiled) {
|
||||
float rad = max_ff(m_size * m_data.sizey, 0.0f);
|
||||
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
|
||||
|
||||
@@ -55,7 +55,7 @@ void GaussianAlphaYBlurOperation::initExecution()
|
||||
/* TODO(manzanilla): to be removed with tiled implementation. */
|
||||
void GaussianAlphaYBlurOperation::updateGauss()
|
||||
{
|
||||
if (this->m_gausstab == nullptr) {
|
||||
if (m_gausstab == nullptr) {
|
||||
updateSize();
|
||||
float rad = max_ff(m_size * m_data.sizey, 0.0f);
|
||||
rad = min_ff(rad, MAX_GAUSSTAB_RADIUS);
|
||||
@@ -64,7 +64,7 @@ void GaussianAlphaYBlurOperation::updateGauss()
|
||||
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
}
|
||||
|
||||
if (this->m_distbuf_inv == nullptr) {
|
||||
if (m_distbuf_inv == nullptr) {
|
||||
updateSize();
|
||||
float rad = max_ff(m_size * m_data.sizey, 0.0f);
|
||||
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
|
||||
@@ -80,7 +80,7 @@ BLI_INLINE float finv_test(const float f, const bool test)
|
||||
|
||||
void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
const bool do_invert = this->m_do_subtract;
|
||||
const bool do_invert = m_do_subtract;
|
||||
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
|
||||
const rcti &input_rect = inputBuffer->get_rect();
|
||||
float *buffer = inputBuffer->getBuffer();
|
||||
@@ -108,20 +108,20 @@ void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, vo
|
||||
for (int ny = ymin; ny < ymax; ny += step) {
|
||||
int bufferindex = ((xmin - bufferstartx)) + ((ny - bufferstarty) * bufferwidth);
|
||||
|
||||
const int index = (ny - y) + this->m_filtersize;
|
||||
const int index = (ny - y) + m_filtersize;
|
||||
float value = finv_test(buffer[bufferindex], do_invert);
|
||||
float multiplier;
|
||||
|
||||
/* gauss */
|
||||
{
|
||||
multiplier = this->m_gausstab[index];
|
||||
multiplier = m_gausstab[index];
|
||||
alpha_accum += value * multiplier;
|
||||
multiplier_accum += multiplier;
|
||||
}
|
||||
|
||||
/* dilate - find most extreme color */
|
||||
if (value > value_max) {
|
||||
multiplier = this->m_distbuf_inv[index];
|
||||
multiplier = m_distbuf_inv[index];
|
||||
value *= multiplier;
|
||||
if (value > value_max) {
|
||||
value_max = value;
|
||||
@@ -140,14 +140,14 @@ void GaussianAlphaYBlurOperation::deinitExecution()
|
||||
{
|
||||
GaussianAlphaBlurBaseOperation::deinitExecution();
|
||||
|
||||
if (this->m_gausstab) {
|
||||
MEM_freeN(this->m_gausstab);
|
||||
this->m_gausstab = nullptr;
|
||||
if (m_gausstab) {
|
||||
MEM_freeN(m_gausstab);
|
||||
m_gausstab = nullptr;
|
||||
}
|
||||
|
||||
if (this->m_distbuf_inv) {
|
||||
MEM_freeN(this->m_distbuf_inv);
|
||||
this->m_distbuf_inv = nullptr;
|
||||
if (m_distbuf_inv) {
|
||||
MEM_freeN(m_distbuf_inv);
|
||||
m_distbuf_inv = nullptr;
|
||||
}
|
||||
|
||||
deinitMutex();
|
||||
@@ -171,11 +171,11 @@ bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (this->m_sizeavailable && this->m_gausstab != nullptr) {
|
||||
if (m_sizeavailable && m_gausstab != nullptr) {
|
||||
newInput.xmax = input->xmax;
|
||||
newInput.xmin = input->xmin;
|
||||
newInput.ymax = input->ymax + this->m_filtersize + 1;
|
||||
newInput.ymin = input->ymin - this->m_filtersize - 1;
|
||||
newInput.ymax = input->ymax + m_filtersize + 1;
|
||||
newInput.ymin = input->ymin - m_filtersize - 1;
|
||||
}
|
||||
else {
|
||||
newInput.xmax = this->getWidth();
|
||||
|
||||
@@ -24,13 +24,13 @@ namespace blender::compositor {
|
||||
|
||||
GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(DataType::Color)
|
||||
{
|
||||
this->m_gausstab = nullptr;
|
||||
m_gausstab = nullptr;
|
||||
}
|
||||
|
||||
void *GaussianBokehBlurOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_sizeavailable) {
|
||||
if (!m_sizeavailable) {
|
||||
updateGauss();
|
||||
}
|
||||
void *buffer = getInputOperation(0)->initializeTileData(nullptr);
|
||||
@@ -44,19 +44,19 @@ void GaussianBokehBlurOperation::init_data()
|
||||
const float width = this->getWidth();
|
||||
const float height = this->getHeight();
|
||||
|
||||
if (!this->m_sizeavailable) {
|
||||
if (!m_sizeavailable) {
|
||||
updateSize();
|
||||
}
|
||||
|
||||
radxf_ = this->m_size * (float)this->m_data.sizex;
|
||||
radxf_ = m_size * (float)m_data.sizex;
|
||||
CLAMP(radxf_, 0.0f, width / 2.0f);
|
||||
|
||||
/* Vertical. */
|
||||
radyf_ = this->m_size * (float)this->m_data.sizey;
|
||||
radyf_ = m_size * (float)m_data.sizey;
|
||||
CLAMP(radyf_, 0.0f, height / 2.0f);
|
||||
|
||||
this->m_radx = ceil(radxf_);
|
||||
this->m_rady = ceil(radyf_);
|
||||
m_radx = ceil(radxf_);
|
||||
m_rady = ceil(radyf_);
|
||||
}
|
||||
|
||||
void GaussianBokehBlurOperation::initExecution()
|
||||
@@ -65,16 +65,16 @@ void GaussianBokehBlurOperation::initExecution()
|
||||
|
||||
initMutex();
|
||||
|
||||
if (this->m_sizeavailable) {
|
||||
if (m_sizeavailable) {
|
||||
updateGauss();
|
||||
}
|
||||
}
|
||||
|
||||
void GaussianBokehBlurOperation::updateGauss()
|
||||
{
|
||||
if (this->m_gausstab == nullptr) {
|
||||
int ddwidth = 2 * this->m_radx + 1;
|
||||
int ddheight = 2 * this->m_rady + 1;
|
||||
if (m_gausstab == nullptr) {
|
||||
int ddwidth = 2 * m_radx + 1;
|
||||
int ddheight = 2 * m_rady + 1;
|
||||
int n = ddwidth * ddheight;
|
||||
/* create a full filter image */
|
||||
float *ddgauss = (float *)MEM_mallocN(sizeof(float) * n, __func__);
|
||||
@@ -82,12 +82,12 @@ void GaussianBokehBlurOperation::updateGauss()
|
||||
float sum = 0.0f;
|
||||
float facx = (radxf_ > 0.0f ? 1.0f / radxf_ : 0.0f);
|
||||
float facy = (radyf_ > 0.0f ? 1.0f / radyf_ : 0.0f);
|
||||
for (int j = -this->m_rady; j <= this->m_rady; j++) {
|
||||
for (int i = -this->m_radx; i <= this->m_radx; i++, dgauss++) {
|
||||
for (int j = -m_rady; j <= m_rady; j++) {
|
||||
for (int i = -m_radx; i <= m_radx; i++, dgauss++) {
|
||||
float fj = (float)j * facy;
|
||||
float fi = (float)i * facx;
|
||||
float dist = sqrt(fj * fj + fi * fi);
|
||||
*dgauss = RE_filter_value(this->m_data.filtertype, dist);
|
||||
*dgauss = RE_filter_value(m_data.filtertype, dist);
|
||||
|
||||
sum += *dgauss;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ void GaussianBokehBlurOperation::updateGauss()
|
||||
ddgauss[center] = 1.0f;
|
||||
}
|
||||
|
||||
this->m_gausstab = ddgauss;
|
||||
m_gausstab = ddgauss;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,21 +124,21 @@ void GaussianBokehBlurOperation::executePixel(float output[4], int x, int y, voi
|
||||
int bufferstartx = input_rect.xmin;
|
||||
int bufferstarty = input_rect.ymin;
|
||||
|
||||
int ymin = max_ii(y - this->m_rady, input_rect.ymin);
|
||||
int ymax = min_ii(y + this->m_rady + 1, input_rect.ymax);
|
||||
int xmin = max_ii(x - this->m_radx, input_rect.xmin);
|
||||
int xmax = min_ii(x + this->m_radx + 1, input_rect.xmax);
|
||||
int ymin = max_ii(y - m_rady, input_rect.ymin);
|
||||
int ymax = min_ii(y + m_rady + 1, input_rect.ymax);
|
||||
int xmin = max_ii(x - m_radx, input_rect.xmin);
|
||||
int xmax = min_ii(x + m_radx + 1, input_rect.xmax);
|
||||
|
||||
int index;
|
||||
int step = QualityStepHelper::getStep();
|
||||
int offsetadd = QualityStepHelper::getOffsetAdd();
|
||||
const int addConst = (xmin - x + this->m_radx);
|
||||
const int mulConst = (this->m_radx * 2 + 1);
|
||||
const int addConst = (xmin - x + m_radx);
|
||||
const int mulConst = (m_radx * 2 + 1);
|
||||
for (int ny = ymin; ny < ymax; ny += step) {
|
||||
index = ((ny - y) + this->m_rady) * mulConst + addConst;
|
||||
index = ((ny - y) + m_rady) * mulConst + addConst;
|
||||
int bufferindex = ((xmin - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
|
||||
for (int nx = xmin; nx < xmax; nx += step) {
|
||||
const float multiplier = this->m_gausstab[index];
|
||||
const float multiplier = m_gausstab[index];
|
||||
madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier);
|
||||
multiplier_accum += multiplier;
|
||||
index += step;
|
||||
@@ -153,9 +153,9 @@ void GaussianBokehBlurOperation::deinitExecution()
|
||||
{
|
||||
BlurBaseOperation::deinitExecution();
|
||||
|
||||
if (this->m_gausstab) {
|
||||
MEM_freeN(this->m_gausstab);
|
||||
this->m_gausstab = nullptr;
|
||||
if (m_gausstab) {
|
||||
MEM_freeN(m_gausstab);
|
||||
m_gausstab = nullptr;
|
||||
}
|
||||
|
||||
deinitMutex();
|
||||
@@ -176,15 +176,15 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this->m_sizeavailable && this->m_gausstab != nullptr) {
|
||||
if (m_sizeavailable && m_gausstab != nullptr) {
|
||||
newInput.xmin = 0;
|
||||
newInput.ymin = 0;
|
||||
newInput.xmax = this->getWidth();
|
||||
newInput.ymax = this->getHeight();
|
||||
}
|
||||
else {
|
||||
int addx = this->m_radx;
|
||||
int addy = this->m_rady;
|
||||
int addx = m_radx;
|
||||
int addy = m_rady;
|
||||
newInput.xmax = input->xmax + addx;
|
||||
newInput.xmin = input->xmin - addx;
|
||||
newInput.ymax = input->ymax + addy;
|
||||
@@ -219,23 +219,23 @@ void GaussianBokehBlurOperation::update_memory_buffer_partial(MemoryBuffer *outp
|
||||
const int x = it.x;
|
||||
const int y = it.y;
|
||||
|
||||
const int ymin = max_ii(y - this->m_rady, input_rect.ymin);
|
||||
const int ymax = min_ii(y + this->m_rady + 1, input_rect.ymax);
|
||||
const int xmin = max_ii(x - this->m_radx, input_rect.xmin);
|
||||
const int xmax = min_ii(x + this->m_radx + 1, input_rect.xmax);
|
||||
const int ymin = max_ii(y - m_rady, input_rect.ymin);
|
||||
const int ymax = min_ii(y + m_rady + 1, input_rect.ymax);
|
||||
const int xmin = max_ii(x - m_radx, input_rect.xmin);
|
||||
const int xmax = min_ii(x + m_radx + 1, input_rect.xmax);
|
||||
|
||||
float tempColor[4] = {0};
|
||||
float multiplier_accum = 0;
|
||||
const int step = QualityStepHelper::getStep();
|
||||
const int elem_step = step * input->elem_stride;
|
||||
const int add_const = (xmin - x + this->m_radx);
|
||||
const int mul_const = (this->m_radx * 2 + 1);
|
||||
const int add_const = (xmin - x + m_radx);
|
||||
const int mul_const = (m_radx * 2 + 1);
|
||||
for (int ny = ymin; ny < ymax; ny += step) {
|
||||
const float *color = input->get_elem(xmin, ny);
|
||||
int gauss_index = ((ny - y) + this->m_rady) * mul_const + add_const;
|
||||
int gauss_index = ((ny - y) + m_rady) * mul_const + add_const;
|
||||
const int gauss_end = gauss_index + (xmax - xmin);
|
||||
for (; gauss_index < gauss_end; gauss_index += step, color += elem_step) {
|
||||
const float multiplier = this->m_gausstab[gauss_index];
|
||||
const float multiplier = m_gausstab[gauss_index];
|
||||
madd_v4_v4fl(tempColor, color, multiplier);
|
||||
multiplier_accum += multiplier;
|
||||
}
|
||||
@@ -249,34 +249,34 @@ void GaussianBokehBlurOperation::update_memory_buffer_partial(MemoryBuffer *outp
|
||||
GaussianBlurReferenceOperation::GaussianBlurReferenceOperation()
|
||||
: BlurBaseOperation(DataType::Color)
|
||||
{
|
||||
this->m_maintabs = nullptr;
|
||||
m_maintabs = nullptr;
|
||||
use_variable_size_ = true;
|
||||
}
|
||||
|
||||
void GaussianBlurReferenceOperation::init_data()
|
||||
{
|
||||
/* Setup variables for gausstab and area of interest. */
|
||||
this->m_data.image_in_width = this->getWidth();
|
||||
this->m_data.image_in_height = this->getHeight();
|
||||
if (this->m_data.relative) {
|
||||
switch (this->m_data.aspect) {
|
||||
m_data.image_in_width = this->getWidth();
|
||||
m_data.image_in_height = this->getHeight();
|
||||
if (m_data.relative) {
|
||||
switch (m_data.aspect) {
|
||||
case CMP_NODE_BLUR_ASPECT_NONE:
|
||||
this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
|
||||
this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
|
||||
m_data.sizex = (int)(m_data.percentx * 0.01f * m_data.image_in_width);
|
||||
m_data.sizey = (int)(m_data.percenty * 0.01f * m_data.image_in_height);
|
||||
break;
|
||||
case CMP_NODE_BLUR_ASPECT_Y:
|
||||
this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
|
||||
this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_width);
|
||||
m_data.sizex = (int)(m_data.percentx * 0.01f * m_data.image_in_width);
|
||||
m_data.sizey = (int)(m_data.percenty * 0.01f * m_data.image_in_width);
|
||||
break;
|
||||
case CMP_NODE_BLUR_ASPECT_X:
|
||||
this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_height);
|
||||
this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
|
||||
m_data.sizex = (int)(m_data.percentx * 0.01f * m_data.image_in_height);
|
||||
m_data.sizey = (int)(m_data.percenty * 0.01f * m_data.image_in_height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Horizontal. */
|
||||
m_filtersizex = (float)this->m_data.sizex;
|
||||
m_filtersizex = (float)m_data.sizex;
|
||||
int imgx = getWidth() / 2;
|
||||
if (m_filtersizex > imgx) {
|
||||
m_filtersizex = imgx;
|
||||
@@ -287,7 +287,7 @@ void GaussianBlurReferenceOperation::init_data()
|
||||
m_radx = (float)m_filtersizex;
|
||||
|
||||
/* Vertical. */
|
||||
m_filtersizey = (float)this->m_data.sizey;
|
||||
m_filtersizey = (float)m_data.sizey;
|
||||
int imgy = getHeight() / 2;
|
||||
if (m_filtersizey > imgy) {
|
||||
m_filtersizey = imgy;
|
||||
@@ -334,7 +334,7 @@ void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y,
|
||||
int imgx = getWidth();
|
||||
int imgy = getHeight();
|
||||
float tempSize[4];
|
||||
this->m_inputSize->read(tempSize, x, y, data);
|
||||
m_inputSize->read(tempSize, x, y, data);
|
||||
float refSize = tempSize[0];
|
||||
int refradx = (int)(refSize * m_radx);
|
||||
int refrady = (int)(refSize * m_rady);
|
||||
@@ -391,11 +391,11 @@ void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y,
|
||||
void GaussianBlurReferenceOperation::deinitExecution()
|
||||
{
|
||||
int x, i;
|
||||
x = MAX2(this->m_filtersizex, this->m_filtersizey);
|
||||
x = MAX2(m_filtersizex, m_filtersizey);
|
||||
for (i = 0; i < x; i++) {
|
||||
MEM_freeN(this->m_maintabs[i]);
|
||||
MEM_freeN(m_maintabs[i]);
|
||||
}
|
||||
MEM_freeN(this->m_maintabs);
|
||||
MEM_freeN(m_maintabs);
|
||||
BlurBaseOperation::deinitExecution();
|
||||
}
|
||||
|
||||
@@ -409,8 +409,8 @@ bool GaussianBlurReferenceOperation::determineDependingAreaOfInterest(
|
||||
return true;
|
||||
}
|
||||
|
||||
int addx = this->m_data.sizex + 2;
|
||||
int addy = this->m_data.sizey + 2;
|
||||
int addx = m_data.sizex + 2;
|
||||
int addy = m_data.sizey + 2;
|
||||
newInput.xmax = input->xmax + addx;
|
||||
newInput.xmin = input->xmin - addx;
|
||||
newInput.ymax = input->ymax + addy;
|
||||
@@ -427,8 +427,8 @@ void GaussianBlurReferenceOperation::get_area_of_interest(const int input_idx,
|
||||
return;
|
||||
}
|
||||
|
||||
const int add_x = this->m_data.sizex + 2;
|
||||
const int add_y = this->m_data.sizey + 2;
|
||||
const int add_x = m_data.sizex + 2;
|
||||
const int add_y = m_data.sizey + 2;
|
||||
r_input_area.xmax = output_area.xmax + add_x;
|
||||
r_input_area.xmin = output_area.xmin - add_x;
|
||||
r_input_area.ymax = output_area.ymax + add_y;
|
||||
|
||||
@@ -28,7 +28,7 @@ GaussianXBlurOperation::GaussianXBlurOperation() : GaussianBlurBaseOperation(eDi
|
||||
void *GaussianXBlurOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_sizeavailable) {
|
||||
if (!m_sizeavailable) {
|
||||
updateGauss();
|
||||
}
|
||||
void *buffer = getInputOperation(0)->initializeTileData(nullptr);
|
||||
@@ -43,14 +43,14 @@ void GaussianXBlurOperation::initExecution()
|
||||
|
||||
initMutex();
|
||||
|
||||
if (this->m_sizeavailable && execution_model_ == eExecutionModel::Tiled) {
|
||||
if (m_sizeavailable && execution_model_ == eExecutionModel::Tiled) {
|
||||
float rad = max_ff(m_size * m_data.sizex, 0.0f);
|
||||
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
|
||||
|
||||
/* TODO(sergey): De-duplicate with the case below and Y blur. */
|
||||
this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
#ifdef BLI_HAVE_SSE2
|
||||
this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab, m_filtersize);
|
||||
m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(m_gausstab, m_filtersize);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -58,15 +58,15 @@ void GaussianXBlurOperation::initExecution()
|
||||
/* TODO(manzanilla): to be removed with tiled implementation. */
|
||||
void GaussianXBlurOperation::updateGauss()
|
||||
{
|
||||
if (this->m_gausstab == nullptr) {
|
||||
if (m_gausstab == nullptr) {
|
||||
updateSize();
|
||||
float rad = max_ff(m_size * m_data.sizex, 0.0f);
|
||||
rad = min_ff(rad, MAX_GAUSSTAB_RADIUS);
|
||||
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
|
||||
|
||||
this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
#ifdef BLI_HAVE_SSE2
|
||||
this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab, m_filtersize);
|
||||
m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(m_gausstab, m_filtersize);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -92,19 +92,17 @@ void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *d
|
||||
|
||||
#ifdef BLI_HAVE_SSE2
|
||||
__m128 accum_r = _mm_load_ps(color_accum);
|
||||
for (int nx = xmin, index = (xmin - x) + this->m_filtersize; nx < xmax;
|
||||
nx += step, index += step) {
|
||||
for (int nx = xmin, index = (xmin - x) + m_filtersize; nx < xmax; nx += step, index += step) {
|
||||
__m128 reg_a = _mm_load_ps(&buffer[bufferindex]);
|
||||
reg_a = _mm_mul_ps(reg_a, this->m_gausstab_sse[index]);
|
||||
reg_a = _mm_mul_ps(reg_a, m_gausstab_sse[index]);
|
||||
accum_r = _mm_add_ps(accum_r, reg_a);
|
||||
multiplier_accum += this->m_gausstab[index];
|
||||
multiplier_accum += m_gausstab[index];
|
||||
bufferindex += offsetadd;
|
||||
}
|
||||
_mm_store_ps(color_accum, accum_r);
|
||||
#else
|
||||
for (int nx = xmin, index = (xmin - x) + this->m_filtersize; nx < xmax;
|
||||
nx += step, index += step) {
|
||||
const float multiplier = this->m_gausstab[index];
|
||||
for (int nx = xmin, index = (xmin - x) + m_filtersize; nx < xmax; nx += step, index += step) {
|
||||
const float multiplier = m_gausstab[index];
|
||||
madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
|
||||
multiplier_accum += multiplier;
|
||||
bufferindex += offsetadd;
|
||||
@@ -122,20 +120,16 @@ void GaussianXBlurOperation::executeOpenCL(OpenCLDevice *device,
|
||||
{
|
||||
cl_kernel gaussianXBlurOperationKernel = device->COM_clCreateKernel(
|
||||
"gaussianXBlurOperationKernel", nullptr);
|
||||
cl_int filter_size = this->m_filtersize;
|
||||
cl_int filter_size = m_filtersize;
|
||||
|
||||
cl_mem gausstab = clCreateBuffer(device->getContext(),
|
||||
CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
|
||||
sizeof(float) * (this->m_filtersize * 2 + 1),
|
||||
this->m_gausstab,
|
||||
sizeof(float) * (m_filtersize * 2 + 1),
|
||||
m_gausstab,
|
||||
nullptr);
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(gaussianXBlurOperationKernel,
|
||||
0,
|
||||
1,
|
||||
clMemToCleanUp,
|
||||
inputMemoryBuffers,
|
||||
this->m_inputProgram);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
gaussianXBlurOperationKernel, 0, 1, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
device->COM_clAttachOutputMemoryBufferToKernelParameter(
|
||||
gaussianXBlurOperationKernel, 2, clOutputBuffer);
|
||||
device->COM_clAttachMemoryBufferOffsetToKernelParameter(
|
||||
@@ -153,14 +147,14 @@ void GaussianXBlurOperation::deinitExecution()
|
||||
{
|
||||
GaussianBlurBaseOperation::deinitExecution();
|
||||
|
||||
if (this->m_gausstab) {
|
||||
MEM_freeN(this->m_gausstab);
|
||||
this->m_gausstab = nullptr;
|
||||
if (m_gausstab) {
|
||||
MEM_freeN(m_gausstab);
|
||||
m_gausstab = nullptr;
|
||||
}
|
||||
#ifdef BLI_HAVE_SSE2
|
||||
if (this->m_gausstab_sse) {
|
||||
MEM_freeN(this->m_gausstab_sse);
|
||||
this->m_gausstab_sse = nullptr;
|
||||
if (m_gausstab_sse) {
|
||||
MEM_freeN(m_gausstab_sse);
|
||||
m_gausstab_sse = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -173,7 +167,7 @@ bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
if (!this->m_sizeavailable) {
|
||||
if (!m_sizeavailable) {
|
||||
rcti sizeInput;
|
||||
sizeInput.xmin = 0;
|
||||
sizeInput.ymin = 0;
|
||||
@@ -185,9 +179,9 @@ bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
}
|
||||
}
|
||||
{
|
||||
if (this->m_sizeavailable && this->m_gausstab != nullptr) {
|
||||
newInput.xmax = input->xmax + this->m_filtersize + 1;
|
||||
newInput.xmin = input->xmin - this->m_filtersize - 1;
|
||||
if (m_sizeavailable && m_gausstab != nullptr) {
|
||||
newInput.xmax = input->xmax + m_filtersize + 1;
|
||||
newInput.xmin = input->xmin - m_filtersize - 1;
|
||||
newInput.ymax = input->ymax;
|
||||
newInput.ymin = input->ymin;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ GaussianYBlurOperation::GaussianYBlurOperation() : GaussianBlurBaseOperation(eDi
|
||||
void *GaussianYBlurOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
lockMutex();
|
||||
if (!this->m_sizeavailable) {
|
||||
if (!m_sizeavailable) {
|
||||
updateGauss();
|
||||
}
|
||||
void *buffer = getInputOperation(0)->initializeTileData(nullptr);
|
||||
@@ -42,28 +42,28 @@ void GaussianYBlurOperation::initExecution()
|
||||
|
||||
initMutex();
|
||||
|
||||
if (this->m_sizeavailable && execution_model_ == eExecutionModel::Tiled) {
|
||||
if (m_sizeavailable && execution_model_ == eExecutionModel::Tiled) {
|
||||
float rad = max_ff(m_size * m_data.sizey, 0.0f);
|
||||
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
|
||||
|
||||
this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
#ifdef BLI_HAVE_SSE2
|
||||
this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab, m_filtersize);
|
||||
m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(m_gausstab, m_filtersize);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void GaussianYBlurOperation::updateGauss()
|
||||
{
|
||||
if (this->m_gausstab == nullptr) {
|
||||
if (m_gausstab == nullptr) {
|
||||
updateSize();
|
||||
float rad = max_ff(m_size * m_data.sizey, 0.0f);
|
||||
rad = min_ff(rad, MAX_GAUSSTAB_RADIUS);
|
||||
m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
|
||||
|
||||
this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
|
||||
#ifdef BLI_HAVE_SSE2
|
||||
this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab, m_filtersize);
|
||||
m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(m_gausstab, m_filtersize);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -90,20 +90,20 @@ void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *d
|
||||
#ifdef BLI_HAVE_SSE2
|
||||
__m128 accum_r = _mm_load_ps(color_accum);
|
||||
for (int ny = ymin; ny < ymax; ny += step) {
|
||||
index = (ny - y) + this->m_filtersize;
|
||||
index = (ny - y) + m_filtersize;
|
||||
int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth);
|
||||
const float multiplier = this->m_gausstab[index];
|
||||
const float multiplier = m_gausstab[index];
|
||||
__m128 reg_a = _mm_load_ps(&buffer[bufferindex]);
|
||||
reg_a = _mm_mul_ps(reg_a, this->m_gausstab_sse[index]);
|
||||
reg_a = _mm_mul_ps(reg_a, m_gausstab_sse[index]);
|
||||
accum_r = _mm_add_ps(accum_r, reg_a);
|
||||
multiplier_accum += multiplier;
|
||||
}
|
||||
_mm_store_ps(color_accum, accum_r);
|
||||
#else
|
||||
for (int ny = ymin; ny < ymax; ny += step) {
|
||||
index = (ny - y) + this->m_filtersize;
|
||||
index = (ny - y) + m_filtersize;
|
||||
int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth);
|
||||
const float multiplier = this->m_gausstab[index];
|
||||
const float multiplier = m_gausstab[index];
|
||||
madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
|
||||
multiplier_accum += multiplier;
|
||||
}
|
||||
@@ -120,20 +120,16 @@ void GaussianYBlurOperation::executeOpenCL(OpenCLDevice *device,
|
||||
{
|
||||
cl_kernel gaussianYBlurOperationKernel = device->COM_clCreateKernel(
|
||||
"gaussianYBlurOperationKernel", nullptr);
|
||||
cl_int filter_size = this->m_filtersize;
|
||||
cl_int filter_size = m_filtersize;
|
||||
|
||||
cl_mem gausstab = clCreateBuffer(device->getContext(),
|
||||
CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
|
||||
sizeof(float) * (this->m_filtersize * 2 + 1),
|
||||
this->m_gausstab,
|
||||
sizeof(float) * (m_filtersize * 2 + 1),
|
||||
m_gausstab,
|
||||
nullptr);
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(gaussianYBlurOperationKernel,
|
||||
0,
|
||||
1,
|
||||
clMemToCleanUp,
|
||||
inputMemoryBuffers,
|
||||
this->m_inputProgram);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
gaussianYBlurOperationKernel, 0, 1, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
device->COM_clAttachOutputMemoryBufferToKernelParameter(
|
||||
gaussianYBlurOperationKernel, 2, clOutputBuffer);
|
||||
device->COM_clAttachMemoryBufferOffsetToKernelParameter(
|
||||
@@ -151,14 +147,14 @@ void GaussianYBlurOperation::deinitExecution()
|
||||
{
|
||||
GaussianBlurBaseOperation::deinitExecution();
|
||||
|
||||
if (this->m_gausstab) {
|
||||
MEM_freeN(this->m_gausstab);
|
||||
this->m_gausstab = nullptr;
|
||||
if (m_gausstab) {
|
||||
MEM_freeN(m_gausstab);
|
||||
m_gausstab = nullptr;
|
||||
}
|
||||
#ifdef BLI_HAVE_SSE2
|
||||
if (this->m_gausstab_sse) {
|
||||
MEM_freeN(this->m_gausstab_sse);
|
||||
this->m_gausstab_sse = nullptr;
|
||||
if (m_gausstab_sse) {
|
||||
MEM_freeN(m_gausstab_sse);
|
||||
m_gausstab_sse = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -183,11 +179,11 @@ bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
}
|
||||
}
|
||||
{
|
||||
if (this->m_sizeavailable && this->m_gausstab != nullptr) {
|
||||
if (m_sizeavailable && m_gausstab != nullptr) {
|
||||
newInput.xmax = input->xmax;
|
||||
newInput.xmin = input->xmin;
|
||||
newInput.ymax = input->ymax + this->m_filtersize + 1;
|
||||
newInput.ymin = input->ymin - this->m_filtersize - 1;
|
||||
newInput.ymax = input->ymax + m_filtersize + 1;
|
||||
newInput.ymin = input->ymin - m_filtersize - 1;
|
||||
}
|
||||
else {
|
||||
newInput.xmax = this->getWidth();
|
||||
|
||||
@@ -24,25 +24,25 @@ GlareBaseOperation::GlareBaseOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_settings = nullptr;
|
||||
m_settings = nullptr;
|
||||
flags.is_fullframe_operation = true;
|
||||
is_output_rendered_ = false;
|
||||
}
|
||||
void GlareBaseOperation::initExecution()
|
||||
{
|
||||
SingleThreadedOperation::initExecution();
|
||||
this->m_inputProgram = getInputSocketReader(0);
|
||||
m_inputProgram = getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void GlareBaseOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
SingleThreadedOperation::deinitExecution();
|
||||
}
|
||||
|
||||
MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2)
|
||||
{
|
||||
MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect2);
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_inputProgram->initializeTileData(rect2);
|
||||
rcti rect;
|
||||
rect.xmin = 0;
|
||||
rect.ymin = 0;
|
||||
@@ -50,7 +50,7 @@ MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2)
|
||||
rect.ymax = getHeight();
|
||||
MemoryBuffer *result = new MemoryBuffer(DataType::Color, rect);
|
||||
float *data = result->getBuffer();
|
||||
this->generateGlare(data, tile, this->m_settings);
|
||||
this->generateGlare(data, tile, m_settings);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class GlareBaseOperation : public SingleThreadedOperation {
|
||||
|
||||
void setGlareSettings(NodeGlare *settings)
|
||||
{
|
||||
this->m_settings = settings;
|
||||
m_settings = settings;
|
||||
}
|
||||
bool determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
|
||||
@@ -26,21 +26,21 @@ GlareThresholdOperation::GlareThresholdOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color, ResizeMode::FitAny);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
void GlareThresholdOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
NodeOperation::determine_canvas(preferred_area, r_area);
|
||||
const int width = BLI_rcti_size_x(&r_area) / (1 << this->m_settings->quality);
|
||||
const int height = BLI_rcti_size_y(&r_area) / (1 << this->m_settings->quality);
|
||||
const int width = BLI_rcti_size_x(&r_area) / (1 << m_settings->quality);
|
||||
const int height = BLI_rcti_size_y(&r_area) / (1 << m_settings->quality);
|
||||
r_area.xmax = r_area.xmin + width;
|
||||
r_area.ymax = r_area.ymin + height;
|
||||
}
|
||||
|
||||
void GlareThresholdOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void GlareThresholdOperation::executePixelSampled(float output[4],
|
||||
@@ -48,9 +48,9 @@ void GlareThresholdOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler sampler)
|
||||
{
|
||||
const float threshold = this->m_settings->threshold;
|
||||
const float threshold = m_settings->threshold;
|
||||
|
||||
this->m_inputProgram->readSampled(output, x, y, sampler);
|
||||
m_inputProgram->readSampled(output, x, y, sampler);
|
||||
if (IMB_colormanagement_get_luminance(output) >= threshold) {
|
||||
output[0] -= threshold;
|
||||
output[1] -= threshold;
|
||||
@@ -67,14 +67,14 @@ void GlareThresholdOperation::executePixelSampled(float output[4],
|
||||
|
||||
void GlareThresholdOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
void GlareThresholdOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
const float threshold = this->m_settings->threshold;
|
||||
const float threshold = m_settings->threshold;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
const float *color = it.in(0);
|
||||
if (IMB_colormanagement_get_luminance(color) >= threshold) {
|
||||
|
||||
@@ -55,7 +55,7 @@ class GlareThresholdOperation : public MultiThreadedOperation {
|
||||
|
||||
void setGlareSettings(NodeGlare *settings)
|
||||
{
|
||||
this->m_settings = settings;
|
||||
m_settings = settings;
|
||||
}
|
||||
|
||||
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
|
||||
|
||||
@@ -29,12 +29,12 @@ HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
void HueSaturationValueCorrectOperation::initExecution()
|
||||
{
|
||||
CurveBaseOperation::initExecution();
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void HueSaturationValueCorrectOperation::executePixelSampled(float output[4],
|
||||
@@ -44,18 +44,18 @@ void HueSaturationValueCorrectOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float hsv[4], f;
|
||||
|
||||
this->m_inputProgram->readSampled(hsv, x, y, sampler);
|
||||
m_inputProgram->readSampled(hsv, x, y, sampler);
|
||||
|
||||
/* adjust hue, scaling returned default 0.5 up to 1 */
|
||||
f = BKE_curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]);
|
||||
f = BKE_curvemapping_evaluateF(m_curveMapping, 0, hsv[0]);
|
||||
hsv[0] += f - 0.5f;
|
||||
|
||||
/* adjust saturation, scaling returned default 0.5 up to 1 */
|
||||
f = BKE_curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]);
|
||||
f = BKE_curvemapping_evaluateF(m_curveMapping, 1, hsv[0]);
|
||||
hsv[1] *= (f * 2.0f);
|
||||
|
||||
/* adjust value, scaling returned default 0.5 up to 1 */
|
||||
f = BKE_curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]);
|
||||
f = BKE_curvemapping_evaluateF(m_curveMapping, 2, hsv[0]);
|
||||
hsv[2] *= (f * 2.0f);
|
||||
|
||||
hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */
|
||||
@@ -70,7 +70,7 @@ void HueSaturationValueCorrectOperation::executePixelSampled(float output[4],
|
||||
void HueSaturationValueCorrectOperation::deinitExecution()
|
||||
{
|
||||
CurveBaseOperation::deinitExecution();
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
void HueSaturationValueCorrectOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -82,15 +82,15 @@ void HueSaturationValueCorrectOperation::update_memory_buffer_partial(MemoryBuff
|
||||
copy_v4_v4(hsv, it.in(0));
|
||||
|
||||
/* Adjust hue, scaling returned default 0.5 up to 1. */
|
||||
float f = BKE_curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]);
|
||||
float f = BKE_curvemapping_evaluateF(m_curveMapping, 0, hsv[0]);
|
||||
hsv[0] += f - 0.5f;
|
||||
|
||||
/* Adjust saturation, scaling returned default 0.5 up to 1. */
|
||||
f = BKE_curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]);
|
||||
f = BKE_curvemapping_evaluateF(m_curveMapping, 1, hsv[0]);
|
||||
hsv[1] *= (f * 2.0f);
|
||||
|
||||
/* Adjust value, scaling returned default 0.5 up to 1. */
|
||||
f = BKE_curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]);
|
||||
f = BKE_curvemapping_evaluateF(m_curveMapping, 2, hsv[0]);
|
||||
hsv[2] *= (f * 2.0f);
|
||||
|
||||
hsv[0] = hsv[0] - floorf(hsv[0]); /* Mod 1.0. */
|
||||
|
||||
@@ -40,7 +40,7 @@ void IDMaskOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
const int buffer_width = input_buffer->getWidth();
|
||||
float *buffer = input_buffer->getBuffer();
|
||||
int buffer_index = (y * buffer_width + x);
|
||||
output[0] = (roundf(buffer[buffer_index]) == this->m_objectIndex) ? 1.0f : 0.0f;
|
||||
output[0] = (roundf(buffer[buffer_index]) == m_objectIndex) ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
void IDMaskOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -34,7 +34,7 @@ class IDMaskOperation : public MultiThreadedOperation {
|
||||
|
||||
void setObjectIndex(float objectIndex)
|
||||
{
|
||||
this->m_objectIndex = objectIndex;
|
||||
m_objectIndex = objectIndex;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -28,19 +28,19 @@ namespace blender::compositor {
|
||||
|
||||
BaseImageOperation::BaseImageOperation()
|
||||
{
|
||||
this->m_image = nullptr;
|
||||
this->m_buffer = nullptr;
|
||||
this->m_imageFloatBuffer = nullptr;
|
||||
this->m_imageByteBuffer = nullptr;
|
||||
this->m_imageUser = nullptr;
|
||||
this->m_imagewidth = 0;
|
||||
this->m_imageheight = 0;
|
||||
this->m_framenumber = 0;
|
||||
this->m_depthBuffer = nullptr;
|
||||
m_image = nullptr;
|
||||
m_buffer = nullptr;
|
||||
m_imageFloatBuffer = nullptr;
|
||||
m_imageByteBuffer = nullptr;
|
||||
m_imageUser = nullptr;
|
||||
m_imagewidth = 0;
|
||||
m_imageheight = 0;
|
||||
m_framenumber = 0;
|
||||
m_depthBuffer = nullptr;
|
||||
depth_buffer_ = nullptr;
|
||||
this->m_numberOfChannels = 0;
|
||||
this->m_rd = nullptr;
|
||||
this->m_viewName = nullptr;
|
||||
m_numberOfChannels = 0;
|
||||
m_rd = nullptr;
|
||||
m_viewName = nullptr;
|
||||
}
|
||||
ImageOperation::ImageOperation() : BaseImageOperation()
|
||||
{
|
||||
@@ -58,20 +58,20 @@ ImageDepthOperation::ImageDepthOperation() : BaseImageOperation()
|
||||
ImBuf *BaseImageOperation::getImBuf()
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
ImageUser iuser = *this->m_imageUser;
|
||||
ImageUser iuser = *m_imageUser;
|
||||
|
||||
if (this->m_image == nullptr) {
|
||||
if (m_image == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* local changes to the original ImageUser */
|
||||
if (BKE_image_is_multilayer(this->m_image) == false) {
|
||||
iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
|
||||
if (BKE_image_is_multilayer(m_image) == false) {
|
||||
iuser.multi_index = BKE_scene_multiview_view_id_get(m_rd, m_viewName);
|
||||
}
|
||||
|
||||
ibuf = BKE_image_acquire_ibuf(this->m_image, &iuser, nullptr);
|
||||
ibuf = BKE_image_acquire_ibuf(m_image, &iuser, nullptr);
|
||||
if (ibuf == nullptr || (ibuf->rect == nullptr && ibuf->rect_float == nullptr)) {
|
||||
BKE_image_release_ibuf(this->m_image, ibuf, nullptr);
|
||||
BKE_image_release_ibuf(m_image, ibuf, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
return ibuf;
|
||||
@@ -80,25 +80,25 @@ ImBuf *BaseImageOperation::getImBuf()
|
||||
void BaseImageOperation::initExecution()
|
||||
{
|
||||
ImBuf *stackbuf = getImBuf();
|
||||
this->m_buffer = stackbuf;
|
||||
m_buffer = stackbuf;
|
||||
if (stackbuf) {
|
||||
this->m_imageFloatBuffer = stackbuf->rect_float;
|
||||
this->m_imageByteBuffer = stackbuf->rect;
|
||||
this->m_depthBuffer = stackbuf->zbuf_float;
|
||||
m_imageFloatBuffer = stackbuf->rect_float;
|
||||
m_imageByteBuffer = stackbuf->rect;
|
||||
m_depthBuffer = stackbuf->zbuf_float;
|
||||
if (stackbuf->zbuf_float) {
|
||||
depth_buffer_ = new MemoryBuffer(stackbuf->zbuf_float, 1, stackbuf->x, stackbuf->y);
|
||||
}
|
||||
this->m_imagewidth = stackbuf->x;
|
||||
this->m_imageheight = stackbuf->y;
|
||||
this->m_numberOfChannels = stackbuf->channels;
|
||||
m_imagewidth = stackbuf->x;
|
||||
m_imageheight = stackbuf->y;
|
||||
m_numberOfChannels = stackbuf->channels;
|
||||
}
|
||||
}
|
||||
|
||||
void BaseImageOperation::deinitExecution()
|
||||
{
|
||||
this->m_imageFloatBuffer = nullptr;
|
||||
this->m_imageByteBuffer = nullptr;
|
||||
BKE_image_release_ibuf(this->m_image, this->m_buffer, nullptr);
|
||||
m_imageFloatBuffer = nullptr;
|
||||
m_imageByteBuffer = nullptr;
|
||||
BKE_image_release_ibuf(m_image, m_buffer, nullptr);
|
||||
if (depth_buffer_) {
|
||||
delete depth_buffer_;
|
||||
depth_buffer_ = nullptr;
|
||||
@@ -115,7 +115,7 @@ void BaseImageOperation::determine_canvas(const rcti &UNUSED(preferred_area), rc
|
||||
BLI_rcti_init(&r_area, 0, stackbuf->x, 0, stackbuf->y);
|
||||
}
|
||||
|
||||
BKE_image_release_ibuf(this->m_image, stackbuf, nullptr);
|
||||
BKE_image_release_ibuf(m_image, stackbuf, nullptr);
|
||||
}
|
||||
|
||||
static void sampleImageAtLocation(
|
||||
@@ -157,14 +157,14 @@ static void sampleImageAtLocation(
|
||||
void ImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
{
|
||||
int ix = x, iy = y;
|
||||
if (this->m_imageFloatBuffer == nullptr && this->m_imageByteBuffer == nullptr) {
|
||||
if (m_imageFloatBuffer == nullptr && m_imageByteBuffer == nullptr) {
|
||||
zero_v4(output);
|
||||
}
|
||||
else if (ix < 0 || iy < 0 || ix >= this->m_buffer->x || iy >= this->m_buffer->y) {
|
||||
else if (ix < 0 || iy < 0 || ix >= m_buffer->x || iy >= m_buffer->y) {
|
||||
zero_v4(output);
|
||||
}
|
||||
else {
|
||||
sampleImageAtLocation(this->m_buffer, x, y, sampler, true, output);
|
||||
sampleImageAtLocation(m_buffer, x, y, sampler, true, output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,12 +182,12 @@ void ImageAlphaOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float tempcolor[4];
|
||||
|
||||
if (this->m_imageFloatBuffer == nullptr && this->m_imageByteBuffer == nullptr) {
|
||||
if (m_imageFloatBuffer == nullptr && m_imageByteBuffer == nullptr) {
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
else {
|
||||
tempcolor[3] = 1.0f;
|
||||
sampleImageAtLocation(this->m_buffer, x, y, sampler, false, tempcolor);
|
||||
sampleImageAtLocation(m_buffer, x, y, sampler, false, tempcolor);
|
||||
output[0] = tempcolor[3];
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ void ImageDepthOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
if (this->m_depthBuffer == nullptr) {
|
||||
if (m_depthBuffer == nullptr) {
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
else {
|
||||
@@ -213,7 +213,7 @@ void ImageDepthOperation::executePixelSampled(float output[4],
|
||||
}
|
||||
else {
|
||||
int offset = y * getWidth() + x;
|
||||
output[0] = this->m_depthBuffer[offset];
|
||||
output[0] = m_depthBuffer[offset];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,23 +63,23 @@ class BaseImageOperation : public MultiThreadedOperation {
|
||||
void deinitExecution() override;
|
||||
void setImage(Image *image)
|
||||
{
|
||||
this->m_image = image;
|
||||
m_image = image;
|
||||
}
|
||||
void setImageUser(ImageUser *imageuser)
|
||||
{
|
||||
this->m_imageUser = imageuser;
|
||||
m_imageUser = imageuser;
|
||||
}
|
||||
void setRenderData(const RenderData *rd)
|
||||
{
|
||||
this->m_rd = rd;
|
||||
m_rd = rd;
|
||||
}
|
||||
void setViewName(const char *viewName)
|
||||
{
|
||||
this->m_viewName = viewName;
|
||||
m_viewName = viewName;
|
||||
}
|
||||
void setFramenumber(int framenumber)
|
||||
{
|
||||
this->m_framenumber = framenumber;
|
||||
m_framenumber = framenumber;
|
||||
}
|
||||
};
|
||||
class ImageOperation : public BaseImageOperation {
|
||||
|
||||
@@ -31,21 +31,21 @@ InpaintSimpleOperation::InpaintSimpleOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_pixelorder = nullptr;
|
||||
this->m_manhattan_distance = nullptr;
|
||||
this->m_cached_buffer = nullptr;
|
||||
this->m_cached_buffer_ready = false;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_pixelorder = nullptr;
|
||||
m_manhattan_distance = nullptr;
|
||||
m_cached_buffer = nullptr;
|
||||
m_cached_buffer_ready = false;
|
||||
flags.is_fullframe_operation = true;
|
||||
}
|
||||
void InpaintSimpleOperation::initExecution()
|
||||
{
|
||||
this->m_inputImageProgram = this->getInputSocketReader(0);
|
||||
m_inputImageProgram = this->getInputSocketReader(0);
|
||||
|
||||
this->m_pixelorder = nullptr;
|
||||
this->m_manhattan_distance = nullptr;
|
||||
this->m_cached_buffer = nullptr;
|
||||
this->m_cached_buffer_ready = false;
|
||||
m_pixelorder = nullptr;
|
||||
m_manhattan_distance = nullptr;
|
||||
m_cached_buffer = nullptr;
|
||||
m_cached_buffer_ready = false;
|
||||
|
||||
this->initMutex();
|
||||
}
|
||||
@@ -76,8 +76,8 @@ float *InpaintSimpleOperation::get_pixel(int x, int y)
|
||||
|
||||
ASSERT_XY_RANGE(x, y);
|
||||
|
||||
return &this->m_cached_buffer[y * width * COM_DATA_TYPE_COLOR_CHANNELS +
|
||||
x * COM_DATA_TYPE_COLOR_CHANNELS];
|
||||
return &m_cached_buffer[y * width * COM_DATA_TYPE_COLOR_CHANNELS +
|
||||
x * COM_DATA_TYPE_COLOR_CHANNELS];
|
||||
}
|
||||
|
||||
int InpaintSimpleOperation::mdist(int x, int y)
|
||||
@@ -86,18 +86,18 @@ int InpaintSimpleOperation::mdist(int x, int y)
|
||||
|
||||
ASSERT_XY_RANGE(x, y);
|
||||
|
||||
return this->m_manhattan_distance[y * width + x];
|
||||
return m_manhattan_distance[y * width + x];
|
||||
}
|
||||
|
||||
bool InpaintSimpleOperation::next_pixel(int &x, int &y, int &curr, int iters)
|
||||
{
|
||||
int width = this->getWidth();
|
||||
|
||||
if (curr >= this->m_area_size) {
|
||||
if (curr >= m_area_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int r = this->m_pixelorder[curr++];
|
||||
int r = m_pixelorder[curr++];
|
||||
|
||||
x = r % width;
|
||||
y = r / width;
|
||||
@@ -113,8 +113,7 @@ void InpaintSimpleOperation::calc_manhattan_distance()
|
||||
{
|
||||
int width = this->getWidth();
|
||||
int height = this->getHeight();
|
||||
short *m = this->m_manhattan_distance = (short *)MEM_mallocN(sizeof(short) * width * height,
|
||||
__func__);
|
||||
short *m = m_manhattan_distance = (short *)MEM_mallocN(sizeof(short) * width * height, __func__);
|
||||
int *offsets;
|
||||
|
||||
offsets = (int *)MEM_callocN(sizeof(int) * (width + height + 1),
|
||||
@@ -160,12 +159,12 @@ void InpaintSimpleOperation::calc_manhattan_distance()
|
||||
offsets[i] += offsets[i - 1];
|
||||
}
|
||||
|
||||
this->m_area_size = offsets[width + height];
|
||||
this->m_pixelorder = (int *)MEM_mallocN(sizeof(int) * this->m_area_size, __func__);
|
||||
m_area_size = offsets[width + height];
|
||||
m_pixelorder = (int *)MEM_mallocN(sizeof(int) * m_area_size, __func__);
|
||||
|
||||
for (int i = 0; i < width * height; i++) {
|
||||
if (m[i] > 0) {
|
||||
this->m_pixelorder[offsets[m[i] - 1]++] = i;
|
||||
m_pixelorder[offsets[m[i] - 1]++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,27 +215,27 @@ void InpaintSimpleOperation::pix_step(int x, int y)
|
||||
|
||||
void *InpaintSimpleOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
if (this->m_cached_buffer_ready) {
|
||||
return this->m_cached_buffer;
|
||||
if (m_cached_buffer_ready) {
|
||||
return m_cached_buffer;
|
||||
}
|
||||
lockMutex();
|
||||
if (!this->m_cached_buffer_ready) {
|
||||
MemoryBuffer *buf = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
|
||||
this->m_cached_buffer = (float *)MEM_dupallocN(buf->getBuffer());
|
||||
if (!m_cached_buffer_ready) {
|
||||
MemoryBuffer *buf = (MemoryBuffer *)m_inputImageProgram->initializeTileData(rect);
|
||||
m_cached_buffer = (float *)MEM_dupallocN(buf->getBuffer());
|
||||
|
||||
this->calc_manhattan_distance();
|
||||
|
||||
int curr = 0;
|
||||
int x, y;
|
||||
|
||||
while (this->next_pixel(x, y, curr, this->m_iterations)) {
|
||||
while (this->next_pixel(x, y, curr, m_iterations)) {
|
||||
this->pix_step(x, y);
|
||||
}
|
||||
this->m_cached_buffer_ready = true;
|
||||
m_cached_buffer_ready = true;
|
||||
}
|
||||
|
||||
unlockMutex();
|
||||
return this->m_cached_buffer;
|
||||
return m_cached_buffer;
|
||||
}
|
||||
|
||||
void InpaintSimpleOperation::executePixel(float output[4], int x, int y, void * /*data*/)
|
||||
@@ -247,30 +246,30 @@ void InpaintSimpleOperation::executePixel(float output[4], int x, int y, void *
|
||||
|
||||
void InpaintSimpleOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputImageProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
this->deinitMutex();
|
||||
if (this->m_cached_buffer) {
|
||||
MEM_freeN(this->m_cached_buffer);
|
||||
this->m_cached_buffer = nullptr;
|
||||
if (m_cached_buffer) {
|
||||
MEM_freeN(m_cached_buffer);
|
||||
m_cached_buffer = nullptr;
|
||||
}
|
||||
|
||||
if (this->m_pixelorder) {
|
||||
MEM_freeN(this->m_pixelorder);
|
||||
this->m_pixelorder = nullptr;
|
||||
if (m_pixelorder) {
|
||||
MEM_freeN(m_pixelorder);
|
||||
m_pixelorder = nullptr;
|
||||
}
|
||||
|
||||
if (this->m_manhattan_distance) {
|
||||
MEM_freeN(this->m_manhattan_distance);
|
||||
this->m_manhattan_distance = nullptr;
|
||||
if (m_manhattan_distance) {
|
||||
MEM_freeN(m_manhattan_distance);
|
||||
m_manhattan_distance = nullptr;
|
||||
}
|
||||
this->m_cached_buffer_ready = false;
|
||||
m_cached_buffer_ready = false;
|
||||
}
|
||||
|
||||
bool InpaintSimpleOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
ReadBufferOperation *readOperation,
|
||||
rcti *output)
|
||||
{
|
||||
if (this->m_cached_buffer_ready) {
|
||||
if (m_cached_buffer_ready) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -313,7 +312,7 @@ void InpaintSimpleOperation::update_memory_buffer(MemoryBuffer *output,
|
||||
|
||||
int curr = 0;
|
||||
int x, y;
|
||||
while (this->next_pixel(x, y, curr, this->m_iterations)) {
|
||||
while (this->next_pixel(x, y, curr, m_iterations)) {
|
||||
this->pix_step(x, y);
|
||||
}
|
||||
m_cached_buffer_ready = true;
|
||||
|
||||
@@ -59,7 +59,7 @@ class InpaintSimpleOperation : public NodeOperation {
|
||||
|
||||
void setIterations(int iterations)
|
||||
{
|
||||
this->m_iterations = iterations;
|
||||
m_iterations = iterations;
|
||||
}
|
||||
|
||||
bool determineDependingAreaOfInterest(rcti *input,
|
||||
|
||||
@@ -25,30 +25,30 @@ InvertOperation::InvertOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputValueProgram = nullptr;
|
||||
this->m_inputColorProgram = nullptr;
|
||||
this->m_color = true;
|
||||
this->m_alpha = false;
|
||||
m_inputValueProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
m_color = true;
|
||||
m_alpha = false;
|
||||
set_canvas_input_index(1);
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
void InvertOperation::initExecution()
|
||||
{
|
||||
this->m_inputValueProgram = this->getInputSocketReader(0);
|
||||
this->m_inputColorProgram = this->getInputSocketReader(1);
|
||||
m_inputValueProgram = this->getInputSocketReader(0);
|
||||
m_inputColorProgram = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void InvertOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
{
|
||||
float inputValue[4];
|
||||
float inputColor[4];
|
||||
this->m_inputValueProgram->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColorProgram->readSampled(inputColor, x, y, sampler);
|
||||
m_inputValueProgram->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColorProgram->readSampled(inputColor, x, y, sampler);
|
||||
|
||||
const float value = inputValue[0];
|
||||
const float invertedValue = 1.0f - value;
|
||||
|
||||
if (this->m_color) {
|
||||
if (m_color) {
|
||||
output[0] = (1.0f - inputColor[0]) * value + inputColor[0] * invertedValue;
|
||||
output[1] = (1.0f - inputColor[1]) * value + inputColor[1] * invertedValue;
|
||||
output[2] = (1.0f - inputColor[2]) * value + inputColor[2] * invertedValue;
|
||||
@@ -57,7 +57,7 @@ void InvertOperation::executePixelSampled(float output[4], float x, float y, Pix
|
||||
copy_v3_v3(output, inputColor);
|
||||
}
|
||||
|
||||
if (this->m_alpha) {
|
||||
if (m_alpha) {
|
||||
output[3] = (1.0f - inputColor[3]) * value + inputColor[3] * invertedValue;
|
||||
}
|
||||
else {
|
||||
@@ -67,8 +67,8 @@ void InvertOperation::executePixelSampled(float output[4], float x, float y, Pix
|
||||
|
||||
void InvertOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputValueProgram = nullptr;
|
||||
this->m_inputColorProgram = nullptr;
|
||||
m_inputValueProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
}
|
||||
|
||||
void InvertOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -80,7 +80,7 @@ void InvertOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const float inverted_value = 1.0f - value;
|
||||
const float *color = it.in(1);
|
||||
|
||||
if (this->m_color) {
|
||||
if (m_color) {
|
||||
it.out[0] = (1.0f - color[0]) * value + color[0] * inverted_value;
|
||||
it.out[1] = (1.0f - color[1]) * value + color[1] * inverted_value;
|
||||
it.out[2] = (1.0f - color[2]) * value + color[2] * inverted_value;
|
||||
@@ -89,7 +89,7 @@ void InvertOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
copy_v3_v3(it.out, color);
|
||||
}
|
||||
|
||||
if (this->m_alpha) {
|
||||
if (m_alpha) {
|
||||
it.out[3] = (1.0f - color[3]) * value + color[3] * inverted_value;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -53,11 +53,11 @@ class InvertOperation : public MultiThreadedOperation {
|
||||
|
||||
void setColor(bool color)
|
||||
{
|
||||
this->m_color = color;
|
||||
m_color = color;
|
||||
}
|
||||
void setAlpha(bool alpha)
|
||||
{
|
||||
this->m_alpha = alpha;
|
||||
m_alpha = alpha;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -25,8 +25,8 @@ KeyingBlurOperation::KeyingBlurOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
|
||||
this->m_size = 0;
|
||||
this->m_axis = BLUR_AXIS_X;
|
||||
m_size = 0;
|
||||
m_axis = BLUR_AXIS_X;
|
||||
|
||||
this->flags.complex = true;
|
||||
}
|
||||
@@ -46,8 +46,8 @@ void KeyingBlurOperation::executePixel(float output[4], int x, int y, void *data
|
||||
int count = 0;
|
||||
float average = 0.0f;
|
||||
|
||||
if (this->m_axis == 0) {
|
||||
const int start = MAX2(0, x - this->m_size + 1), end = MIN2(bufferWidth, x + this->m_size);
|
||||
if (m_axis == 0) {
|
||||
const int start = MAX2(0, x - m_size + 1), end = MIN2(bufferWidth, x + m_size);
|
||||
for (int cx = start; cx < end; cx++) {
|
||||
int bufferIndex = (y * bufferWidth + cx);
|
||||
average += buffer[bufferIndex];
|
||||
@@ -55,8 +55,7 @@ void KeyingBlurOperation::executePixel(float output[4], int x, int y, void *data
|
||||
}
|
||||
}
|
||||
else {
|
||||
const int start = MAX2(0, y - this->m_size + 1),
|
||||
end = MIN2(inputBuffer->getHeight(), y + this->m_size);
|
||||
const int start = MAX2(0, y - m_size + 1), end = MIN2(inputBuffer->getHeight(), y + m_size);
|
||||
for (int cy = start; cy < end; cy++) {
|
||||
int bufferIndex = (cy * bufferWidth + x);
|
||||
average += buffer[bufferIndex];
|
||||
@@ -75,17 +74,17 @@ bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
if (this->m_axis == BLUR_AXIS_X) {
|
||||
newInput.xmin = input->xmin - this->m_size;
|
||||
if (m_axis == BLUR_AXIS_X) {
|
||||
newInput.xmin = input->xmin - m_size;
|
||||
newInput.ymin = input->ymin;
|
||||
newInput.xmax = input->xmax + this->m_size;
|
||||
newInput.xmax = input->xmax + m_size;
|
||||
newInput.ymax = input->ymax;
|
||||
}
|
||||
else {
|
||||
newInput.xmin = input->xmin;
|
||||
newInput.ymin = input->ymin - this->m_size;
|
||||
newInput.ymin = input->ymin - m_size;
|
||||
newInput.xmax = input->xmax;
|
||||
newInput.ymax = input->ymax + this->m_size;
|
||||
newInput.ymax = input->ymax + m_size;
|
||||
}
|
||||
|
||||
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
|
||||
|
||||
@@ -40,11 +40,11 @@ class KeyingBlurOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSize(int value)
|
||||
{
|
||||
this->m_size = value;
|
||||
m_size = value;
|
||||
}
|
||||
void setAxis(int value)
|
||||
{
|
||||
this->m_axis = value;
|
||||
m_axis = value;
|
||||
}
|
||||
|
||||
void *initializeTileData(rcti *rect) override;
|
||||
|
||||
@@ -25,13 +25,13 @@ KeyingClipOperation::KeyingClipOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
|
||||
this->m_kernelRadius = 3;
|
||||
this->m_kernelTolerance = 0.1f;
|
||||
m_kernelRadius = 3;
|
||||
m_kernelTolerance = 0.1f;
|
||||
|
||||
this->m_clipBlack = 0.0f;
|
||||
this->m_clipWhite = 1.0f;
|
||||
m_clipBlack = 0.0f;
|
||||
m_clipWhite = 1.0f;
|
||||
|
||||
this->m_isEdgeMatte = false;
|
||||
m_isEdgeMatte = false;
|
||||
|
||||
this->flags.complex = true;
|
||||
}
|
||||
@@ -45,8 +45,8 @@ void *KeyingClipOperation::initializeTileData(rcti *rect)
|
||||
|
||||
void KeyingClipOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
const int delta = this->m_kernelRadius;
|
||||
const float tolerance = this->m_kernelTolerance;
|
||||
const int delta = m_kernelRadius;
|
||||
const float tolerance = m_kernelTolerance;
|
||||
|
||||
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
|
||||
float *buffer = inputBuffer->getBuffer();
|
||||
@@ -86,7 +86,7 @@ void KeyingClipOperation::executePixel(float output[4], int x, int y, void *data
|
||||
}
|
||||
}
|
||||
|
||||
if (this->m_isEdgeMatte) {
|
||||
if (m_isEdgeMatte) {
|
||||
if (ok) {
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
@@ -98,14 +98,14 @@ void KeyingClipOperation::executePixel(float output[4], int x, int y, void *data
|
||||
output[0] = value;
|
||||
|
||||
if (ok) {
|
||||
if (output[0] < this->m_clipBlack) {
|
||||
if (output[0] < m_clipBlack) {
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
else if (output[0] >= this->m_clipWhite) {
|
||||
else if (output[0] >= m_clipWhite) {
|
||||
output[0] = 1.0f;
|
||||
}
|
||||
else {
|
||||
output[0] = (output[0] - this->m_clipBlack) / (this->m_clipWhite - this->m_clipBlack);
|
||||
output[0] = (output[0] - m_clipBlack) / (m_clipWhite - m_clipBlack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,10 +117,10 @@ bool KeyingClipOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
newInput.xmin = input->xmin - this->m_kernelRadius;
|
||||
newInput.ymin = input->ymin - this->m_kernelRadius;
|
||||
newInput.xmax = input->xmax + this->m_kernelRadius;
|
||||
newInput.ymax = input->ymax + this->m_kernelRadius;
|
||||
newInput.xmin = input->xmin - m_kernelRadius;
|
||||
newInput.ymin = input->ymin - m_kernelRadius;
|
||||
newInput.xmax = input->xmax + m_kernelRadius;
|
||||
newInput.ymax = input->ymax + m_kernelRadius;
|
||||
|
||||
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
|
||||
}
|
||||
|
||||
@@ -40,25 +40,25 @@ class KeyingClipOperation : public MultiThreadedOperation {
|
||||
|
||||
void setClipBlack(float value)
|
||||
{
|
||||
this->m_clipBlack = value;
|
||||
m_clipBlack = value;
|
||||
}
|
||||
void setClipWhite(float value)
|
||||
{
|
||||
this->m_clipWhite = value;
|
||||
m_clipWhite = value;
|
||||
}
|
||||
|
||||
void setKernelRadius(int value)
|
||||
{
|
||||
this->m_kernelRadius = value;
|
||||
m_kernelRadius = value;
|
||||
}
|
||||
void setKernelTolerance(float value)
|
||||
{
|
||||
this->m_kernelTolerance = value;
|
||||
m_kernelTolerance = value;
|
||||
}
|
||||
|
||||
void setIsEdgeMatte(bool value)
|
||||
{
|
||||
this->m_isEdgeMatte = value;
|
||||
m_isEdgeMatte = value;
|
||||
}
|
||||
|
||||
void *initializeTileData(rcti *rect) override;
|
||||
|
||||
@@ -26,24 +26,24 @@ KeyingDespillOperation::KeyingDespillOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_despillFactor = 0.5f;
|
||||
this->m_colorBalance = 0.5f;
|
||||
m_despillFactor = 0.5f;
|
||||
m_colorBalance = 0.5f;
|
||||
|
||||
this->m_pixelReader = nullptr;
|
||||
this->m_screenReader = nullptr;
|
||||
m_pixelReader = nullptr;
|
||||
m_screenReader = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void KeyingDespillOperation::initExecution()
|
||||
{
|
||||
this->m_pixelReader = this->getInputSocketReader(0);
|
||||
this->m_screenReader = this->getInputSocketReader(1);
|
||||
m_pixelReader = this->getInputSocketReader(0);
|
||||
m_screenReader = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void KeyingDespillOperation::deinitExecution()
|
||||
{
|
||||
this->m_pixelReader = nullptr;
|
||||
this->m_screenReader = nullptr;
|
||||
m_pixelReader = nullptr;
|
||||
m_screenReader = nullptr;
|
||||
}
|
||||
|
||||
void KeyingDespillOperation::executePixelSampled(float output[4],
|
||||
@@ -54,8 +54,8 @@ void KeyingDespillOperation::executePixelSampled(float output[4],
|
||||
float pixelColor[4];
|
||||
float screenColor[4];
|
||||
|
||||
this->m_pixelReader->readSampled(pixelColor, x, y, sampler);
|
||||
this->m_screenReader->readSampled(screenColor, x, y, sampler);
|
||||
m_pixelReader->readSampled(pixelColor, x, y, sampler);
|
||||
m_screenReader->readSampled(screenColor, x, y, sampler);
|
||||
|
||||
const int screen_primary_channel = max_axis_v3(screenColor);
|
||||
const int other_1 = (screen_primary_channel + 1) % 3;
|
||||
@@ -66,13 +66,13 @@ void KeyingDespillOperation::executePixelSampled(float output[4],
|
||||
|
||||
float average_value, amount;
|
||||
|
||||
average_value = this->m_colorBalance * pixelColor[min_channel] +
|
||||
(1.0f - this->m_colorBalance) * pixelColor[max_channel];
|
||||
average_value = m_colorBalance * pixelColor[min_channel] +
|
||||
(1.0f - m_colorBalance) * pixelColor[max_channel];
|
||||
amount = (pixelColor[screen_primary_channel] - average_value);
|
||||
|
||||
copy_v4_v4(output, pixelColor);
|
||||
|
||||
const float amount_despill = this->m_despillFactor * amount;
|
||||
const float amount_despill = m_despillFactor * amount;
|
||||
if (amount_despill > 0.0f) {
|
||||
output[screen_primary_channel] = pixelColor[screen_primary_channel] - amount_despill;
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ class KeyingDespillOperation : public MultiThreadedOperation {
|
||||
|
||||
void setDespillFactor(float value)
|
||||
{
|
||||
this->m_despillFactor = value;
|
||||
m_despillFactor = value;
|
||||
}
|
||||
void setColorBalance(float value)
|
||||
{
|
||||
this->m_colorBalance = value;
|
||||
m_colorBalance = value;
|
||||
}
|
||||
|
||||
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
|
||||
|
||||
@@ -42,22 +42,22 @@ KeyingOperation::KeyingOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
|
||||
this->m_screenBalance = 0.5f;
|
||||
m_screenBalance = 0.5f;
|
||||
|
||||
this->m_pixelReader = nullptr;
|
||||
this->m_screenReader = nullptr;
|
||||
m_pixelReader = nullptr;
|
||||
m_screenReader = nullptr;
|
||||
}
|
||||
|
||||
void KeyingOperation::initExecution()
|
||||
{
|
||||
this->m_pixelReader = this->getInputSocketReader(0);
|
||||
this->m_screenReader = this->getInputSocketReader(1);
|
||||
m_pixelReader = this->getInputSocketReader(0);
|
||||
m_screenReader = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void KeyingOperation::deinitExecution()
|
||||
{
|
||||
this->m_pixelReader = nullptr;
|
||||
this->m_screenReader = nullptr;
|
||||
m_pixelReader = nullptr;
|
||||
m_screenReader = nullptr;
|
||||
}
|
||||
|
||||
void KeyingOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
@@ -65,8 +65,8 @@ void KeyingOperation::executePixelSampled(float output[4], float x, float y, Pix
|
||||
float pixel_color[4];
|
||||
float screen_color[4];
|
||||
|
||||
this->m_pixelReader->readSampled(pixel_color, x, y, sampler);
|
||||
this->m_screenReader->readSampled(screen_color, x, y, sampler);
|
||||
m_pixelReader->readSampled(pixel_color, x, y, sampler);
|
||||
m_screenReader->readSampled(screen_color, x, y, sampler);
|
||||
|
||||
const int primary_channel = max_axis_v3(screen_color);
|
||||
const float min_pixel_color = min_fff(pixel_color[0], pixel_color[1], pixel_color[2]);
|
||||
@@ -80,9 +80,8 @@ void KeyingOperation::executePixelSampled(float output[4], float x, float y, Pix
|
||||
output[0] = 1.0f;
|
||||
}
|
||||
else {
|
||||
float saturation = get_pixel_saturation(pixel_color, this->m_screenBalance, primary_channel);
|
||||
float screen_saturation = get_pixel_saturation(
|
||||
screen_color, this->m_screenBalance, primary_channel);
|
||||
float saturation = get_pixel_saturation(pixel_color, m_screenBalance, primary_channel);
|
||||
float screen_saturation = get_pixel_saturation(screen_color, m_screenBalance, primary_channel);
|
||||
|
||||
if (saturation < 0) {
|
||||
/* means main channel of pixel is different from screen,
|
||||
|
||||
@@ -44,7 +44,7 @@ class KeyingOperation : public MultiThreadedOperation {
|
||||
|
||||
void setScreenBalance(float value)
|
||||
{
|
||||
this->m_screenBalance = value;
|
||||
m_screenBalance = value;
|
||||
}
|
||||
|
||||
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace blender::compositor {
|
||||
KeyingScreenOperation::KeyingScreenOperation()
|
||||
{
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_movieClip = nullptr;
|
||||
this->m_framenumber = 0;
|
||||
this->m_trackingObject[0] = 0;
|
||||
m_movieClip = nullptr;
|
||||
m_framenumber = 0;
|
||||
m_trackingObject[0] = 0;
|
||||
flags.complex = true;
|
||||
m_cachedTriangulation = nullptr;
|
||||
}
|
||||
@@ -46,14 +46,14 @@ void KeyingScreenOperation::initExecution()
|
||||
}
|
||||
}
|
||||
else {
|
||||
this->m_cachedTriangulation = nullptr;
|
||||
m_cachedTriangulation = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void KeyingScreenOperation::deinitExecution()
|
||||
{
|
||||
if (this->m_cachedTriangulation) {
|
||||
TriangulationData *triangulation = this->m_cachedTriangulation;
|
||||
if (m_cachedTriangulation) {
|
||||
TriangulationData *triangulation = m_cachedTriangulation;
|
||||
|
||||
if (triangulation->triangulated_points) {
|
||||
MEM_freeN(triangulation->triangulated_points);
|
||||
@@ -67,9 +67,9 @@ void KeyingScreenOperation::deinitExecution()
|
||||
MEM_freeN(triangulation->triangles_AABB);
|
||||
}
|
||||
|
||||
MEM_freeN(this->m_cachedTriangulation);
|
||||
MEM_freeN(m_cachedTriangulation);
|
||||
|
||||
this->m_cachedTriangulation = nullptr;
|
||||
m_cachedTriangulation = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
|
||||
{
|
||||
MovieClipUser user = {0};
|
||||
TriangulationData *triangulation;
|
||||
MovieTracking *tracking = &this->m_movieClip->tracking;
|
||||
MovieTracking *tracking = &m_movieClip->tracking;
|
||||
MovieTrackingTrack *track;
|
||||
VoronoiSite *sites, *site;
|
||||
ImBuf *ibuf;
|
||||
@@ -87,10 +87,10 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
|
||||
int i;
|
||||
int width = this->getWidth();
|
||||
int height = this->getHeight();
|
||||
int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber);
|
||||
int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(m_movieClip, m_framenumber);
|
||||
|
||||
if (this->m_trackingObject[0]) {
|
||||
MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->m_trackingObject);
|
||||
if (m_trackingObject[0]) {
|
||||
MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, m_trackingObject);
|
||||
|
||||
if (!object) {
|
||||
return nullptr;
|
||||
@@ -126,7 +126,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
|
||||
}
|
||||
|
||||
BKE_movieclip_user_set_frame(&user, clip_frame);
|
||||
ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, &user);
|
||||
ibuf = BKE_movieclip_get_ibuf(m_movieClip, &user);
|
||||
|
||||
if (!ibuf) {
|
||||
return nullptr;
|
||||
@@ -237,7 +237,7 @@ KeyingScreenOperation::TileData *KeyingScreenOperation::triangulate(const rcti *
|
||||
int chunk_size = 20;
|
||||
int i;
|
||||
|
||||
triangulation = this->m_cachedTriangulation;
|
||||
triangulation = m_cachedTriangulation;
|
||||
|
||||
if (!triangulation) {
|
||||
return nullptr;
|
||||
@@ -271,14 +271,14 @@ KeyingScreenOperation::TileData *KeyingScreenOperation::triangulate(const rcti *
|
||||
|
||||
void *KeyingScreenOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
if (this->m_movieClip == nullptr) {
|
||||
if (m_movieClip == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!this->m_cachedTriangulation) {
|
||||
if (!m_cachedTriangulation) {
|
||||
lockMutex();
|
||||
if (this->m_cachedTriangulation == nullptr) {
|
||||
this->m_cachedTriangulation = buildVoronoiTriangulation();
|
||||
if (m_cachedTriangulation == nullptr) {
|
||||
m_cachedTriangulation = buildVoronoiTriangulation();
|
||||
}
|
||||
unlockMutex();
|
||||
}
|
||||
@@ -301,14 +301,13 @@ void KeyingScreenOperation::determine_canvas(const rcti &preferred_area, rcti &r
|
||||
{
|
||||
r_area = COM_AREA_NONE;
|
||||
|
||||
if (this->m_movieClip) {
|
||||
if (m_movieClip) {
|
||||
MovieClipUser user = {0};
|
||||
int width, height;
|
||||
int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
|
||||
this->m_framenumber);
|
||||
int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(m_movieClip, m_framenumber);
|
||||
|
||||
BKE_movieclip_user_set_frame(&user, clip_frame);
|
||||
BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height);
|
||||
BKE_movieclip_get_size(m_movieClip, &user, &width, &height);
|
||||
r_area = preferred_area;
|
||||
r_area.xmax = r_area.xmin + width;
|
||||
r_area.ymax = r_area.ymin + height;
|
||||
@@ -322,8 +321,8 @@ void KeyingScreenOperation::executePixel(float output[4], int x, int y, void *da
|
||||
output[2] = 0.0f;
|
||||
output[3] = 1.0f;
|
||||
|
||||
if (this->m_movieClip && data) {
|
||||
TriangulationData *triangulation = this->m_cachedTriangulation;
|
||||
if (m_movieClip && data) {
|
||||
TriangulationData *triangulation = m_cachedTriangulation;
|
||||
TileData *tile_data = (TileData *)data;
|
||||
int i;
|
||||
float co[2] = {(float)x, (float)y};
|
||||
|
||||
@@ -72,15 +72,15 @@ class KeyingScreenOperation : public MultiThreadedOperation {
|
||||
|
||||
void setMovieClip(MovieClip *clip)
|
||||
{
|
||||
this->m_movieClip = clip;
|
||||
m_movieClip = clip;
|
||||
}
|
||||
void setTrackingObject(const char *object)
|
||||
{
|
||||
BLI_strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject));
|
||||
BLI_strncpy(m_trackingObject, object, sizeof(m_trackingObject));
|
||||
}
|
||||
void setFramenumber(int framenumber)
|
||||
{
|
||||
this->m_framenumber = framenumber;
|
||||
m_framenumber = framenumber;
|
||||
}
|
||||
|
||||
void executePixel(float output[4], int x, int y, void *data) override;
|
||||
|
||||
@@ -27,18 +27,18 @@ LuminanceMatteOperation::LuminanceMatteOperation()
|
||||
addInputSocket(DataType::Color);
|
||||
addOutputSocket(DataType::Value);
|
||||
|
||||
this->m_inputImageProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void LuminanceMatteOperation::initExecution()
|
||||
{
|
||||
this->m_inputImageProgram = this->getInputSocketReader(0);
|
||||
m_inputImageProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void LuminanceMatteOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputImageProgram = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
}
|
||||
|
||||
void LuminanceMatteOperation::executePixelSampled(float output[4],
|
||||
@@ -47,10 +47,10 @@ void LuminanceMatteOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float inColor[4];
|
||||
this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
|
||||
m_inputImageProgram->readSampled(inColor, x, y, sampler);
|
||||
|
||||
const float high = this->m_settings->t1;
|
||||
const float low = this->m_settings->t2;
|
||||
const float high = m_settings->t1;
|
||||
const float low = m_settings->t2;
|
||||
const float luminance = IMB_colormanagement_get_luminance(inColor);
|
||||
|
||||
float alpha;
|
||||
|
||||
@@ -47,7 +47,7 @@ class LuminanceMatteOperation : public MultiThreadedOperation {
|
||||
|
||||
void setSettings(NodeChroma *nodeChroma)
|
||||
{
|
||||
this->m_settings = nodeChroma;
|
||||
m_settings = nodeChroma;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -28,18 +28,18 @@ MapRangeOperation::MapRangeOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_useClamp = false;
|
||||
m_inputOperation = nullptr;
|
||||
m_useClamp = false;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void MapRangeOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
this->m_sourceMinOperation = this->getInputSocketReader(1);
|
||||
this->m_sourceMaxOperation = this->getInputSocketReader(2);
|
||||
this->m_destMinOperation = this->getInputSocketReader(3);
|
||||
this->m_destMaxOperation = this->getInputSocketReader(4);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
m_sourceMinOperation = this->getInputSocketReader(1);
|
||||
m_sourceMaxOperation = this->getInputSocketReader(2);
|
||||
m_destMinOperation = this->getInputSocketReader(3);
|
||||
m_destMaxOperation = this->getInputSocketReader(4);
|
||||
}
|
||||
|
||||
/* The code below assumes all data is inside range +- this, and that input buffer is single channel
|
||||
@@ -56,11 +56,11 @@ void MapRangeOperation::executePixelSampled(float output[4],
|
||||
float source_min, source_max;
|
||||
float dest_min, dest_max;
|
||||
|
||||
this->m_inputOperation->readSampled(inputs, x, y, sampler);
|
||||
this->m_sourceMinOperation->readSampled(inputs + 1, x, y, sampler);
|
||||
this->m_sourceMaxOperation->readSampled(inputs + 2, x, y, sampler);
|
||||
this->m_destMinOperation->readSampled(inputs + 3, x, y, sampler);
|
||||
this->m_destMaxOperation->readSampled(inputs + 4, x, y, sampler);
|
||||
m_inputOperation->readSampled(inputs, x, y, sampler);
|
||||
m_sourceMinOperation->readSampled(inputs + 1, x, y, sampler);
|
||||
m_sourceMaxOperation->readSampled(inputs + 2, x, y, sampler);
|
||||
m_destMinOperation->readSampled(inputs + 3, x, y, sampler);
|
||||
m_destMaxOperation->readSampled(inputs + 4, x, y, sampler);
|
||||
|
||||
value = inputs[0];
|
||||
source_min = inputs[1];
|
||||
@@ -84,7 +84,7 @@ void MapRangeOperation::executePixelSampled(float output[4],
|
||||
value = dest_min;
|
||||
}
|
||||
|
||||
if (this->m_useClamp) {
|
||||
if (m_useClamp) {
|
||||
if (dest_max > dest_min) {
|
||||
CLAMP(value, dest_min, dest_max);
|
||||
}
|
||||
@@ -98,11 +98,11 @@ void MapRangeOperation::executePixelSampled(float output[4],
|
||||
|
||||
void MapRangeOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_sourceMinOperation = nullptr;
|
||||
this->m_sourceMaxOperation = nullptr;
|
||||
this->m_destMinOperation = nullptr;
|
||||
this->m_destMaxOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
m_sourceMinOperation = nullptr;
|
||||
m_sourceMaxOperation = nullptr;
|
||||
m_destMinOperation = nullptr;
|
||||
m_destMaxOperation = nullptr;
|
||||
}
|
||||
|
||||
void MapRangeOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -66,7 +66,7 @@ class MapRangeOperation : public MultiThreadedOperation {
|
||||
*/
|
||||
void setUseClamp(bool value)
|
||||
{
|
||||
this->m_useClamp = value;
|
||||
m_useClamp = value;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -25,12 +25,12 @@ MapUVOperation::MapUVOperation()
|
||||
this->addInputSocket(DataType::Color, ResizeMode::Align);
|
||||
this->addInputSocket(DataType::Vector);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_alpha = 0.0f;
|
||||
m_alpha = 0.0f;
|
||||
this->flags.complex = true;
|
||||
set_canvas_input_index(UV_INPUT_INDEX);
|
||||
|
||||
this->m_inputUVProgram = nullptr;
|
||||
this->m_inputColorProgram = nullptr;
|
||||
m_inputUVProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
}
|
||||
|
||||
void MapUVOperation::init_data()
|
||||
@@ -46,11 +46,11 @@ void MapUVOperation::init_data()
|
||||
|
||||
void MapUVOperation::initExecution()
|
||||
{
|
||||
this->m_inputColorProgram = this->getInputSocketReader(0);
|
||||
this->m_inputUVProgram = this->getInputSocketReader(1);
|
||||
m_inputColorProgram = this->getInputSocketReader(0);
|
||||
m_inputUVProgram = this->getInputSocketReader(1);
|
||||
if (execution_model_ == eExecutionModel::Tiled) {
|
||||
uv_input_read_fn_ = [=](float x, float y, float *out) {
|
||||
this->m_inputUVProgram->readSampled(out, x, y, PixelSampler::Bilinear);
|
||||
m_inputUVProgram->readSampled(out, x, y, PixelSampler::Bilinear);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -70,10 +70,10 @@ void MapUVOperation::executePixelSampled(float output[4],
|
||||
}
|
||||
|
||||
/* EWA filtering */
|
||||
this->m_inputColorProgram->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
|
||||
m_inputColorProgram->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
|
||||
|
||||
/* UV to alpha threshold */
|
||||
const float threshold = this->m_alpha * 0.05f;
|
||||
const float threshold = m_alpha * 0.05f;
|
||||
/* XXX alpha threshold is used to fade out pixels on boundaries with invalid derivatives.
|
||||
* this calculation is not very well defined, should be looked into if it becomes a problem ...
|
||||
*/
|
||||
@@ -164,8 +164,8 @@ void MapUVOperation::pixelTransform(const float xy[2],
|
||||
|
||||
void MapUVOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputUVProgram = nullptr;
|
||||
this->m_inputColorProgram = nullptr;
|
||||
m_inputUVProgram = nullptr;
|
||||
m_inputColorProgram = nullptr;
|
||||
}
|
||||
|
||||
bool MapUVOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -246,7 +246,7 @@ void MapUVOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
input_image->read_elem_filtered(uv[0], uv[1], deriv[0], deriv[1], it.out);
|
||||
|
||||
/* UV to alpha threshold. */
|
||||
const float threshold = this->m_alpha * 0.05f;
|
||||
const float threshold = m_alpha * 0.05f;
|
||||
/* XXX alpha threshold is used to fade out pixels on boundaries with invalid derivatives.
|
||||
* this calculation is not very well defined, should be looked into if it becomes a problem ...
|
||||
*/
|
||||
|
||||
@@ -72,7 +72,7 @@ class MapUVOperation : public MultiThreadedOperation {
|
||||
|
||||
void setAlpha(float alpha)
|
||||
{
|
||||
this->m_alpha = alpha;
|
||||
m_alpha = alpha;
|
||||
}
|
||||
|
||||
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
|
||||
|
||||
@@ -24,13 +24,13 @@ MapValueOperation::MapValueOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void MapValueOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void MapValueOperation::executePixelSampled(float output[4],
|
||||
@@ -39,8 +39,8 @@ void MapValueOperation::executePixelSampled(float output[4],
|
||||
PixelSampler sampler)
|
||||
{
|
||||
float src[4];
|
||||
this->m_inputOperation->readSampled(src, x, y, sampler);
|
||||
TexMapping *texmap = this->m_settings;
|
||||
m_inputOperation->readSampled(src, x, y, sampler);
|
||||
TexMapping *texmap = m_settings;
|
||||
float value = (src[0] + texmap->loc[0]) * texmap->size[0];
|
||||
if (texmap->flag & TEXMAP_CLIP_MIN) {
|
||||
if (value < texmap->min[0]) {
|
||||
@@ -58,7 +58,7 @@ void MapValueOperation::executePixelSampled(float output[4],
|
||||
|
||||
void MapValueOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
|
||||
void MapValueOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -67,7 +67,7 @@ void MapValueOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
{
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
const float input = *it.in(0);
|
||||
TexMapping *texmap = this->m_settings;
|
||||
TexMapping *texmap = m_settings;
|
||||
float value = (input + texmap->loc[0]) * texmap->size[0];
|
||||
if (texmap->flag & TEXMAP_CLIP_MIN) {
|
||||
if (value < texmap->min[0]) {
|
||||
|
||||
@@ -61,7 +61,7 @@ class MapValueOperation : public MultiThreadedOperation {
|
||||
*/
|
||||
void setSettings(TexMapping *settings)
|
||||
{
|
||||
this->m_settings = settings;
|
||||
m_settings = settings;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,39 +26,34 @@ namespace blender::compositor {
|
||||
MaskOperation::MaskOperation()
|
||||
{
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_mask = nullptr;
|
||||
this->m_maskWidth = 0;
|
||||
this->m_maskHeight = 0;
|
||||
this->m_maskWidthInv = 0.0f;
|
||||
this->m_maskHeightInv = 0.0f;
|
||||
this->m_frame_shutter = 0.0f;
|
||||
this->m_frame_number = 0;
|
||||
this->m_rasterMaskHandleTot = 1;
|
||||
memset(this->m_rasterMaskHandles, 0, sizeof(this->m_rasterMaskHandles));
|
||||
m_mask = nullptr;
|
||||
m_maskWidth = 0;
|
||||
m_maskHeight = 0;
|
||||
m_maskWidthInv = 0.0f;
|
||||
m_maskHeightInv = 0.0f;
|
||||
m_frame_shutter = 0.0f;
|
||||
m_frame_number = 0;
|
||||
m_rasterMaskHandleTot = 1;
|
||||
memset(m_rasterMaskHandles, 0, sizeof(m_rasterMaskHandles));
|
||||
}
|
||||
|
||||
void MaskOperation::initExecution()
|
||||
{
|
||||
if (this->m_mask && this->m_rasterMaskHandles[0] == nullptr) {
|
||||
if (this->m_rasterMaskHandleTot == 1) {
|
||||
this->m_rasterMaskHandles[0] = BKE_maskrasterize_handle_new();
|
||||
if (m_mask && m_rasterMaskHandles[0] == nullptr) {
|
||||
if (m_rasterMaskHandleTot == 1) {
|
||||
m_rasterMaskHandles[0] = BKE_maskrasterize_handle_new();
|
||||
|
||||
BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[0],
|
||||
this->m_mask,
|
||||
this->m_maskWidth,
|
||||
this->m_maskHeight,
|
||||
true,
|
||||
true,
|
||||
this->m_do_feather);
|
||||
BKE_maskrasterize_handle_init(
|
||||
m_rasterMaskHandles[0], m_mask, m_maskWidth, m_maskHeight, true, true, m_do_feather);
|
||||
}
|
||||
else {
|
||||
/* make a throw away copy of the mask */
|
||||
const float frame = (float)this->m_frame_number - this->m_frame_shutter;
|
||||
const float frame_step = (this->m_frame_shutter * 2.0f) / this->m_rasterMaskHandleTot;
|
||||
const float frame = (float)m_frame_number - m_frame_shutter;
|
||||
const float frame_step = (m_frame_shutter * 2.0f) / m_rasterMaskHandleTot;
|
||||
float frame_iter = frame;
|
||||
|
||||
Mask *mask_temp = (Mask *)BKE_id_copy_ex(
|
||||
nullptr, &this->m_mask->id, nullptr, LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
|
||||
nullptr, &m_mask->id, nullptr, LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
|
||||
|
||||
/* trick so we can get unkeyed edits to display */
|
||||
{
|
||||
@@ -67,24 +62,24 @@ void MaskOperation::initExecution()
|
||||
|
||||
for (masklay = (MaskLayer *)mask_temp->masklayers.first; masklay;
|
||||
masklay = masklay->next) {
|
||||
masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, this->m_frame_number);
|
||||
masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, m_frame_number);
|
||||
BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
|
||||
this->m_rasterMaskHandles[i] = BKE_maskrasterize_handle_new();
|
||||
for (unsigned int i = 0; i < m_rasterMaskHandleTot; i++) {
|
||||
m_rasterMaskHandles[i] = BKE_maskrasterize_handle_new();
|
||||
|
||||
/* re-eval frame info */
|
||||
BKE_mask_evaluate(mask_temp, frame_iter, true);
|
||||
|
||||
BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[i],
|
||||
BKE_maskrasterize_handle_init(m_rasterMaskHandles[i],
|
||||
mask_temp,
|
||||
this->m_maskWidth,
|
||||
this->m_maskHeight,
|
||||
m_maskWidth,
|
||||
m_maskHeight,
|
||||
true,
|
||||
true,
|
||||
this->m_do_feather);
|
||||
m_do_feather);
|
||||
|
||||
frame_iter += frame_step;
|
||||
}
|
||||
@@ -96,17 +91,17 @@ void MaskOperation::initExecution()
|
||||
|
||||
void MaskOperation::deinitExecution()
|
||||
{
|
||||
for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
|
||||
if (this->m_rasterMaskHandles[i]) {
|
||||
BKE_maskrasterize_handle_free(this->m_rasterMaskHandles[i]);
|
||||
this->m_rasterMaskHandles[i] = nullptr;
|
||||
for (unsigned int i = 0; i < m_rasterMaskHandleTot; i++) {
|
||||
if (m_rasterMaskHandles[i]) {
|
||||
BKE_maskrasterize_handle_free(m_rasterMaskHandles[i]);
|
||||
m_rasterMaskHandles[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MaskOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
if (this->m_maskWidth == 0 || this->m_maskHeight == 0) {
|
||||
if (m_maskWidth == 0 || m_maskHeight == 0) {
|
||||
r_area = COM_AREA_NONE;
|
||||
}
|
||||
else {
|
||||
@@ -122,13 +117,13 @@ void MaskOperation::executePixelSampled(float output[4],
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
const float xy[2] = {
|
||||
(x * this->m_maskWidthInv) + this->m_mask_px_ofs[0],
|
||||
(y * this->m_maskHeightInv) + this->m_mask_px_ofs[1],
|
||||
(x * m_maskWidthInv) + m_mask_px_ofs[0],
|
||||
(y * m_maskHeightInv) + m_mask_px_ofs[1],
|
||||
};
|
||||
|
||||
if (this->m_rasterMaskHandleTot == 1) {
|
||||
if (this->m_rasterMaskHandles[0]) {
|
||||
output[0] = BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[0], xy);
|
||||
if (m_rasterMaskHandleTot == 1) {
|
||||
if (m_rasterMaskHandles[0]) {
|
||||
output[0] = BKE_maskrasterize_handle_sample(m_rasterMaskHandles[0], xy);
|
||||
}
|
||||
else {
|
||||
output[0] = 0.0f;
|
||||
@@ -138,14 +133,14 @@ void MaskOperation::executePixelSampled(float output[4],
|
||||
/* In case loop below fails. */
|
||||
output[0] = 0.0f;
|
||||
|
||||
for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
|
||||
if (this->m_rasterMaskHandles[i]) {
|
||||
output[0] += BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[i], xy);
|
||||
for (unsigned int i = 0; i < m_rasterMaskHandleTot; i++) {
|
||||
if (m_rasterMaskHandles[i]) {
|
||||
output[0] += BKE_maskrasterize_handle_sample(m_rasterMaskHandles[i], xy);
|
||||
}
|
||||
}
|
||||
|
||||
/* until we get better falloff */
|
||||
output[0] /= this->m_rasterMaskHandleTot;
|
||||
output[0] /= m_rasterMaskHandleTot;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,36 +64,36 @@ class MaskOperation : public MultiThreadedOperation {
|
||||
|
||||
void setMask(Mask *mask)
|
||||
{
|
||||
this->m_mask = mask;
|
||||
m_mask = mask;
|
||||
}
|
||||
void setMaskWidth(int width)
|
||||
{
|
||||
this->m_maskWidth = width;
|
||||
this->m_maskWidthInv = 1.0f / (float)width;
|
||||
this->m_mask_px_ofs[0] = this->m_maskWidthInv * 0.5f;
|
||||
m_maskWidth = width;
|
||||
m_maskWidthInv = 1.0f / (float)width;
|
||||
m_mask_px_ofs[0] = m_maskWidthInv * 0.5f;
|
||||
}
|
||||
void setMaskHeight(int height)
|
||||
{
|
||||
this->m_maskHeight = height;
|
||||
this->m_maskHeightInv = 1.0f / (float)height;
|
||||
this->m_mask_px_ofs[1] = this->m_maskHeightInv * 0.5f;
|
||||
m_maskHeight = height;
|
||||
m_maskHeightInv = 1.0f / (float)height;
|
||||
m_mask_px_ofs[1] = m_maskHeightInv * 0.5f;
|
||||
}
|
||||
void setFramenumber(int frame_number)
|
||||
{
|
||||
this->m_frame_number = frame_number;
|
||||
m_frame_number = frame_number;
|
||||
}
|
||||
void setFeather(bool feather)
|
||||
{
|
||||
this->m_do_feather = feather;
|
||||
m_do_feather = feather;
|
||||
}
|
||||
|
||||
void setMotionBlurSamples(int samples)
|
||||
{
|
||||
this->m_rasterMaskHandleTot = MIN2(MAX2(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX);
|
||||
m_rasterMaskHandleTot = MIN2(MAX2(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX);
|
||||
}
|
||||
void setMotionBlurShutter(float shutter)
|
||||
{
|
||||
this->m_frame_shutter = shutter;
|
||||
m_frame_shutter = shutter;
|
||||
}
|
||||
|
||||
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
|
||||
|
||||
@@ -28,25 +28,25 @@ MathBaseOperation::MathBaseOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_inputValue1Operation = nullptr;
|
||||
this->m_inputValue2Operation = nullptr;
|
||||
this->m_inputValue3Operation = nullptr;
|
||||
this->m_useClamp = false;
|
||||
m_inputValue1Operation = nullptr;
|
||||
m_inputValue2Operation = nullptr;
|
||||
m_inputValue3Operation = nullptr;
|
||||
m_useClamp = false;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void MathBaseOperation::initExecution()
|
||||
{
|
||||
this->m_inputValue1Operation = this->getInputSocketReader(0);
|
||||
this->m_inputValue2Operation = this->getInputSocketReader(1);
|
||||
this->m_inputValue3Operation = this->getInputSocketReader(2);
|
||||
m_inputValue1Operation = this->getInputSocketReader(0);
|
||||
m_inputValue2Operation = this->getInputSocketReader(1);
|
||||
m_inputValue3Operation = this->getInputSocketReader(2);
|
||||
}
|
||||
|
||||
void MathBaseOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputValue1Operation = nullptr;
|
||||
this->m_inputValue2Operation = nullptr;
|
||||
this->m_inputValue3Operation = nullptr;
|
||||
m_inputValue1Operation = nullptr;
|
||||
m_inputValue2Operation = nullptr;
|
||||
m_inputValue3Operation = nullptr;
|
||||
}
|
||||
|
||||
void MathBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
@@ -66,7 +66,7 @@ void MathBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_are
|
||||
|
||||
void MathBaseOperation::clampIfNeeded(float *color)
|
||||
{
|
||||
if (this->m_useClamp) {
|
||||
if (m_useClamp) {
|
||||
CLAMP(color[0], 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
@@ -84,8 +84,8 @@ void MathAddOperation::executePixelSampled(float output[4], float x, float y, Pi
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = inputValue1[0] + inputValue2[0];
|
||||
|
||||
@@ -100,8 +100,8 @@ void MathSubtractOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = inputValue1[0] - inputValue2[0];
|
||||
|
||||
@@ -116,8 +116,8 @@ void MathMultiplyOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = inputValue1[0] * inputValue2[0];
|
||||
|
||||
@@ -132,8 +132,8 @@ void MathDivideOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
if (inputValue2[0] == 0) { /* We don't want to divide by zero. */
|
||||
output[0] = 0.0;
|
||||
@@ -161,8 +161,8 @@ void MathSineOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = sin(inputValue1[0]);
|
||||
|
||||
@@ -185,8 +185,8 @@ void MathCosineOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = cos(inputValue1[0]);
|
||||
|
||||
@@ -209,8 +209,8 @@ void MathTangentOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = tan(inputValue1[0]);
|
||||
|
||||
@@ -233,8 +233,8 @@ void MathHyperbolicSineOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = sinh(inputValue1[0]);
|
||||
|
||||
@@ -257,8 +257,8 @@ void MathHyperbolicCosineOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = cosh(inputValue1[0]);
|
||||
|
||||
@@ -281,8 +281,8 @@ void MathHyperbolicTangentOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = tanh(inputValue1[0]);
|
||||
|
||||
@@ -305,8 +305,8 @@ void MathArcSineOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
if (inputValue1[0] <= 1 && inputValue1[0] >= -1) {
|
||||
output[0] = asin(inputValue1[0]);
|
||||
@@ -334,8 +334,8 @@ void MathArcCosineOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
if (inputValue1[0] <= 1 && inputValue1[0] >= -1) {
|
||||
output[0] = acos(inputValue1[0]);
|
||||
@@ -363,8 +363,8 @@ void MathArcTangentOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = atan(inputValue1[0]);
|
||||
|
||||
@@ -387,8 +387,8 @@ void MathPowerOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
if (inputValue1[0] >= 0) {
|
||||
output[0] = pow(inputValue1[0], inputValue2[0]);
|
||||
@@ -438,8 +438,8 @@ void MathLogarithmOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
if (inputValue1[0] > 0 && inputValue2[0] > 0) {
|
||||
output[0] = log(inputValue1[0]) / log(inputValue2[0]);
|
||||
@@ -474,8 +474,8 @@ void MathMinimumOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = MIN2(inputValue1[0], inputValue2[0]);
|
||||
|
||||
@@ -498,8 +498,8 @@ void MathMaximumOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = MAX2(inputValue1[0], inputValue2[0]);
|
||||
|
||||
@@ -522,8 +522,8 @@ void MathRoundOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = round(inputValue1[0]);
|
||||
|
||||
@@ -546,8 +546,8 @@ void MathLessThanOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f;
|
||||
|
||||
@@ -562,8 +562,8 @@ void MathGreaterThanOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f;
|
||||
|
||||
@@ -578,8 +578,8 @@ void MathModuloOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
if (inputValue2[0] == 0) {
|
||||
output[0] = 0.0;
|
||||
@@ -607,7 +607,7 @@ void MathAbsoluteOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
output[0] = fabs(inputValue1[0]);
|
||||
|
||||
@@ -629,7 +629,7 @@ void MathRadiansOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
output[0] = DEG2RADF(inputValue1[0]);
|
||||
|
||||
@@ -651,7 +651,7 @@ void MathDegreesOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
output[0] = RAD2DEGF(inputValue1[0]);
|
||||
|
||||
@@ -674,8 +674,8 @@ void MathArcTan2Operation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = atan2(inputValue1[0], inputValue2[0]);
|
||||
|
||||
@@ -697,7 +697,7 @@ void MathFloorOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
output[0] = floor(inputValue1[0]);
|
||||
|
||||
@@ -719,7 +719,7 @@ void MathCeilOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
output[0] = ceil(inputValue1[0]);
|
||||
|
||||
@@ -741,7 +741,7 @@ void MathFractOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
output[0] = inputValue1[0] - floor(inputValue1[0]);
|
||||
|
||||
@@ -763,7 +763,7 @@ void MathSqrtOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
if (inputValue1[0] > 0) {
|
||||
output[0] = sqrt(inputValue1[0]);
|
||||
@@ -790,7 +790,7 @@ void MathInverseSqrtOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
if (inputValue1[0] > 0) {
|
||||
output[0] = 1.0f / sqrt(inputValue1[0]);
|
||||
@@ -817,7 +817,7 @@ void MathSignOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
output[0] = compatible_signf(inputValue1[0]);
|
||||
|
||||
@@ -839,7 +839,7 @@ void MathExponentOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
output[0] = expf(inputValue1[0]);
|
||||
|
||||
@@ -861,7 +861,7 @@ void MathTruncOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float inputValue1[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
|
||||
output[0] = (inputValue1[0] >= 0.0f) ? floor(inputValue1[0]) : ceil(inputValue1[0]);
|
||||
|
||||
@@ -885,8 +885,8 @@ void MathSnapOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
if (inputValue1[0] == 0 || inputValue2[0] == 0) { /* We don't want to divide by zero. */
|
||||
output[0] = 0.0f;
|
||||
@@ -922,9 +922,9 @@ void MathWrapOperation::executePixelSampled(float output[4],
|
||||
float inputValue2[4];
|
||||
float inputValue3[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
this->m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
|
||||
output[0] = wrapf(inputValue1[0], inputValue2[0], inputValue3[0]);
|
||||
|
||||
@@ -947,8 +947,8 @@ void MathPingpongOperation::executePixelSampled(float output[4],
|
||||
float inputValue1[4];
|
||||
float inputValue2[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
|
||||
output[0] = pingpongf(inputValue1[0], inputValue2[0]);
|
||||
|
||||
@@ -972,9 +972,9 @@ void MathCompareOperation::executePixelSampled(float output[4],
|
||||
float inputValue2[4];
|
||||
float inputValue3[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
this->m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
|
||||
output[0] = (fabsf(inputValue1[0] - inputValue2[0]) <= MAX2(inputValue3[0], 1e-5f)) ? 1.0f :
|
||||
0.0f;
|
||||
@@ -999,9 +999,9 @@ void MathMultiplyAddOperation::executePixelSampled(float output[4],
|
||||
float inputValue2[4];
|
||||
float inputValue3[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
this->m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
|
||||
output[0] = inputValue1[0] * inputValue2[0] + inputValue3[0];
|
||||
|
||||
@@ -1025,9 +1025,9 @@ void MathSmoothMinOperation::executePixelSampled(float output[4],
|
||||
float inputValue2[4];
|
||||
float inputValue3[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
this->m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
|
||||
output[0] = smoothminf(inputValue1[0], inputValue2[0], inputValue3[0]);
|
||||
|
||||
@@ -1051,9 +1051,9 @@ void MathSmoothMaxOperation::executePixelSampled(float output[4],
|
||||
float inputValue2[4];
|
||||
float inputValue3[4];
|
||||
|
||||
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
this->m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
|
||||
m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
|
||||
m_inputValue3Operation->readSampled(inputValue3, x, y, sampler);
|
||||
|
||||
output[0] = -smoothminf(-inputValue1[0], -inputValue2[0], inputValue3[0]);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class MathBaseOperation : public MultiThreadedOperation {
|
||||
|
||||
float clamp_when_enabled(float value)
|
||||
{
|
||||
if (this->m_useClamp) {
|
||||
if (m_useClamp) {
|
||||
return CLAMPIS(value, 0.0f, 1.0f);
|
||||
}
|
||||
return value;
|
||||
@@ -56,7 +56,7 @@ class MathBaseOperation : public MultiThreadedOperation {
|
||||
|
||||
void clamp_when_enabled(float *out)
|
||||
{
|
||||
if (this->m_useClamp) {
|
||||
if (m_useClamp) {
|
||||
CLAMP(*out, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class MathBaseOperation : public MultiThreadedOperation {
|
||||
|
||||
void setUseClamp(bool value)
|
||||
{
|
||||
this->m_useClamp = value;
|
||||
m_useClamp = value;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -28,9 +28,9 @@ MixBaseOperation::MixBaseOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputValueOperation = nullptr;
|
||||
this->m_inputColor1Operation = nullptr;
|
||||
this->m_inputColor2Operation = nullptr;
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColor1Operation = nullptr;
|
||||
m_inputColor2Operation = nullptr;
|
||||
this->setUseValueAlphaMultiply(false);
|
||||
this->setUseClamp(false);
|
||||
flags.can_be_constant = true;
|
||||
@@ -38,9 +38,9 @@ MixBaseOperation::MixBaseOperation()
|
||||
|
||||
void MixBaseOperation::initExecution()
|
||||
{
|
||||
this->m_inputValueOperation = this->getInputSocketReader(0);
|
||||
this->m_inputColor1Operation = this->getInputSocketReader(1);
|
||||
this->m_inputColor2Operation = this->getInputSocketReader(2);
|
||||
m_inputValueOperation = this->getInputSocketReader(0);
|
||||
m_inputColor1Operation = this->getInputSocketReader(1);
|
||||
m_inputColor2Operation = this->getInputSocketReader(2);
|
||||
}
|
||||
|
||||
void MixBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
@@ -49,9 +49,9 @@ void MixBaseOperation::executePixelSampled(float output[4], float x, float y, Pi
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -89,9 +89,9 @@ void MixBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area
|
||||
|
||||
void MixBaseOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputValueOperation = nullptr;
|
||||
this->m_inputColor1Operation = nullptr;
|
||||
this->m_inputColor2Operation = nullptr;
|
||||
m_inputValueOperation = nullptr;
|
||||
m_inputColor1Operation = nullptr;
|
||||
m_inputColor2Operation = nullptr;
|
||||
}
|
||||
|
||||
void MixBaseOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -141,9 +141,9 @@ void MixAddOperation::executePixelSampled(float output[4], float x, float y, Pix
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -186,9 +186,9 @@ void MixBlendOperation::executePixelSampled(float output[4],
|
||||
float inputValue[4];
|
||||
float value;
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
value = inputValue[0];
|
||||
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -233,9 +233,9 @@ void MixColorBurnOperation::executePixelSampled(float output[4],
|
||||
float inputValue[4];
|
||||
float tmp;
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -352,9 +352,9 @@ void MixColorOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -422,9 +422,9 @@ void MixDarkenOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -468,9 +468,9 @@ void MixDifferenceOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -514,9 +514,9 @@ void MixDivideOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -595,9 +595,9 @@ void MixDodgeOperation::executePixelSampled(float output[4],
|
||||
float inputValue[4];
|
||||
float tmp;
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -736,9 +736,9 @@ void MixGlareOperation::executePixelSampled(float output[4],
|
||||
float inputValue[4];
|
||||
float value, input_weight, glare_weight;
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
value = inputValue[0];
|
||||
/* Linear interpolation between 3 cases:
|
||||
* value=-1:output=input value=0:output=input+glare value=1:output=glare
|
||||
@@ -794,9 +794,9 @@ void MixHueOperation::executePixelSampled(float output[4], float x, float y, Pix
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -864,9 +864,9 @@ void MixLightenOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -934,9 +934,9 @@ void MixLinearLightOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -1010,9 +1010,9 @@ void MixMultiplyOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -1057,9 +1057,9 @@ void MixOverlayOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -1136,9 +1136,9 @@ void MixSaturationOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -1200,9 +1200,9 @@ void MixScreenOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -1248,9 +1248,9 @@ void MixSoftLightOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -1317,9 +1317,9 @@ void MixSubtractOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
@@ -1361,9 +1361,9 @@ void MixValueOperation::executePixelSampled(float output[4],
|
||||
float inputColor2[4];
|
||||
float inputValue[4];
|
||||
|
||||
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
m_inputValueOperation->readSampled(inputValue, x, y, sampler);
|
||||
m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
|
||||
float value = inputValue[0];
|
||||
if (this->useValueAlphaMultiply()) {
|
||||
|
||||
@@ -91,15 +91,15 @@ class MixBaseOperation : public MultiThreadedOperation {
|
||||
|
||||
void setUseValueAlphaMultiply(const bool value)
|
||||
{
|
||||
this->m_valueAlphaMultiply = value;
|
||||
m_valueAlphaMultiply = value;
|
||||
}
|
||||
inline bool useValueAlphaMultiply()
|
||||
{
|
||||
return this->m_valueAlphaMultiply;
|
||||
return m_valueAlphaMultiply;
|
||||
}
|
||||
void setUseClamp(bool value)
|
||||
{
|
||||
this->m_useClamp = value;
|
||||
m_useClamp = value;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace blender::compositor {
|
||||
MovieClipAttributeOperation::MovieClipAttributeOperation()
|
||||
{
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_framenumber = 0;
|
||||
this->m_attribute = MCA_X;
|
||||
this->m_invert = false;
|
||||
m_framenumber = 0;
|
||||
m_attribute = MCA_X;
|
||||
m_invert = false;
|
||||
needs_canvas_to_get_constant_ = true;
|
||||
is_value_calculated_ = false;
|
||||
stabilization_resolution_socket_ = nullptr;
|
||||
@@ -45,7 +45,7 @@ void MovieClipAttributeOperation::calc_value()
|
||||
{
|
||||
BLI_assert(this->get_flags().is_canvas_set);
|
||||
is_value_calculated_ = true;
|
||||
if (this->m_clip == nullptr) {
|
||||
if (m_clip == nullptr) {
|
||||
return;
|
||||
}
|
||||
float loc[2], scale, angle;
|
||||
@@ -53,38 +53,38 @@ void MovieClipAttributeOperation::calc_value()
|
||||
loc[1] = 0.0f;
|
||||
scale = 1.0f;
|
||||
angle = 0.0f;
|
||||
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_clip, this->m_framenumber);
|
||||
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(m_clip, m_framenumber);
|
||||
NodeOperation &stabilization_operation =
|
||||
stabilization_resolution_socket_ ?
|
||||
stabilization_resolution_socket_->getLink()->getOperation() :
|
||||
*this;
|
||||
BKE_tracking_stabilization_data_get(this->m_clip,
|
||||
BKE_tracking_stabilization_data_get(m_clip,
|
||||
clip_framenr,
|
||||
stabilization_operation.getWidth(),
|
||||
stabilization_operation.getHeight(),
|
||||
loc,
|
||||
&scale,
|
||||
&angle);
|
||||
switch (this->m_attribute) {
|
||||
switch (m_attribute) {
|
||||
case MCA_SCALE:
|
||||
this->m_value = scale;
|
||||
m_value = scale;
|
||||
break;
|
||||
case MCA_ANGLE:
|
||||
this->m_value = angle;
|
||||
m_value = angle;
|
||||
break;
|
||||
case MCA_X:
|
||||
this->m_value = loc[0];
|
||||
m_value = loc[0];
|
||||
break;
|
||||
case MCA_Y:
|
||||
this->m_value = loc[1];
|
||||
m_value = loc[1];
|
||||
break;
|
||||
}
|
||||
if (this->m_invert) {
|
||||
if (this->m_attribute != MCA_SCALE) {
|
||||
this->m_value = -this->m_value;
|
||||
if (m_invert) {
|
||||
if (m_attribute != MCA_SCALE) {
|
||||
m_value = -m_value;
|
||||
}
|
||||
else {
|
||||
this->m_value = 1.0f / this->m_value;
|
||||
m_value = 1.0f / m_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ void MovieClipAttributeOperation::executePixelSampled(float output[4],
|
||||
float /*y*/,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
output[0] = this->m_value;
|
||||
output[0] = m_value;
|
||||
}
|
||||
|
||||
void MovieClipAttributeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
|
||||
@@ -62,19 +62,19 @@ class MovieClipAttributeOperation : public ConstantOperation {
|
||||
|
||||
void setMovieClip(MovieClip *clip)
|
||||
{
|
||||
this->m_clip = clip;
|
||||
m_clip = clip;
|
||||
}
|
||||
void setFramenumber(int framenumber)
|
||||
{
|
||||
this->m_framenumber = framenumber;
|
||||
m_framenumber = framenumber;
|
||||
}
|
||||
void setAttribute(MovieClipAttribute attribute)
|
||||
{
|
||||
this->m_attribute = attribute;
|
||||
m_attribute = attribute;
|
||||
}
|
||||
void setInvert(bool invert)
|
||||
{
|
||||
this->m_invert = invert;
|
||||
m_invert = invert;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,30 +27,30 @@ namespace blender::compositor {
|
||||
|
||||
MovieClipBaseOperation::MovieClipBaseOperation()
|
||||
{
|
||||
this->m_movieClip = nullptr;
|
||||
this->m_movieClipBuffer = nullptr;
|
||||
this->m_movieClipUser = nullptr;
|
||||
this->m_movieClipwidth = 0;
|
||||
this->m_movieClipheight = 0;
|
||||
this->m_framenumber = 0;
|
||||
m_movieClip = nullptr;
|
||||
m_movieClipBuffer = nullptr;
|
||||
m_movieClipUser = nullptr;
|
||||
m_movieClipwidth = 0;
|
||||
m_movieClipheight = 0;
|
||||
m_framenumber = 0;
|
||||
}
|
||||
|
||||
void MovieClipBaseOperation::initExecution()
|
||||
{
|
||||
if (this->m_movieClip) {
|
||||
BKE_movieclip_user_set_frame(this->m_movieClipUser, this->m_framenumber);
|
||||
if (m_movieClip) {
|
||||
BKE_movieclip_user_set_frame(m_movieClipUser, m_framenumber);
|
||||
ImBuf *ibuf;
|
||||
|
||||
if (this->m_cacheFrame) {
|
||||
ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, this->m_movieClipUser);
|
||||
if (m_cacheFrame) {
|
||||
ibuf = BKE_movieclip_get_ibuf(m_movieClip, m_movieClipUser);
|
||||
}
|
||||
else {
|
||||
ibuf = BKE_movieclip_get_ibuf_flag(
|
||||
this->m_movieClip, this->m_movieClipUser, this->m_movieClip->flag, MOVIECLIP_CACHE_SKIP);
|
||||
m_movieClip, m_movieClipUser, m_movieClip->flag, MOVIECLIP_CACHE_SKIP);
|
||||
}
|
||||
|
||||
if (ibuf) {
|
||||
this->m_movieClipBuffer = ibuf;
|
||||
m_movieClipBuffer = ibuf;
|
||||
if (ibuf->rect_float == nullptr || ibuf->userflags & IB_RECT_INVALID) {
|
||||
IMB_float_from_rect(ibuf);
|
||||
ibuf->userflags &= ~IB_RECT_INVALID;
|
||||
@@ -61,19 +61,19 @@ void MovieClipBaseOperation::initExecution()
|
||||
|
||||
void MovieClipBaseOperation::deinitExecution()
|
||||
{
|
||||
if (this->m_movieClipBuffer) {
|
||||
IMB_freeImBuf(this->m_movieClipBuffer);
|
||||
if (m_movieClipBuffer) {
|
||||
IMB_freeImBuf(m_movieClipBuffer);
|
||||
|
||||
this->m_movieClipBuffer = nullptr;
|
||||
m_movieClipBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MovieClipBaseOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area)
|
||||
{
|
||||
r_area = COM_AREA_NONE;
|
||||
if (this->m_movieClip) {
|
||||
if (m_movieClip) {
|
||||
int width, height;
|
||||
BKE_movieclip_get_size(this->m_movieClip, this->m_movieClipUser, &width, &height);
|
||||
BKE_movieclip_get_size(m_movieClip, m_movieClipUser, &width, &height);
|
||||
BLI_rcti_init(&r_area, 0, width, 0, height);
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void MovieClipBaseOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler sampler)
|
||||
{
|
||||
ImBuf *ibuf = this->m_movieClipBuffer;
|
||||
ImBuf *ibuf = m_movieClipBuffer;
|
||||
|
||||
if (ibuf == nullptr) {
|
||||
zero_v4(output);
|
||||
|
||||
@@ -50,20 +50,20 @@ class MovieClipBaseOperation : public MultiThreadedOperation {
|
||||
void deinitExecution() override;
|
||||
void setMovieClip(MovieClip *image)
|
||||
{
|
||||
this->m_movieClip = image;
|
||||
m_movieClip = image;
|
||||
}
|
||||
void setMovieClipUser(MovieClipUser *imageuser)
|
||||
{
|
||||
this->m_movieClipUser = imageuser;
|
||||
m_movieClipUser = imageuser;
|
||||
}
|
||||
void setCacheFrame(bool value)
|
||||
{
|
||||
this->m_cacheFrame = value;
|
||||
m_cacheFrame = value;
|
||||
}
|
||||
|
||||
void setFramenumber(int framenumber)
|
||||
{
|
||||
this->m_framenumber = framenumber;
|
||||
m_framenumber = framenumber;
|
||||
}
|
||||
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
|
||||
|
||||
|
||||
@@ -27,20 +27,20 @@ MovieDistortionOperation::MovieDistortionOperation(bool distortion)
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->set_canvas_input_index(0);
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_movieClip = nullptr;
|
||||
this->m_apply = distortion;
|
||||
m_inputOperation = nullptr;
|
||||
m_movieClip = nullptr;
|
||||
m_apply = distortion;
|
||||
}
|
||||
|
||||
void MovieDistortionOperation::init_data()
|
||||
{
|
||||
if (this->m_movieClip) {
|
||||
MovieTracking *tracking = &this->m_movieClip->tracking;
|
||||
if (m_movieClip) {
|
||||
MovieTracking *tracking = &m_movieClip->tracking;
|
||||
MovieClipUser clipUser = {0};
|
||||
int calibration_width, calibration_height;
|
||||
|
||||
BKE_movieclip_user_set_frame(&clipUser, this->m_framenumber);
|
||||
BKE_movieclip_get_size(this->m_movieClip, &clipUser, &calibration_width, &calibration_height);
|
||||
BKE_movieclip_user_set_frame(&clipUser, m_framenumber);
|
||||
BKE_movieclip_get_size(m_movieClip, &clipUser, &calibration_width, &calibration_height);
|
||||
|
||||
float delta[2];
|
||||
rcti full_frame;
|
||||
@@ -48,7 +48,7 @@ void MovieDistortionOperation::init_data()
|
||||
full_frame.xmax = this->getWidth();
|
||||
full_frame.ymax = this->getHeight();
|
||||
BKE_tracking_max_distortion_delta_across_bound(
|
||||
tracking, this->getWidth(), this->getHeight(), &full_frame, !this->m_apply, delta);
|
||||
tracking, this->getWidth(), this->getHeight(), &full_frame, !m_apply, delta);
|
||||
|
||||
/* 5 is just in case we didn't hit real max of distortion in
|
||||
* BKE_tracking_max_undistortion_delta_across_bound
|
||||
@@ -56,9 +56,9 @@ void MovieDistortionOperation::init_data()
|
||||
m_margin[0] = delta[0] + 5;
|
||||
m_margin[1] = delta[1] + 5;
|
||||
|
||||
this->m_calibration_width = calibration_width;
|
||||
this->m_calibration_height = calibration_height;
|
||||
this->m_pixel_aspect = tracking->camera.pixel_aspect;
|
||||
m_calibration_width = calibration_width;
|
||||
m_calibration_height = calibration_height;
|
||||
m_pixel_aspect = tracking->camera.pixel_aspect;
|
||||
}
|
||||
else {
|
||||
m_margin[0] = m_margin[1] = 0;
|
||||
@@ -80,10 +80,10 @@ void MovieDistortionOperation::initExecution()
|
||||
|
||||
void MovieDistortionOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_movieClip = nullptr;
|
||||
if (this->m_distortion != nullptr) {
|
||||
BKE_tracking_distortion_free(this->m_distortion);
|
||||
m_inputOperation = nullptr;
|
||||
m_movieClip = nullptr;
|
||||
if (m_distortion != nullptr) {
|
||||
BKE_tracking_distortion_free(m_distortion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,33 +92,33 @@ void MovieDistortionOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
if (this->m_distortion != nullptr) {
|
||||
if (m_distortion != nullptr) {
|
||||
/* float overscan = 0.0f; */
|
||||
const float pixel_aspect = this->m_pixel_aspect;
|
||||
const float pixel_aspect = m_pixel_aspect;
|
||||
const float w = (float)this->getWidth() /* / (1 + overscan) */;
|
||||
const float h = (float)this->getHeight() /* / (1 + overscan) */;
|
||||
const float aspx = w / (float)this->m_calibration_width;
|
||||
const float aspy = h / (float)this->m_calibration_height;
|
||||
const float aspx = w / (float)m_calibration_width;
|
||||
const float aspy = h / (float)m_calibration_height;
|
||||
float in[2];
|
||||
float out[2];
|
||||
|
||||
in[0] = (x /* - 0.5 * overscan * w */) / aspx;
|
||||
in[1] = (y /* - 0.5 * overscan * h */) / aspy / pixel_aspect;
|
||||
|
||||
if (this->m_apply) {
|
||||
BKE_tracking_distortion_undistort_v2(this->m_distortion, in, out);
|
||||
if (m_apply) {
|
||||
BKE_tracking_distortion_undistort_v2(m_distortion, in, out);
|
||||
}
|
||||
else {
|
||||
BKE_tracking_distortion_distort_v2(this->m_distortion, in, out);
|
||||
BKE_tracking_distortion_distort_v2(m_distortion, in, out);
|
||||
}
|
||||
|
||||
float u = out[0] * aspx /* + 0.5 * overscan * w */,
|
||||
v = (out[1] * aspy /* + 0.5 * overscan * h */) * pixel_aspect;
|
||||
|
||||
this->m_inputOperation->readSampled(output, u, v, PixelSampler::Bilinear);
|
||||
m_inputOperation->readSampled(output, u, v, PixelSampler::Bilinear);
|
||||
}
|
||||
else {
|
||||
this->m_inputOperation->readSampled(output, x, y, PixelSampler::Bilinear);
|
||||
m_inputOperation->readSampled(output, x, y, PixelSampler::Bilinear);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,28 +151,28 @@ void MovieDistortionOperation::update_memory_buffer_partial(MemoryBuffer *output
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
const MemoryBuffer *input_img = inputs[0];
|
||||
if (this->m_distortion == nullptr) {
|
||||
if (m_distortion == nullptr) {
|
||||
output->copy_from(input_img, area);
|
||||
return;
|
||||
}
|
||||
|
||||
/* `float overscan = 0.0f;` */
|
||||
const float pixel_aspect = this->m_pixel_aspect;
|
||||
const float pixel_aspect = m_pixel_aspect;
|
||||
const float w = (float)this->getWidth() /* `/ (1 + overscan)` */;
|
||||
const float h = (float)this->getHeight() /* `/ (1 + overscan)` */;
|
||||
const float aspx = w / (float)this->m_calibration_width;
|
||||
const float aspy = h / (float)this->m_calibration_height;
|
||||
const float aspx = w / (float)m_calibration_width;
|
||||
const float aspy = h / (float)m_calibration_height;
|
||||
float xy[2];
|
||||
float distorted_xy[2];
|
||||
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
|
||||
xy[0] = (it.x /* `- 0.5 * overscan * w` */) / aspx;
|
||||
xy[1] = (it.y /* `- 0.5 * overscan * h` */) / aspy / pixel_aspect;
|
||||
|
||||
if (this->m_apply) {
|
||||
BKE_tracking_distortion_undistort_v2(this->m_distortion, xy, distorted_xy);
|
||||
if (m_apply) {
|
||||
BKE_tracking_distortion_undistort_v2(m_distortion, xy, distorted_xy);
|
||||
}
|
||||
else {
|
||||
BKE_tracking_distortion_distort_v2(this->m_distortion, xy, distorted_xy);
|
||||
BKE_tracking_distortion_distort_v2(m_distortion, xy, distorted_xy);
|
||||
}
|
||||
|
||||
const float u = distorted_xy[0] * aspx /* `+ 0.5 * overscan * w` */;
|
||||
|
||||
@@ -50,11 +50,11 @@ class MovieDistortionOperation : public MultiThreadedOperation {
|
||||
|
||||
void setMovieClip(MovieClip *clip)
|
||||
{
|
||||
this->m_movieClip = clip;
|
||||
m_movieClip = clip;
|
||||
}
|
||||
void setFramenumber(int framenumber)
|
||||
{
|
||||
this->m_framenumber = framenumber;
|
||||
m_framenumber = framenumber;
|
||||
}
|
||||
bool determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
|
||||
@@ -26,27 +26,27 @@ MultilayerBaseOperation::MultilayerBaseOperation(RenderLayer *render_layer,
|
||||
RenderPass *render_pass,
|
||||
int view)
|
||||
{
|
||||
this->m_passId = BLI_findindex(&render_layer->passes, render_pass);
|
||||
this->m_view = view;
|
||||
this->m_renderLayer = render_layer;
|
||||
this->m_renderPass = render_pass;
|
||||
m_passId = BLI_findindex(&render_layer->passes, render_pass);
|
||||
m_view = view;
|
||||
m_renderLayer = render_layer;
|
||||
m_renderPass = render_pass;
|
||||
}
|
||||
|
||||
ImBuf *MultilayerBaseOperation::getImBuf()
|
||||
{
|
||||
/* temporarily changes the view to get the right ImBuf */
|
||||
int view = this->m_imageUser->view;
|
||||
int view = m_imageUser->view;
|
||||
|
||||
this->m_imageUser->view = this->m_view;
|
||||
this->m_imageUser->pass = this->m_passId;
|
||||
m_imageUser->view = m_view;
|
||||
m_imageUser->pass = m_passId;
|
||||
|
||||
if (BKE_image_multilayer_index(this->m_image->rr, this->m_imageUser)) {
|
||||
if (BKE_image_multilayer_index(m_image->rr, m_imageUser)) {
|
||||
ImBuf *ibuf = BaseImageOperation::getImBuf();
|
||||
this->m_imageUser->view = view;
|
||||
m_imageUser->view = view;
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
this->m_imageUser->view = view;
|
||||
m_imageUser->view = view;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ void MultilayerBaseOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
std::unique_ptr<MetaData> MultilayerColorOperation::getMetaData()
|
||||
{
|
||||
BLI_assert(this->m_buffer);
|
||||
BLI_assert(m_buffer);
|
||||
MetaDataExtractCallbackData callback_data = {nullptr};
|
||||
RenderResult *render_result = this->m_image->rr;
|
||||
RenderResult *render_result = m_image->rr;
|
||||
if (render_result && render_result->stamp_data) {
|
||||
RenderLayer *render_layer = this->m_renderLayer;
|
||||
RenderPass *render_pass = this->m_renderPass;
|
||||
RenderLayer *render_layer = m_renderLayer;
|
||||
RenderPass *render_pass = m_renderPass;
|
||||
std::string full_layer_name =
|
||||
std::string(render_layer->name,
|
||||
BLI_strnlen(render_layer->name, sizeof(render_layer->name))) +
|
||||
@@ -88,20 +88,20 @@ void MultilayerColorOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler sampler)
|
||||
{
|
||||
if (this->m_imageFloatBuffer == nullptr) {
|
||||
if (m_imageFloatBuffer == nullptr) {
|
||||
zero_v4(output);
|
||||
}
|
||||
else {
|
||||
if (this->m_numberOfChannels == 4) {
|
||||
if (m_numberOfChannels == 4) {
|
||||
switch (sampler) {
|
||||
case PixelSampler::Nearest:
|
||||
nearest_interpolation_color(this->m_buffer, nullptr, output, x, y);
|
||||
nearest_interpolation_color(m_buffer, nullptr, output, x, y);
|
||||
break;
|
||||
case PixelSampler::Bilinear:
|
||||
bilinear_interpolation_color(this->m_buffer, nullptr, output, x, y);
|
||||
bilinear_interpolation_color(m_buffer, nullptr, output, x, y);
|
||||
break;
|
||||
case PixelSampler::Bicubic:
|
||||
bicubic_interpolation_color(this->m_buffer, nullptr, output, x, y);
|
||||
bicubic_interpolation_color(m_buffer, nullptr, output, x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ void MultilayerColorOperation::executePixelSampled(float output[4],
|
||||
}
|
||||
else {
|
||||
int offset = (yi * this->getWidth() + xi) * 3;
|
||||
copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
|
||||
copy_v3_v3(output, &m_imageFloatBuffer[offset]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ void MultilayerValueOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
if (this->m_imageFloatBuffer == nullptr) {
|
||||
if (m_imageFloatBuffer == nullptr) {
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
else {
|
||||
@@ -136,7 +136,7 @@ void MultilayerValueOperation::executePixelSampled(float output[4],
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
else {
|
||||
float result = this->m_imageFloatBuffer[yi * this->getWidth() + xi];
|
||||
float result = m_imageFloatBuffer[yi * this->getWidth() + xi];
|
||||
output[0] = result;
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ void MultilayerVectorOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
if (this->m_imageFloatBuffer == nullptr) {
|
||||
if (m_imageFloatBuffer == nullptr) {
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
else {
|
||||
@@ -159,7 +159,7 @@ void MultilayerVectorOperation::executePixelSampled(float output[4],
|
||||
}
|
||||
else {
|
||||
int offset = (yi * this->getWidth() + xi) * 3;
|
||||
copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
|
||||
copy_v3_v3(output, &m_imageFloatBuffer[offset]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,14 +24,14 @@ NormalizeOperation::NormalizeOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_imageReader = nullptr;
|
||||
this->m_cachedInstance = nullptr;
|
||||
m_imageReader = nullptr;
|
||||
m_cachedInstance = nullptr;
|
||||
this->flags.complex = true;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
void NormalizeOperation::initExecution()
|
||||
{
|
||||
this->m_imageReader = this->getInputSocketReader(0);
|
||||
m_imageReader = this->getInputSocketReader(0);
|
||||
NodeOperation::initMutex();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ void NormalizeOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
/* using generic two floats struct to store `x: min`, `y: multiply` */
|
||||
NodeTwoFloats *minmult = (NodeTwoFloats *)data;
|
||||
|
||||
this->m_imageReader->read(output, x, y, nullptr);
|
||||
m_imageReader->read(output, x, y, nullptr);
|
||||
|
||||
output[0] = (output[0] - minmult->x) * minmult->y;
|
||||
|
||||
@@ -55,8 +55,8 @@ void NormalizeOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
|
||||
void NormalizeOperation::deinitExecution()
|
||||
{
|
||||
this->m_imageReader = nullptr;
|
||||
delete this->m_cachedInstance;
|
||||
m_imageReader = nullptr;
|
||||
delete m_cachedInstance;
|
||||
m_cachedInstance = nullptr;
|
||||
NodeOperation::deinitMutex();
|
||||
}
|
||||
@@ -66,7 +66,7 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
rcti *output)
|
||||
{
|
||||
rcti imageInput;
|
||||
if (this->m_cachedInstance) {
|
||||
if (m_cachedInstance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
void *NormalizeOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
lockMutex();
|
||||
if (this->m_cachedInstance == nullptr) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
|
||||
if (m_cachedInstance == nullptr) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_imageReader->initializeTileData(rect);
|
||||
/* using generic two floats struct to store `x: min`, `y: multiply`. */
|
||||
NodeTwoFloats *minmult = new NodeTwoFloats();
|
||||
|
||||
@@ -117,11 +117,11 @@ void *NormalizeOperation::initializeTileData(rcti *rect)
|
||||
/* The rare case of flat buffer would cause a divide by 0 */
|
||||
minmult->y = ((maxv != minv) ? 1.0f / (maxv - minv) : 0.0f);
|
||||
|
||||
this->m_cachedInstance = minmult;
|
||||
m_cachedInstance = minmult;
|
||||
}
|
||||
|
||||
unlockMutex();
|
||||
return this->m_cachedInstance;
|
||||
return m_cachedInstance;
|
||||
}
|
||||
|
||||
void NormalizeOperation::deinitializeTileData(rcti * /*rect*/, void * /*data*/)
|
||||
|
||||
@@ -56,27 +56,26 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam
|
||||
|
||||
exrhandle = IMB_exr_get_handle_name(filename);
|
||||
|
||||
if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
|
||||
if (!BKE_scene_multiview_is_render_view_first(m_rd, m_viewName)) {
|
||||
return exrhandle;
|
||||
}
|
||||
|
||||
IMB_exr_clear_channels(exrhandle);
|
||||
|
||||
for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
|
||||
if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false) {
|
||||
for (srv = (SceneRenderView *)m_rd->views.first; srv; srv = srv->next) {
|
||||
if (BKE_scene_multiview_is_render_view_active(m_rd, srv) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IMB_exr_add_view(exrhandle, srv->name);
|
||||
add_exr_channels(exrhandle, nullptr, this->m_datatype, srv->name, width, false, nullptr);
|
||||
add_exr_channels(exrhandle, nullptr, m_datatype, srv->name, width, false, nullptr);
|
||||
}
|
||||
|
||||
BLI_make_existing_file(filename);
|
||||
|
||||
/* prepare the file with all the channels */
|
||||
|
||||
if (!IMB_exr_begin_write(
|
||||
exrhandle, filename, width, height, this->m_format->exr_codec, nullptr)) {
|
||||
if (!IMB_exr_begin_write(exrhandle, filename, width, height, m_format->exr_codec, nullptr)) {
|
||||
printf("Error Writing Singlelayer Multiview Openexr\n");
|
||||
IMB_exr_close(exrhandle);
|
||||
}
|
||||
@@ -98,33 +97,33 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
|
||||
char filename[FILE_MAX];
|
||||
|
||||
BKE_image_path_from_imtype(filename,
|
||||
this->m_path,
|
||||
m_path,
|
||||
BKE_main_blendfile_path_from_global(),
|
||||
this->m_rd->cfra,
|
||||
m_rd->cfra,
|
||||
R_IMF_IMTYPE_OPENEXR,
|
||||
(this->m_rd->scemode & R_EXTENSION) != 0,
|
||||
(m_rd->scemode & R_EXTENSION) != 0,
|
||||
true,
|
||||
nullptr);
|
||||
|
||||
exrhandle = this->get_handle(filename);
|
||||
add_exr_channels(exrhandle,
|
||||
nullptr,
|
||||
this->m_datatype,
|
||||
this->m_viewName,
|
||||
m_datatype,
|
||||
m_viewName,
|
||||
width,
|
||||
this->m_format->depth == R_IMF_CHAN_DEPTH_16,
|
||||
this->m_outputBuffer);
|
||||
m_format->depth == R_IMF_CHAN_DEPTH_16,
|
||||
m_outputBuffer);
|
||||
|
||||
/* memory can only be freed after we write all views to the file */
|
||||
this->m_outputBuffer = nullptr;
|
||||
this->m_imageInput = nullptr;
|
||||
m_outputBuffer = nullptr;
|
||||
m_imageInput = nullptr;
|
||||
|
||||
/* ready to close the file */
|
||||
if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
|
||||
if (BKE_scene_multiview_is_render_view_last(m_rd, m_viewName)) {
|
||||
IMB_exr_write_channels(exrhandle);
|
||||
|
||||
/* free buffer memory for all the views */
|
||||
free_exr_channels(exrhandle, this->m_rd, nullptr, this->m_datatype);
|
||||
free_exr_channels(exrhandle, m_rd, nullptr, m_datatype);
|
||||
|
||||
/* remove exr handle and data */
|
||||
IMB_exr_close(exrhandle);
|
||||
@@ -159,28 +158,28 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename
|
||||
/* get a new global handle */
|
||||
exrhandle = IMB_exr_get_handle_name(filename);
|
||||
|
||||
if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
|
||||
if (!BKE_scene_multiview_is_render_view_first(m_rd, m_viewName)) {
|
||||
return exrhandle;
|
||||
}
|
||||
|
||||
IMB_exr_clear_channels(exrhandle);
|
||||
|
||||
/* check renderdata for amount of views */
|
||||
for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
|
||||
for (srv = (SceneRenderView *)m_rd->views.first; srv; srv = srv->next) {
|
||||
|
||||
if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false) {
|
||||
if (BKE_scene_multiview_is_render_view_active(m_rd, srv) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IMB_exr_add_view(exrhandle, srv->name);
|
||||
|
||||
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
|
||||
for (unsigned int i = 0; i < m_layers.size(); i++) {
|
||||
add_exr_channels(exrhandle,
|
||||
this->m_layers[i].name,
|
||||
this->m_layers[i].datatype,
|
||||
m_layers[i].name,
|
||||
m_layers[i].datatype,
|
||||
srv->name,
|
||||
width,
|
||||
this->m_exr_half_float,
|
||||
m_exr_half_float,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
@@ -189,7 +188,7 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename
|
||||
|
||||
/* prepare the file with all the channels for the header */
|
||||
StampData *stamp_data = createStampData();
|
||||
if (!IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, stamp_data)) {
|
||||
if (!IMB_exr_begin_write(exrhandle, filename, width, height, m_exr_codec, stamp_data)) {
|
||||
printf("Error Writing Multilayer Multiview Openexr\n");
|
||||
IMB_exr_close(exrhandle);
|
||||
BKE_stamp_data_free(stamp_data);
|
||||
@@ -213,40 +212,39 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
|
||||
char filename[FILE_MAX];
|
||||
|
||||
BKE_image_path_from_imtype(filename,
|
||||
this->m_path,
|
||||
m_path,
|
||||
BKE_main_blendfile_path_from_global(),
|
||||
this->m_rd->cfra,
|
||||
m_rd->cfra,
|
||||
R_IMF_IMTYPE_MULTILAYER,
|
||||
(this->m_rd->scemode & R_EXTENSION) != 0,
|
||||
(m_rd->scemode & R_EXTENSION) != 0,
|
||||
true,
|
||||
nullptr);
|
||||
|
||||
exrhandle = this->get_handle(filename);
|
||||
|
||||
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
|
||||
for (unsigned int i = 0; i < m_layers.size(); i++) {
|
||||
add_exr_channels(exrhandle,
|
||||
this->m_layers[i].name,
|
||||
this->m_layers[i].datatype,
|
||||
this->m_viewName,
|
||||
m_layers[i].name,
|
||||
m_layers[i].datatype,
|
||||
m_viewName,
|
||||
width,
|
||||
this->m_exr_half_float,
|
||||
this->m_layers[i].outputBuffer);
|
||||
m_exr_half_float,
|
||||
m_layers[i].outputBuffer);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
|
||||
for (unsigned int i = 0; i < m_layers.size(); i++) {
|
||||
/* memory can only be freed after we write all views to the file */
|
||||
this->m_layers[i].outputBuffer = nullptr;
|
||||
this->m_layers[i].imageInput = nullptr;
|
||||
m_layers[i].outputBuffer = nullptr;
|
||||
m_layers[i].imageInput = nullptr;
|
||||
}
|
||||
|
||||
/* ready to close the file */
|
||||
if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
|
||||
if (BKE_scene_multiview_is_render_view_last(m_rd, m_viewName)) {
|
||||
IMB_exr_write_channels(exrhandle);
|
||||
|
||||
/* free buffer memory for all the views */
|
||||
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
|
||||
free_exr_channels(
|
||||
exrhandle, this->m_rd, this->m_layers[i].name, this->m_layers[i].datatype);
|
||||
for (unsigned int i = 0; i < m_layers.size(); i++) {
|
||||
free_exr_channels(exrhandle, m_rd, m_layers[i].name, m_layers[i].datatype);
|
||||
}
|
||||
|
||||
IMB_exr_close(exrhandle);
|
||||
@@ -269,8 +267,8 @@ OutputStereoOperation::OutputStereoOperation(const RenderData *rd,
|
||||
: OutputSingleLayerOperation(
|
||||
rd, tree, datatype, format, path, viewSettings, displaySettings, viewName, saveAsRender)
|
||||
{
|
||||
BLI_strncpy(this->m_name, name, sizeof(this->m_name));
|
||||
this->m_channels = get_datatype_size(datatype);
|
||||
BLI_strncpy(m_name, name, sizeof(m_name));
|
||||
m_channels = get_datatype_size(datatype);
|
||||
}
|
||||
|
||||
void *OutputStereoOperation::get_handle(const char *filename)
|
||||
@@ -285,7 +283,7 @@ void *OutputStereoOperation::get_handle(const char *filename)
|
||||
|
||||
exrhandle = IMB_exr_get_handle_name(filename);
|
||||
|
||||
if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
|
||||
if (!BKE_scene_multiview_is_render_view_first(m_rd, m_viewName)) {
|
||||
return exrhandle;
|
||||
}
|
||||
|
||||
@@ -308,24 +306,24 @@ void OutputStereoOperation::deinitExecution()
|
||||
if (width != 0 && height != 0) {
|
||||
void *exrhandle;
|
||||
|
||||
exrhandle = this->get_handle(this->m_path);
|
||||
float *buf = this->m_outputBuffer;
|
||||
exrhandle = this->get_handle(m_path);
|
||||
float *buf = m_outputBuffer;
|
||||
|
||||
/* populate single EXR channel with view data */
|
||||
IMB_exr_add_channel(exrhandle,
|
||||
nullptr,
|
||||
this->m_name,
|
||||
this->m_viewName,
|
||||
m_name,
|
||||
m_viewName,
|
||||
1,
|
||||
this->m_channels * width * height,
|
||||
m_channels * width * height,
|
||||
buf,
|
||||
this->m_format->depth == R_IMF_CHAN_DEPTH_16);
|
||||
m_format->depth == R_IMF_CHAN_DEPTH_16);
|
||||
|
||||
this->m_imageInput = nullptr;
|
||||
this->m_outputBuffer = nullptr;
|
||||
m_imageInput = nullptr;
|
||||
m_outputBuffer = nullptr;
|
||||
|
||||
/* create stereo ibuf */
|
||||
if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
|
||||
if (BKE_scene_multiview_is_render_view_last(m_rd, m_viewName)) {
|
||||
ImBuf *ibuf[3] = {nullptr};
|
||||
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
||||
char filename[FILE_MAX];
|
||||
@@ -333,33 +331,33 @@ void OutputStereoOperation::deinitExecution()
|
||||
|
||||
/* get rectf from EXR */
|
||||
for (i = 0; i < 2; i++) {
|
||||
float *rectf = IMB_exr_channel_rect(exrhandle, nullptr, this->m_name, names[i]);
|
||||
ibuf[i] = IMB_allocImBuf(width, height, this->m_format->planes, 0);
|
||||
float *rectf = IMB_exr_channel_rect(exrhandle, nullptr, m_name, names[i]);
|
||||
ibuf[i] = IMB_allocImBuf(width, height, m_format->planes, 0);
|
||||
|
||||
ibuf[i]->channels = this->m_channels;
|
||||
ibuf[i]->channels = m_channels;
|
||||
ibuf[i]->rect_float = rectf;
|
||||
ibuf[i]->mall |= IB_rectfloat;
|
||||
ibuf[i]->dither = this->m_rd->dither_intensity;
|
||||
ibuf[i]->dither = m_rd->dither_intensity;
|
||||
|
||||
/* do colormanagement in the individual views, so it doesn't need to do in the stereo */
|
||||
IMB_colormanagement_imbuf_for_write(
|
||||
ibuf[i], true, false, this->m_viewSettings, this->m_displaySettings, this->m_format);
|
||||
ibuf[i], true, false, m_viewSettings, m_displaySettings, m_format);
|
||||
IMB_prepare_write_ImBuf(IMB_isfloat(ibuf[i]), ibuf[i]);
|
||||
}
|
||||
|
||||
/* create stereo buffer */
|
||||
ibuf[2] = IMB_stereo3d_ImBuf(this->m_format, ibuf[0], ibuf[1]);
|
||||
ibuf[2] = IMB_stereo3d_ImBuf(m_format, ibuf[0], ibuf[1]);
|
||||
|
||||
BKE_image_path_from_imformat(filename,
|
||||
this->m_path,
|
||||
m_path,
|
||||
BKE_main_blendfile_path_from_global(),
|
||||
this->m_rd->cfra,
|
||||
this->m_format,
|
||||
(this->m_rd->scemode & R_EXTENSION) != 0,
|
||||
m_rd->cfra,
|
||||
m_format,
|
||||
(m_rd->scemode & R_EXTENSION) != 0,
|
||||
true,
|
||||
nullptr);
|
||||
|
||||
BKE_imbuf_write(ibuf[2], filename, this->m_format);
|
||||
BKE_imbuf_write(ibuf[2], filename, m_format);
|
||||
|
||||
/* imbuf knows which rects are not part of ibuf */
|
||||
for (i = 0; i < 3; i++) {
|
||||
|
||||
@@ -213,69 +213,64 @@ OutputSingleLayerOperation::OutputSingleLayerOperation(
|
||||
const char *viewName,
|
||||
const bool saveAsRender)
|
||||
{
|
||||
this->m_rd = rd;
|
||||
this->m_tree = tree;
|
||||
m_rd = rd;
|
||||
m_tree = tree;
|
||||
|
||||
this->addInputSocket(datatype);
|
||||
|
||||
this->m_outputBuffer = nullptr;
|
||||
this->m_datatype = datatype;
|
||||
this->m_imageInput = nullptr;
|
||||
m_outputBuffer = nullptr;
|
||||
m_datatype = datatype;
|
||||
m_imageInput = nullptr;
|
||||
|
||||
this->m_format = format;
|
||||
BLI_strncpy(this->m_path, path, sizeof(this->m_path));
|
||||
m_format = format;
|
||||
BLI_strncpy(m_path, path, sizeof(m_path));
|
||||
|
||||
this->m_viewSettings = viewSettings;
|
||||
this->m_displaySettings = displaySettings;
|
||||
this->m_viewName = viewName;
|
||||
this->m_saveAsRender = saveAsRender;
|
||||
m_viewSettings = viewSettings;
|
||||
m_displaySettings = displaySettings;
|
||||
m_viewName = viewName;
|
||||
m_saveAsRender = saveAsRender;
|
||||
}
|
||||
|
||||
void OutputSingleLayerOperation::initExecution()
|
||||
{
|
||||
this->m_imageInput = getInputSocketReader(0);
|
||||
this->m_outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_datatype);
|
||||
m_imageInput = getInputSocketReader(0);
|
||||
m_outputBuffer = init_buffer(this->getWidth(), this->getHeight(), m_datatype);
|
||||
}
|
||||
|
||||
void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
{
|
||||
write_buffer_rect(rect,
|
||||
this->m_tree,
|
||||
this->m_imageInput,
|
||||
this->m_outputBuffer,
|
||||
this->getWidth(),
|
||||
this->m_datatype);
|
||||
write_buffer_rect(rect, m_tree, m_imageInput, m_outputBuffer, this->getWidth(), m_datatype);
|
||||
}
|
||||
|
||||
void OutputSingleLayerOperation::deinitExecution()
|
||||
{
|
||||
if (this->getWidth() * this->getHeight() != 0) {
|
||||
|
||||
int size = get_datatype_size(this->m_datatype);
|
||||
ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), this->m_format->planes, 0);
|
||||
int size = get_datatype_size(m_datatype);
|
||||
ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), m_format->planes, 0);
|
||||
char filename[FILE_MAX];
|
||||
const char *suffix;
|
||||
|
||||
ibuf->channels = size;
|
||||
ibuf->rect_float = this->m_outputBuffer;
|
||||
ibuf->rect_float = m_outputBuffer;
|
||||
ibuf->mall |= IB_rectfloat;
|
||||
ibuf->dither = this->m_rd->dither_intensity;
|
||||
ibuf->dither = m_rd->dither_intensity;
|
||||
|
||||
IMB_colormanagement_imbuf_for_write(
|
||||
ibuf, m_saveAsRender, false, m_viewSettings, m_displaySettings, this->m_format);
|
||||
ibuf, m_saveAsRender, false, m_viewSettings, m_displaySettings, m_format);
|
||||
|
||||
suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName);
|
||||
suffix = BKE_scene_multiview_view_suffix_get(m_rd, m_viewName);
|
||||
|
||||
BKE_image_path_from_imformat(filename,
|
||||
this->m_path,
|
||||
m_path,
|
||||
BKE_main_blendfile_path_from_global(),
|
||||
this->m_rd->cfra,
|
||||
this->m_format,
|
||||
(this->m_rd->scemode & R_EXTENSION) != 0,
|
||||
m_rd->cfra,
|
||||
m_format,
|
||||
(m_rd->scemode & R_EXTENSION) != 0,
|
||||
true,
|
||||
suffix);
|
||||
|
||||
if (0 == BKE_imbuf_write(ibuf, filename, this->m_format)) {
|
||||
if (0 == BKE_imbuf_write(ibuf, filename, m_format)) {
|
||||
printf("Cannot save Node File Output to %s\n", filename);
|
||||
}
|
||||
else {
|
||||
@@ -284,8 +279,8 @@ void OutputSingleLayerOperation::deinitExecution()
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
}
|
||||
this->m_outputBuffer = nullptr;
|
||||
this->m_imageInput = nullptr;
|
||||
m_outputBuffer = nullptr;
|
||||
m_imageInput = nullptr;
|
||||
}
|
||||
|
||||
void OutputSingleLayerOperation::update_memory_buffer_partial(MemoryBuffer *UNUSED(output),
|
||||
@@ -296,10 +291,8 @@ void OutputSingleLayerOperation::update_memory_buffer_partial(MemoryBuffer *UNUS
|
||||
return;
|
||||
}
|
||||
|
||||
MemoryBuffer output_buf(m_outputBuffer,
|
||||
COM_data_type_num_channels(this->m_datatype),
|
||||
this->getWidth(),
|
||||
this->getHeight());
|
||||
MemoryBuffer output_buf(
|
||||
m_outputBuffer, COM_data_type_num_channels(m_datatype), this->getWidth(), this->getHeight());
|
||||
const MemoryBuffer *input_image = inputs[0];
|
||||
output_buf.copy_from(input_image, area);
|
||||
}
|
||||
@@ -325,14 +318,14 @@ OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(const Scene *
|
||||
bool exr_half_float,
|
||||
const char *viewName)
|
||||
{
|
||||
this->m_scene = scene;
|
||||
this->m_rd = rd;
|
||||
this->m_tree = tree;
|
||||
m_scene = scene;
|
||||
m_rd = rd;
|
||||
m_tree = tree;
|
||||
|
||||
BLI_strncpy(this->m_path, path, sizeof(this->m_path));
|
||||
this->m_exr_codec = exr_codec;
|
||||
this->m_exr_half_float = exr_half_float;
|
||||
this->m_viewName = viewName;
|
||||
BLI_strncpy(m_path, path, sizeof(m_path));
|
||||
m_exr_codec = exr_codec;
|
||||
m_exr_half_float = exr_half_float;
|
||||
m_viewName = viewName;
|
||||
this->set_canvas_input_index(RESOLUTION_INPUT_ANY);
|
||||
}
|
||||
|
||||
@@ -341,7 +334,7 @@ void OutputOpenExrMultiLayerOperation::add_layer(const char *name,
|
||||
bool use_layer)
|
||||
{
|
||||
this->addInputSocket(datatype);
|
||||
this->m_layers.append(OutputOpenExrLayer(name, datatype, use_layer));
|
||||
m_layers.append(OutputOpenExrLayer(name, datatype, use_layer));
|
||||
}
|
||||
|
||||
StampData *OutputOpenExrMultiLayerOperation::createStampData() const
|
||||
@@ -370,27 +363,23 @@ StampData *OutputOpenExrMultiLayerOperation::createStampData() const
|
||||
|
||||
void OutputOpenExrMultiLayerOperation::initExecution()
|
||||
{
|
||||
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
|
||||
if (this->m_layers[i].use_layer) {
|
||||
for (unsigned int i = 0; i < m_layers.size(); i++) {
|
||||
if (m_layers[i].use_layer) {
|
||||
SocketReader *reader = getInputSocketReader(i);
|
||||
this->m_layers[i].imageInput = reader;
|
||||
this->m_layers[i].outputBuffer = init_buffer(
|
||||
this->getWidth(), this->getHeight(), this->m_layers[i].datatype);
|
||||
m_layers[i].imageInput = reader;
|
||||
m_layers[i].outputBuffer = init_buffer(
|
||||
this->getWidth(), this->getHeight(), m_layers[i].datatype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
{
|
||||
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
|
||||
OutputOpenExrLayer &layer = this->m_layers[i];
|
||||
for (unsigned int i = 0; i < m_layers.size(); i++) {
|
||||
OutputOpenExrLayer &layer = m_layers[i];
|
||||
if (layer.imageInput) {
|
||||
write_buffer_rect(rect,
|
||||
this->m_tree,
|
||||
layer.imageInput,
|
||||
layer.outputBuffer,
|
||||
this->getWidth(),
|
||||
layer.datatype);
|
||||
write_buffer_rect(
|
||||
rect, m_tree, layer.imageInput, layer.outputBuffer, this->getWidth(), layer.datatype);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,35 +393,35 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
|
||||
const char *suffix;
|
||||
void *exrhandle = IMB_exr_get_handle();
|
||||
|
||||
suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName);
|
||||
suffix = BKE_scene_multiview_view_suffix_get(m_rd, m_viewName);
|
||||
BKE_image_path_from_imtype(filename,
|
||||
this->m_path,
|
||||
m_path,
|
||||
BKE_main_blendfile_path_from_global(),
|
||||
this->m_rd->cfra,
|
||||
m_rd->cfra,
|
||||
R_IMF_IMTYPE_MULTILAYER,
|
||||
(this->m_rd->scemode & R_EXTENSION) != 0,
|
||||
(m_rd->scemode & R_EXTENSION) != 0,
|
||||
true,
|
||||
suffix);
|
||||
BLI_make_existing_file(filename);
|
||||
|
||||
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
|
||||
OutputOpenExrLayer &layer = this->m_layers[i];
|
||||
for (unsigned int i = 0; i < m_layers.size(); i++) {
|
||||
OutputOpenExrLayer &layer = m_layers[i];
|
||||
if (!layer.imageInput) {
|
||||
continue; /* skip unconnected sockets */
|
||||
}
|
||||
|
||||
add_exr_channels(exrhandle,
|
||||
this->m_layers[i].name,
|
||||
this->m_layers[i].datatype,
|
||||
m_layers[i].name,
|
||||
m_layers[i].datatype,
|
||||
"",
|
||||
width,
|
||||
this->m_exr_half_float,
|
||||
this->m_layers[i].outputBuffer);
|
||||
m_exr_half_float,
|
||||
m_layers[i].outputBuffer);
|
||||
}
|
||||
|
||||
/* when the filename has no permissions, this can fail */
|
||||
StampData *stamp_data = createStampData();
|
||||
if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, stamp_data)) {
|
||||
if (IMB_exr_begin_write(exrhandle, filename, width, height, m_exr_codec, stamp_data)) {
|
||||
IMB_exr_write_channels(exrhandle);
|
||||
}
|
||||
else {
|
||||
@@ -442,13 +431,13 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
|
||||
}
|
||||
|
||||
IMB_exr_close(exrhandle);
|
||||
for (unsigned int i = 0; i < this->m_layers.size(); i++) {
|
||||
if (this->m_layers[i].outputBuffer) {
|
||||
MEM_freeN(this->m_layers[i].outputBuffer);
|
||||
this->m_layers[i].outputBuffer = nullptr;
|
||||
for (unsigned int i = 0; i < m_layers.size(); i++) {
|
||||
if (m_layers[i].outputBuffer) {
|
||||
MEM_freeN(m_layers[i].outputBuffer);
|
||||
m_layers[i].outputBuffer = nullptr;
|
||||
}
|
||||
|
||||
this->m_layers[i].imageInput = nullptr;
|
||||
m_layers[i].imageInput = nullptr;
|
||||
}
|
||||
BKE_stamp_data_free(stamp_data);
|
||||
}
|
||||
@@ -459,8 +448,8 @@ void OutputOpenExrMultiLayerOperation::update_memory_buffer_partial(MemoryBuffer
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
const MemoryBuffer *input_image = inputs[0];
|
||||
for (int i = 0; i < this->m_layers.size(); i++) {
|
||||
OutputOpenExrLayer &layer = this->m_layers[i];
|
||||
for (int i = 0; i < m_layers.size(); i++) {
|
||||
OutputOpenExrLayer &layer = m_layers[i];
|
||||
if (layer.outputBuffer) {
|
||||
MemoryBuffer output_buf(layer.outputBuffer,
|
||||
COM_data_type_num_channels(layer.datatype),
|
||||
|
||||
@@ -25,17 +25,17 @@ PixelateOperation::PixelateOperation(DataType datatype)
|
||||
this->addInputSocket(datatype);
|
||||
this->addOutputSocket(datatype);
|
||||
this->set_canvas_input_index(0);
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
|
||||
void PixelateOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void PixelateOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
|
||||
void PixelateOperation::executePixelSampled(float output[4],
|
||||
@@ -45,7 +45,7 @@ void PixelateOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float nx = round(x);
|
||||
float ny = round(y);
|
||||
this->m_inputOperation->readSampled(output, nx, ny, sampler);
|
||||
m_inputOperation->readSampled(output, nx, ny, sampler);
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -33,8 +33,8 @@ void PlaneDistortBaseOperation::calculateCorners(const float corners[4][2],
|
||||
bool normalized,
|
||||
int sample)
|
||||
{
|
||||
BLI_assert(sample < this->m_motion_blur_samples);
|
||||
MotionSample *sample_data = &this->m_samples[sample];
|
||||
BLI_assert(sample < m_motion_blur_samples);
|
||||
MotionSample *sample_data = &m_samples[sample];
|
||||
if (normalized) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
sample_data->frameSpaceCorners[i][0] = corners[i][0] * this->getWidth();
|
||||
@@ -68,7 +68,7 @@ PlaneDistortWarpImageOperation::PlaneDistortWarpImageOperation() : PlaneDistortB
|
||||
{
|
||||
this->addInputSocket(DataType::Color, ResizeMode::Align);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_pixelReader = nullptr;
|
||||
m_pixelReader = nullptr;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
|
||||
@@ -83,19 +83,19 @@ void PlaneDistortWarpImageOperation::calculateCorners(const float corners[4][2],
|
||||
const int height = image->getHeight();
|
||||
float frame_corners[4][2] = {
|
||||
{0.0f, 0.0f}, {(float)width, 0.0f}, {(float)width, (float)height}, {0.0f, (float)height}};
|
||||
MotionSample *sample_data = &this->m_samples[sample];
|
||||
MotionSample *sample_data = &m_samples[sample];
|
||||
BKE_tracking_homography_between_two_quads(
|
||||
sample_data->frameSpaceCorners, frame_corners, sample_data->perspectiveMatrix);
|
||||
}
|
||||
|
||||
void PlaneDistortWarpImageOperation::initExecution()
|
||||
{
|
||||
this->m_pixelReader = this->getInputSocketReader(0);
|
||||
m_pixelReader = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void PlaneDistortWarpImageOperation::deinitExecution()
|
||||
{
|
||||
this->m_pixelReader = nullptr;
|
||||
m_pixelReader = nullptr;
|
||||
}
|
||||
|
||||
void PlaneDistortWarpImageOperation::executePixelSampled(float output[4],
|
||||
@@ -105,19 +105,19 @@ void PlaneDistortWarpImageOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float uv[2];
|
||||
float deriv[2][2];
|
||||
if (this->m_motion_blur_samples == 1) {
|
||||
warpCoord(x, y, this->m_samples[0].perspectiveMatrix, uv, deriv);
|
||||
if (m_motion_blur_samples == 1) {
|
||||
warpCoord(x, y, m_samples[0].perspectiveMatrix, uv, deriv);
|
||||
m_pixelReader->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
|
||||
}
|
||||
else {
|
||||
zero_v4(output);
|
||||
for (int sample = 0; sample < this->m_motion_blur_samples; sample++) {
|
||||
for (int sample = 0; sample < m_motion_blur_samples; sample++) {
|
||||
float color[4];
|
||||
warpCoord(x, y, this->m_samples[sample].perspectiveMatrix, uv, deriv);
|
||||
warpCoord(x, y, m_samples[sample].perspectiveMatrix, uv, deriv);
|
||||
m_pixelReader->readFiltered(color, uv[0], uv[1], deriv[0], deriv[1]);
|
||||
add_v4_v4(output, color);
|
||||
}
|
||||
mul_v4_fl(output, 1.0f / (float)this->m_motion_blur_samples);
|
||||
mul_v4_fl(output, 1.0f / (float)m_motion_blur_samples);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,22 +129,22 @@ void PlaneDistortWarpImageOperation::update_memory_buffer_partial(MemoryBuffer *
|
||||
float uv[2];
|
||||
float deriv[2][2];
|
||||
BuffersIterator<float> it = output->iterate_with({}, area);
|
||||
if (this->m_motion_blur_samples == 1) {
|
||||
if (m_motion_blur_samples == 1) {
|
||||
for (; !it.is_end(); ++it) {
|
||||
warpCoord(it.x, it.y, this->m_samples[0].perspectiveMatrix, uv, deriv);
|
||||
warpCoord(it.x, it.y, m_samples[0].perspectiveMatrix, uv, deriv);
|
||||
input_img->read_elem_filtered(uv[0], uv[1], deriv[0], deriv[1], it.out);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (; !it.is_end(); ++it) {
|
||||
zero_v4(it.out);
|
||||
for (const int sample : IndexRange(this->m_motion_blur_samples)) {
|
||||
for (const int sample : IndexRange(m_motion_blur_samples)) {
|
||||
float color[4];
|
||||
warpCoord(it.x, it.y, this->m_samples[sample].perspectiveMatrix, uv, deriv);
|
||||
warpCoord(it.x, it.y, m_samples[sample].perspectiveMatrix, uv, deriv);
|
||||
input_img->read_elem_filtered(uv[0], uv[1], deriv[0], deriv[1], color);
|
||||
add_v4_v4(it.out, color);
|
||||
}
|
||||
mul_v4_fl(it.out, 1.0f / (float)this->m_motion_blur_samples);
|
||||
mul_v4_fl(it.out, 1.0f / (float)m_motion_blur_samples);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,10 +155,10 @@ bool PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(
|
||||
float min[2], max[2];
|
||||
INIT_MINMAX2(min, max);
|
||||
|
||||
for (int sample = 0; sample < this->m_motion_blur_samples; sample++) {
|
||||
for (int sample = 0; sample < m_motion_blur_samples; sample++) {
|
||||
float UVs[4][2];
|
||||
float deriv[2][2];
|
||||
MotionSample *sample_data = &this->m_samples[sample];
|
||||
MotionSample *sample_data = &m_samples[sample];
|
||||
/* TODO(sergey): figure out proper way to do this. */
|
||||
warpCoord(input->xmin - 2, input->ymin - 2, sample_data->perspectiveMatrix, UVs[0], deriv);
|
||||
warpCoord(input->xmax + 2, input->ymin - 2, sample_data->perspectiveMatrix, UVs[1], deriv);
|
||||
@@ -196,10 +196,10 @@ void PlaneDistortWarpImageOperation::get_area_of_interest(const int input_idx,
|
||||
#if 0
|
||||
float min[2], max[2];
|
||||
INIT_MINMAX2(min, max);
|
||||
for (int sample = 0; sample < this->m_motion_blur_samples; sample++) {
|
||||
for (int sample = 0; sample < m_motion_blur_samples; sample++) {
|
||||
float UVs[4][2];
|
||||
float deriv[2][2];
|
||||
MotionSample *sample_data = &this->m_samples[sample];
|
||||
MotionSample *sample_data = &m_samples[sample];
|
||||
/* TODO(sergey): figure out proper way to do this. */
|
||||
warpCoord(
|
||||
output_area.xmin - 2, output_area.ymin - 2, sample_data->perspectiveMatrix, UVs[0], deriv);
|
||||
@@ -243,11 +243,11 @@ void PlaneDistortMaskOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float point[2];
|
||||
int inside_counter = 0;
|
||||
if (this->m_motion_blur_samples == 1) {
|
||||
MotionSample *sample_data = &this->m_samples[0];
|
||||
for (int sample = 0; sample < this->m_osa; sample++) {
|
||||
point[0] = x + this->m_jitter[sample][0];
|
||||
point[1] = y + this->m_jitter[sample][1];
|
||||
if (m_motion_blur_samples == 1) {
|
||||
MotionSample *sample_data = &m_samples[0];
|
||||
for (int sample = 0; sample < m_osa; sample++) {
|
||||
point[0] = x + m_jitter[sample][0];
|
||||
point[1] = y + m_jitter[sample][1];
|
||||
if (isect_point_tri_v2(point,
|
||||
sample_data->frameSpaceCorners[0],
|
||||
sample_data->frameSpaceCorners[1],
|
||||
@@ -259,14 +259,14 @@ void PlaneDistortMaskOperation::executePixelSampled(float output[4],
|
||||
inside_counter++;
|
||||
}
|
||||
}
|
||||
output[0] = (float)inside_counter / this->m_osa;
|
||||
output[0] = (float)inside_counter / m_osa;
|
||||
}
|
||||
else {
|
||||
for (int motion_sample = 0; motion_sample < this->m_motion_blur_samples; motion_sample++) {
|
||||
MotionSample *sample_data = &this->m_samples[motion_sample];
|
||||
for (int osa_sample = 0; osa_sample < this->m_osa; osa_sample++) {
|
||||
point[0] = x + this->m_jitter[osa_sample][0];
|
||||
point[1] = y + this->m_jitter[osa_sample][1];
|
||||
for (int motion_sample = 0; motion_sample < m_motion_blur_samples; motion_sample++) {
|
||||
MotionSample *sample_data = &m_samples[motion_sample];
|
||||
for (int osa_sample = 0; osa_sample < m_osa; osa_sample++) {
|
||||
point[0] = x + m_jitter[osa_sample][0];
|
||||
point[1] = y + m_jitter[osa_sample][1];
|
||||
if (isect_point_tri_v2(point,
|
||||
sample_data->frameSpaceCorners[0],
|
||||
sample_data->frameSpaceCorners[1],
|
||||
@@ -279,7 +279,7 @@ void PlaneDistortMaskOperation::executePixelSampled(float output[4],
|
||||
}
|
||||
}
|
||||
}
|
||||
output[0] = (float)inside_counter / (this->m_osa * this->m_motion_blur_samples);
|
||||
output[0] = (float)inside_counter / (m_osa * m_motion_blur_samples);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,11 +289,11 @@ void PlaneDistortMaskOperation::update_memory_buffer_partial(MemoryBuffer *outpu
|
||||
{
|
||||
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
|
||||
int inside_count = 0;
|
||||
for (const int motion_sample : IndexRange(this->m_motion_blur_samples)) {
|
||||
MotionSample &sample = this->m_samples[motion_sample];
|
||||
for (const int motion_sample : IndexRange(m_motion_blur_samples)) {
|
||||
MotionSample &sample = m_samples[motion_sample];
|
||||
inside_count += get_jitter_samples_inside_count(it.x, it.y, sample);
|
||||
}
|
||||
*it.out = (float)inside_count / (this->m_osa * this->m_motion_blur_samples);
|
||||
*it.out = (float)inside_count / (m_osa * m_motion_blur_samples);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,9 +303,9 @@ int PlaneDistortMaskOperation::get_jitter_samples_inside_count(int x,
|
||||
{
|
||||
float point[2];
|
||||
int inside_count = 0;
|
||||
for (int sample = 0; sample < this->m_osa; sample++) {
|
||||
point[0] = x + this->m_jitter[sample][0];
|
||||
point[1] = y + this->m_jitter[sample][1];
|
||||
for (int sample = 0; sample < m_osa; sample++) {
|
||||
point[0] = x + m_jitter[sample][0];
|
||||
point[1] = y + m_jitter[sample][1];
|
||||
if (isect_point_tri_v2(point,
|
||||
sample_data.frameSpaceCorners[0],
|
||||
sample_data.frameSpaceCorners[1],
|
||||
|
||||
@@ -48,11 +48,11 @@ class PlaneDistortBaseOperation : public MultiThreadedOperation {
|
||||
void setMotionBlurSamples(int samples)
|
||||
{
|
||||
BLI_assert(samples <= PLANE_DISTORT_MAX_SAMPLES);
|
||||
this->m_motion_blur_samples = samples;
|
||||
m_motion_blur_samples = samples;
|
||||
}
|
||||
void setMotionBlurShutter(float shutter)
|
||||
{
|
||||
this->m_motion_blur_shutter = shutter;
|
||||
m_motion_blur_shutter = shutter;
|
||||
}
|
||||
|
||||
virtual void calculateCorners(const float corners[4][2], bool normalized, int sample);
|
||||
|
||||
@@ -27,21 +27,21 @@ namespace blender::compositor {
|
||||
|
||||
PlaneTrackCommon::PlaneTrackCommon()
|
||||
{
|
||||
this->m_movieClip = nullptr;
|
||||
this->m_framenumber = 0;
|
||||
this->m_trackingObjectName[0] = '\0';
|
||||
this->m_planeTrackName[0] = '\0';
|
||||
m_movieClip = nullptr;
|
||||
m_framenumber = 0;
|
||||
m_trackingObjectName[0] = '\0';
|
||||
m_planeTrackName[0] = '\0';
|
||||
}
|
||||
|
||||
void PlaneTrackCommon::read_and_calculate_corners(PlaneDistortBaseOperation *distort_op)
|
||||
{
|
||||
float corners[4][2];
|
||||
if (distort_op->m_motion_blur_samples == 1) {
|
||||
readCornersFromTrack(corners, this->m_framenumber);
|
||||
readCornersFromTrack(corners, m_framenumber);
|
||||
distort_op->calculateCorners(corners, true, 0);
|
||||
}
|
||||
else {
|
||||
const float frame = (float)this->m_framenumber - distort_op->m_motion_blur_shutter;
|
||||
const float frame = (float)m_framenumber - distort_op->m_motion_blur_shutter;
|
||||
const float frame_step = (distort_op->m_motion_blur_shutter * 2.0f) /
|
||||
distort_op->m_motion_blur_samples;
|
||||
float frame_iter = frame;
|
||||
@@ -58,18 +58,18 @@ void PlaneTrackCommon::readCornersFromTrack(float corners[4][2], float frame)
|
||||
MovieTracking *tracking;
|
||||
MovieTrackingObject *object;
|
||||
|
||||
if (!this->m_movieClip) {
|
||||
if (!m_movieClip) {
|
||||
return;
|
||||
}
|
||||
|
||||
tracking = &this->m_movieClip->tracking;
|
||||
tracking = &m_movieClip->tracking;
|
||||
|
||||
object = BKE_tracking_object_get_named(tracking, this->m_trackingObjectName);
|
||||
object = BKE_tracking_object_get_named(tracking, m_trackingObjectName);
|
||||
if (object) {
|
||||
MovieTrackingPlaneTrack *plane_track;
|
||||
plane_track = BKE_tracking_plane_track_get_named(tracking, object, this->m_planeTrackName);
|
||||
plane_track = BKE_tracking_plane_track_get_named(tracking, object, m_planeTrackName);
|
||||
if (plane_track) {
|
||||
float clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, frame);
|
||||
float clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(m_movieClip, frame);
|
||||
BKE_tracking_plane_marker_get_subframe_corners(plane_track, clip_framenr, corners);
|
||||
}
|
||||
}
|
||||
@@ -78,11 +78,11 @@ void PlaneTrackCommon::readCornersFromTrack(float corners[4][2], float frame)
|
||||
void PlaneTrackCommon::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
r_area = COM_AREA_NONE;
|
||||
if (this->m_movieClip) {
|
||||
if (m_movieClip) {
|
||||
int width, height;
|
||||
MovieClipUser user = {0};
|
||||
BKE_movieclip_user_set_frame(&user, this->m_framenumber);
|
||||
BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height);
|
||||
BKE_movieclip_user_set_frame(&user, m_framenumber);
|
||||
BKE_movieclip_get_size(m_movieClip, &user, &width, &height);
|
||||
r_area = preferred_area;
|
||||
r_area.xmax = r_area.xmin + width;
|
||||
r_area.ymax = r_area.ymin + height;
|
||||
|
||||
@@ -48,19 +48,19 @@ class PlaneTrackCommon {
|
||||
|
||||
void setMovieClip(MovieClip *clip)
|
||||
{
|
||||
this->m_movieClip = clip;
|
||||
m_movieClip = clip;
|
||||
}
|
||||
void setTrackingObject(char *object)
|
||||
{
|
||||
BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName));
|
||||
BLI_strncpy(m_trackingObjectName, object, sizeof(m_trackingObjectName));
|
||||
}
|
||||
void setPlaneTrackName(char *plane_track)
|
||||
{
|
||||
BLI_strncpy(this->m_planeTrackName, plane_track, sizeof(this->m_planeTrackName));
|
||||
BLI_strncpy(m_planeTrackName, plane_track, sizeof(m_planeTrackName));
|
||||
}
|
||||
void setFramenumber(int framenumber)
|
||||
{
|
||||
this->m_framenumber = framenumber;
|
||||
m_framenumber = framenumber;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -25,15 +25,15 @@ PosterizeOperation::PosterizeOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputStepsProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputStepsProgram = nullptr;
|
||||
flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void PosterizeOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
this->m_inputStepsProgram = this->getInputSocketReader(1);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputStepsProgram = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void PosterizeOperation::executePixelSampled(float output[4],
|
||||
@@ -44,8 +44,8 @@ void PosterizeOperation::executePixelSampled(float output[4],
|
||||
float inputValue[4];
|
||||
float inputSteps[4];
|
||||
|
||||
this->m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
this->m_inputStepsProgram->readSampled(inputSteps, x, y, sampler);
|
||||
m_inputProgram->readSampled(inputValue, x, y, sampler);
|
||||
m_inputStepsProgram->readSampled(inputSteps, x, y, sampler);
|
||||
CLAMP(inputSteps[0], 2.0f, 1024.0f);
|
||||
const float steps_inv = 1.0f / inputSteps[0];
|
||||
|
||||
@@ -75,8 +75,8 @@ void PosterizeOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
void PosterizeOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputStepsProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputStepsProgram = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -30,14 +30,14 @@ PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings,
|
||||
|
||||
{
|
||||
this->addInputSocket(DataType::Color, ResizeMode::Align);
|
||||
this->m_preview = nullptr;
|
||||
this->m_outputBuffer = nullptr;
|
||||
this->m_input = nullptr;
|
||||
this->m_divider = 1.0f;
|
||||
this->m_viewSettings = viewSettings;
|
||||
this->m_displaySettings = displaySettings;
|
||||
this->m_defaultWidth = defaultWidth;
|
||||
this->m_defaultHeight = defaultHeight;
|
||||
m_preview = nullptr;
|
||||
m_outputBuffer = nullptr;
|
||||
m_input = nullptr;
|
||||
m_divider = 1.0f;
|
||||
m_viewSettings = viewSettings;
|
||||
m_displaySettings = displaySettings;
|
||||
m_defaultWidth = defaultWidth;
|
||||
m_defaultHeight = defaultHeight;
|
||||
flags.use_viewer_border = true;
|
||||
flags.is_preview_operation = true;
|
||||
}
|
||||
@@ -47,34 +47,34 @@ void PreviewOperation::verifyPreview(bNodeInstanceHash *previews, bNodeInstanceK
|
||||
/* Size (0, 0) ensures the preview rect is not allocated in advance,
|
||||
* this is set later in initExecution once the resolution is determined.
|
||||
*/
|
||||
this->m_preview = BKE_node_preview_verify(previews, key, 0, 0, true);
|
||||
m_preview = BKE_node_preview_verify(previews, key, 0, 0, true);
|
||||
}
|
||||
|
||||
void PreviewOperation::initExecution()
|
||||
{
|
||||
this->m_input = getInputSocketReader(0);
|
||||
m_input = getInputSocketReader(0);
|
||||
|
||||
if (this->getWidth() == (unsigned int)this->m_preview->xsize &&
|
||||
this->getHeight() == (unsigned int)this->m_preview->ysize) {
|
||||
this->m_outputBuffer = this->m_preview->rect;
|
||||
if (this->getWidth() == (unsigned int)m_preview->xsize &&
|
||||
this->getHeight() == (unsigned int)m_preview->ysize) {
|
||||
m_outputBuffer = m_preview->rect;
|
||||
}
|
||||
|
||||
if (this->m_outputBuffer == nullptr) {
|
||||
this->m_outputBuffer = (unsigned char *)MEM_callocN(
|
||||
if (m_outputBuffer == nullptr) {
|
||||
m_outputBuffer = (unsigned char *)MEM_callocN(
|
||||
sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation");
|
||||
if (this->m_preview->rect) {
|
||||
MEM_freeN(this->m_preview->rect);
|
||||
if (m_preview->rect) {
|
||||
MEM_freeN(m_preview->rect);
|
||||
}
|
||||
this->m_preview->xsize = getWidth();
|
||||
this->m_preview->ysize = getHeight();
|
||||
this->m_preview->rect = this->m_outputBuffer;
|
||||
m_preview->xsize = getWidth();
|
||||
m_preview->ysize = getHeight();
|
||||
m_preview->rect = m_outputBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewOperation::deinitExecution()
|
||||
{
|
||||
this->m_outputBuffer = nullptr;
|
||||
this->m_input = nullptr;
|
||||
m_outputBuffer = nullptr;
|
||||
m_input = nullptr;
|
||||
}
|
||||
|
||||
void PreviewOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
@@ -83,22 +83,21 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
float color[4];
|
||||
struct ColormanageProcessor *cm_processor;
|
||||
|
||||
cm_processor = IMB_colormanagement_display_processor_new(this->m_viewSettings,
|
||||
this->m_displaySettings);
|
||||
cm_processor = IMB_colormanagement_display_processor_new(m_viewSettings, m_displaySettings);
|
||||
|
||||
for (int y = rect->ymin; y < rect->ymax; y++) {
|
||||
offset = (y * getWidth() + rect->xmin) * 4;
|
||||
for (int x = rect->xmin; x < rect->xmax; x++) {
|
||||
float rx = floor(x / this->m_divider);
|
||||
float ry = floor(y / this->m_divider);
|
||||
float rx = floor(x / m_divider);
|
||||
float ry = floor(y / m_divider);
|
||||
|
||||
color[0] = 0.0f;
|
||||
color[1] = 0.0f;
|
||||
color[2] = 0.0f;
|
||||
color[3] = 1.0f;
|
||||
this->m_input->readSampled(color, rx, ry, PixelSampler::Nearest);
|
||||
m_input->readSampled(color, rx, ry, PixelSampler::Nearest);
|
||||
IMB_colormanagement_processor_apply_v4(cm_processor, color);
|
||||
rgba_float_to_uchar(this->m_outputBuffer + offset, color);
|
||||
rgba_float_to_uchar(m_outputBuffer + offset, color);
|
||||
offset += 4;
|
||||
}
|
||||
}
|
||||
@@ -111,10 +110,10 @@ bool PreviewOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
newInput.xmin = input->xmin / this->m_divider;
|
||||
newInput.xmax = input->xmax / this->m_divider;
|
||||
newInput.ymin = input->ymin / this->m_divider;
|
||||
newInput.ymax = input->ymax / this->m_divider;
|
||||
newInput.xmin = input->xmin / m_divider;
|
||||
newInput.xmax = input->xmax / m_divider;
|
||||
newInput.ymin = input->ymin / m_divider;
|
||||
newInput.ymax = input->ymax / m_divider;
|
||||
|
||||
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
|
||||
}
|
||||
@@ -122,7 +121,7 @@ void PreviewOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti
|
||||
{
|
||||
/* Use default preview resolution as preferred ensuring it has size so that
|
||||
* generated inputs (which don't have resolution on their own) are displayed */
|
||||
BLI_assert(this->m_defaultWidth > 0 && this->m_defaultHeight > 0);
|
||||
BLI_assert(m_defaultWidth > 0 && m_defaultHeight > 0);
|
||||
rcti local_preferred;
|
||||
BLI_rcti_init(&local_preferred, 0, m_defaultWidth, 0, m_defaultHeight);
|
||||
NodeOperation::determine_canvas(local_preferred, r_area);
|
||||
@@ -138,17 +137,17 @@ void PreviewOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti
|
||||
*/
|
||||
int width = BLI_rcti_size_x(&r_area);
|
||||
int height = BLI_rcti_size_y(&r_area);
|
||||
this->m_divider = 0.0f;
|
||||
m_divider = 0.0f;
|
||||
if (width > 0 && height > 0) {
|
||||
if (width > height) {
|
||||
this->m_divider = (float)COM_PREVIEW_SIZE / (width);
|
||||
m_divider = (float)COM_PREVIEW_SIZE / (width);
|
||||
}
|
||||
else {
|
||||
this->m_divider = (float)COM_PREVIEW_SIZE / (height);
|
||||
m_divider = (float)COM_PREVIEW_SIZE / (height);
|
||||
}
|
||||
}
|
||||
width = width * this->m_divider;
|
||||
height = height * this->m_divider;
|
||||
width = width * m_divider;
|
||||
height = height * m_divider;
|
||||
|
||||
BLI_rcti_init(&r_area, r_area.xmin, r_area.xmin + width, r_area.ymin, r_area.ymin + height);
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ ProjectorLensDistortionOperation::ProjectorLensDistortionOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_dispersionAvailable = false;
|
||||
this->m_dispersion = 0.0f;
|
||||
m_inputProgram = nullptr;
|
||||
m_dispersionAvailable = false;
|
||||
m_dispersion = 0.0f;
|
||||
}
|
||||
|
||||
void ProjectorLensDistortionOperation::init_data()
|
||||
@@ -37,24 +37,23 @@ void ProjectorLensDistortionOperation::init_data()
|
||||
if (execution_model_ == eExecutionModel::FullFrame) {
|
||||
NodeOperation *dispersion_input = get_input_operation(1);
|
||||
if (dispersion_input->get_flags().is_constant_operation) {
|
||||
this->m_dispersion =
|
||||
static_cast<ConstantOperation *>(dispersion_input)->get_constant_elem()[0];
|
||||
m_dispersion = static_cast<ConstantOperation *>(dispersion_input)->get_constant_elem()[0];
|
||||
}
|
||||
this->m_kr = 0.25f * max_ff(min_ff(this->m_dispersion, 1.0f), 0.0f);
|
||||
this->m_kr2 = this->m_kr * 20;
|
||||
m_kr = 0.25f * max_ff(min_ff(m_dispersion, 1.0f), 0.0f);
|
||||
m_kr2 = m_kr * 20;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectorLensDistortionOperation::initExecution()
|
||||
{
|
||||
this->initMutex();
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void *ProjectorLensDistortionOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
updateDispersion();
|
||||
void *buffer = this->m_inputProgram->initializeTileData(nullptr);
|
||||
void *buffer = m_inputProgram->initializeTileData(nullptr);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -66,11 +65,11 @@ void ProjectorLensDistortionOperation::executePixel(float output[4], int x, int
|
||||
const float v = (y + 0.5f) / height;
|
||||
const float u = (x + 0.5f) / width;
|
||||
MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
|
||||
inputBuffer->readBilinear(inputValue, (u * width + this->m_kr2) - 0.5f, v * height - 0.5f);
|
||||
inputBuffer->readBilinear(inputValue, (u * width + m_kr2) - 0.5f, v * height - 0.5f);
|
||||
output[0] = inputValue[0];
|
||||
inputBuffer->read(inputValue, x, y);
|
||||
output[1] = inputValue[1];
|
||||
inputBuffer->readBilinear(inputValue, (u * width - this->m_kr2) - 0.5f, v * height - 0.5f);
|
||||
inputBuffer->readBilinear(inputValue, (u * width - m_kr2) - 0.5f, v * height - 0.5f);
|
||||
output[2] = inputValue[2];
|
||||
output[3] = 1.0f;
|
||||
}
|
||||
@@ -78,18 +77,18 @@ void ProjectorLensDistortionOperation::executePixel(float output[4], int x, int
|
||||
void ProjectorLensDistortionOperation::deinitExecution()
|
||||
{
|
||||
this->deinitMutex();
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(
|
||||
rcti *input, ReadBufferOperation *readOperation, rcti *output)
|
||||
{
|
||||
rcti newInput;
|
||||
if (this->m_dispersionAvailable) {
|
||||
if (m_dispersionAvailable) {
|
||||
newInput.ymax = input->ymax;
|
||||
newInput.ymin = input->ymin;
|
||||
newInput.xmin = input->xmin - this->m_kr2 - 2;
|
||||
newInput.xmax = input->xmax + this->m_kr2 + 2;
|
||||
newInput.xmin = input->xmin - m_kr2 - 2;
|
||||
newInput.xmax = input->xmax + m_kr2 + 2;
|
||||
}
|
||||
else {
|
||||
rcti dispInput;
|
||||
@@ -113,17 +112,17 @@ bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(
|
||||
/* TODO(manzanilla): to be removed with tiled implementation. */
|
||||
void ProjectorLensDistortionOperation::updateDispersion()
|
||||
{
|
||||
if (this->m_dispersionAvailable) {
|
||||
if (m_dispersionAvailable) {
|
||||
return;
|
||||
}
|
||||
this->lockMutex();
|
||||
if (!this->m_dispersionAvailable) {
|
||||
if (!m_dispersionAvailable) {
|
||||
float result[4];
|
||||
this->getInputSocketReader(1)->readSampled(result, 1, 1, PixelSampler::Nearest);
|
||||
this->m_dispersion = result[0];
|
||||
this->m_kr = 0.25f * max_ff(min_ff(this->m_dispersion, 1.0f), 0.0f);
|
||||
this->m_kr2 = this->m_kr * 20;
|
||||
this->m_dispersionAvailable = true;
|
||||
m_dispersion = result[0];
|
||||
m_kr = 0.25f * max_ff(min_ff(m_dispersion, 1.0f), 0.0f);
|
||||
m_kr2 = m_kr * 20;
|
||||
m_dispersionAvailable = true;
|
||||
}
|
||||
this->unlockMutex();
|
||||
}
|
||||
@@ -157,8 +156,8 @@ void ProjectorLensDistortionOperation::get_area_of_interest(const int input_idx,
|
||||
|
||||
r_input_area.ymax = output_area.ymax;
|
||||
r_input_area.ymin = output_area.ymin;
|
||||
r_input_area.xmin = output_area.xmin - this->m_kr2 - 2;
|
||||
r_input_area.xmax = output_area.xmax + this->m_kr2 + 2;
|
||||
r_input_area.xmin = output_area.xmin - m_kr2 - 2;
|
||||
r_input_area.xmax = output_area.xmax + m_kr2 + 2;
|
||||
}
|
||||
|
||||
void ProjectorLensDistortionOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
@@ -172,11 +171,11 @@ void ProjectorLensDistortionOperation::update_memory_buffer_partial(MemoryBuffer
|
||||
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
|
||||
const float v = (it.y + 0.5f) / height;
|
||||
const float u = (it.x + 0.5f) / width;
|
||||
input_image->read_elem_bilinear((u * width + this->m_kr2) - 0.5f, v * height - 0.5f, color);
|
||||
input_image->read_elem_bilinear((u * width + m_kr2) - 0.5f, v * height - 0.5f, color);
|
||||
it.out[0] = color[0];
|
||||
input_image->read_elem(it.x, it.y, color);
|
||||
it.out[1] = color[1];
|
||||
input_image->read_elem_bilinear((u * width - this->m_kr2) - 0.5f, v * height - 0.5f, color);
|
||||
input_image->read_elem_bilinear((u * width - m_kr2) - 0.5f, v * height - 0.5f, color);
|
||||
it.out[2] = color[2];
|
||||
it.out[3] = 1.0f;
|
||||
}
|
||||
|
||||
@@ -22,45 +22,45 @@ namespace blender::compositor {
|
||||
|
||||
QualityStepHelper::QualityStepHelper()
|
||||
{
|
||||
this->m_quality = eCompositorQuality::High;
|
||||
this->m_step = 1;
|
||||
this->m_offsetadd = 4;
|
||||
m_quality = eCompositorQuality::High;
|
||||
m_step = 1;
|
||||
m_offsetadd = 4;
|
||||
}
|
||||
|
||||
void QualityStepHelper::initExecution(QualityHelper helper)
|
||||
{
|
||||
switch (helper) {
|
||||
case COM_QH_INCREASE:
|
||||
switch (this->m_quality) {
|
||||
switch (m_quality) {
|
||||
case eCompositorQuality::High:
|
||||
default:
|
||||
this->m_step = 1;
|
||||
this->m_offsetadd = 1;
|
||||
m_step = 1;
|
||||
m_offsetadd = 1;
|
||||
break;
|
||||
case eCompositorQuality::Medium:
|
||||
this->m_step = 2;
|
||||
this->m_offsetadd = 2;
|
||||
m_step = 2;
|
||||
m_offsetadd = 2;
|
||||
break;
|
||||
case eCompositorQuality::Low:
|
||||
this->m_step = 3;
|
||||
this->m_offsetadd = 3;
|
||||
m_step = 3;
|
||||
m_offsetadd = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case COM_QH_MULTIPLY:
|
||||
switch (this->m_quality) {
|
||||
switch (m_quality) {
|
||||
case eCompositorQuality::High:
|
||||
default:
|
||||
this->m_step = 1;
|
||||
this->m_offsetadd = 4;
|
||||
m_step = 1;
|
||||
m_offsetadd = 4;
|
||||
break;
|
||||
case eCompositorQuality::Medium:
|
||||
this->m_step = 2;
|
||||
this->m_offsetadd = 8;
|
||||
m_step = 2;
|
||||
m_offsetadd = 8;
|
||||
break;
|
||||
case eCompositorQuality::Low:
|
||||
this->m_step = 4;
|
||||
this->m_offsetadd = 16;
|
||||
m_step = 4;
|
||||
m_offsetadd = 16;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -41,11 +41,11 @@ class QualityStepHelper {
|
||||
|
||||
inline int getStep() const
|
||||
{
|
||||
return this->m_step;
|
||||
return m_step;
|
||||
}
|
||||
inline int getOffsetAdd() const
|
||||
{
|
||||
return this->m_offsetadd;
|
||||
return m_offsetadd;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -53,7 +53,7 @@ class QualityStepHelper {
|
||||
|
||||
void setQuality(eCompositorQuality quality)
|
||||
{
|
||||
this->m_quality = quality;
|
||||
m_quality = quality;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace blender::compositor {
|
||||
ReadBufferOperation::ReadBufferOperation(DataType datatype)
|
||||
{
|
||||
this->addOutputSocket(datatype);
|
||||
this->m_single_value = false;
|
||||
this->m_offset = 0;
|
||||
this->m_buffer = nullptr;
|
||||
m_single_value = false;
|
||||
m_offset = 0;
|
||||
m_buffer = nullptr;
|
||||
flags.is_read_buffer_operation = true;
|
||||
}
|
||||
|
||||
@@ -39,16 +39,16 @@ void *ReadBufferOperation::initializeTileData(rcti * /*rect*/)
|
||||
|
||||
void ReadBufferOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
if (this->m_memoryProxy != nullptr) {
|
||||
WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation();
|
||||
if (m_memoryProxy != nullptr) {
|
||||
WriteBufferOperation *operation = m_memoryProxy->getWriteBufferOperation();
|
||||
operation->determine_canvas(preferred_area, r_area);
|
||||
operation->set_canvas(r_area);
|
||||
|
||||
/** \todo may not occur! But does with blur node. */
|
||||
if (this->m_memoryProxy->getExecutor()) {
|
||||
if (m_memoryProxy->getExecutor()) {
|
||||
uint resolution[2] = {static_cast<uint>(BLI_rcti_size_x(&r_area)),
|
||||
static_cast<uint>(BLI_rcti_size_y(&r_area))};
|
||||
this->m_memoryProxy->getExecutor()->setResolution(resolution);
|
||||
m_memoryProxy->getExecutor()->setResolution(resolution);
|
||||
}
|
||||
|
||||
m_single_value = operation->isSingleValue();
|
||||
@@ -125,8 +125,8 @@ bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
|
||||
void ReadBufferOperation::readResolutionFromWriteBuffer()
|
||||
{
|
||||
if (this->m_memoryProxy != nullptr) {
|
||||
WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation();
|
||||
if (m_memoryProxy != nullptr) {
|
||||
WriteBufferOperation *operation = m_memoryProxy->getWriteBufferOperation();
|
||||
this->setWidth(operation->getWidth());
|
||||
this->setHeight(operation->getHeight());
|
||||
}
|
||||
@@ -134,7 +134,7 @@ void ReadBufferOperation::readResolutionFromWriteBuffer()
|
||||
|
||||
void ReadBufferOperation::updateMemoryBuffer()
|
||||
{
|
||||
this->m_buffer = this->getMemoryProxy()->getBuffer();
|
||||
m_buffer = this->getMemoryProxy()->getBuffer();
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -35,12 +35,12 @@ class ReadBufferOperation : public NodeOperation {
|
||||
ReadBufferOperation(DataType datatype);
|
||||
void setMemoryProxy(MemoryProxy *memoryProxy)
|
||||
{
|
||||
this->m_memoryProxy = memoryProxy;
|
||||
m_memoryProxy = memoryProxy;
|
||||
}
|
||||
|
||||
MemoryProxy *getMemoryProxy() const
|
||||
{
|
||||
return this->m_memoryProxy;
|
||||
return m_memoryProxy;
|
||||
}
|
||||
|
||||
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
|
||||
@@ -56,18 +56,18 @@ class ReadBufferOperation : public NodeOperation {
|
||||
void executePixelFiltered(float output[4], float x, float y, float dx[2], float dy[2]) override;
|
||||
void setOffset(unsigned int offset)
|
||||
{
|
||||
this->m_offset = offset;
|
||||
m_offset = offset;
|
||||
}
|
||||
unsigned int getOffset() const
|
||||
{
|
||||
return this->m_offset;
|
||||
return m_offset;
|
||||
}
|
||||
bool determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
rcti *output) override;
|
||||
MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) override
|
||||
{
|
||||
return memoryBuffers[this->m_offset];
|
||||
return memoryBuffers[m_offset];
|
||||
}
|
||||
void readResolutionFromWriteBuffer();
|
||||
void updateMemoryBuffer();
|
||||
|
||||
@@ -28,9 +28,9 @@ RenderLayersProg::RenderLayersProg(const char *passName, DataType type, int elem
|
||||
: m_passName(passName)
|
||||
{
|
||||
this->setScene(nullptr);
|
||||
this->m_inputBuffer = nullptr;
|
||||
this->m_elementsize = elementsize;
|
||||
this->m_rd = nullptr;
|
||||
m_inputBuffer = nullptr;
|
||||
m_elementsize = elementsize;
|
||||
m_rd = nullptr;
|
||||
layer_buffer_ = nullptr;
|
||||
|
||||
this->addOutputSocket(type);
|
||||
@@ -52,8 +52,7 @@ void RenderLayersProg::initExecution()
|
||||
|
||||
RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
|
||||
if (rl) {
|
||||
this->m_inputBuffer = RE_RenderLayerGetPass(
|
||||
rl, this->m_passName.c_str(), this->m_viewName);
|
||||
m_inputBuffer = RE_RenderLayerGetPass(rl, m_passName.c_str(), m_viewName);
|
||||
if (m_inputBuffer) {
|
||||
layer_buffer_ = new MemoryBuffer(m_inputBuffer, m_elementsize, getWidth(), getHeight());
|
||||
}
|
||||
@@ -73,10 +72,10 @@ void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelS
|
||||
|
||||
int ix = x, iy = y;
|
||||
if (ix < 0 || iy < 0 || ix >= width || iy >= height) {
|
||||
if (this->m_elementsize == 1) {
|
||||
if (m_elementsize == 1) {
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
else if (this->m_elementsize == 3) {
|
||||
else if (m_elementsize == 3) {
|
||||
zero_v3(output);
|
||||
}
|
||||
else {
|
||||
@@ -87,28 +86,26 @@ void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelS
|
||||
|
||||
switch (sampler) {
|
||||
case PixelSampler::Nearest: {
|
||||
offset = (iy * width + ix) * this->m_elementsize;
|
||||
offset = (iy * width + ix) * m_elementsize;
|
||||
|
||||
if (this->m_elementsize == 1) {
|
||||
output[0] = this->m_inputBuffer[offset];
|
||||
if (m_elementsize == 1) {
|
||||
output[0] = m_inputBuffer[offset];
|
||||
}
|
||||
else if (this->m_elementsize == 3) {
|
||||
copy_v3_v3(output, &this->m_inputBuffer[offset]);
|
||||
else if (m_elementsize == 3) {
|
||||
copy_v3_v3(output, &m_inputBuffer[offset]);
|
||||
}
|
||||
else {
|
||||
copy_v4_v4(output, &this->m_inputBuffer[offset]);
|
||||
copy_v4_v4(output, &m_inputBuffer[offset]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PixelSampler::Bilinear:
|
||||
BLI_bilinear_interpolation_fl(
|
||||
this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
|
||||
BLI_bilinear_interpolation_fl(m_inputBuffer, output, width, height, m_elementsize, x, y);
|
||||
break;
|
||||
|
||||
case PixelSampler::Bicubic:
|
||||
BLI_bicubic_interpolation_fl(
|
||||
this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
|
||||
BLI_bicubic_interpolation_fl(m_inputBuffer, output, width, height, m_elementsize, x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -116,7 +113,7 @@ void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelS
|
||||
void RenderLayersProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
{
|
||||
#if 0
|
||||
const RenderData *rd = this->m_rd;
|
||||
const RenderData *rd = m_rd;
|
||||
|
||||
int dx = 0, dy = 0;
|
||||
|
||||
@@ -138,7 +135,7 @@ void RenderLayersProg::executePixelSampled(float output[4], float x, float y, Pi
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
const DataType data_type = this->getOutputSocket()->getDataType();
|
||||
int actual_element_size = this->m_elementsize;
|
||||
int actual_element_size = m_elementsize;
|
||||
int expected_element_size;
|
||||
if (data_type == DataType::Value) {
|
||||
expected_element_size = 1;
|
||||
@@ -157,8 +154,8 @@ void RenderLayersProg::executePixelSampled(float output[4], float x, float y, Pi
|
||||
}
|
||||
#endif
|
||||
|
||||
if (this->m_inputBuffer == nullptr) {
|
||||
int elemsize = this->m_elementsize;
|
||||
if (m_inputBuffer == nullptr) {
|
||||
int elemsize = m_elementsize;
|
||||
if (elemsize == 1) {
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
@@ -177,7 +174,7 @@ void RenderLayersProg::executePixelSampled(float output[4], float x, float y, Pi
|
||||
|
||||
void RenderLayersProg::deinitExecution()
|
||||
{
|
||||
this->m_inputBuffer = nullptr;
|
||||
m_inputBuffer = nullptr;
|
||||
if (layer_buffer_) {
|
||||
delete layer_buffer_;
|
||||
layer_buffer_ = nullptr;
|
||||
|
||||
@@ -80,7 +80,7 @@ class RenderLayersProg : public MultiThreadedOperation {
|
||||
*/
|
||||
inline float *getInputBuffer()
|
||||
{
|
||||
return this->m_inputBuffer;
|
||||
return m_inputBuffer;
|
||||
}
|
||||
|
||||
void doInterpolation(float output[4], float x, float y, PixelSampler sampler);
|
||||
@@ -97,31 +97,31 @@ class RenderLayersProg : public MultiThreadedOperation {
|
||||
*/
|
||||
void setScene(Scene *scene)
|
||||
{
|
||||
this->m_scene = scene;
|
||||
m_scene = scene;
|
||||
}
|
||||
Scene *getScene() const
|
||||
{
|
||||
return this->m_scene;
|
||||
return m_scene;
|
||||
}
|
||||
void setRenderData(const RenderData *rd)
|
||||
{
|
||||
this->m_rd = rd;
|
||||
m_rd = rd;
|
||||
}
|
||||
void setLayerId(short layerId)
|
||||
{
|
||||
this->m_layerId = layerId;
|
||||
m_layerId = layerId;
|
||||
}
|
||||
short getLayerId() const
|
||||
{
|
||||
return this->m_layerId;
|
||||
return m_layerId;
|
||||
}
|
||||
void setViewName(const char *viewName)
|
||||
{
|
||||
this->m_viewName = viewName;
|
||||
m_viewName = viewName;
|
||||
}
|
||||
const char *getViewName()
|
||||
{
|
||||
return this->m_viewName;
|
||||
return m_viewName;
|
||||
}
|
||||
void initExecution() override;
|
||||
void deinitExecution() override;
|
||||
|
||||
@@ -26,10 +26,10 @@ RotateOperation::RotateOperation()
|
||||
this->addInputSocket(DataType::Value, ResizeMode::None);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->set_canvas_input_index(0);
|
||||
this->m_imageSocket = nullptr;
|
||||
this->m_degreeSocket = nullptr;
|
||||
this->m_doDegree2RadConversion = false;
|
||||
this->m_isDegreeSet = false;
|
||||
m_imageSocket = nullptr;
|
||||
m_degreeSocket = nullptr;
|
||||
m_doDegree2RadConversion = false;
|
||||
m_isDegreeSet = false;
|
||||
sampler_ = PixelSampler::Bilinear;
|
||||
}
|
||||
|
||||
@@ -133,23 +133,23 @@ void RotateOperation::init_data()
|
||||
|
||||
void RotateOperation::initExecution()
|
||||
{
|
||||
this->m_imageSocket = this->getInputSocketReader(0);
|
||||
this->m_degreeSocket = this->getInputSocketReader(1);
|
||||
m_imageSocket = this->getInputSocketReader(0);
|
||||
m_degreeSocket = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void RotateOperation::deinitExecution()
|
||||
{
|
||||
this->m_imageSocket = nullptr;
|
||||
this->m_degreeSocket = nullptr;
|
||||
m_imageSocket = nullptr;
|
||||
m_degreeSocket = nullptr;
|
||||
}
|
||||
|
||||
inline void RotateOperation::ensureDegree()
|
||||
{
|
||||
if (!this->m_isDegreeSet) {
|
||||
if (!m_isDegreeSet) {
|
||||
float degree[4];
|
||||
switch (execution_model_) {
|
||||
case eExecutionModel::Tiled:
|
||||
this->m_degreeSocket->readSampled(degree, 0, 0, PixelSampler::Nearest);
|
||||
m_degreeSocket->readSampled(degree, 0, 0, PixelSampler::Nearest);
|
||||
break;
|
||||
case eExecutionModel::FullFrame:
|
||||
degree[0] = get_input_operation(DEGREE_INPUT_INDEX)->get_constant_value_default(0.0f);
|
||||
@@ -157,27 +157,27 @@ inline void RotateOperation::ensureDegree()
|
||||
}
|
||||
|
||||
double rad;
|
||||
if (this->m_doDegree2RadConversion) {
|
||||
if (m_doDegree2RadConversion) {
|
||||
rad = DEG2RAD((double)degree[0]);
|
||||
}
|
||||
else {
|
||||
rad = degree[0];
|
||||
}
|
||||
this->m_cosine = cos(rad);
|
||||
this->m_sine = sin(rad);
|
||||
m_cosine = cos(rad);
|
||||
m_sine = sin(rad);
|
||||
|
||||
this->m_isDegreeSet = true;
|
||||
m_isDegreeSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
void RotateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
{
|
||||
ensureDegree();
|
||||
const float dy = y - this->m_centerY;
|
||||
const float dx = x - this->m_centerX;
|
||||
const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy);
|
||||
const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy);
|
||||
this->m_imageSocket->readSampled(output, nx, ny, sampler);
|
||||
const float dy = y - m_centerY;
|
||||
const float dx = x - m_centerX;
|
||||
const float nx = m_centerX + (m_cosine * dx + m_sine * dy);
|
||||
const float ny = m_centerY + (-m_sine * dx + m_cosine * dy);
|
||||
m_imageSocket->readSampled(output, nx, ny, sampler);
|
||||
}
|
||||
|
||||
bool RotateOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -187,19 +187,19 @@ bool RotateOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
ensureDegree();
|
||||
rcti newInput;
|
||||
|
||||
const float dxmin = input->xmin - this->m_centerX;
|
||||
const float dymin = input->ymin - this->m_centerY;
|
||||
const float dxmax = input->xmax - this->m_centerX;
|
||||
const float dymax = input->ymax - this->m_centerY;
|
||||
const float dxmin = input->xmin - m_centerX;
|
||||
const float dymin = input->ymin - m_centerY;
|
||||
const float dxmax = input->xmax - m_centerX;
|
||||
const float dymax = input->ymax - m_centerY;
|
||||
|
||||
const float x1 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymin);
|
||||
const float x2 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymin);
|
||||
const float x3 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymax);
|
||||
const float x4 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymax);
|
||||
const float y1 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymin);
|
||||
const float y2 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymin);
|
||||
const float y3 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymax);
|
||||
const float y4 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymax);
|
||||
const float x1 = m_centerX + (m_cosine * dxmin + m_sine * dymin);
|
||||
const float x2 = m_centerX + (m_cosine * dxmax + m_sine * dymin);
|
||||
const float x3 = m_centerX + (m_cosine * dxmin + m_sine * dymax);
|
||||
const float x4 = m_centerX + (m_cosine * dxmax + m_sine * dymax);
|
||||
const float y1 = m_centerY + (-m_sine * dxmin + m_cosine * dymin);
|
||||
const float y2 = m_centerY + (-m_sine * dxmax + m_cosine * dymin);
|
||||
const float y3 = m_centerY + (-m_sine * dxmin + m_cosine * dymax);
|
||||
const float y4 = m_centerY + (-m_sine * dxmax + m_cosine * dymax);
|
||||
const float minx = MIN2(x1, MIN2(x2, MIN2(x3, x4)));
|
||||
const float maxx = MAX2(x1, MAX2(x2, MAX2(x3, x4)));
|
||||
const float miny = MIN2(y1, MIN2(y2, MIN2(y3, y4)));
|
||||
|
||||
@@ -89,7 +89,7 @@ class RotateOperation : public MultiThreadedOperation {
|
||||
|
||||
void setDoDegree2RadConversion(bool abool)
|
||||
{
|
||||
this->m_doDegree2RadConversion = abool;
|
||||
m_doDegree2RadConversion = abool;
|
||||
}
|
||||
|
||||
void set_sampler(PixelSampler sampler)
|
||||
|
||||
@@ -171,22 +171,22 @@ SMAAEdgeDetectionOperation::SMAAEdgeDetectionOperation()
|
||||
this->addInputSocket(DataType::Value); /* Depth, material ID, etc. TODO: currently unused. */
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
this->m_imageReader = nullptr;
|
||||
this->m_valueReader = nullptr;
|
||||
m_imageReader = nullptr;
|
||||
m_valueReader = nullptr;
|
||||
this->setThreshold(CMP_DEFAULT_SMAA_THRESHOLD);
|
||||
this->setLocalContrastAdaptationFactor(CMP_DEFAULT_SMAA_CONTRAST_LIMIT);
|
||||
}
|
||||
|
||||
void SMAAEdgeDetectionOperation::initExecution()
|
||||
{
|
||||
this->m_imageReader = this->getInputSocketReader(0);
|
||||
this->m_valueReader = this->getInputSocketReader(1);
|
||||
m_imageReader = this->getInputSocketReader(0);
|
||||
m_valueReader = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void SMAAEdgeDetectionOperation::deinitExecution()
|
||||
{
|
||||
this->m_imageReader = nullptr;
|
||||
this->m_valueReader = nullptr;
|
||||
m_imageReader = nullptr;
|
||||
m_valueReader = nullptr;
|
||||
}
|
||||
|
||||
void SMAAEdgeDetectionOperation::setThreshold(float threshold)
|
||||
@@ -401,7 +401,7 @@ SMAABlendingWeightCalculationOperation::SMAABlendingWeightCalculationOperation()
|
||||
this->addInputSocket(DataType::Color); /* edges */
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
this->m_imageReader = nullptr;
|
||||
m_imageReader = nullptr;
|
||||
this->setCornerRounding(CMP_DEFAULT_SMAA_CORNER_ROUNDING);
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ void *SMAABlendingWeightCalculationOperation::initializeTileData(rcti *rect)
|
||||
|
||||
void SMAABlendingWeightCalculationOperation::initExecution()
|
||||
{
|
||||
this->m_imageReader = this->getInputSocketReader(0);
|
||||
m_imageReader = this->getInputSocketReader(0);
|
||||
if (execution_model_ == eExecutionModel::Tiled) {
|
||||
sample_image_fn_ = [=](int x, int y, float *out) { sample(m_imageReader, x, y, out); };
|
||||
}
|
||||
@@ -630,7 +630,7 @@ void SMAABlendingWeightCalculationOperation::update_memory_buffer_partial(
|
||||
|
||||
void SMAABlendingWeightCalculationOperation::deinitExecution()
|
||||
{
|
||||
this->m_imageReader = nullptr;
|
||||
m_imageReader = nullptr;
|
||||
}
|
||||
|
||||
bool SMAABlendingWeightCalculationOperation::determineDependingAreaOfInterest(
|
||||
@@ -1011,8 +1011,8 @@ SMAANeighborhoodBlendingOperation::SMAANeighborhoodBlendingOperation()
|
||||
this->addInputSocket(DataType::Color); /* blend */
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
this->m_image1Reader = nullptr;
|
||||
this->m_image2Reader = nullptr;
|
||||
m_image1Reader = nullptr;
|
||||
m_image2Reader = nullptr;
|
||||
}
|
||||
|
||||
void *SMAANeighborhoodBlendingOperation::initializeTileData(rcti *rect)
|
||||
@@ -1022,8 +1022,8 @@ void *SMAANeighborhoodBlendingOperation::initializeTileData(rcti *rect)
|
||||
|
||||
void SMAANeighborhoodBlendingOperation::initExecution()
|
||||
{
|
||||
this->m_image1Reader = this->getInputSocketReader(0);
|
||||
this->m_image2Reader = this->getInputSocketReader(1);
|
||||
m_image1Reader = this->getInputSocketReader(0);
|
||||
m_image2Reader = this->getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void SMAANeighborhoodBlendingOperation::executePixel(float output[4],
|
||||
@@ -1129,8 +1129,8 @@ void SMAANeighborhoodBlendingOperation::update_memory_buffer_partial(MemoryBuffe
|
||||
|
||||
void SMAANeighborhoodBlendingOperation::deinitExecution()
|
||||
{
|
||||
this->m_image1Reader = nullptr;
|
||||
this->m_image2Reader = nullptr;
|
||||
m_image1Reader = nullptr;
|
||||
m_image2Reader = nullptr;
|
||||
}
|
||||
|
||||
bool SMAANeighborhoodBlendingOperation::determineDependingAreaOfInterest(
|
||||
|
||||
@@ -53,9 +53,9 @@ ScaleOperation::ScaleOperation(DataType data_type) : BaseScaleOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(data_type);
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_inputXOperation = nullptr;
|
||||
this->m_inputYOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
m_inputXOperation = nullptr;
|
||||
m_inputYOperation = nullptr;
|
||||
}
|
||||
|
||||
float ScaleOperation::get_constant_scale(const int input_op_idx, const float factor)
|
||||
@@ -118,16 +118,16 @@ void ScaleOperation::init_data()
|
||||
|
||||
void ScaleOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
this->m_inputXOperation = this->getInputSocketReader(1);
|
||||
this->m_inputYOperation = this->getInputSocketReader(2);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputXOperation = this->getInputSocketReader(1);
|
||||
m_inputYOperation = this->getInputSocketReader(2);
|
||||
}
|
||||
|
||||
void ScaleOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_inputXOperation = nullptr;
|
||||
this->m_inputYOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
m_inputXOperation = nullptr;
|
||||
m_inputYOperation = nullptr;
|
||||
}
|
||||
|
||||
void ScaleOperation::get_scale_offset(const rcti &input_canvas,
|
||||
@@ -268,15 +268,15 @@ void ScaleRelativeOperation::executePixelSampled(float output[4],
|
||||
float scaleX[4];
|
||||
float scaleY[4];
|
||||
|
||||
this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
|
||||
this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
|
||||
m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
|
||||
m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
|
||||
|
||||
const float scx = scaleX[0];
|
||||
const float scy = scaleY[0];
|
||||
|
||||
float nx = this->canvas_center_x_ + (x - this->canvas_center_x_) / scx;
|
||||
float ny = this->canvas_center_y_ + (y - this->canvas_center_y_) / scy;
|
||||
this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
|
||||
m_inputOperation->readSampled(output, nx, ny, effective_sampler);
|
||||
}
|
||||
|
||||
bool ScaleRelativeOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -288,8 +288,8 @@ bool ScaleRelativeOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
float scaleX[4];
|
||||
float scaleY[4];
|
||||
|
||||
this->m_inputXOperation->readSampled(scaleX, 0, 0, PixelSampler::Nearest);
|
||||
this->m_inputYOperation->readSampled(scaleY, 0, 0, PixelSampler::Nearest);
|
||||
m_inputXOperation->readSampled(scaleX, 0, 0, PixelSampler::Nearest);
|
||||
m_inputYOperation->readSampled(scaleY, 0, 0, PixelSampler::Nearest);
|
||||
|
||||
const float scx = scaleX[0];
|
||||
const float scy = scaleY[0];
|
||||
@@ -318,8 +318,8 @@ void ScaleAbsoluteOperation::executePixelSampled(float output[4],
|
||||
float scaleX[4];
|
||||
float scaleY[4];
|
||||
|
||||
this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
|
||||
this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
|
||||
m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
|
||||
m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
|
||||
|
||||
const float scx = scaleX[0]; /* Target absolute scale. */
|
||||
const float scy = scaleY[0]; /* Target absolute scale. */
|
||||
@@ -333,7 +333,7 @@ void ScaleAbsoluteOperation::executePixelSampled(float output[4],
|
||||
float nx = this->canvas_center_x_ + (x - this->canvas_center_x_) / relativeXScale;
|
||||
float ny = this->canvas_center_y_ + (y - this->canvas_center_y_) / relativeYScale;
|
||||
|
||||
this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
|
||||
m_inputOperation->readSampled(output, nx, ny, effective_sampler);
|
||||
}
|
||||
|
||||
bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
@@ -345,8 +345,8 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
float scaleX[4];
|
||||
float scaleY[4];
|
||||
|
||||
this->m_inputXOperation->readSampled(scaleX, 0, 0, PixelSampler::Nearest);
|
||||
this->m_inputYOperation->readSampled(scaleY, 0, 0, PixelSampler::Nearest);
|
||||
m_inputXOperation->readSampled(scaleX, 0, 0, PixelSampler::Nearest);
|
||||
m_inputYOperation->readSampled(scaleY, 0, 0, PixelSampler::Nearest);
|
||||
|
||||
const float scx = scaleX[0];
|
||||
const float scy = scaleY[0];
|
||||
@@ -380,49 +380,49 @@ ScaleFixedSizeOperation::ScaleFixedSizeOperation() : BaseScaleOperation()
|
||||
this->addInputSocket(DataType::Color, ResizeMode::None);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->set_canvas_input_index(0);
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_is_offset = false;
|
||||
m_inputOperation = nullptr;
|
||||
m_is_offset = false;
|
||||
}
|
||||
|
||||
void ScaleFixedSizeOperation::init_data(const rcti &input_canvas)
|
||||
{
|
||||
const int input_width = BLI_rcti_size_x(&input_canvas);
|
||||
const int input_height = BLI_rcti_size_y(&input_canvas);
|
||||
this->m_relX = input_width / (float)this->m_newWidth;
|
||||
this->m_relY = input_height / (float)this->m_newHeight;
|
||||
m_relX = input_width / (float)m_newWidth;
|
||||
m_relY = input_height / (float)m_newHeight;
|
||||
|
||||
/* *** all the options below are for a fairly special case - camera framing *** */
|
||||
if (this->m_offsetX != 0.0f || this->m_offsetY != 0.0f) {
|
||||
this->m_is_offset = true;
|
||||
if (m_offsetX != 0.0f || m_offsetY != 0.0f) {
|
||||
m_is_offset = true;
|
||||
|
||||
if (this->m_newWidth > this->m_newHeight) {
|
||||
this->m_offsetX *= this->m_newWidth;
|
||||
this->m_offsetY *= this->m_newWidth;
|
||||
if (m_newWidth > m_newHeight) {
|
||||
m_offsetX *= m_newWidth;
|
||||
m_offsetY *= m_newWidth;
|
||||
}
|
||||
else {
|
||||
this->m_offsetX *= this->m_newHeight;
|
||||
this->m_offsetY *= this->m_newHeight;
|
||||
m_offsetX *= m_newHeight;
|
||||
m_offsetY *= m_newHeight;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->m_is_aspect) {
|
||||
if (m_is_aspect) {
|
||||
/* apply aspect from clip */
|
||||
const float w_src = input_width;
|
||||
const float h_src = input_height;
|
||||
|
||||
/* destination aspect is already applied from the camera frame */
|
||||
const float w_dst = this->m_newWidth;
|
||||
const float h_dst = this->m_newHeight;
|
||||
const float w_dst = m_newWidth;
|
||||
const float h_dst = m_newHeight;
|
||||
|
||||
const float asp_src = w_src / h_src;
|
||||
const float asp_dst = w_dst / h_dst;
|
||||
|
||||
if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
|
||||
if ((asp_src > asp_dst) == (this->m_is_crop == true)) {
|
||||
if ((asp_src > asp_dst) == (m_is_crop == true)) {
|
||||
/* fit X */
|
||||
const float div = asp_src / asp_dst;
|
||||
this->m_relX /= div;
|
||||
this->m_offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
|
||||
m_relX /= div;
|
||||
m_offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
|
||||
if (m_is_crop && execution_model_ == eExecutionModel::FullFrame) {
|
||||
int fit_width = m_newWidth * div;
|
||||
if (fit_width > max_scale_canvas_size_.x) {
|
||||
@@ -437,8 +437,8 @@ void ScaleFixedSizeOperation::init_data(const rcti &input_canvas)
|
||||
else {
|
||||
/* fit Y */
|
||||
const float div = asp_dst / asp_src;
|
||||
this->m_relY /= div;
|
||||
this->m_offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
|
||||
m_relY /= div;
|
||||
m_offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
|
||||
if (m_is_crop && execution_model_ == eExecutionModel::FullFrame) {
|
||||
int fit_height = m_newHeight * div;
|
||||
if (fit_height > max_scale_canvas_size_.y) {
|
||||
@@ -451,7 +451,7 @@ void ScaleFixedSizeOperation::init_data(const rcti &input_canvas)
|
||||
}
|
||||
}
|
||||
|
||||
this->m_is_offset = true;
|
||||
m_is_offset = true;
|
||||
}
|
||||
}
|
||||
/* *** end framing options *** */
|
||||
@@ -459,12 +459,12 @@ void ScaleFixedSizeOperation::init_data(const rcti &input_canvas)
|
||||
|
||||
void ScaleFixedSizeOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void ScaleFixedSizeOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
}
|
||||
|
||||
void ScaleFixedSizeOperation::executePixelSampled(float output[4],
|
||||
@@ -474,14 +474,13 @@ void ScaleFixedSizeOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
PixelSampler effective_sampler = getEffectiveSampler(sampler);
|
||||
|
||||
if (this->m_is_offset) {
|
||||
float nx = ((x - this->m_offsetX) * this->m_relX);
|
||||
float ny = ((y - this->m_offsetY) * this->m_relY);
|
||||
this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
|
||||
if (m_is_offset) {
|
||||
float nx = ((x - m_offsetX) * m_relX);
|
||||
float ny = ((y - m_offsetY) * m_relY);
|
||||
m_inputOperation->readSampled(output, nx, ny, effective_sampler);
|
||||
}
|
||||
else {
|
||||
this->m_inputOperation->readSampled(
|
||||
output, x * this->m_relX, y * this->m_relY, effective_sampler);
|
||||
m_inputOperation->readSampled(output, x * m_relX, y * m_relY, effective_sampler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,10 +490,10 @@ bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
{
|
||||
rcti newInput;
|
||||
|
||||
newInput.xmax = (input->xmax - m_offsetX) * this->m_relX + 1;
|
||||
newInput.xmin = (input->xmin - m_offsetX) * this->m_relX;
|
||||
newInput.ymax = (input->ymax - m_offsetY) * this->m_relY + 1;
|
||||
newInput.ymin = (input->ymin - m_offsetY) * this->m_relY;
|
||||
newInput.xmax = (input->xmax - m_offsetX) * m_relX + 1;
|
||||
newInput.xmin = (input->xmin - m_offsetX) * m_relX;
|
||||
newInput.ymax = (input->ymax - m_offsetY) * m_relY + 1;
|
||||
newInput.ymin = (input->ymin - m_offsetY) * m_relY;
|
||||
|
||||
return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
|
||||
}
|
||||
@@ -528,10 +527,10 @@ void ScaleFixedSizeOperation::get_area_of_interest(const int input_idx,
|
||||
BLI_assert(input_idx == 0);
|
||||
UNUSED_VARS_NDEBUG(input_idx);
|
||||
|
||||
r_input_area.xmax = ceilf((output_area.xmax - m_offsetX) * this->m_relX);
|
||||
r_input_area.xmin = floorf((output_area.xmin - m_offsetX) * this->m_relX);
|
||||
r_input_area.ymax = ceilf((output_area.ymax - m_offsetY) * this->m_relY);
|
||||
r_input_area.ymin = floorf((output_area.ymin - m_offsetY) * this->m_relY);
|
||||
r_input_area.xmax = ceilf((output_area.xmax - m_offsetX) * m_relX);
|
||||
r_input_area.xmin = floorf((output_area.xmin - m_offsetX) * m_relX);
|
||||
r_input_area.ymax = ceilf((output_area.ymax - m_offsetY) * m_relY);
|
||||
r_input_area.ymin = floorf((output_area.ymin - m_offsetY) * m_relY);
|
||||
expand_area_for_sampler(r_input_area, (PixelSampler)m_sampler);
|
||||
}
|
||||
|
||||
@@ -542,17 +541,17 @@ void ScaleFixedSizeOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const MemoryBuffer *input_img = inputs[0];
|
||||
PixelSampler sampler = (PixelSampler)m_sampler;
|
||||
BuffersIterator<float> it = output->iterate_with({}, area);
|
||||
if (this->m_is_offset) {
|
||||
if (m_is_offset) {
|
||||
for (; !it.is_end(); ++it) {
|
||||
const float nx = (canvas_.xmin + it.x - this->m_offsetX) * this->m_relX;
|
||||
const float ny = (canvas_.ymin + it.y - this->m_offsetY) * this->m_relY;
|
||||
const float nx = (canvas_.xmin + it.x - m_offsetX) * m_relX;
|
||||
const float ny = (canvas_.ymin + it.y - m_offsetY) * m_relY;
|
||||
input_img->read_elem_sampled(nx - canvas_.xmin, ny - canvas_.ymin, sampler, it.out);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (; !it.is_end(); ++it) {
|
||||
input_img->read_elem_sampled((canvas_.xmin + it.x) * this->m_relX - canvas_.xmin,
|
||||
(canvas_.ymin + it.y) * this->m_relY - canvas_.ymin,
|
||||
input_img->read_elem_sampled((canvas_.xmin + it.x) * m_relX - canvas_.xmin,
|
||||
(canvas_.ymin + it.y) * m_relY - canvas_.ymin,
|
||||
sampler,
|
||||
it.out);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class BaseScaleOperation : public MultiThreadedOperation {
|
||||
public:
|
||||
void setSampler(PixelSampler sampler)
|
||||
{
|
||||
this->m_sampler = (int)sampler;
|
||||
m_sampler = (int)sampler;
|
||||
}
|
||||
void setVariableSize(bool variable_size)
|
||||
{
|
||||
@@ -184,24 +184,24 @@ class ScaleFixedSizeOperation : public BaseScaleOperation {
|
||||
void deinitExecution() override;
|
||||
void setNewWidth(int width)
|
||||
{
|
||||
this->m_newWidth = width;
|
||||
m_newWidth = width;
|
||||
}
|
||||
void setNewHeight(int height)
|
||||
{
|
||||
this->m_newHeight = height;
|
||||
m_newHeight = height;
|
||||
}
|
||||
void setIsAspect(bool is_aspect)
|
||||
{
|
||||
this->m_is_aspect = is_aspect;
|
||||
m_is_aspect = is_aspect;
|
||||
}
|
||||
void setIsCrop(bool is_crop)
|
||||
{
|
||||
this->m_is_crop = is_crop;
|
||||
m_is_crop = is_crop;
|
||||
}
|
||||
void setOffset(float x, float y)
|
||||
{
|
||||
this->m_offsetX = x;
|
||||
this->m_offsetY = y;
|
||||
m_offsetX = x;
|
||||
m_offsetY = y;
|
||||
}
|
||||
|
||||
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override;
|
||||
|
||||
@@ -33,12 +33,12 @@ ScreenLensDistortionOperation::ScreenLensDistortionOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_distortion = 0.0f;
|
||||
this->m_dispersion = 0.0f;
|
||||
this->m_distortion_const = false;
|
||||
this->m_dispersion_const = false;
|
||||
this->m_variables_ready = false;
|
||||
m_inputProgram = nullptr;
|
||||
m_distortion = 0.0f;
|
||||
m_dispersion = 0.0f;
|
||||
m_distortion_const = false;
|
||||
m_dispersion_const = false;
|
||||
m_variables_ready = false;
|
||||
}
|
||||
|
||||
void ScreenLensDistortionOperation::setDistortion(float distortion)
|
||||
@@ -55,8 +55,8 @@ void ScreenLensDistortionOperation::setDispersion(float dispersion)
|
||||
|
||||
void ScreenLensDistortionOperation::init_data()
|
||||
{
|
||||
this->m_cx = 0.5f * (float)getWidth();
|
||||
this->m_cy = 0.5f * (float)getHeight();
|
||||
m_cx = 0.5f * (float)getWidth();
|
||||
m_cy = 0.5f * (float)getHeight();
|
||||
|
||||
switch (execution_model_) {
|
||||
case eExecutionModel::FullFrame: {
|
||||
@@ -84,17 +84,17 @@ void ScreenLensDistortionOperation::init_data()
|
||||
|
||||
void ScreenLensDistortionOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
this->initMutex();
|
||||
|
||||
uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX);
|
||||
rng_seed ^= (uint)POINTER_AS_INT(m_inputProgram);
|
||||
this->m_rng = BLI_rng_new(rng_seed);
|
||||
m_rng = BLI_rng_new(rng_seed);
|
||||
}
|
||||
|
||||
void *ScreenLensDistortionOperation::initializeTileData(rcti * /*rect*/)
|
||||
{
|
||||
void *buffer = this->m_inputProgram->initializeTileData(nullptr);
|
||||
void *buffer = m_inputProgram->initializeTileData(nullptr);
|
||||
|
||||
/* get distortion/dispersion values once, by reading inputs at (0,0)
|
||||
* XXX this assumes invariable values (no image inputs),
|
||||
@@ -231,8 +231,8 @@ void ScreenLensDistortionOperation::executePixel(float output[4], int x, int y,
|
||||
void ScreenLensDistortionOperation::deinitExecution()
|
||||
{
|
||||
this->deinitMutex();
|
||||
this->m_inputProgram = nullptr;
|
||||
BLI_rng_free(this->m_rng);
|
||||
m_inputProgram = nullptr;
|
||||
BLI_rng_free(m_rng);
|
||||
}
|
||||
|
||||
void ScreenLensDistortionOperation::determineUV(float result[6], float x, float y) const
|
||||
|
||||
@@ -26,15 +26,15 @@ SetAlphaMultiplyOperation::SetAlphaMultiplyOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_inputColor = nullptr;
|
||||
this->m_inputAlpha = nullptr;
|
||||
m_inputColor = nullptr;
|
||||
m_inputAlpha = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void SetAlphaMultiplyOperation::initExecution()
|
||||
{
|
||||
this->m_inputColor = getInputSocketReader(0);
|
||||
this->m_inputAlpha = getInputSocketReader(1);
|
||||
m_inputColor = getInputSocketReader(0);
|
||||
m_inputAlpha = getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void SetAlphaMultiplyOperation::executePixelSampled(float output[4],
|
||||
@@ -45,16 +45,16 @@ void SetAlphaMultiplyOperation::executePixelSampled(float output[4],
|
||||
float color_input[4];
|
||||
float alpha_input[4];
|
||||
|
||||
this->m_inputColor->readSampled(color_input, x, y, sampler);
|
||||
this->m_inputAlpha->readSampled(alpha_input, x, y, sampler);
|
||||
m_inputColor->readSampled(color_input, x, y, sampler);
|
||||
m_inputAlpha->readSampled(alpha_input, x, y, sampler);
|
||||
|
||||
mul_v4_v4fl(output, color_input, alpha_input[0]);
|
||||
}
|
||||
|
||||
void SetAlphaMultiplyOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputColor = nullptr;
|
||||
this->m_inputAlpha = nullptr;
|
||||
m_inputColor = nullptr;
|
||||
m_inputAlpha = nullptr;
|
||||
}
|
||||
|
||||
void SetAlphaMultiplyOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -26,15 +26,15 @@ SetAlphaReplaceOperation::SetAlphaReplaceOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_inputColor = nullptr;
|
||||
this->m_inputAlpha = nullptr;
|
||||
m_inputColor = nullptr;
|
||||
m_inputAlpha = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void SetAlphaReplaceOperation::initExecution()
|
||||
{
|
||||
this->m_inputColor = getInputSocketReader(0);
|
||||
this->m_inputAlpha = getInputSocketReader(1);
|
||||
m_inputColor = getInputSocketReader(0);
|
||||
m_inputAlpha = getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void SetAlphaReplaceOperation::executePixelSampled(float output[4],
|
||||
@@ -44,15 +44,15 @@ void SetAlphaReplaceOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float alpha_input[4];
|
||||
|
||||
this->m_inputColor->readSampled(output, x, y, sampler);
|
||||
this->m_inputAlpha->readSampled(alpha_input, x, y, sampler);
|
||||
m_inputColor->readSampled(output, x, y, sampler);
|
||||
m_inputAlpha->readSampled(alpha_input, x, y, sampler);
|
||||
output[3] = alpha_input[0];
|
||||
}
|
||||
|
||||
void SetAlphaReplaceOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputColor = nullptr;
|
||||
this->m_inputAlpha = nullptr;
|
||||
m_inputColor = nullptr;
|
||||
m_inputAlpha = nullptr;
|
||||
}
|
||||
|
||||
void SetAlphaReplaceOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -31,7 +31,7 @@ void SetColorOperation::executePixelSampled(float output[4],
|
||||
float /*y*/,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
copy_v4_v4(output, this->m_color);
|
||||
copy_v4_v4(output, m_color);
|
||||
}
|
||||
|
||||
void SetColorOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
|
||||
@@ -43,39 +43,39 @@ class SetColorOperation : public ConstantOperation {
|
||||
|
||||
float getChannel1()
|
||||
{
|
||||
return this->m_color[0];
|
||||
return m_color[0];
|
||||
}
|
||||
void setChannel1(float value)
|
||||
{
|
||||
this->m_color[0] = value;
|
||||
m_color[0] = value;
|
||||
}
|
||||
float getChannel2()
|
||||
{
|
||||
return this->m_color[1];
|
||||
return m_color[1];
|
||||
}
|
||||
void setChannel2(float value)
|
||||
{
|
||||
this->m_color[1] = value;
|
||||
m_color[1] = value;
|
||||
}
|
||||
float getChannel3()
|
||||
{
|
||||
return this->m_color[2];
|
||||
return m_color[2];
|
||||
}
|
||||
void setChannel3(float value)
|
||||
{
|
||||
this->m_color[2] = value;
|
||||
m_color[2] = value;
|
||||
}
|
||||
float getChannel4()
|
||||
{
|
||||
return this->m_color[3];
|
||||
return m_color[3];
|
||||
}
|
||||
void setChannel4(const float value)
|
||||
{
|
||||
this->m_color[3] = value;
|
||||
m_color[3] = value;
|
||||
}
|
||||
void setChannels(const float value[4])
|
||||
{
|
||||
copy_v4_v4(this->m_color, value);
|
||||
copy_v4_v4(m_color, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,11 +28,11 @@ SetSamplerOperation::SetSamplerOperation()
|
||||
|
||||
void SetSamplerOperation::initExecution()
|
||||
{
|
||||
this->m_reader = this->getInputSocketReader(0);
|
||||
m_reader = this->getInputSocketReader(0);
|
||||
}
|
||||
void SetSamplerOperation::deinitExecution()
|
||||
{
|
||||
this->m_reader = nullptr;
|
||||
m_reader = nullptr;
|
||||
}
|
||||
|
||||
void SetSamplerOperation::executePixelSampled(float output[4],
|
||||
@@ -40,7 +40,7 @@ void SetSamplerOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
this->m_reader->readSampled(output, x, y, this->m_sampler);
|
||||
m_reader->readSampled(output, x, y, m_sampler);
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -39,7 +39,7 @@ class SetSamplerOperation : public NodeOperation {
|
||||
|
||||
void setSampler(PixelSampler sampler)
|
||||
{
|
||||
this->m_sampler = sampler;
|
||||
m_sampler = sampler;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ void SetValueOperation::executePixelSampled(float output[4],
|
||||
float /*y*/,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
output[0] = this->m_value;
|
||||
output[0] = m_value;
|
||||
}
|
||||
|
||||
void SetValueOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
|
||||
@@ -43,11 +43,11 @@ class SetValueOperation : public ConstantOperation {
|
||||
|
||||
float getValue()
|
||||
{
|
||||
return this->m_value;
|
||||
return m_value;
|
||||
}
|
||||
void setValue(float value)
|
||||
{
|
||||
this->m_value = value;
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,21 +25,21 @@ SplitOperation::SplitOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_image1Input = nullptr;
|
||||
this->m_image2Input = nullptr;
|
||||
m_image1Input = nullptr;
|
||||
m_image2Input = nullptr;
|
||||
}
|
||||
|
||||
void SplitOperation::initExecution()
|
||||
{
|
||||
/* When initializing the tree during initial load the width and height can be zero. */
|
||||
this->m_image1Input = getInputSocketReader(0);
|
||||
this->m_image2Input = getInputSocketReader(1);
|
||||
m_image1Input = getInputSocketReader(0);
|
||||
m_image2Input = getInputSocketReader(1);
|
||||
}
|
||||
|
||||
void SplitOperation::deinitExecution()
|
||||
{
|
||||
this->m_image1Input = nullptr;
|
||||
this->m_image2Input = nullptr;
|
||||
m_image1Input = nullptr;
|
||||
m_image2Input = nullptr;
|
||||
}
|
||||
|
||||
void SplitOperation::executePixelSampled(float output[4],
|
||||
@@ -47,14 +47,14 @@ void SplitOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f :
|
||||
this->m_splitPercentage * this->getHeight() / 100.0f;
|
||||
bool image1 = this->m_xSplit ? x > perc : y > perc;
|
||||
int perc = m_xSplit ? m_splitPercentage * this->getWidth() / 100.0f :
|
||||
m_splitPercentage * this->getHeight() / 100.0f;
|
||||
bool image1 = m_xSplit ? x > perc : y > perc;
|
||||
if (image1) {
|
||||
this->m_image1Input->readSampled(output, x, y, PixelSampler::Nearest);
|
||||
m_image1Input->readSampled(output, x, y, PixelSampler::Nearest);
|
||||
}
|
||||
else {
|
||||
this->m_image2Input->readSampled(output, x, y, PixelSampler::Nearest);
|
||||
m_image2Input->readSampled(output, x, y, PixelSampler::Nearest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,11 +72,11 @@ void SplitOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
const int percent = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f :
|
||||
this->m_splitPercentage * this->getHeight() / 100.0f;
|
||||
const int percent = m_xSplit ? m_splitPercentage * this->getWidth() / 100.0f :
|
||||
m_splitPercentage * this->getHeight() / 100.0f;
|
||||
const size_t elem_bytes = COM_data_type_bytes_len(getOutputSocket()->getDataType());
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
const bool is_image1 = this->m_xSplit ? it.x > percent : it.y > percent;
|
||||
const bool is_image1 = m_xSplit ? it.x > percent : it.y > percent;
|
||||
memcpy(it.out, it.in(is_image1 ? 0 : 1), elem_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ class SplitOperation : public MultiThreadedOperation {
|
||||
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
|
||||
void setSplitPercentage(float splitPercentage)
|
||||
{
|
||||
this->m_splitPercentage = splitPercentage;
|
||||
m_splitPercentage = splitPercentage;
|
||||
}
|
||||
void setXSplit(bool xsplit)
|
||||
{
|
||||
this->m_xSplit = xsplit;
|
||||
m_xSplit = xsplit;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -33,9 +33,9 @@ SunBeamsOperation::SunBeamsOperation()
|
||||
void SunBeamsOperation::calc_rays_common_data()
|
||||
{
|
||||
/* convert to pixels */
|
||||
this->m_source_px[0] = this->m_data.source[0] * this->getWidth();
|
||||
this->m_source_px[1] = this->m_data.source[1] * this->getHeight();
|
||||
this->m_ray_length_px = this->m_data.ray_length * MAX2(this->getWidth(), this->getHeight());
|
||||
m_source_px[0] = m_data.source[0] * this->getWidth();
|
||||
m_source_px[1] = m_data.source[1] * this->getHeight();
|
||||
m_ray_length_px = m_data.ray_length * MAX2(this->getWidth(), this->getHeight());
|
||||
}
|
||||
|
||||
void SunBeamsOperation::initExecution()
|
||||
@@ -322,8 +322,7 @@ void SunBeamsOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
const float co[2] = {(float)x, (float)y};
|
||||
|
||||
accumulate_line(
|
||||
(MemoryBuffer *)data, output, co, this->m_source_px, 0.0f, this->m_ray_length_px);
|
||||
accumulate_line((MemoryBuffer *)data, output, co, m_source_px, 0.0f, m_ray_length_px);
|
||||
}
|
||||
|
||||
static void calc_ray_shift(rcti *rect, float x, float y, const float source[2], float ray_length)
|
||||
@@ -350,10 +349,10 @@ bool SunBeamsOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
* and gives a rect that contains all possible accumulated pixels.
|
||||
*/
|
||||
rcti rect = *input;
|
||||
calc_ray_shift(&rect, input->xmin, input->ymin, this->m_source_px, this->m_ray_length_px);
|
||||
calc_ray_shift(&rect, input->xmin, input->ymax, this->m_source_px, this->m_ray_length_px);
|
||||
calc_ray_shift(&rect, input->xmax, input->ymin, this->m_source_px, this->m_ray_length_px);
|
||||
calc_ray_shift(&rect, input->xmax, input->ymax, this->m_source_px, this->m_ray_length_px);
|
||||
calc_ray_shift(&rect, input->xmin, input->ymin, m_source_px, m_ray_length_px);
|
||||
calc_ray_shift(&rect, input->xmin, input->ymax, m_source_px, m_ray_length_px);
|
||||
calc_ray_shift(&rect, input->xmax, input->ymin, m_source_px, m_ray_length_px);
|
||||
calc_ray_shift(&rect, input->xmax, input->ymax, m_source_px, m_ray_length_px);
|
||||
|
||||
return NodeOperation::determineDependingAreaOfInterest(&rect, readOperation, output);
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ TextureBaseOperation::TextureBaseOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Vector); // offset
|
||||
this->addInputSocket(DataType::Vector); // size
|
||||
this->m_texture = nullptr;
|
||||
this->m_inputSize = nullptr;
|
||||
this->m_inputOffset = nullptr;
|
||||
this->m_rd = nullptr;
|
||||
this->m_pool = nullptr;
|
||||
this->m_sceneColorManage = false;
|
||||
m_texture = nullptr;
|
||||
m_inputSize = nullptr;
|
||||
m_inputOffset = nullptr;
|
||||
m_rd = nullptr;
|
||||
m_pool = nullptr;
|
||||
m_sceneColorManage = false;
|
||||
flags.complex = true;
|
||||
}
|
||||
TextureOperation::TextureOperation() : TextureBaseOperation()
|
||||
@@ -47,24 +47,23 @@ TextureAlphaOperation::TextureAlphaOperation() : TextureBaseOperation()
|
||||
|
||||
void TextureBaseOperation::initExecution()
|
||||
{
|
||||
this->m_inputOffset = getInputSocketReader(0);
|
||||
this->m_inputSize = getInputSocketReader(1);
|
||||
this->m_pool = BKE_image_pool_new();
|
||||
if (this->m_texture != nullptr && this->m_texture->nodetree != nullptr &&
|
||||
this->m_texture->use_nodes) {
|
||||
ntreeTexBeginExecTree(this->m_texture->nodetree);
|
||||
m_inputOffset = getInputSocketReader(0);
|
||||
m_inputSize = getInputSocketReader(1);
|
||||
m_pool = BKE_image_pool_new();
|
||||
if (m_texture != nullptr && m_texture->nodetree != nullptr && m_texture->use_nodes) {
|
||||
ntreeTexBeginExecTree(m_texture->nodetree);
|
||||
}
|
||||
NodeOperation::initExecution();
|
||||
}
|
||||
void TextureBaseOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputSize = nullptr;
|
||||
this->m_inputOffset = nullptr;
|
||||
BKE_image_pool_free(this->m_pool);
|
||||
this->m_pool = nullptr;
|
||||
if (this->m_texture != nullptr && this->m_texture->use_nodes &&
|
||||
this->m_texture->nodetree != nullptr && this->m_texture->nodetree->execdata != nullptr) {
|
||||
ntreeTexEndExecTree(this->m_texture->nodetree->execdata);
|
||||
m_inputSize = nullptr;
|
||||
m_inputOffset = nullptr;
|
||||
BKE_image_pool_free(m_pool);
|
||||
m_pool = nullptr;
|
||||
if (m_texture != nullptr && m_texture->use_nodes && m_texture->nodetree != nullptr &&
|
||||
m_texture->nodetree->execdata != nullptr) {
|
||||
ntreeTexEndExecTree(m_texture->nodetree->execdata);
|
||||
}
|
||||
NodeOperation::deinitExecution();
|
||||
}
|
||||
@@ -73,8 +72,8 @@ void TextureBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_
|
||||
{
|
||||
r_area = preferred_area;
|
||||
if (BLI_rcti_is_empty(&preferred_area)) {
|
||||
int width = this->m_rd->xsch * this->m_rd->size / 100;
|
||||
int height = this->m_rd->ysch * this->m_rd->size / 100;
|
||||
int width = m_rd->xsch * m_rd->size / 100;
|
||||
int height = m_rd->ysch * m_rd->size / 100;
|
||||
r_area.xmax = preferred_area.xmin + width;
|
||||
r_area.ymax = preferred_area.ymin + height;
|
||||
}
|
||||
@@ -121,24 +120,16 @@ void TextureBaseOperation::executePixelSampled(float output[4],
|
||||
v += 0.5f / cy;
|
||||
}
|
||||
|
||||
this->m_inputSize->readSampled(textureSize, x, y, sampler);
|
||||
this->m_inputOffset->readSampled(textureOffset, x, y, sampler);
|
||||
m_inputSize->readSampled(textureSize, x, y, sampler);
|
||||
m_inputOffset->readSampled(textureOffset, x, y, sampler);
|
||||
|
||||
vec[0] = textureSize[0] * (u + textureOffset[0]);
|
||||
vec[1] = textureSize[1] * (v + textureOffset[1]);
|
||||
vec[2] = textureSize[2] * textureOffset[2];
|
||||
|
||||
const int thread_id = WorkScheduler::current_thread_id();
|
||||
retval = multitex_ext(this->m_texture,
|
||||
vec,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
&texres,
|
||||
thread_id,
|
||||
m_pool,
|
||||
m_sceneColorManage,
|
||||
false);
|
||||
retval = multitex_ext(
|
||||
m_texture, vec, nullptr, nullptr, 0, &texres, thread_id, m_pool, m_sceneColorManage, false);
|
||||
|
||||
output[3] = texres.talpha ? texres.ta : texres.tin;
|
||||
if (retval & TEX_RGB) {
|
||||
@@ -182,7 +173,7 @@ void TextureBaseOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
vec[1] = tex_size[1] * (v + tex_offset[1]);
|
||||
vec[2] = tex_size[2] * tex_offset[2];
|
||||
|
||||
const int retval = multitex_ext(this->m_texture,
|
||||
const int retval = multitex_ext(m_texture,
|
||||
vec,
|
||||
nullptr,
|
||||
nullptr,
|
||||
|
||||
@@ -58,17 +58,17 @@ class TextureBaseOperation : public MultiThreadedOperation {
|
||||
|
||||
void setTexture(Tex *texture)
|
||||
{
|
||||
this->m_texture = texture;
|
||||
m_texture = texture;
|
||||
}
|
||||
void initExecution() override;
|
||||
void deinitExecution() override;
|
||||
void setRenderData(const RenderData *rd)
|
||||
{
|
||||
this->m_rd = rd;
|
||||
m_rd = rd;
|
||||
}
|
||||
void setSceneColorManage(bool sceneColorManage)
|
||||
{
|
||||
this->m_sceneColorManage = sceneColorManage;
|
||||
m_sceneColorManage = sceneColorManage;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -28,14 +28,14 @@ TonemapOperation::TonemapOperation()
|
||||
{
|
||||
this->addInputSocket(DataType::Color, ResizeMode::Align);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_imageReader = nullptr;
|
||||
this->m_data = nullptr;
|
||||
this->m_cachedInstance = nullptr;
|
||||
m_imageReader = nullptr;
|
||||
m_data = nullptr;
|
||||
m_cachedInstance = nullptr;
|
||||
this->flags.complex = true;
|
||||
}
|
||||
void TonemapOperation::initExecution()
|
||||
{
|
||||
this->m_imageReader = this->getInputSocketReader(0);
|
||||
m_imageReader = this->getInputSocketReader(0);
|
||||
NodeOperation::initMutex();
|
||||
}
|
||||
|
||||
@@ -43,11 +43,11 @@ void TonemapOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
AvgLogLum *avg = (AvgLogLum *)data;
|
||||
|
||||
this->m_imageReader->read(output, x, y, nullptr);
|
||||
m_imageReader->read(output, x, y, nullptr);
|
||||
mul_v3_fl(output, avg->al);
|
||||
float dr = output[0] + this->m_data->offset;
|
||||
float dg = output[1] + this->m_data->offset;
|
||||
float db = output[2] + this->m_data->offset;
|
||||
float dr = output[0] + m_data->offset;
|
||||
float dg = output[1] + m_data->offset;
|
||||
float db = output[2] + m_data->offset;
|
||||
output[0] /= ((dr == 0.0f) ? 1.0f : dr);
|
||||
output[1] /= ((dg == 0.0f) ? 1.0f : dg);
|
||||
output[2] /= ((db == 0.0f) ? 1.0f : db);
|
||||
@@ -61,13 +61,13 @@ void TonemapOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
void PhotoreceptorTonemapOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
{
|
||||
AvgLogLum *avg = (AvgLogLum *)data;
|
||||
NodeTonemap *ntm = this->m_data;
|
||||
NodeTonemap *ntm = m_data;
|
||||
|
||||
const float f = expf(-this->m_data->f);
|
||||
const float f = expf(-m_data->f);
|
||||
const float m = (ntm->m > 0.0f) ? ntm->m : (0.3f + 0.7f * powf(avg->auto_key, 1.4f));
|
||||
const float ic = 1.0f - ntm->c, ia = 1.0f - ntm->a;
|
||||
|
||||
this->m_imageReader->read(output, x, y, nullptr);
|
||||
m_imageReader->read(output, x, y, nullptr);
|
||||
|
||||
const float L = IMB_colormanagement_get_luminance(output);
|
||||
float I_l = output[0] + ic * (L - output[0]);
|
||||
@@ -86,8 +86,8 @@ void PhotoreceptorTonemapOperation::executePixel(float output[4], int x, int y,
|
||||
|
||||
void TonemapOperation::deinitExecution()
|
||||
{
|
||||
this->m_imageReader = nullptr;
|
||||
delete this->m_cachedInstance;
|
||||
m_imageReader = nullptr;
|
||||
delete m_cachedInstance;
|
||||
NodeOperation::deinitMutex();
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ bool TonemapOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
void *TonemapOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
lockMutex();
|
||||
if (this->m_cachedInstance == nullptr) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
|
||||
if (m_cachedInstance == nullptr) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_imageReader->initializeTileData(rect);
|
||||
AvgLogLum *data = new AvgLogLum();
|
||||
|
||||
float *buffer = tile->getBuffer();
|
||||
@@ -140,12 +140,12 @@ void *TonemapOperation::initializeTileData(rcti *rect)
|
||||
avl = lsum * sc;
|
||||
data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.0f;
|
||||
float al = exp((double)avl);
|
||||
data->al = (al == 0.0f) ? 0.0f : (this->m_data->key / al);
|
||||
data->igm = (this->m_data->gamma == 0.0f) ? 1 : (1.0f / this->m_data->gamma);
|
||||
this->m_cachedInstance = data;
|
||||
data->al = (al == 0.0f) ? 0.0f : (m_data->key / al);
|
||||
data->igm = (m_data->gamma == 0.0f) ? 1 : (1.0f / m_data->gamma);
|
||||
m_cachedInstance = data;
|
||||
}
|
||||
unlockMutex();
|
||||
return this->m_cachedInstance;
|
||||
return m_cachedInstance;
|
||||
}
|
||||
|
||||
void TonemapOperation::deinitializeTileData(rcti * /*rect*/, void * /*data*/)
|
||||
@@ -189,7 +189,7 @@ void TonemapOperation::update_memory_buffer_started(MemoryBuffer *UNUSED(output)
|
||||
const rcti &UNUSED(area),
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
if (this->m_cachedInstance == nullptr) {
|
||||
if (m_cachedInstance == nullptr) {
|
||||
Luminance lum = {0};
|
||||
const MemoryBuffer *input = inputs[0];
|
||||
exec_system_->execute_work<Luminance>(
|
||||
@@ -213,9 +213,9 @@ void TonemapOperation::update_memory_buffer_started(MemoryBuffer *UNUSED(output)
|
||||
const float avg_log = lum.log_sum / lum.num_pixels;
|
||||
avg->auto_key = (max_log > min_log) ? ((max_log - avg_log) / (max_log - min_log)) : 1.0f;
|
||||
const float al = exp((double)avg_log);
|
||||
avg->al = (al == 0.0f) ? 0.0f : (this->m_data->key / al);
|
||||
avg->igm = (this->m_data->gamma == 0.0f) ? 1 : (1.0f / this->m_data->gamma);
|
||||
this->m_cachedInstance = avg;
|
||||
avg->al = (al == 0.0f) ? 0.0f : (m_data->key / al);
|
||||
avg->igm = (m_data->gamma == 0.0f) ? 1 : (1.0f / m_data->gamma);
|
||||
m_cachedInstance = avg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ void TonemapOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
{
|
||||
AvgLogLum *avg = m_cachedInstance;
|
||||
const float igm = avg->igm;
|
||||
const float offset = this->m_data->offset;
|
||||
const float offset = m_data->offset;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
copy_v4_v4(it.out, it.in(0));
|
||||
mul_v3_fl(it.out, avg->al);
|
||||
@@ -248,8 +248,8 @@ void PhotoreceptorTonemapOperation::update_memory_buffer_partial(MemoryBuffer *o
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
AvgLogLum *avg = m_cachedInstance;
|
||||
NodeTonemap *ntm = this->m_data;
|
||||
const float f = expf(-this->m_data->f);
|
||||
NodeTonemap *ntm = m_data;
|
||||
const float f = expf(-m_data->f);
|
||||
const float m = (ntm->m > 0.0f) ? ntm->m : (0.3f + 0.7f * powf(avg->auto_key, 1.4f));
|
||||
const float ic = 1.0f - ntm->c;
|
||||
const float ia = 1.0f - ntm->a;
|
||||
|
||||
@@ -79,7 +79,7 @@ class TonemapOperation : public MultiThreadedOperation {
|
||||
|
||||
void setData(NodeTonemap *data)
|
||||
{
|
||||
this->m_data = data;
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
bool determineDependingAreaOfInterest(rcti *input,
|
||||
|
||||
@@ -27,14 +27,14 @@ namespace blender::compositor {
|
||||
TrackPositionOperation::TrackPositionOperation()
|
||||
{
|
||||
this->addOutputSocket(DataType::Value);
|
||||
this->m_movieClip = nullptr;
|
||||
this->m_framenumber = 0;
|
||||
this->m_trackingObjectName[0] = 0;
|
||||
this->m_trackName[0] = 0;
|
||||
this->m_axis = 0;
|
||||
this->m_position = CMP_TRACKPOS_ABSOLUTE;
|
||||
this->m_relativeFrame = 0;
|
||||
this->m_speed_output = false;
|
||||
m_movieClip = nullptr;
|
||||
m_framenumber = 0;
|
||||
m_trackingObjectName[0] = 0;
|
||||
m_trackName[0] = 0;
|
||||
m_axis = 0;
|
||||
m_position = CMP_TRACKPOS_ABSOLUTE;
|
||||
m_relativeFrame = 0;
|
||||
m_speed_output = false;
|
||||
flags.is_set_operation = true;
|
||||
is_track_position_calculated_ = false;
|
||||
}
|
||||
@@ -54,77 +54,76 @@ void TrackPositionOperation::calc_track_position()
|
||||
MovieTrackingObject *object;
|
||||
|
||||
track_position_ = 0;
|
||||
zero_v2(this->m_markerPos);
|
||||
zero_v2(this->m_relativePos);
|
||||
zero_v2(m_markerPos);
|
||||
zero_v2(m_relativePos);
|
||||
|
||||
if (!this->m_movieClip) {
|
||||
if (!m_movieClip) {
|
||||
return;
|
||||
}
|
||||
|
||||
tracking = &this->m_movieClip->tracking;
|
||||
tracking = &m_movieClip->tracking;
|
||||
|
||||
BKE_movieclip_user_set_frame(&user, this->m_framenumber);
|
||||
BKE_movieclip_get_size(this->m_movieClip, &user, &this->m_width, &this->m_height);
|
||||
BKE_movieclip_user_set_frame(&user, m_framenumber);
|
||||
BKE_movieclip_get_size(m_movieClip, &user, &m_width, &m_height);
|
||||
|
||||
object = BKE_tracking_object_get_named(tracking, this->m_trackingObjectName);
|
||||
object = BKE_tracking_object_get_named(tracking, m_trackingObjectName);
|
||||
if (object) {
|
||||
MovieTrackingTrack *track;
|
||||
|
||||
track = BKE_tracking_track_get_named(tracking, object, this->m_trackName);
|
||||
track = BKE_tracking_track_get_named(tracking, object, m_trackName);
|
||||
|
||||
if (track) {
|
||||
MovieTrackingMarker *marker;
|
||||
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
|
||||
this->m_framenumber);
|
||||
int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(m_movieClip, m_framenumber);
|
||||
|
||||
marker = BKE_tracking_marker_get(track, clip_framenr);
|
||||
|
||||
copy_v2_v2(this->m_markerPos, marker->pos);
|
||||
copy_v2_v2(m_markerPos, marker->pos);
|
||||
|
||||
if (this->m_speed_output) {
|
||||
int relative_clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
|
||||
this->m_relativeFrame);
|
||||
if (m_speed_output) {
|
||||
int relative_clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(m_movieClip,
|
||||
m_relativeFrame);
|
||||
|
||||
marker = BKE_tracking_marker_get_exact(track, relative_clip_framenr);
|
||||
if (marker != nullptr && (marker->flag & MARKER_DISABLED) == 0) {
|
||||
copy_v2_v2(this->m_relativePos, marker->pos);
|
||||
copy_v2_v2(m_relativePos, marker->pos);
|
||||
}
|
||||
else {
|
||||
copy_v2_v2(this->m_relativePos, this->m_markerPos);
|
||||
copy_v2_v2(m_relativePos, m_markerPos);
|
||||
}
|
||||
if (this->m_relativeFrame < this->m_framenumber) {
|
||||
swap_v2_v2(this->m_relativePos, this->m_markerPos);
|
||||
if (m_relativeFrame < m_framenumber) {
|
||||
swap_v2_v2(m_relativePos, m_markerPos);
|
||||
}
|
||||
}
|
||||
else if (this->m_position == CMP_TRACKPOS_RELATIVE_START) {
|
||||
else if (m_position == CMP_TRACKPOS_RELATIVE_START) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < track->markersnr; i++) {
|
||||
marker = &track->markers[i];
|
||||
|
||||
if ((marker->flag & MARKER_DISABLED) == 0) {
|
||||
copy_v2_v2(this->m_relativePos, marker->pos);
|
||||
copy_v2_v2(m_relativePos, marker->pos);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this->m_position == CMP_TRACKPOS_RELATIVE_FRAME) {
|
||||
int relative_clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
|
||||
this->m_relativeFrame);
|
||||
else if (m_position == CMP_TRACKPOS_RELATIVE_FRAME) {
|
||||
int relative_clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(m_movieClip,
|
||||
m_relativeFrame);
|
||||
|
||||
marker = BKE_tracking_marker_get(track, relative_clip_framenr);
|
||||
copy_v2_v2(this->m_relativePos, marker->pos);
|
||||
copy_v2_v2(m_relativePos, marker->pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
track_position_ = this->m_markerPos[this->m_axis] - this->m_relativePos[this->m_axis];
|
||||
if (this->m_axis == 0) {
|
||||
track_position_ *= this->m_width;
|
||||
track_position_ = m_markerPos[m_axis] - m_relativePos[m_axis];
|
||||
if (m_axis == 0) {
|
||||
track_position_ *= m_width;
|
||||
}
|
||||
else {
|
||||
track_position_ *= this->m_height;
|
||||
track_position_ *= m_height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,13 +132,13 @@ void TrackPositionOperation::executePixelSampled(float output[4],
|
||||
float /*y*/,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
output[0] = this->m_markerPos[this->m_axis] - this->m_relativePos[this->m_axis];
|
||||
output[0] = m_markerPos[m_axis] - m_relativePos[m_axis];
|
||||
|
||||
if (this->m_axis == 0) {
|
||||
output[0] *= this->m_width;
|
||||
if (m_axis == 0) {
|
||||
output[0] *= m_width;
|
||||
}
|
||||
else {
|
||||
output[0] *= this->m_height;
|
||||
output[0] *= m_height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,35 +60,35 @@ class TrackPositionOperation : public ConstantOperation {
|
||||
|
||||
void setMovieClip(MovieClip *clip)
|
||||
{
|
||||
this->m_movieClip = clip;
|
||||
m_movieClip = clip;
|
||||
}
|
||||
void setTrackingObject(char *object)
|
||||
{
|
||||
BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName));
|
||||
BLI_strncpy(m_trackingObjectName, object, sizeof(m_trackingObjectName));
|
||||
}
|
||||
void setTrackName(char *track)
|
||||
{
|
||||
BLI_strncpy(this->m_trackName, track, sizeof(this->m_trackName));
|
||||
BLI_strncpy(m_trackName, track, sizeof(m_trackName));
|
||||
}
|
||||
void setFramenumber(int framenumber)
|
||||
{
|
||||
this->m_framenumber = framenumber;
|
||||
m_framenumber = framenumber;
|
||||
}
|
||||
void setAxis(int value)
|
||||
{
|
||||
this->m_axis = value;
|
||||
m_axis = value;
|
||||
}
|
||||
void setPosition(int value)
|
||||
{
|
||||
this->m_position = value;
|
||||
m_position = value;
|
||||
}
|
||||
void setRelativeFrame(int value)
|
||||
{
|
||||
this->m_relativeFrame = value;
|
||||
m_relativeFrame = value;
|
||||
}
|
||||
void setSpeedOutput(bool speed_output)
|
||||
{
|
||||
this->m_speed_output = speed_output;
|
||||
m_speed_output = speed_output;
|
||||
}
|
||||
|
||||
void initExecution() override;
|
||||
|
||||
@@ -30,28 +30,28 @@ TranslateOperation::TranslateOperation(DataType data_type, ResizeMode resize_mod
|
||||
this->addInputSocket(DataType::Value, ResizeMode::None);
|
||||
this->addOutputSocket(data_type);
|
||||
this->set_canvas_input_index(0);
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_inputXOperation = nullptr;
|
||||
this->m_inputYOperation = nullptr;
|
||||
this->m_isDeltaSet = false;
|
||||
this->m_factorX = 1.0f;
|
||||
this->m_factorY = 1.0f;
|
||||
m_inputOperation = nullptr;
|
||||
m_inputXOperation = nullptr;
|
||||
m_inputYOperation = nullptr;
|
||||
m_isDeltaSet = false;
|
||||
m_factorX = 1.0f;
|
||||
m_factorY = 1.0f;
|
||||
this->x_extend_mode_ = MemoryBufferExtend::Clip;
|
||||
this->y_extend_mode_ = MemoryBufferExtend::Clip;
|
||||
}
|
||||
|
||||
void TranslateOperation::initExecution()
|
||||
{
|
||||
this->m_inputOperation = this->getInputSocketReader(0);
|
||||
this->m_inputXOperation = this->getInputSocketReader(1);
|
||||
this->m_inputYOperation = this->getInputSocketReader(2);
|
||||
m_inputOperation = this->getInputSocketReader(0);
|
||||
m_inputXOperation = this->getInputSocketReader(1);
|
||||
m_inputYOperation = this->getInputSocketReader(2);
|
||||
}
|
||||
|
||||
void TranslateOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputOperation = nullptr;
|
||||
this->m_inputXOperation = nullptr;
|
||||
this->m_inputYOperation = nullptr;
|
||||
m_inputOperation = nullptr;
|
||||
m_inputXOperation = nullptr;
|
||||
m_inputYOperation = nullptr;
|
||||
}
|
||||
|
||||
void TranslateOperation::executePixelSampled(float output[4],
|
||||
@@ -64,7 +64,7 @@ void TranslateOperation::executePixelSampled(float output[4],
|
||||
float originalXPos = x - this->getDeltaX();
|
||||
float originalYPos = y - this->getDeltaY();
|
||||
|
||||
this->m_inputOperation->readSampled(output, originalXPos, originalYPos, PixelSampler::Bilinear);
|
||||
m_inputOperation->readSampled(output, originalXPos, originalYPos, PixelSampler::Bilinear);
|
||||
}
|
||||
|
||||
bool TranslateOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
|
||||
@@ -56,29 +56,29 @@ class TranslateOperation : public MultiThreadedOperation {
|
||||
|
||||
float getDeltaX()
|
||||
{
|
||||
return this->m_deltaX * this->m_factorX;
|
||||
return m_deltaX * m_factorX;
|
||||
}
|
||||
float getDeltaY()
|
||||
{
|
||||
return this->m_deltaY * this->m_factorY;
|
||||
return m_deltaY * m_factorY;
|
||||
}
|
||||
|
||||
inline void ensureDelta()
|
||||
{
|
||||
if (!this->m_isDeltaSet) {
|
||||
if (!m_isDeltaSet) {
|
||||
if (execution_model_ == eExecutionModel::Tiled) {
|
||||
float tempDelta[4];
|
||||
this->m_inputXOperation->readSampled(tempDelta, 0, 0, PixelSampler::Nearest);
|
||||
this->m_deltaX = tempDelta[0];
|
||||
this->m_inputYOperation->readSampled(tempDelta, 0, 0, PixelSampler::Nearest);
|
||||
this->m_deltaY = tempDelta[0];
|
||||
m_inputXOperation->readSampled(tempDelta, 0, 0, PixelSampler::Nearest);
|
||||
m_deltaX = tempDelta[0];
|
||||
m_inputYOperation->readSampled(tempDelta, 0, 0, PixelSampler::Nearest);
|
||||
m_deltaY = tempDelta[0];
|
||||
}
|
||||
else {
|
||||
m_deltaX = get_input_operation(X_INPUT_INDEX)->get_constant_value_default(0.0f);
|
||||
m_deltaY = get_input_operation(Y_INPUT_INDEX)->get_constant_value_default(0.0f);
|
||||
}
|
||||
|
||||
this->m_isDeltaSet = true;
|
||||
m_isDeltaSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,24 +34,24 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation()
|
||||
flags.complex = true;
|
||||
flags.open_cl = true;
|
||||
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputBokehProgram = nullptr;
|
||||
this->m_inputSizeProgram = nullptr;
|
||||
this->m_maxBlur = 32.0f;
|
||||
this->m_threshold = 1.0f;
|
||||
this->m_do_size_scale = false;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputBokehProgram = nullptr;
|
||||
m_inputSizeProgram = nullptr;
|
||||
m_maxBlur = 32.0f;
|
||||
m_threshold = 1.0f;
|
||||
m_do_size_scale = false;
|
||||
#ifdef COM_DEFOCUS_SEARCH
|
||||
this->m_inputSearchProgram = nullptr;
|
||||
m_inputSearchProgram = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void VariableSizeBokehBlurOperation::initExecution()
|
||||
{
|
||||
this->m_inputProgram = getInputSocketReader(0);
|
||||
this->m_inputBokehProgram = getInputSocketReader(1);
|
||||
this->m_inputSizeProgram = getInputSocketReader(2);
|
||||
m_inputProgram = getInputSocketReader(0);
|
||||
m_inputBokehProgram = getInputSocketReader(1);
|
||||
m_inputSizeProgram = getInputSocketReader(2);
|
||||
#ifdef COM_DEFOCUS_SEARCH
|
||||
this->m_inputSearchProgram = getInputSocketReader(3);
|
||||
m_inputSearchProgram = getInputSocketReader(3);
|
||||
#endif
|
||||
QualityStepHelper::initExecution(COM_QH_INCREASE);
|
||||
}
|
||||
@@ -65,19 +65,18 @@ struct VariableSizeBokehBlurTileData {
|
||||
void *VariableSizeBokehBlurOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
VariableSizeBokehBlurTileData *data = new VariableSizeBokehBlurTileData();
|
||||
data->color = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
|
||||
data->bokeh = (MemoryBuffer *)this->m_inputBokehProgram->initializeTileData(rect);
|
||||
data->size = (MemoryBuffer *)this->m_inputSizeProgram->initializeTileData(rect);
|
||||
data->color = (MemoryBuffer *)m_inputProgram->initializeTileData(rect);
|
||||
data->bokeh = (MemoryBuffer *)m_inputBokehProgram->initializeTileData(rect);
|
||||
data->size = (MemoryBuffer *)m_inputSizeProgram->initializeTileData(rect);
|
||||
|
||||
rcti rect2;
|
||||
this->determineDependingAreaOfInterest(
|
||||
rect, (ReadBufferOperation *)this->m_inputSizeProgram, &rect2);
|
||||
this->determineDependingAreaOfInterest(rect, (ReadBufferOperation *)m_inputSizeProgram, &rect2);
|
||||
|
||||
const float max_dim = MAX2(this->getWidth(), this->getHeight());
|
||||
const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
|
||||
const float scalar = m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
|
||||
|
||||
data->maxBlurScalar = (int)(data->size->get_max_value(rect2) * scalar);
|
||||
CLAMP(data->maxBlurScalar, 1.0f, this->m_maxBlur);
|
||||
CLAMP(data->maxBlurScalar, 1.0f, m_maxBlur);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -102,7 +101,7 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
|
||||
float color_accum[4];
|
||||
|
||||
const float max_dim = MAX2(getWidth(), getHeight());
|
||||
const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
|
||||
const float scalar = m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
|
||||
int maxBlurScalar = tileData->maxBlurScalar;
|
||||
|
||||
BLI_assert(inputBokehBuffer->getWidth() == COM_BLUR_BOKEH_PIXELS);
|
||||
@@ -110,10 +109,10 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
|
||||
|
||||
#ifdef COM_DEFOCUS_SEARCH
|
||||
float search[4];
|
||||
this->m_inputSearchProgram->read(search,
|
||||
x / InverseSearchRadiusOperation::DIVIDER,
|
||||
y / InverseSearchRadiusOperation::DIVIDER,
|
||||
nullptr);
|
||||
m_inputSearchProgram->read(search,
|
||||
x / InverseSearchRadiusOperation::DIVIDER,
|
||||
y / InverseSearchRadiusOperation::DIVIDER,
|
||||
nullptr);
|
||||
int minx = search[0];
|
||||
int miny = search[1];
|
||||
int maxx = search[2];
|
||||
@@ -136,7 +135,7 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
|
||||
const int addYStepValue = addXStepValue;
|
||||
const int addXStepColor = addXStepValue * COM_DATA_TYPE_COLOR_CHANNELS;
|
||||
|
||||
if (size_center > this->m_threshold) {
|
||||
if (size_center > m_threshold) {
|
||||
for (int ny = miny; ny < maxy; ny += addYStepValue) {
|
||||
float dy = ny - y;
|
||||
int offsetValueNy = ny * inputSizeBuffer->getWidth();
|
||||
@@ -145,7 +144,7 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
|
||||
for (int nx = minx; nx < maxx; nx += addXStepValue) {
|
||||
if (nx != x || ny != y) {
|
||||
float size = MIN2(inputSizeFloatBuffer[offsetValueNxNy] * scalar, size_center);
|
||||
if (size > this->m_threshold) {
|
||||
if (size > m_threshold) {
|
||||
float dx = nx - x;
|
||||
if (size > fabsf(dx) && size > fabsf(dy)) {
|
||||
float uv[2] = {
|
||||
@@ -172,9 +171,9 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
|
||||
output[3] = color_accum[3] / multiplier_accum[3];
|
||||
|
||||
/* blend in out values over the threshold, otherwise we get sharp, ugly transitions */
|
||||
if ((size_center > this->m_threshold) && (size_center < this->m_threshold * 2.0f)) {
|
||||
if ((size_center > m_threshold) && (size_center < m_threshold * 2.0f)) {
|
||||
/* factor from 0-1 */
|
||||
float fac = (size_center - this->m_threshold) / this->m_threshold;
|
||||
float fac = (size_center - m_threshold) / m_threshold;
|
||||
interp_v4_v4v4(output, readColor, output, fac);
|
||||
}
|
||||
}
|
||||
@@ -191,22 +190,21 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
|
||||
|
||||
cl_int step = this->getStep();
|
||||
cl_int maxBlur;
|
||||
cl_float threshold = this->m_threshold;
|
||||
cl_float threshold = m_threshold;
|
||||
|
||||
MemoryBuffer *sizeMemoryBuffer = this->m_inputSizeProgram->getInputMemoryBuffer(
|
||||
inputMemoryBuffers);
|
||||
MemoryBuffer *sizeMemoryBuffer = m_inputSizeProgram->getInputMemoryBuffer(inputMemoryBuffers);
|
||||
|
||||
const float max_dim = MAX2(getWidth(), getHeight());
|
||||
cl_float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
|
||||
cl_float scalar = m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
|
||||
|
||||
maxBlur = (cl_int)min_ff(sizeMemoryBuffer->get_max_value() * scalar, (float)this->m_maxBlur);
|
||||
maxBlur = (cl_int)min_ff(sizeMemoryBuffer->get_max_value() * scalar, (float)m_maxBlur);
|
||||
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
|
||||
defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, m_inputProgram);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
defocusKernel, 1, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
|
||||
defocusKernel, 1, -1, clMemToCleanUp, inputMemoryBuffers, m_inputBokehProgram);
|
||||
device->COM_clAttachMemoryBufferToKernelParameter(
|
||||
defocusKernel, 2, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputSizeProgram);
|
||||
defocusKernel, 2, 4, clMemToCleanUp, inputMemoryBuffers, m_inputSizeProgram);
|
||||
device->COM_clAttachOutputMemoryBufferToKernelParameter(defocusKernel, 3, clOutputBuffer);
|
||||
device->COM_clAttachMemoryBufferOffsetToKernelParameter(defocusKernel, 5, outputMemoryBuffer);
|
||||
clSetKernelArg(defocusKernel, 6, sizeof(cl_int), &step);
|
||||
@@ -220,11 +218,11 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
|
||||
|
||||
void VariableSizeBokehBlurOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputProgram = nullptr;
|
||||
this->m_inputBokehProgram = nullptr;
|
||||
this->m_inputSizeProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
m_inputBokehProgram = nullptr;
|
||||
m_inputSizeProgram = nullptr;
|
||||
#ifdef COM_DEFOCUS_SEARCH
|
||||
this->m_inputSearchProgram = nullptr;
|
||||
m_inputSearchProgram = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -235,8 +233,8 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(
|
||||
rcti bokehInput;
|
||||
|
||||
const float max_dim = MAX2(getWidth(), getHeight());
|
||||
const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
|
||||
int maxBlurScalar = this->m_maxBlur * scalar;
|
||||
const float scalar = m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
|
||||
int maxBlurScalar = m_maxBlur * scalar;
|
||||
|
||||
newInput.xmax = input->xmax + maxBlurScalar + 2;
|
||||
newInput.xmin = input->xmin - maxBlurScalar + 2;
|
||||
@@ -439,12 +437,12 @@ InverseSearchRadiusOperation::InverseSearchRadiusOperation()
|
||||
this->addInputSocket(DataType::Value, ResizeMode::Align); /* Radius. */
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->flags.complex = true;
|
||||
this->m_inputRadius = nullptr;
|
||||
m_inputRadius = nullptr;
|
||||
}
|
||||
|
||||
void InverseSearchRadiusOperation::initExecution()
|
||||
{
|
||||
this->m_inputRadius = this->getInputSocketReader(0);
|
||||
m_inputRadius = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
|
||||
@@ -452,8 +450,8 @@ void *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
|
||||
MemoryBuffer *data = new MemoryBuffer(DataType::Color, rect);
|
||||
float *buffer = data->getBuffer();
|
||||
int x, y;
|
||||
int width = this->m_inputRadius->getWidth();
|
||||
int height = this->m_inputRadius->getHeight();
|
||||
int width = m_inputRadius->getWidth();
|
||||
int height = m_inputRadius->getHeight();
|
||||
float temp[4];
|
||||
int offset = 0;
|
||||
for (y = rect->ymin; y < rect->ymax; y++) {
|
||||
@@ -478,7 +476,7 @@ void *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
|
||||
|
||||
for (int x2 = 0; x2 < DIVIDER; x2++) {
|
||||
for (int y2 = 0; y2 < DIVIDER; y2++) {
|
||||
this->m_inputRadius->read(temp, rx + x2, ry + y2, PixelSampler::Nearest);
|
||||
m_inputRadius->read(temp, rx + x2, ry + y2, PixelSampler::Nearest);
|
||||
if (radius < temp[0]) {
|
||||
radius = temp[0];
|
||||
maxx = x2;
|
||||
@@ -519,7 +517,7 @@ void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, void *data)
|
||||
|
||||
void InverseSearchRadiusOperation::deinitExecution()
|
||||
{
|
||||
this->m_inputRadius = nullptr;
|
||||
m_inputRadius = nullptr;
|
||||
}
|
||||
|
||||
void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[2],
|
||||
|
||||
@@ -72,17 +72,17 @@ class VariableSizeBokehBlurOperation : public MultiThreadedOperation, public Qua
|
||||
|
||||
void setMaxBlur(int maxRadius)
|
||||
{
|
||||
this->m_maxBlur = maxRadius;
|
||||
m_maxBlur = maxRadius;
|
||||
}
|
||||
|
||||
void setThreshold(float threshold)
|
||||
{
|
||||
this->m_threshold = threshold;
|
||||
m_threshold = threshold;
|
||||
}
|
||||
|
||||
void setDoScaleSize(bool scale_size)
|
||||
{
|
||||
this->m_do_size_scale = scale_size;
|
||||
m_do_size_scale = scale_size;
|
||||
}
|
||||
|
||||
void executeOpenCL(OpenCLDevice *device,
|
||||
@@ -134,7 +134,7 @@ class InverseSearchRadiusOperation : public NodeOperation {
|
||||
|
||||
void setMaxBlur(int maxRadius)
|
||||
{
|
||||
this->m_maxBlur = maxRadius;
|
||||
m_maxBlur = maxRadius;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -46,21 +46,21 @@ VectorBlurOperation::VectorBlurOperation()
|
||||
this->addInputSocket(DataType::Value); /* ZBUF */
|
||||
this->addInputSocket(DataType::Color); /* SPEED */
|
||||
this->addOutputSocket(DataType::Color);
|
||||
this->m_settings = nullptr;
|
||||
this->m_cachedInstance = nullptr;
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputSpeedProgram = nullptr;
|
||||
this->m_inputZProgram = nullptr;
|
||||
m_settings = nullptr;
|
||||
m_cachedInstance = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputSpeedProgram = nullptr;
|
||||
m_inputZProgram = nullptr;
|
||||
flags.complex = true;
|
||||
flags.is_fullframe_operation = true;
|
||||
}
|
||||
void VectorBlurOperation::initExecution()
|
||||
{
|
||||
initMutex();
|
||||
this->m_inputImageProgram = getInputSocketReader(0);
|
||||
this->m_inputZProgram = getInputSocketReader(1);
|
||||
this->m_inputSpeedProgram = getInputSocketReader(2);
|
||||
this->m_cachedInstance = nullptr;
|
||||
m_inputImageProgram = getInputSocketReader(0);
|
||||
m_inputZProgram = getInputSocketReader(1);
|
||||
m_inputSpeedProgram = getInputSocketReader(2);
|
||||
m_cachedInstance = nullptr;
|
||||
QualityStepHelper::initExecution(COM_QH_INCREASE);
|
||||
}
|
||||
|
||||
@@ -74,38 +74,38 @@ void VectorBlurOperation::executePixel(float output[4], int x, int y, void *data
|
||||
void VectorBlurOperation::deinitExecution()
|
||||
{
|
||||
deinitMutex();
|
||||
this->m_inputImageProgram = nullptr;
|
||||
this->m_inputSpeedProgram = nullptr;
|
||||
this->m_inputZProgram = nullptr;
|
||||
if (this->m_cachedInstance) {
|
||||
MEM_freeN(this->m_cachedInstance);
|
||||
this->m_cachedInstance = nullptr;
|
||||
m_inputImageProgram = nullptr;
|
||||
m_inputSpeedProgram = nullptr;
|
||||
m_inputZProgram = nullptr;
|
||||
if (m_cachedInstance) {
|
||||
MEM_freeN(m_cachedInstance);
|
||||
m_cachedInstance = nullptr;
|
||||
}
|
||||
}
|
||||
void *VectorBlurOperation::initializeTileData(rcti *rect)
|
||||
{
|
||||
if (this->m_cachedInstance) {
|
||||
return this->m_cachedInstance;
|
||||
if (m_cachedInstance) {
|
||||
return m_cachedInstance;
|
||||
}
|
||||
|
||||
lockMutex();
|
||||
if (this->m_cachedInstance == nullptr) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
|
||||
MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect);
|
||||
MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect);
|
||||
if (m_cachedInstance == nullptr) {
|
||||
MemoryBuffer *tile = (MemoryBuffer *)m_inputImageProgram->initializeTileData(rect);
|
||||
MemoryBuffer *speed = (MemoryBuffer *)m_inputSpeedProgram->initializeTileData(rect);
|
||||
MemoryBuffer *z = (MemoryBuffer *)m_inputZProgram->initializeTileData(rect);
|
||||
float *data = (float *)MEM_dupallocN(tile->getBuffer());
|
||||
this->generateVectorBlur(data, tile, speed, z);
|
||||
this->m_cachedInstance = data;
|
||||
m_cachedInstance = data;
|
||||
}
|
||||
unlockMutex();
|
||||
return this->m_cachedInstance;
|
||||
return m_cachedInstance;
|
||||
}
|
||||
|
||||
bool VectorBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/,
|
||||
ReadBufferOperation *readOperation,
|
||||
rcti *output)
|
||||
{
|
||||
if (this->m_cachedInstance == nullptr) {
|
||||
if (m_cachedInstance == nullptr) {
|
||||
rcti newInput;
|
||||
newInput.xmax = this->getWidth();
|
||||
newInput.xmin = 0;
|
||||
@@ -165,11 +165,11 @@ void VectorBlurOperation::generateVectorBlur(float *data,
|
||||
MemoryBuffer *inputZ)
|
||||
{
|
||||
NodeBlurData blurdata;
|
||||
blurdata.samples = this->m_settings->samples / QualityStepHelper::getStep();
|
||||
blurdata.maxspeed = this->m_settings->maxspeed;
|
||||
blurdata.minspeed = this->m_settings->minspeed;
|
||||
blurdata.curved = this->m_settings->curved;
|
||||
blurdata.fac = this->m_settings->fac;
|
||||
blurdata.samples = m_settings->samples / QualityStepHelper::getStep();
|
||||
blurdata.maxspeed = m_settings->maxspeed;
|
||||
blurdata.minspeed = m_settings->minspeed;
|
||||
blurdata.curved = m_settings->curved;
|
||||
blurdata.fac = m_settings->fac;
|
||||
zbuf_accumulate_vecblur(&blurdata,
|
||||
this->getWidth(),
|
||||
this->getHeight(),
|
||||
|
||||
@@ -66,7 +66,7 @@ class VectorBlurOperation : public NodeOperation, public QualityStepHelper {
|
||||
|
||||
void setVectorBlurSettings(NodeBlurData *settings)
|
||||
{
|
||||
this->m_settings = settings;
|
||||
m_settings = settings;
|
||||
}
|
||||
bool determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
|
||||
@@ -27,12 +27,12 @@ VectorCurveOperation::VectorCurveOperation()
|
||||
this->addInputSocket(DataType::Vector);
|
||||
this->addOutputSocket(DataType::Vector);
|
||||
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
void VectorCurveOperation::initExecution()
|
||||
{
|
||||
CurveBaseOperation::initExecution();
|
||||
this->m_inputProgram = this->getInputSocketReader(0);
|
||||
m_inputProgram = this->getInputSocketReader(0);
|
||||
}
|
||||
|
||||
void VectorCurveOperation::executePixelSampled(float output[4],
|
||||
@@ -42,22 +42,22 @@ void VectorCurveOperation::executePixelSampled(float output[4],
|
||||
{
|
||||
float input[4];
|
||||
|
||||
this->m_inputProgram->readSampled(input, x, y, sampler);
|
||||
m_inputProgram->readSampled(input, x, y, sampler);
|
||||
|
||||
BKE_curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input);
|
||||
BKE_curvemapping_evaluate_premulRGBF(m_curveMapping, output, input);
|
||||
}
|
||||
|
||||
void VectorCurveOperation::deinitExecution()
|
||||
{
|
||||
CurveBaseOperation::deinitExecution();
|
||||
this->m_inputProgram = nullptr;
|
||||
m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
void VectorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
CurveMapping *curve_map = this->m_curveMapping;
|
||||
CurveMapping *curve_map = m_curveMapping;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
BKE_curvemapping_evaluate_premulRGBF(curve_map, it.out, it.in(0));
|
||||
}
|
||||
|
||||
@@ -33,23 +33,23 @@ ViewerOperation::ViewerOperation()
|
||||
{
|
||||
this->setImage(nullptr);
|
||||
this->setImageUser(nullptr);
|
||||
this->m_outputBuffer = nullptr;
|
||||
this->m_depthBuffer = nullptr;
|
||||
this->m_active = false;
|
||||
this->m_doDepthBuffer = false;
|
||||
this->m_viewSettings = nullptr;
|
||||
this->m_displaySettings = nullptr;
|
||||
this->m_useAlphaInput = false;
|
||||
m_outputBuffer = nullptr;
|
||||
m_depthBuffer = nullptr;
|
||||
m_active = false;
|
||||
m_doDepthBuffer = false;
|
||||
m_viewSettings = nullptr;
|
||||
m_displaySettings = nullptr;
|
||||
m_useAlphaInput = false;
|
||||
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addInputSocket(DataType::Value);
|
||||
|
||||
this->m_imageInput = nullptr;
|
||||
this->m_alphaInput = nullptr;
|
||||
this->m_depthInput = nullptr;
|
||||
this->m_rd = nullptr;
|
||||
this->m_viewName = nullptr;
|
||||
m_imageInput = nullptr;
|
||||
m_alphaInput = nullptr;
|
||||
m_depthInput = nullptr;
|
||||
m_rd = nullptr;
|
||||
m_viewName = nullptr;
|
||||
flags.use_viewer_border = true;
|
||||
flags.is_viewer_operation = true;
|
||||
}
|
||||
@@ -57,10 +57,10 @@ ViewerOperation::ViewerOperation()
|
||||
void ViewerOperation::initExecution()
|
||||
{
|
||||
/* When initializing the tree during initial load the width and height can be zero. */
|
||||
this->m_imageInput = getInputSocketReader(0);
|
||||
this->m_alphaInput = getInputSocketReader(1);
|
||||
this->m_depthInput = getInputSocketReader(2);
|
||||
this->m_doDepthBuffer = (this->m_depthInput != nullptr);
|
||||
m_imageInput = getInputSocketReader(0);
|
||||
m_alphaInput = getInputSocketReader(1);
|
||||
m_depthInput = getInputSocketReader(2);
|
||||
m_doDepthBuffer = (m_depthInput != nullptr);
|
||||
|
||||
if (isActiveViewerOutput() && !exec_system_->is_breaked()) {
|
||||
initImage();
|
||||
@@ -69,16 +69,16 @@ void ViewerOperation::initExecution()
|
||||
|
||||
void ViewerOperation::deinitExecution()
|
||||
{
|
||||
this->m_imageInput = nullptr;
|
||||
this->m_alphaInput = nullptr;
|
||||
this->m_depthInput = nullptr;
|
||||
this->m_outputBuffer = nullptr;
|
||||
m_imageInput = nullptr;
|
||||
m_alphaInput = nullptr;
|
||||
m_depthInput = nullptr;
|
||||
m_outputBuffer = nullptr;
|
||||
}
|
||||
|
||||
void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
{
|
||||
float *buffer = this->m_outputBuffer;
|
||||
float *depthbuffer = this->m_depthBuffer;
|
||||
float *buffer = m_outputBuffer;
|
||||
float *depthbuffer = m_depthBuffer;
|
||||
if (!buffer) {
|
||||
return;
|
||||
}
|
||||
@@ -97,12 +97,12 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
|
||||
for (y = y1; y < y2 && (!breaked); y++) {
|
||||
for (x = x1; x < x2; x++) {
|
||||
this->m_imageInput->readSampled(&(buffer[offset4]), x, y, PixelSampler::Nearest);
|
||||
if (this->m_useAlphaInput) {
|
||||
this->m_alphaInput->readSampled(alpha, x, y, PixelSampler::Nearest);
|
||||
m_imageInput->readSampled(&(buffer[offset4]), x, y, PixelSampler::Nearest);
|
||||
if (m_useAlphaInput) {
|
||||
m_alphaInput->readSampled(alpha, x, y, PixelSampler::Nearest);
|
||||
buffer[offset4 + 3] = alpha[0];
|
||||
}
|
||||
this->m_depthInput->readSampled(depth, x, y, PixelSampler::Nearest);
|
||||
m_depthInput->readSampled(depth, x, y, PixelSampler::Nearest);
|
||||
depthbuffer[offset] = depth[0];
|
||||
|
||||
offset++;
|
||||
@@ -119,8 +119,8 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
|
||||
void ViewerOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
const int sceneRenderWidth = this->m_rd->xsch * this->m_rd->size / 100;
|
||||
const int sceneRenderHeight = this->m_rd->ysch * this->m_rd->size / 100;
|
||||
const int sceneRenderWidth = m_rd->xsch * m_rd->size / 100;
|
||||
const int sceneRenderHeight = m_rd->ysch * m_rd->size / 100;
|
||||
|
||||
rcti local_preferred = preferred_area;
|
||||
local_preferred.xmax = local_preferred.xmin + sceneRenderWidth;
|
||||
@@ -131,20 +131,20 @@ void ViewerOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
|
||||
void ViewerOperation::initImage()
|
||||
{
|
||||
Image *ima = this->m_image;
|
||||
ImageUser iuser = *this->m_imageUser;
|
||||
Image *ima = m_image;
|
||||
ImageUser iuser = *m_imageUser;
|
||||
void *lock;
|
||||
ImBuf *ibuf;
|
||||
|
||||
/* make sure the image has the correct number of views */
|
||||
if (ima && BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
|
||||
BKE_image_ensure_viewer_views(this->m_rd, ima, this->m_imageUser);
|
||||
if (ima && BKE_scene_multiview_is_render_view_first(m_rd, m_viewName)) {
|
||||
BKE_image_ensure_viewer_views(m_rd, ima, m_imageUser);
|
||||
}
|
||||
|
||||
BLI_thread_lock(LOCK_DRAW_IMAGE);
|
||||
|
||||
/* local changes to the original ImageUser */
|
||||
iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
|
||||
iuser.multi_index = BKE_scene_multiview_view_id_get(m_rd, m_viewName);
|
||||
ibuf = BKE_image_acquire_ibuf(ima, &iuser, &lock);
|
||||
|
||||
if (!ibuf) {
|
||||
@@ -184,16 +184,16 @@ void ViewerOperation::initImage()
|
||||
}
|
||||
|
||||
/* now we combine the input with ibuf */
|
||||
this->m_outputBuffer = ibuf->rect_float;
|
||||
m_outputBuffer = ibuf->rect_float;
|
||||
|
||||
/* needed for display buffer update */
|
||||
this->m_ibuf = ibuf;
|
||||
m_ibuf = ibuf;
|
||||
|
||||
if (m_doDepthBuffer) {
|
||||
this->m_depthBuffer = ibuf->zbuf_float;
|
||||
m_depthBuffer = ibuf->zbuf_float;
|
||||
}
|
||||
|
||||
BKE_image_release_ibuf(this->m_image, this->m_ibuf, lock);
|
||||
BKE_image_release_ibuf(m_image, m_ibuf, lock);
|
||||
|
||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||
}
|
||||
@@ -205,19 +205,19 @@ void ViewerOperation::updateImage(const rcti *rect)
|
||||
}
|
||||
|
||||
float *buffer = m_outputBuffer;
|
||||
IMB_partial_display_buffer_update(this->m_ibuf,
|
||||
IMB_partial_display_buffer_update(m_ibuf,
|
||||
buffer,
|
||||
nullptr,
|
||||
display_width_,
|
||||
0,
|
||||
0,
|
||||
this->m_viewSettings,
|
||||
this->m_displaySettings,
|
||||
m_viewSettings,
|
||||
m_displaySettings,
|
||||
rect->xmin,
|
||||
rect->ymin,
|
||||
rect->xmax,
|
||||
rect->ymax);
|
||||
this->m_image->gpuflag |= IMA_GPU_REFRESH;
|
||||
m_image->gpuflag |= IMA_GPU_REFRESH;
|
||||
this->updateDraw();
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ void ViewerOperation::update_memory_buffer_partial(MemoryBuffer *UNUSED(output),
|
||||
m_outputBuffer, COM_DATA_TYPE_COLOR_CHANNELS, display_width_, display_height_);
|
||||
const MemoryBuffer *input_image = inputs[0];
|
||||
output_buffer.copy_from(input_image, area, offset_x, offset_y);
|
||||
if (this->m_useAlphaInput) {
|
||||
if (m_useAlphaInput) {
|
||||
const MemoryBuffer *input_alpha = inputs[1];
|
||||
output_buffer.copy_from(
|
||||
input_alpha, area, 0, COM_DATA_TYPE_VALUE_CHANNELS, offset_x, offset_y, 3);
|
||||
|
||||
@@ -68,65 +68,65 @@ class ViewerOperation : public MultiThreadedOperation {
|
||||
}
|
||||
void setImage(Image *image)
|
||||
{
|
||||
this->m_image = image;
|
||||
m_image = image;
|
||||
}
|
||||
void setImageUser(ImageUser *imageUser)
|
||||
{
|
||||
this->m_imageUser = imageUser;
|
||||
m_imageUser = imageUser;
|
||||
}
|
||||
bool isActiveViewerOutput() const override
|
||||
{
|
||||
return this->m_active;
|
||||
return m_active;
|
||||
}
|
||||
void setActive(bool active)
|
||||
{
|
||||
this->m_active = active;
|
||||
m_active = active;
|
||||
}
|
||||
void setCenterX(float centerX)
|
||||
{
|
||||
this->m_centerX = centerX;
|
||||
m_centerX = centerX;
|
||||
}
|
||||
void setCenterY(float centerY)
|
||||
{
|
||||
this->m_centerY = centerY;
|
||||
m_centerY = centerY;
|
||||
}
|
||||
void setChunkOrder(ChunkOrdering tileOrder)
|
||||
{
|
||||
this->m_chunkOrder = tileOrder;
|
||||
m_chunkOrder = tileOrder;
|
||||
}
|
||||
float getCenterX() const
|
||||
{
|
||||
return this->m_centerX;
|
||||
return m_centerX;
|
||||
}
|
||||
float getCenterY() const
|
||||
{
|
||||
return this->m_centerY;
|
||||
return m_centerY;
|
||||
}
|
||||
ChunkOrdering getChunkOrder() const
|
||||
{
|
||||
return this->m_chunkOrder;
|
||||
return m_chunkOrder;
|
||||
}
|
||||
eCompositorPriority getRenderPriority() const override;
|
||||
void setUseAlphaInput(bool value)
|
||||
{
|
||||
this->m_useAlphaInput = value;
|
||||
m_useAlphaInput = value;
|
||||
}
|
||||
void setRenderData(const RenderData *rd)
|
||||
{
|
||||
this->m_rd = rd;
|
||||
m_rd = rd;
|
||||
}
|
||||
void setViewName(const char *viewName)
|
||||
{
|
||||
this->m_viewName = viewName;
|
||||
m_viewName = viewName;
|
||||
}
|
||||
|
||||
void setViewSettings(const ColorManagedViewSettings *viewSettings)
|
||||
{
|
||||
this->m_viewSettings = viewSettings;
|
||||
m_viewSettings = viewSettings;
|
||||
}
|
||||
void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings)
|
||||
{
|
||||
this->m_displaySettings = displaySettings;
|
||||
m_displaySettings = displaySettings;
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace blender::compositor {
|
||||
|
||||
WrapOperation::WrapOperation(DataType datatype) : ReadBufferOperation(datatype)
|
||||
{
|
||||
this->m_wrappingType = CMP_NODE_WRAP_NONE;
|
||||
m_wrappingType = CMP_NODE_WRAP_NONE;
|
||||
}
|
||||
|
||||
inline float WrapOperation::getWrappedOriginalXPos(float x)
|
||||
|
||||
@@ -24,16 +24,16 @@ namespace blender::compositor {
|
||||
WriteBufferOperation::WriteBufferOperation(DataType datatype)
|
||||
{
|
||||
this->addInputSocket(datatype);
|
||||
this->m_memoryProxy = new MemoryProxy(datatype);
|
||||
this->m_memoryProxy->setWriteBufferOperation(this);
|
||||
this->m_memoryProxy->setExecutor(nullptr);
|
||||
m_memoryProxy = new MemoryProxy(datatype);
|
||||
m_memoryProxy->setWriteBufferOperation(this);
|
||||
m_memoryProxy->setExecutor(nullptr);
|
||||
flags.is_write_buffer_operation = true;
|
||||
}
|
||||
WriteBufferOperation::~WriteBufferOperation()
|
||||
{
|
||||
if (this->m_memoryProxy) {
|
||||
delete this->m_memoryProxy;
|
||||
this->m_memoryProxy = nullptr;
|
||||
if (m_memoryProxy) {
|
||||
delete m_memoryProxy;
|
||||
m_memoryProxy = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,28 +42,28 @@ void WriteBufferOperation::executePixelSampled(float output[4],
|
||||
float y,
|
||||
PixelSampler sampler)
|
||||
{
|
||||
this->m_input->readSampled(output, x, y, sampler);
|
||||
m_input->readSampled(output, x, y, sampler);
|
||||
}
|
||||
|
||||
void WriteBufferOperation::initExecution()
|
||||
{
|
||||
this->m_input = this->getInputOperation(0);
|
||||
this->m_memoryProxy->allocate(this->getWidth(), this->getHeight());
|
||||
m_input = this->getInputOperation(0);
|
||||
m_memoryProxy->allocate(this->getWidth(), this->getHeight());
|
||||
}
|
||||
|
||||
void WriteBufferOperation::deinitExecution()
|
||||
{
|
||||
this->m_input = nullptr;
|
||||
this->m_memoryProxy->free();
|
||||
m_input = nullptr;
|
||||
m_memoryProxy->free();
|
||||
}
|
||||
|
||||
void WriteBufferOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
|
||||
{
|
||||
MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer();
|
||||
MemoryBuffer *memoryBuffer = m_memoryProxy->getBuffer();
|
||||
float *buffer = memoryBuffer->getBuffer();
|
||||
const uint8_t num_channels = memoryBuffer->get_num_channels();
|
||||
if (this->m_input->get_flags().complex) {
|
||||
void *data = this->m_input->initializeTileData(rect);
|
||||
if (m_input->get_flags().complex) {
|
||||
void *data = m_input->initializeTileData(rect);
|
||||
int x1 = rect->xmin;
|
||||
int y1 = rect->ymin;
|
||||
int x2 = rect->xmax;
|
||||
@@ -74,7 +74,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/
|
||||
for (y = y1; y < y2 && (!breaked); y++) {
|
||||
int offset4 = (y * memoryBuffer->getWidth() + x1) * num_channels;
|
||||
for (x = x1; x < x2; x++) {
|
||||
this->m_input->read(&(buffer[offset4]), x, y, data);
|
||||
m_input->read(&(buffer[offset4]), x, y, data);
|
||||
offset4 += num_channels;
|
||||
}
|
||||
if (isBraked()) {
|
||||
@@ -82,7 +82,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/
|
||||
}
|
||||
}
|
||||
if (data) {
|
||||
this->m_input->deinitializeTileData(rect, data);
|
||||
m_input->deinitializeTileData(rect, data);
|
||||
data = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/
|
||||
for (y = y1; y < y2 && (!breaked); y++) {
|
||||
int offset4 = (y * memoryBuffer->getWidth() + x1) * num_channels;
|
||||
for (x = x1; x < x2; x++) {
|
||||
this->m_input->readSampled(&(buffer[offset4]), x, y, PixelSampler::Nearest);
|
||||
m_input->readSampled(&(buffer[offset4]), x, y, PixelSampler::Nearest);
|
||||
offset4 += num_channels;
|
||||
}
|
||||
if (isBraked()) {
|
||||
@@ -147,12 +147,12 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device,
|
||||
clMemToCleanUp->push_back(clOutputBuffer);
|
||||
std::list<cl_kernel> *clKernelsToCleanUp = new std::list<cl_kernel>();
|
||||
|
||||
this->m_input->executeOpenCL(device,
|
||||
outputBuffer,
|
||||
clOutputBuffer,
|
||||
inputMemoryBuffers,
|
||||
clMemToCleanUp,
|
||||
clKernelsToCleanUp);
|
||||
m_input->executeOpenCL(device,
|
||||
outputBuffer,
|
||||
clOutputBuffer,
|
||||
inputMemoryBuffers,
|
||||
clMemToCleanUp,
|
||||
clKernelsToCleanUp);
|
||||
|
||||
/* STEP 3 */
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class WriteBufferOperation : public NodeOperation {
|
||||
~WriteBufferOperation();
|
||||
MemoryProxy *getMemoryProxy()
|
||||
{
|
||||
return this->m_memoryProxy;
|
||||
return m_memoryProxy;
|
||||
}
|
||||
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
|
||||
bool isSingleValue() const
|
||||
|
||||
@@ -28,19 +28,19 @@ ZCombineOperation::ZCombineOperation()
|
||||
this->addInputSocket(DataType::Value);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_image1Reader = nullptr;
|
||||
this->m_depth1Reader = nullptr;
|
||||
this->m_image2Reader = nullptr;
|
||||
this->m_depth2Reader = nullptr;
|
||||
m_image1Reader = nullptr;
|
||||
m_depth1Reader = nullptr;
|
||||
m_image2Reader = nullptr;
|
||||
m_depth2Reader = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
void ZCombineOperation::initExecution()
|
||||
{
|
||||
this->m_image1Reader = this->getInputSocketReader(0);
|
||||
this->m_depth1Reader = this->getInputSocketReader(1);
|
||||
this->m_image2Reader = this->getInputSocketReader(2);
|
||||
this->m_depth2Reader = this->getInputSocketReader(3);
|
||||
m_image1Reader = this->getInputSocketReader(0);
|
||||
m_depth1Reader = this->getInputSocketReader(1);
|
||||
m_image2Reader = this->getInputSocketReader(2);
|
||||
m_depth2Reader = this->getInputSocketReader(3);
|
||||
}
|
||||
|
||||
void ZCombineOperation::executePixelSampled(float output[4],
|
||||
@@ -51,13 +51,13 @@ void ZCombineOperation::executePixelSampled(float output[4],
|
||||
float depth1[4];
|
||||
float depth2[4];
|
||||
|
||||
this->m_depth1Reader->readSampled(depth1, x, y, sampler);
|
||||
this->m_depth2Reader->readSampled(depth2, x, y, sampler);
|
||||
m_depth1Reader->readSampled(depth1, x, y, sampler);
|
||||
m_depth2Reader->readSampled(depth2, x, y, sampler);
|
||||
if (depth1[0] < depth2[0]) {
|
||||
this->m_image1Reader->readSampled(output, x, y, sampler);
|
||||
m_image1Reader->readSampled(output, x, y, sampler);
|
||||
}
|
||||
else {
|
||||
this->m_image2Reader->readSampled(output, x, y, sampler);
|
||||
m_image2Reader->readSampled(output, x, y, sampler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,15 +83,15 @@ void ZCombineAlphaOperation::executePixelSampled(float output[4],
|
||||
float color1[4];
|
||||
float color2[4];
|
||||
|
||||
this->m_depth1Reader->readSampled(depth1, x, y, sampler);
|
||||
this->m_depth2Reader->readSampled(depth2, x, y, sampler);
|
||||
m_depth1Reader->readSampled(depth1, x, y, sampler);
|
||||
m_depth2Reader->readSampled(depth2, x, y, sampler);
|
||||
if (depth1[0] <= depth2[0]) {
|
||||
this->m_image1Reader->readSampled(color1, x, y, sampler);
|
||||
this->m_image2Reader->readSampled(color2, x, y, sampler);
|
||||
m_image1Reader->readSampled(color1, x, y, sampler);
|
||||
m_image2Reader->readSampled(color2, x, y, sampler);
|
||||
}
|
||||
else {
|
||||
this->m_image1Reader->readSampled(color2, x, y, sampler);
|
||||
this->m_image2Reader->readSampled(color1, x, y, sampler);
|
||||
m_image1Reader->readSampled(color2, x, y, sampler);
|
||||
m_image2Reader->readSampled(color1, x, y, sampler);
|
||||
}
|
||||
float fac = color1[3];
|
||||
float ifac = 1.0f - fac;
|
||||
@@ -129,10 +129,10 @@ void ZCombineAlphaOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
|
||||
void ZCombineOperation::deinitExecution()
|
||||
{
|
||||
this->m_image1Reader = nullptr;
|
||||
this->m_depth1Reader = nullptr;
|
||||
this->m_image2Reader = nullptr;
|
||||
this->m_depth2Reader = nullptr;
|
||||
m_image1Reader = nullptr;
|
||||
m_depth1Reader = nullptr;
|
||||
m_image2Reader = nullptr;
|
||||
m_depth2Reader = nullptr;
|
||||
}
|
||||
|
||||
// MASK combine
|
||||
@@ -143,16 +143,16 @@ ZCombineMaskOperation::ZCombineMaskOperation()
|
||||
this->addInputSocket(DataType::Color);
|
||||
this->addOutputSocket(DataType::Color);
|
||||
|
||||
this->m_maskReader = nullptr;
|
||||
this->m_image1Reader = nullptr;
|
||||
this->m_image2Reader = nullptr;
|
||||
m_maskReader = nullptr;
|
||||
m_image1Reader = nullptr;
|
||||
m_image2Reader = nullptr;
|
||||
}
|
||||
|
||||
void ZCombineMaskOperation::initExecution()
|
||||
{
|
||||
this->m_maskReader = this->getInputSocketReader(0);
|
||||
this->m_image1Reader = this->getInputSocketReader(1);
|
||||
this->m_image2Reader = this->getInputSocketReader(2);
|
||||
m_maskReader = this->getInputSocketReader(0);
|
||||
m_image1Reader = this->getInputSocketReader(1);
|
||||
m_image2Reader = this->getInputSocketReader(2);
|
||||
}
|
||||
|
||||
void ZCombineMaskOperation::executePixelSampled(float output[4],
|
||||
@@ -164,9 +164,9 @@ void ZCombineMaskOperation::executePixelSampled(float output[4],
|
||||
float color1[4];
|
||||
float color2[4];
|
||||
|
||||
this->m_maskReader->readSampled(mask, x, y, sampler);
|
||||
this->m_image1Reader->readSampled(color1, x, y, sampler);
|
||||
this->m_image2Reader->readSampled(color2, x, y, sampler);
|
||||
m_maskReader->readSampled(mask, x, y, sampler);
|
||||
m_image1Reader->readSampled(color1, x, y, sampler);
|
||||
m_image2Reader->readSampled(color2, x, y, sampler);
|
||||
|
||||
interp_v4_v4v4(output, color1, color2, 1.0f - mask[0]);
|
||||
}
|
||||
@@ -192,9 +192,9 @@ void ZCombineMaskAlphaOperation::executePixelSampled(float output[4],
|
||||
float color1[4];
|
||||
float color2[4];
|
||||
|
||||
this->m_maskReader->readSampled(mask, x, y, sampler);
|
||||
this->m_image1Reader->readSampled(color1, x, y, sampler);
|
||||
this->m_image2Reader->readSampled(color2, x, y, sampler);
|
||||
m_maskReader->readSampled(mask, x, y, sampler);
|
||||
m_image1Reader->readSampled(color1, x, y, sampler);
|
||||
m_image2Reader->readSampled(color2, x, y, sampler);
|
||||
|
||||
float fac = (1.0f - mask[0]) * (1.0f - color1[3]) + mask[0] * color2[3];
|
||||
float mfac = 1.0f - fac;
|
||||
@@ -225,9 +225,9 @@ void ZCombineMaskAlphaOperation::update_memory_buffer_partial(MemoryBuffer *outp
|
||||
|
||||
void ZCombineMaskOperation::deinitExecution()
|
||||
{
|
||||
this->m_image1Reader = nullptr;
|
||||
this->m_maskReader = nullptr;
|
||||
this->m_image2Reader = nullptr;
|
||||
m_image1Reader = nullptr;
|
||||
m_maskReader = nullptr;
|
||||
m_image2Reader = nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
Reference in New Issue
Block a user