Cleanup: Compositor: silence warning 'size' is deprecated

Decouple Node data from Operation. This avoids usage of deprecated members, e.g. through copying NodeKuwaharaData.

Pull Request: https://projects.blender.org/blender/blender/pulls/118971
This commit is contained in:
Habib Gahbiche 2024-03-02 13:11:16 +01:00 committed by Habib Gahbiche
parent 14a8149318
commit 38b27a9ea9
5 changed files with 23 additions and 11 deletions

View File

@ -2,8 +2,6 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#define DNA_DEPRECATED_ALLOW /* For copy of deprecated NodeKuwaharaData members. */
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
@ -26,7 +24,7 @@ void KuwaharaNode::convert_to_operations(NodeConverter &converter,
switch (data->variation) {
case CMP_NODE_KUWAHARA_CLASSIC: {
KuwaharaClassicOperation *kuwahara_classic = new KuwaharaClassicOperation();
kuwahara_classic->set_data(data);
kuwahara_classic->set_high_precision(data->high_precision);
converter.add_operation(kuwahara_classic);
converter.map_input_socket(get_input_socket(0), kuwahara_classic->get_input_socket(0));
converter.map_input_socket(get_input_socket(1), kuwahara_classic->get_input_socket(1));
@ -78,7 +76,8 @@ void KuwaharaNode::convert_to_operations(NodeConverter &converter,
KuwaharaAnisotropicOperation *kuwahara_anisotropic_operation =
new KuwaharaAnisotropicOperation();
kuwahara_anisotropic_operation->data = *data;
kuwahara_anisotropic_operation->set_sharpness(data->sharpness);
kuwahara_anisotropic_operation->set_eccentricity(data->eccentricity);
converter.add_operation(kuwahara_anisotropic_operation);
converter.map_input_socket(get_input_socket(0),

View File

@ -279,7 +279,7 @@ void KuwaharaAnisotropicOperation::update_memory_buffer_partial(MemoryBuffer *ou
* zero to counter its exponential nature for more intuitive user control. */
float KuwaharaAnisotropicOperation::get_sharpness()
{
return data.sharpness * data.sharpness * 16.0f;
return sharpness_ * sharpness_ * 16.0f;
}
/* The eccentricity controls how much the image anisotropy affects the eccentricity of the
@ -297,7 +297,17 @@ float KuwaharaAnisotropicOperation::get_sharpness()
* that of infinity. */
float KuwaharaAnisotropicOperation::get_eccentricity()
{
return 1.0f / math::max(0.01f, data.eccentricity);
return 1.0f / math::max(0.01f, eccentricity_);
}
void KuwaharaAnisotropicOperation::set_sharpness(float sharpness)
{
sharpness_ = sharpness;
}
void KuwaharaAnisotropicOperation::set_eccentricity(float eccentricity)
{
eccentricity_ = eccentricity;
}
} // namespace blender::compositor

View File

@ -12,7 +12,8 @@ namespace blender::compositor {
class KuwaharaAnisotropicOperation : public MultiThreadedOperation {
public:
NodeKuwaharaData data;
float sharpness_;
float eccentricity_;
KuwaharaAnisotropicOperation();
@ -21,6 +22,8 @@ class KuwaharaAnisotropicOperation : public MultiThreadedOperation {
Span<MemoryBuffer *> inputs) override;
float get_sharpness();
float get_eccentricity();
void set_sharpness(float sharpness);
void set_eccentricity(float eccentricity);
};
} // namespace blender::compositor

View File

@ -52,7 +52,7 @@ void KuwaharaClassicOperation::update_memory_buffer_partial(MemoryBuffer *output
/* For high radii, we accelerate the filter using a summed area table, making the filter
* execute in constant time as opposed to having quadratic complexity. Except if high precision
* is enabled, since summed area tables are less precise. */
if (!data_->high_precision && size > 5.0f) {
if (!high_precision_ && size > 5.0f) {
for (int q = 0; q < 4; q++) {
/* A fancy expression to compute the sign of the quadrant q. */
int2 sign = int2((q % 2) * 2 - 1, ((q / 2) * 2 - 1));

View File

@ -9,14 +9,14 @@
namespace blender::compositor {
class KuwaharaClassicOperation : public MultiThreadedOperation {
const NodeKuwaharaData *data_;
bool high_precision_;
public:
KuwaharaClassicOperation();
void set_data(const NodeKuwaharaData *data)
void set_high_precision(bool high_precision)
{
data_ = data;
high_precision_ = high_precision;
}
void update_memory_buffer_partial(MemoryBuffer *output,