style: unify identifier naming per updated conventions

Automated with clang-tidy readability-identifier-naming (config added to
.clang-tidy) plus scripted passes, per the updated rules now documented
in CONTRIBUTING.md:

- types (class/struct/enum/alias/template params): PascalCase
- functions, variables, members: snake_case (incl. rational -> Rational)
- private/protected members: trailing underscore; static member
  variables likewise (instance_, available_themes_)
- constants and enum values: snake_case (kLinear -> k_linear,
  F32P -> f32p); ALL_CAPS reserved for macros
- macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG ->
  OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE,
  include guards -> OAK_*)
- file names: all lowercase (Current/Plugin/OliveHost/OliveClip/
  OlivePluginInstance -> current/plugin/olivehost/oliveclip/
  oliveplugininstance)
- getters share the member name sans underscore, setters set_foo()
- Qt and third-party (OpenFX) virtual overrides and framework callbacks
  keep their original names (exempt in .clang-tidy)

Manual follow-ups required where automation could not reach:
- string-based QMetaObject/SIGNAL/SLOT references updated to renamed
  methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...)
- macro bodies referencing renamed methods (OLIVE_CONFIG,
  NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*)
- self-shadowing locals renamed where signals/methods became same-named
  (size_changed, worker_count, selected_items, import param, filters)
- third_party OFX member/namespace usages restored (OFX::Host::*,
  _created, _clipPrefsDirty, createInstance, clearPersistentMessage)
- STL protocol aliases restored (const_iterator) with .clang-tidy
  ignore rules; qHash overloads restored

Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
2026-07-19 16:10:54 +08:00
parent cb1718a103
commit bb40b4923e
1014 changed files with 44257 additions and 44220 deletions
+39 -39
View File
@@ -24,32 +24,32 @@
namespace olive
{
const QString MathNode::kMethodIn = QStringLiteral("method_in");
const QString MathNode::kParamAIn = QStringLiteral("param_a_in");
const QString MathNode::kParamBIn = QStringLiteral("param_b_in");
const QString MathNode::kParamCIn = QStringLiteral("param_c_in");
const QString MathNode::k_method_in = QStringLiteral("method_in");
const QString MathNode::k_param_a_in = QStringLiteral("param_a_in");
const QString MathNode::k_param_b_in = QStringLiteral("param_b_in");
const QString MathNode::k_param_c_in = QStringLiteral("param_c_in");
#define super MathNodeBase
MathNode::MathNode()
{
AddInput(kMethodIn, NodeValue::kCombo,
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
add_input(k_method_in, NodeValue::k_combo,
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
AddInput(kParamAIn, NodeValue::kFloat, 0.0);
SetInputProperty(kParamAIn, QStringLiteral("decimalplaces"), 8);
SetInputProperty(kParamAIn, QStringLiteral("autotrim"), true);
add_input(k_param_a_in, NodeValue::k_float, 0.0);
set_input_property(k_param_a_in, QStringLiteral("decimalplaces"), 8);
set_input_property(k_param_a_in, QStringLiteral("autotrim"), true);
AddInput(kParamBIn, NodeValue::kFloat, 0.0);
SetInputProperty(kParamBIn, QStringLiteral("decimalplaces"), 8);
SetInputProperty(kParamBIn, QStringLiteral("autotrim"), true);
add_input(k_param_b_in, NodeValue::k_float, 0.0);
set_input_property(k_param_b_in, QStringLiteral("decimalplaces"), 8);
set_input_property(k_param_b_in, QStringLiteral("autotrim"), true);
}
QString MathNode::Name() const
QString MathNode::name() const
{
// Default to naming after the operation
if (parent()) {
QString op_name = GetOperationName(GetOperation());
QString op_name = get_operation_name(get_operation());
if (!op_name.isEmpty()) {
return op_name;
}
@@ -63,63 +63,63 @@ QString MathNode::id() const
return QStringLiteral("org.olivevideoeditor.Olive.math");
}
QVector<Node::CategoryID> MathNode::Category() const
QVector<Node::CategoryID> MathNode::category() const
{
return { kCategoryMath };
return { k_category_math };
}
QString MathNode::Description() const
QString MathNode::description() const
{
return tr("Perform a mathematical operation between two values.");
}
void MathNode::Retranslate()
void MathNode::retranslate()
{
super::Retranslate();
super::retranslate();
SetInputName(kMethodIn, tr("Method"));
SetInputName(kParamAIn, tr("Value"));
SetInputName(kParamBIn, tr("Value"));
set_input_name(k_method_in, tr("Method"));
set_input_name(k_param_a_in, tr("Value"));
set_input_name(k_param_b_in, tr("Value"));
QStringList operations = { GetOperationName(kOpAdd),
GetOperationName(kOpSubtract),
GetOperationName(kOpMultiply),
GetOperationName(kOpDivide),
GetOperationName(kOpPower) };
QStringList operations = { get_operation_name(k_op_add),
get_operation_name(k_op_subtract),
get_operation_name(k_op_multiply),
get_operation_name(k_op_divide),
get_operation_name(k_op_power) };
SetComboBoxStrings(kMethodIn, operations);
set_combo_box_strings(k_method_in, operations);
}
ShaderCode MathNode::GetShaderCode(const ShaderRequest &request) const
ShaderCode MathNode::get_shader_code(const ShaderRequest &request) const
{
return GetShaderCodeInternal(request.id, kParamAIn, kParamBIn);
return get_shader_code_internal(request.id, k_param_a_in, k_param_b_in);
}
void MathNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
void MathNode::value(const NodeValueRow &value, const NodeGlobals &globals,
NodeValueTable *table) const
{
// Auto-detect what values to operate with
// FIXME: Very inefficient
NodeValueTable at, bt;
at.Push(value[kParamAIn]);
bt.Push(value[kParamBIn]);
at.push(value[k_param_a_in]);
bt.push(value[k_param_b_in]);
PairingCalculator calc(at, bt);
// Do nothing if no pairing was found
if (!calc.FoundMostLikelyPairing()) {
if (!calc.found_most_likely_pairing()) {
return;
}
return ValueInternal(GetOperation(), calc.GetMostLikelyPairing(), kParamAIn,
calc.GetMostLikelyValueA(), kParamBIn,
calc.GetMostLikelyValueB(), globals, table);
return value_internal(get_operation(), calc.get_most_likely_pairing(), k_param_a_in,
calc.get_most_likely_value_a(), k_param_b_in,
calc.get_most_likely_value_b(), globals, table);
}
void MathNode::ProcessSamples(const NodeValueRow &values,
void MathNode::process_samples(const NodeValueRow &values,
const SampleBuffer &input, SampleBuffer &output,
int index) const
{
return ProcessSamplesInternal(values, GetOperation(), kParamAIn, kParamBIn,
return process_samples_internal(values, get_operation(), k_param_a_in, k_param_b_in,
input, output, index);
}
+18 -18
View File
@@ -19,8 +19,8 @@
***/
#ifndef MATHNODE_H
#define MATHNODE_H
#ifndef OAK_MATHNODE_H
#define OAK_MATHNODE_H
#include "mathbase.h"
@@ -34,39 +34,39 @@ public:
NODE_DEFAULT_FUNCTIONS(MathNode)
virtual QString Name() const override;
virtual QString name() const override;
virtual QString id() const override;
virtual QVector<CategoryID> Category() const override;
virtual QString Description() const override;
virtual QVector<CategoryID> category() const override;
virtual QString description() const override;
virtual void Retranslate() override;
virtual void retranslate() override;
virtual ShaderCode
GetShaderCode(const ShaderRequest &request) const override;
get_shader_code(const ShaderRequest &request) const override;
Operation GetOperation() const
Operation get_operation() const
{
return static_cast<Operation>(GetStandardValue(kMethodIn).toInt());
return static_cast<Operation>(get_standard_value(k_method_in).toInt());
}
void SetOperation(Operation o)
void set_operation(Operation o)
{
SetStandardValue(kMethodIn, o);
set_standard_value(k_method_in, o);
}
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
NodeValueTable *table) const override;
virtual void ProcessSamples(const NodeValueRow &values,
virtual void process_samples(const NodeValueRow &values,
const SampleBuffer &input, SampleBuffer &output,
int index) const override;
static const QString kMethodIn;
static const QString kParamAIn;
static const QString kParamBIn;
static const QString kParamCIn;
static const QString k_method_in;
static const QString k_param_a_in;
static const QString k_param_b_in;
static const QString k_param_c_in;
};
}
#endif // MATHNODE_H
#endif // OAK_MATHNODE_H
+238 -238
View File
@@ -30,7 +30,7 @@
namespace olive
{
ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id,
ShaderCode MathNodeBase::get_shader_code_internal(const QString &shader_id,
const QString &param_a_in,
const QString &param_b_in) const
{
@@ -45,11 +45,11 @@ ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id,
QString operation, frag, vert;
if (pairing == kPairTextureMatrix && op == kOpMultiply) {
if (pairing == k_pair_texture_matrix && op == k_op_multiply) {
// Override the operation for this operation since we multiply texture COORDS by the matrix rather than
const QString &tex_in = (type_a == NodeValue::kTexture) ? param_a_in :
const QString &tex_in = (type_a == NodeValue::k_texture) ? param_a_in :
param_b_in;
const QString &mat_in = (type_a == NodeValue::kTexture) ? param_b_in :
const QString &mat_in = (type_a == NodeValue::k_texture) ? param_b_in :
param_a_in;
// No-op frag shader (can we return QString() instead?)
@@ -70,20 +70,20 @@ ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id,
} else {
switch (op) {
case kOpAdd:
case k_op_add:
operation = QStringLiteral("%1 + %2");
break;
case kOpSubtract:
case k_op_subtract:
operation = QStringLiteral("%1 - %2");
break;
case kOpMultiply:
case k_op_multiply:
operation = QStringLiteral("%1 * %2");
break;
case kOpDivide:
case k_op_divide:
operation = QStringLiteral("%1 / %2");
break;
case kOpPower:
if (pairing == kPairTextureNumber) {
case k_op_power:
if (pairing == k_pair_texture_number) {
// The "number" in this operation has to be declared a vec4
if (NodeValue::type_is_numeric(type_a)) {
operation = QStringLiteral("pow(%2, vec4(%1))");
@@ -96,8 +96,8 @@ ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id,
break;
}
operation = operation.arg(GetShaderVariableCall(param_a_in, type_a),
GetShaderVariableCall(param_b_in, type_b));
operation = operation.arg(get_shader_variable_call(param_a_in, type_a),
get_shader_variable_call(param_b_in, type_b));
}
frag =
@@ -113,31 +113,31 @@ ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id,
" c.a = clamp(c.a, 0.0, 1.0);\n" // Ensure alpha is between 0.0 and 1.0
" frag_color = c;\n"
"}\n")
.arg(GetShaderUniformType(type_a), GetShaderUniformType(type_b),
.arg(get_shader_uniform_type(type_a), get_shader_uniform_type(type_b),
param_a_in, param_b_in, operation);
return ShaderCode(frag, vert);
}
QString MathNodeBase::GetShaderUniformType(const olive::NodeValue::Type &type)
QString MathNodeBase::get_shader_uniform_type(const olive::NodeValue::Type &type)
{
switch (type) {
case NodeValue::kTexture:
case NodeValue::k_texture:
return QStringLiteral("sampler2D");
case NodeValue::kColor:
case NodeValue::k_color:
return QStringLiteral("vec4");
case NodeValue::kMatrix:
case NodeValue::k_matrix:
return QStringLiteral("mat4");
default:
return QStringLiteral("float");
}
}
QString MathNodeBase::GetShaderVariableCall(const QString &input_id,
QString MathNodeBase::get_shader_variable_call(const QString &input_id,
const NodeValue::Type &type,
const QString &coord_op)
{
if (type == NodeValue::kTexture) {
if (type == NodeValue::k_texture) {
return QStringLiteral("texture(%1, ove_texcoord%2)")
.arg(input_id, coord_op);
}
@@ -145,67 +145,67 @@ QString MathNodeBase::GetShaderVariableCall(const QString &input_id,
return input_id;
}
QVector4D MathNodeBase::RetrieveVector(const NodeValue &val)
QVector4D MathNodeBase::retrieve_vector(const NodeValue &val)
{
// QVariant doesn't know that QVector*D can convert themselves so we do it here
switch (val.type()) {
case NodeValue::kVec2:
return QVector4D(val.toVec2());
case NodeValue::kVec3:
return QVector4D(val.toVec3());
case NodeValue::kVec4:
case NodeValue::k_vec2:
return QVector4D(val.to_vec2());
case NodeValue::k_vec3:
return QVector4D(val.to_vec3());
case NodeValue::k_vec4:
default:
return val.toVec4();
return val.to_vec4();
}
}
void MathNodeBase::PushVector(NodeValueTable *output,
void MathNodeBase::push_vector(NodeValueTable *output,
olive::NodeValue::Type type,
const QVector4D &vec) const
{
switch (type) {
case NodeValue::kVec2:
output->Push(type, QVector2D(vec), this);
case NodeValue::k_vec2:
output->push(type, QVector2D(vec), this);
break;
case NodeValue::kVec3:
output->Push(type, QVector3D(vec), this);
case NodeValue::k_vec3:
output->push(type, QVector3D(vec), this);
break;
case NodeValue::kVec4:
output->Push(type, vec, this);
case NodeValue::k_vec4:
output->push(type, vec, this);
break;
default:
break;
}
}
QString MathNodeBase::GetOperationName(Operation o)
QString MathNodeBase::get_operation_name(Operation o)
{
switch (o) {
case kOpAdd:
case k_op_add:
return tr("Add");
case kOpSubtract:
case k_op_subtract:
return tr("Subtract");
case kOpMultiply:
case k_op_multiply:
return tr("Multiply");
case kOpDivide:
case k_op_divide:
return tr("Divide");
case kOpPower:
case k_op_power:
return tr("Power");
}
return QString();
}
void MathNodeBase::PerformAllOnFloatBuffer(Operation operation, float *a,
void MathNodeBase::perform_all_on_float_buffer(Operation operation, float *a,
float b, int start, int end)
{
for (int j = start; j < end; j++) {
a[j] = PerformAll(operation, a[j], b);
a[j] = perform_all(operation, a[j], b);
}
}
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
void MathNodeBase::PerformAllOnFloatBufferSSE(Operation operation, float *a,
void MathNodeBase::perform_all_on_float_buffer_sse(Operation operation, float *a,
float b, int start, int end)
{
int end_divisible_4 = (end / 4) * 4;
@@ -214,32 +214,32 @@ void MathNodeBase::PerformAllOnFloatBufferSSE(Operation operation, float *a,
__m128 mult = _mm_load1_ps(&b);
switch (operation) {
case kOpAdd:
case k_op_add:
// Loop all values
for (int j = 0; j < end_divisible_4; j += 4) {
_mm_storeu_ps(a + start + j,
_mm_add_ps(_mm_loadu_ps(a + start + j), mult));
}
break;
case kOpSubtract:
case k_op_subtract:
for (int j = 0; j < end_divisible_4; j += 4) {
_mm_storeu_ps(a + start + j,
_mm_sub_ps(_mm_loadu_ps(a + start + j), mult));
}
break;
case kOpMultiply:
case k_op_multiply:
for (int j = 0; j < end_divisible_4; j += 4) {
_mm_storeu_ps(a + start + j,
_mm_mul_ps(_mm_loadu_ps(a + start + j), mult));
}
break;
case kOpDivide:
case k_op_divide:
for (int j = 0; j < end_divisible_4; j += 4) {
_mm_storeu_ps(a + start + j,
_mm_div_ps(_mm_loadu_ps(a + start + j), mult));
}
break;
case kOpPower:
case k_op_power:
// Fallback for operations we can't support here
end_divisible_4 = 0;
break;
@@ -247,133 +247,133 @@ void MathNodeBase::PerformAllOnFloatBufferSSE(Operation operation, float *a,
// Handle last 1-3 bytes if necessary, or all bytes if we couldn't
// support this op on SSE
PerformAllOnFloatBuffer(operation, a, b, end_divisible_4, end);
perform_all_on_float_buffer(operation, a, b, end_divisible_4, end);
}
#endif
void MathNodeBase::ValueInternal(
void MathNodeBase::value_internal(
Operation operation, Pairing pairing, const QString &param_a_in,
const NodeValue &val_a, const QString &param_b_in, const NodeValue &val_b,
const NodeGlobals &globals, NodeValueTable *output) const
{
switch (pairing) {
case kPairNumberNumber: {
if (val_a.type() == NodeValue::kRational &&
val_b.type() == NodeValue::kRational && operation != kOpPower) {
case k_pair_number_number: {
if (val_a.type() == NodeValue::k_rational &&
val_b.type() == NodeValue::k_rational && operation != k_op_power) {
// Preserve rationals
output->Push(
NodeValue::kRational,
QVariant::fromValue(PerformAddSubMultDiv<rational, rational>(
operation, val_a.toRational(), val_b.toRational())),
output->push(
NodeValue::k_rational,
QVariant::fromValue(perform_add_sub_mult_div<Rational, Rational>(
operation, val_a.to_rational(), val_b.to_rational())),
this);
} else {
output->Push(NodeValue::kFloat,
PerformAll<float, float>(operation,
RetrieveNumber(val_a),
RetrieveNumber(val_b)),
output->push(NodeValue::k_float,
perform_all<float, float>(operation,
retrieve_number(val_a),
retrieve_number(val_b)),
this);
}
break;
}
case kPairVecVec: {
case k_pair_vec_vec: {
// We convert all vectors to QVector4D just for simplicity and exploit the fact that kVec4 is higher than kVec2 in
// the enum to find the largest data type
QVector4D vec_a = RetrieveVector(val_a);
QVector4D vec_b = RetrieveVector(val_b);
QVector4D vec_a = retrieve_vector(val_a);
QVector4D vec_b = retrieve_vector(val_b);
if (operation == kOpDivide) {
if (operation == k_op_divide) {
// Lower-dimensional vectors are padded with zeros; dividing the
// padding components would be 0/0 (assert in Qt debug builds, NaN
// otherwise). Force those components to 0/1 so the result is a
// well-defined zero, which is discarded by PushVector anyway.
const NodeValue::Type max_type = qMax(val_a.type(), val_b.type());
if (max_type == NodeValue::kVec2) {
if (max_type == NodeValue::k_vec2) {
vec_a.setZ(0.0f);
vec_a.setW(0.0f);
vec_b.setZ(1.0f);
vec_b.setW(1.0f);
} else if (max_type == NodeValue::kVec3) {
} else if (max_type == NodeValue::k_vec3) {
vec_a.setW(0.0f);
vec_b.setW(1.0f);
}
}
PushVector(output, qMax(val_a.type(), val_b.type()),
PerformAddSubMultDiv<QVector4D, QVector4D>(operation, vec_a,
push_vector(output, qMax(val_a.type(), val_b.type()),
perform_add_sub_mult_div<QVector4D, QVector4D>(operation, vec_a,
vec_b));
break;
}
case kPairMatrixVec: {
QMatrix4x4 matrix = (val_a.type() == NodeValue::kMatrix) ?
val_a.toMatrix() :
val_b.toMatrix();
QVector4D vec = (val_a.type() == NodeValue::kMatrix) ?
RetrieveVector(val_b) :
RetrieveVector(val_a);
case k_pair_matrix_vec: {
QMatrix4x4 matrix = (val_a.type() == NodeValue::k_matrix) ?
val_a.to_matrix() :
val_b.to_matrix();
QVector4D vec = (val_a.type() == NodeValue::k_matrix) ?
retrieve_vector(val_b) :
retrieve_vector(val_a);
// Only valid operation is multiply
PushVector(output, qMax(val_a.type(), val_b.type()),
PerformMult<QVector4D, QMatrix4x4>(operation, vec, matrix));
push_vector(output, qMax(val_a.type(), val_b.type()),
perform_mult<QVector4D, QMatrix4x4>(operation, vec, matrix));
break;
}
case kPairVecNumber: {
case k_pair_vec_number: {
QVector4D vec = (NodeValue::type_is_vector(val_a.type()) ?
RetrieveVector(val_a) :
RetrieveVector(val_b));
float number = RetrieveNumber(NodeValue::type_is_vector(val_a.type()) ?
retrieve_vector(val_a) :
retrieve_vector(val_b));
float number = retrieve_number(NodeValue::type_is_vector(val_a.type()) ?
val_b :
val_a);
// Only multiply and divide are valid operations
PushVector(output,
push_vector(output,
NodeValue::type_is_vector(val_a.type()) ? val_a.type() :
val_b.type(),
PerformMultDiv<QVector4D, float>(operation, vec, number));
perform_mult_div<QVector4D, float>(operation, vec, number));
break;
}
case kPairMatrixMatrix: {
QMatrix4x4 mat_a = val_a.toMatrix();
QMatrix4x4 mat_b = val_b.toMatrix();
output->Push(NodeValue::kMatrix,
PerformAddSubMult<QMatrix4x4, QMatrix4x4>(operation, mat_a,
case k_pair_matrix_matrix: {
QMatrix4x4 mat_a = val_a.to_matrix();
QMatrix4x4 mat_b = val_b.to_matrix();
output->push(NodeValue::k_matrix,
perform_add_sub_mult<QMatrix4x4, QMatrix4x4>(operation, mat_a,
mat_b),
this);
break;
}
case kPairColorColor: {
Color col_a = val_a.toColor();
Color col_b = val_b.toColor();
case k_pair_color_color: {
Color col_a = val_a.to_color();
Color col_b = val_b.to_color();
// Only add and subtract are valid operations
output->Push(NodeValue::kColor,
output->push(NodeValue::k_color,
QVariant::fromValue(
PerformAddSub<Color, Color>(operation, col_a, col_b)),
perform_add_sub<Color, Color>(operation, col_a, col_b)),
this);
break;
}
case kPairNumberColor: {
Color col = (val_a.type() == NodeValue::kColor) ? val_a.toColor() :
val_b.toColor();
float num = (val_a.type() == NodeValue::kColor) ? val_b.toDouble() :
val_a.toDouble();
case k_pair_number_color: {
Color col = (val_a.type() == NodeValue::k_color) ? val_a.to_color() :
val_b.to_color();
float num = (val_a.type() == NodeValue::k_color) ? val_b.to_double() :
val_a.to_double();
// Only multiply and divide are valid operations
output->Push(
NodeValue::kColor,
QVariant::fromValue(PerformMult<Color, float>(operation, col, num)),
output->push(
NodeValue::k_color,
QVariant::fromValue(perform_mult<Color, float>(operation, col, num)),
this);
break;
}
case kPairSampleSample: {
SampleBuffer samples_a = val_a.toSamples();
SampleBuffer samples_b = val_b.toSamples();
case k_pair_sample_sample: {
SampleBuffer samples_a = val_a.to_samples();
SampleBuffer samples_b = val_b.to_samples();
size_t max_samples =
qMax(samples_a.sample_count(), samples_b.sample_count());
@@ -386,7 +386,7 @@ void MathNodeBase::ValueInternal(
for (int i = 0; i < mixed_samples.audio_params().channel_count(); i++) {
// Mix samples that are in both buffers
for (size_t j = 0; j < min_samples; j++) {
mixed_samples.data(i)[j] = PerformAll<float, float>(
mixed_samples.data(i)[j] = perform_all<float, float>(
operation, samples_a.data(i)[j], samples_b.data(i)[j]);
}
}
@@ -407,94 +407,94 @@ void MathNodeBase::ValueInternal(
}
}
output->Push(NodeValue::kSamples, QVariant::fromValue(mixed_samples),
output->push(NodeValue::k_samples, QVariant::fromValue(mixed_samples),
this);
break;
}
case kPairTextureColor:
case kPairTextureNumber:
case kPairTextureTexture:
case kPairTextureMatrix: {
case k_pair_texture_color:
case k_pair_texture_number:
case k_pair_texture_texture:
case k_pair_texture_matrix: {
ShaderJob job;
job.SetShaderID(QStringLiteral("%1.%2.%3.%4")
job.set_shader_id(QStringLiteral("%1.%2.%3.%4")
.arg(QString::number(operation),
QString::number(pairing),
QString::number(val_a.type()),
QString::number(val_b.type())));
job.Insert(param_a_in, val_a);
job.Insert(param_b_in, val_b);
job.insert(param_a_in, val_a);
job.insert(param_b_in, val_b);
bool operation_is_noop = false;
const NodeValue &number_val =
val_a.type() == NodeValue::kTexture ? val_b : val_a;
val_a.type() == NodeValue::k_texture ? val_b : val_a;
const NodeValue &texture_val =
val_a.type() == NodeValue::kTexture ? val_a : val_b;
TexturePtr texture = texture_val.toTexture();
val_a.type() == NodeValue::k_texture ? val_a : val_b;
TexturePtr texture = texture_val.to_texture();
if (!texture) {
operation_is_noop = true;
} else if (pairing == kPairTextureNumber) {
if (NumberIsNoOp(operation, RetrieveNumber(number_val))) {
} else if (pairing == k_pair_texture_number) {
if (number_is_no_op(operation, retrieve_number(number_val))) {
operation_is_noop = true;
}
} else if (pairing == kPairTextureMatrix) {
} else if (pairing == k_pair_texture_matrix) {
// Only allow matrix multiplication
const QVector2D &sequence_res = globals.nonsquare_resolution();
QVector2D texture_res(texture->params().width() *
texture->pixel_aspect_ratio().toDouble(),
texture->pixel_aspect_ratio().to_double(),
texture->params().height());
QMatrix4x4 adjusted_matrix =
TransformDistortNode::AdjustMatrixByResolutions(
number_val.toMatrix(), sequence_res,
TransformDistortNode::adjust_matrix_by_resolutions(
number_val.to_matrix(), sequence_res,
texture->params().offset(), texture_res);
if (operation != kOpMultiply || adjusted_matrix.isIdentity()) {
if (operation != k_op_multiply || adjusted_matrix.isIdentity()) {
operation_is_noop = true;
} else {
// Replace with adjusted matrix
job.Insert(val_a.type() == NodeValue::kTexture ? param_b_in :
job.insert(val_a.type() == NodeValue::k_texture ? param_b_in :
param_a_in,
NodeValue(NodeValue::kMatrix, adjusted_matrix,
NodeValue(NodeValue::k_matrix, adjusted_matrix,
this));
}
}
if (operation_is_noop) {
// Just push texture as-is
output->Push(texture_val);
output->push(texture_val);
} else {
// Push shader job
output->Push(NodeValue::kTexture,
Texture::Job(globals.vparams(), job), this);
output->push(NodeValue::k_texture,
Texture::job(globals.vparams(), job), this);
}
break;
}
case kPairSampleNumber: {
case k_pair_sample_number: {
// Queue a sample job
const NodeValue &number_val =
val_a.type() == NodeValue::kSamples ? val_b : val_a;
val_a.type() == NodeValue::k_samples ? val_b : val_a;
const QString &number_param =
val_a.type() == NodeValue::kSamples ? param_b_in : param_a_in;
val_a.type() == NodeValue::k_samples ? param_b_in : param_a_in;
float number = RetrieveNumber(number_val);
float number = retrieve_number(number_val);
SampleBuffer buffer = val_a.type() == NodeValue::kSamples ?
val_a.toSamples() :
val_b.toSamples();
SampleBuffer buffer = val_a.type() == NodeValue::k_samples ?
val_a.to_samples() :
val_b.to_samples();
if (buffer.is_allocated()) {
if (IsInputStatic(number_param)) {
if (!NumberIsNoOp(operation, number)) {
if (is_input_static(number_param)) {
if (!number_is_no_op(operation, number)) {
for (int i = 0; i < buffer.audio_params().channel_count();
i++) {
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
// Use SSE instructions for optimization
PerformAllOnFloatBufferSSE(operation, buffer.data(i),
perform_all_on_float_buffer_sse(operation, buffer.data(i),
number, 0,
buffer.sample_count());
#else
@@ -505,28 +505,28 @@ void MathNodeBase::ValueInternal(
}
}
output->Push(NodeValue::kSamples, QVariant::fromValue(buffer),
output->push(NodeValue::k_samples, QVariant::fromValue(buffer),
this);
} else {
SampleJob job(globals.time(),
val_a.type() == NodeValue::kSamples ? val_a :
val_a.type() == NodeValue::k_samples ? val_a :
val_b);
job.Insert(number_param,
NodeValue(NodeValue::kFloat, number, this));
output->Push(NodeValue::kSamples, QVariant::fromValue(job),
job.insert(number_param,
NodeValue(NodeValue::k_float, number, this));
output->push(NodeValue::k_samples, QVariant::fromValue(job),
this);
}
}
break;
}
case kPairNone:
case kPairCount:
case k_pair_none:
case k_pair_count:
break;
}
}
void MathNodeBase::ProcessSamplesInternal(const NodeValueRow &values,
void MathNodeBase::process_samples_internal(const NodeValueRow &values,
MathNodeBase::Operation operation,
const QString &param_a_in,
const QString &param_b_in,
@@ -537,44 +537,44 @@ void MathNodeBase::ProcessSamplesInternal(const NodeValueRow &values,
// This function is only used for sample+number pairing
NodeValue number_val = values[param_a_in];
if (number_val.type() == NodeValue::kNone) {
if (number_val.type() == NodeValue::k_none) {
number_val = values[param_b_in];
if (number_val.type() == NodeValue::kNone) {
if (number_val.type() == NodeValue::k_none) {
return;
}
}
float number_flt = RetrieveNumber(number_val);
float number_flt = retrieve_number(number_val);
for (int i = 0; i < output.audio_params().channel_count(); i++) {
output.data(i)[index] = PerformAll<float, float>(
output.data(i)[index] = perform_all<float, float>(
operation, input.data(i)[index], number_flt);
}
}
float MathNodeBase::RetrieveNumber(const NodeValue &val)
float MathNodeBase::retrieve_number(const NodeValue &val)
{
if (val.type() == NodeValue::kRational) {
return val.toRational().toDouble();
if (val.type() == NodeValue::k_rational) {
return val.to_rational().to_double();
} else {
return val.toDouble();
return val.to_double();
}
}
bool MathNodeBase::NumberIsNoOp(const MathNodeBase::Operation &op,
bool MathNodeBase::number_is_no_op(const MathNodeBase::Operation &op,
const float &number)
{
switch (op) {
case kOpAdd:
case kOpSubtract:
case k_op_add:
case k_op_subtract:
if (qIsNull(number)) {
return true;
}
break;
case kOpMultiply:
case kOpDivide:
case kOpPower:
case k_op_multiply:
case k_op_divide:
case k_op_power:
if (qFuzzyCompare(number, 1.0f)) {
return true;
}
@@ -587,15 +587,15 @@ bool MathNodeBase::NumberIsNoOp(const MathNodeBase::Operation &op,
MathNodeBase::PairingCalculator::PairingCalculator(
const NodeValueTable &table_a, const NodeValueTable &table_b)
{
QVector<int> pair_likelihood_a = GetPairLikelihood(table_a);
QVector<int> pair_likelihood_b = GetPairLikelihood(table_b);
QVector<int> pair_likelihood_a = get_pair_likelihood(table_a);
QVector<int> pair_likelihood_b = get_pair_likelihood(table_b);
int weight_a = qMax(0, table_b.Count() - table_a.Count());
int weight_b = qMax(0, table_a.Count() - table_b.Count());
int weight_a = qMax(0, table_b.count() - table_a.count());
int weight_b = qMax(0, table_a.count() - table_b.count());
QVector<int> likelihoods(kPairCount);
QVector<int> likelihoods(k_pair_count);
for (int i = 0; i < kPairCount; i++) {
for (int i = 0; i < k_pair_count; i++) {
if (pair_likelihood_a.at(i) == -1 || pair_likelihood_b.at(i) == -1) {
likelihoods.replace(i, -1);
} else {
@@ -604,18 +604,18 @@ MathNodeBase::PairingCalculator::PairingCalculator(
}
}
most_likely_pairing_ = kPairNone;
most_likely_pairing_ = k_pair_none;
for (int i = 0; i < likelihoods.size(); i++) {
if (likelihoods.at(i) > -1) {
if (most_likely_pairing_ == kPairNone ||
if (most_likely_pairing_ == k_pair_none ||
likelihoods.at(i) > likelihoods.at(most_likely_pairing_)) {
most_likely_pairing_ = static_cast<Pairing>(i);
}
}
}
if (most_likely_pairing_ != kPairNone) {
if (most_likely_pairing_ != k_pair_none) {
most_likely_value_a_ =
table_a.at(pair_likelihood_a.at(most_likely_pairing_));
most_likely_value_b_ =
@@ -624,82 +624,82 @@ MathNodeBase::PairingCalculator::PairingCalculator(
}
QVector<int>
MathNodeBase::PairingCalculator::GetPairLikelihood(const NodeValueTable &table)
MathNodeBase::PairingCalculator::get_pair_likelihood(const NodeValueTable &table)
{
QVector<int> likelihood(kPairCount, -1);
QVector<int> likelihood(k_pair_count, -1);
for (int i = 0; i < table.Count(); i++) {
for (int i = 0; i < table.count(); i++) {
NodeValue::Type type = table.at(i).type();
int weight = i;
if (NodeValue::type_is_vector(type)) {
likelihood.replace(kPairVecVec, weight);
likelihood.replace(kPairVecNumber, weight);
likelihood.replace(kPairMatrixVec, weight);
} else if (type == NodeValue::kMatrix) {
likelihood.replace(kPairMatrixMatrix, weight);
likelihood.replace(kPairMatrixVec, weight);
likelihood.replace(kPairTextureMatrix, weight);
} else if (type == NodeValue::kColor) {
likelihood.replace(kPairColorColor, weight);
likelihood.replace(kPairNumberColor, weight);
likelihood.replace(kPairTextureColor, weight);
likelihood.replace(k_pair_vec_vec, weight);
likelihood.replace(k_pair_vec_number, weight);
likelihood.replace(k_pair_matrix_vec, weight);
} else if (type == NodeValue::k_matrix) {
likelihood.replace(k_pair_matrix_matrix, weight);
likelihood.replace(k_pair_matrix_vec, weight);
likelihood.replace(k_pair_texture_matrix, weight);
} else if (type == NodeValue::k_color) {
likelihood.replace(k_pair_color_color, weight);
likelihood.replace(k_pair_number_color, weight);
likelihood.replace(k_pair_texture_color, weight);
} else if (NodeValue::type_is_numeric(type)) {
likelihood.replace(kPairNumberNumber, weight);
likelihood.replace(kPairVecNumber, weight);
likelihood.replace(kPairNumberColor, weight);
likelihood.replace(kPairTextureNumber, weight);
likelihood.replace(kPairSampleNumber, weight);
} else if (type == NodeValue::kSamples) {
likelihood.replace(kPairSampleSample, weight);
likelihood.replace(kPairSampleNumber, weight);
} else if (type == NodeValue::kTexture) {
likelihood.replace(kPairTextureTexture, weight);
likelihood.replace(kPairTextureNumber, weight);
likelihood.replace(kPairTextureColor, weight);
likelihood.replace(kPairTextureMatrix, weight);
likelihood.replace(k_pair_number_number, weight);
likelihood.replace(k_pair_vec_number, weight);
likelihood.replace(k_pair_number_color, weight);
likelihood.replace(k_pair_texture_number, weight);
likelihood.replace(k_pair_sample_number, weight);
} else if (type == NodeValue::k_samples) {
likelihood.replace(k_pair_sample_sample, weight);
likelihood.replace(k_pair_sample_number, weight);
} else if (type == NodeValue::k_texture) {
likelihood.replace(k_pair_texture_texture, weight);
likelihood.replace(k_pair_texture_number, weight);
likelihood.replace(k_pair_texture_color, weight);
likelihood.replace(k_pair_texture_matrix, weight);
}
}
return likelihood;
}
bool MathNodeBase::PairingCalculator::FoundMostLikelyPairing() const
bool MathNodeBase::PairingCalculator::found_most_likely_pairing() const
{
return (most_likely_pairing_ > kPairNone &&
most_likely_pairing_ < kPairCount);
return (most_likely_pairing_ > k_pair_none &&
most_likely_pairing_ < k_pair_count);
}
MathNodeBase::Pairing
MathNodeBase::PairingCalculator::GetMostLikelyPairing() const
MathNodeBase::PairingCalculator::get_most_likely_pairing() const
{
return most_likely_pairing_;
}
const NodeValue &MathNodeBase::PairingCalculator::GetMostLikelyValueA() const
const NodeValue &MathNodeBase::PairingCalculator::get_most_likely_value_a() const
{
return most_likely_value_a_;
}
const NodeValue &MathNodeBase::PairingCalculator::GetMostLikelyValueB() const
const NodeValue &MathNodeBase::PairingCalculator::get_most_likely_value_b() const
{
return most_likely_value_b_;
}
template <typename T, typename U>
T MathNodeBase::PerformAll(Operation operation, T a, U b)
T MathNodeBase::perform_all(Operation operation, T a, U b)
{
switch (operation) {
case kOpAdd:
case k_op_add:
return a + b;
case kOpSubtract:
case k_op_subtract:
return a - b;
case kOpMultiply:
case k_op_multiply:
return a * b;
case kOpDivide:
case k_op_divide:
return a / b;
case kOpPower:
case k_op_power:
return std::pow(a, b);
}
@@ -707,16 +707,16 @@ T MathNodeBase::PerformAll(Operation operation, T a, U b)
}
template <typename T, typename U>
T MathNodeBase::PerformMultDiv(Operation operation, T a, U b)
T MathNodeBase::perform_mult_div(Operation operation, T a, U b)
{
switch (operation) {
case kOpMultiply:
case k_op_multiply:
return a * b;
case kOpDivide:
case k_op_divide:
return a / b;
case kOpAdd:
case kOpSubtract:
case kOpPower:
case k_op_add:
case k_op_subtract:
case k_op_power:
break;
}
@@ -724,16 +724,16 @@ T MathNodeBase::PerformMultDiv(Operation operation, T a, U b)
}
template <typename T, typename U>
T MathNodeBase::PerformAddSub(Operation operation, T a, U b)
T MathNodeBase::perform_add_sub(Operation operation, T a, U b)
{
switch (operation) {
case kOpAdd:
case k_op_add:
return a + b;
case kOpSubtract:
case k_op_subtract:
return a - b;
case kOpMultiply:
case kOpDivide:
case kOpPower:
case k_op_multiply:
case k_op_divide:
case k_op_power:
break;
}
@@ -741,15 +741,15 @@ T MathNodeBase::PerformAddSub(Operation operation, T a, U b)
}
template <typename T, typename U>
T MathNodeBase::PerformMult(Operation operation, T a, U b)
T MathNodeBase::perform_mult(Operation operation, T a, U b)
{
switch (operation) {
case kOpMultiply:
case k_op_multiply:
return a * b;
case kOpAdd:
case kOpSubtract:
case kOpDivide:
case kOpPower:
case k_op_add:
case k_op_subtract:
case k_op_divide:
case k_op_power:
break;
}
@@ -757,17 +757,17 @@ T MathNodeBase::PerformMult(Operation operation, T a, U b)
}
template <typename T, typename U>
T MathNodeBase::PerformAddSubMult(Operation operation, T a, U b)
T MathNodeBase::perform_add_sub_mult(Operation operation, T a, U b)
{
switch (operation) {
case kOpAdd:
case k_op_add:
return a + b;
case kOpSubtract:
case k_op_subtract:
return a - b;
case kOpMultiply:
case k_op_multiply:
return a * b;
case kOpDivide:
case kOpPower:
case k_op_divide:
case k_op_power:
break;
}
@@ -775,18 +775,18 @@ T MathNodeBase::PerformAddSubMult(Operation operation, T a, U b)
}
template <typename T, typename U>
T MathNodeBase::PerformAddSubMultDiv(Operation operation, T a, U b)
T MathNodeBase::perform_add_sub_mult_div(Operation operation, T a, U b)
{
switch (operation) {
case kOpAdd:
case k_op_add:
return a + b;
case kOpSubtract:
case k_op_subtract:
return a - b;
case kOpMultiply:
case k_op_multiply:
return a * b;
case kOpDivide:
case k_op_divide:
return a / b;
case kOpPower:
case k_op_power:
break;
}
+42 -42
View File
@@ -19,8 +19,8 @@
***/
#ifndef MATHNODEBASE_H
#define MATHNODEBASE_H
#ifndef OAK_MATHNODEBASE_H
#define OAK_MATHNODEBASE_H
#include "node/node.h"
@@ -31,30 +31,30 @@ class MathNodeBase : public Node {
public:
MathNodeBase() = default;
enum Operation { kOpAdd, kOpSubtract, kOpMultiply, kOpDivide, kOpPower };
enum Operation { k_op_add, k_op_subtract, k_op_multiply, k_op_divide, k_op_power };
static QString GetOperationName(Operation o);
static QString get_operation_name(Operation o);
protected:
enum Pairing {
kPairNone = -1,
k_pair_none = -1,
kPairNumberNumber,
kPairVecVec,
kPairMatrixMatrix,
kPairColorColor,
kPairTextureTexture,
k_pair_number_number,
k_pair_vec_vec,
k_pair_matrix_matrix,
k_pair_color_color,
k_pair_texture_texture,
kPairVecNumber,
kPairMatrixVec,
kPairNumberColor,
kPairTextureNumber,
kPairTextureColor,
kPairTextureMatrix,
kPairSampleSample,
kPairSampleNumber,
k_pair_vec_number,
k_pair_matrix_vec,
k_pair_number_color,
k_pair_texture_number,
k_pair_texture_color,
k_pair_texture_matrix,
k_pair_sample_sample,
k_pair_sample_number,
kPairCount
k_pair_count
};
class PairingCalculator {
@@ -62,14 +62,14 @@ protected:
PairingCalculator(const NodeValueTable &table_a,
const NodeValueTable &table_b);
bool FoundMostLikelyPairing() const;
Pairing GetMostLikelyPairing() const;
bool found_most_likely_pairing() const;
Pairing get_most_likely_pairing() const;
const NodeValue &GetMostLikelyValueA() const;
const NodeValue &GetMostLikelyValueB() const;
const NodeValue &get_most_likely_value_a() const;
const NodeValue &get_most_likely_value_b() const;
private:
static QVector<int> GetPairLikelihood(const NodeValueTable &table);
static QVector<int> get_pair_likelihood(const NodeValueTable &table);
Pairing most_likely_pairing_;
@@ -79,57 +79,57 @@ protected:
};
template <typename T, typename U>
static T PerformAll(Operation operation, T a, U b);
static T perform_all(Operation operation, T a, U b);
template <typename T, typename U>
static T PerformMultDiv(Operation operation, T a, U b);
static T perform_mult_div(Operation operation, T a, U b);
template <typename T, typename U>
static T PerformAddSub(Operation operation, T a, U b);
static T perform_add_sub(Operation operation, T a, U b);
template <typename T, typename U>
static T PerformMult(Operation operation, T a, U b);
static T perform_mult(Operation operation, T a, U b);
template <typename T, typename U>
static T PerformAddSubMult(Operation operation, T a, U b);
static T perform_add_sub_mult(Operation operation, T a, U b);
template <typename T, typename U>
static T PerformAddSubMultDiv(Operation operation, T a, U b);
static T perform_add_sub_mult_div(Operation operation, T a, U b);
static void PerformAllOnFloatBuffer(Operation operation, float *a, float b,
static void perform_all_on_float_buffer(Operation operation, float *a, float b,
int start, int end);
#if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM)
static void PerformAllOnFloatBufferSSE(Operation operation, float *a,
static void perform_all_on_float_buffer_sse(Operation operation, float *a,
float b, int start, int end);
#endif
static QString GetShaderUniformType(const NodeValue::Type &type);
static QString get_shader_uniform_type(const NodeValue::Type &type);
static QString GetShaderVariableCall(const QString &input_id,
static QString get_shader_variable_call(const QString &input_id,
const NodeValue::Type &type,
const QString &coord_op = QString());
static QVector4D RetrieveVector(const NodeValue &val);
static QVector4D retrieve_vector(const NodeValue &val);
static float RetrieveNumber(const NodeValue &val);
static float retrieve_number(const NodeValue &val);
static bool NumberIsNoOp(const Operation &op, const float &number);
static bool number_is_no_op(const Operation &op, const float &number);
ShaderCode GetShaderCodeInternal(const QString &shader_id,
ShaderCode get_shader_code_internal(const QString &shader_id,
const QString &param_a_in,
const QString &param_b_in) const;
void PushVector(NodeValueTable *output, NodeValue::Type type,
void push_vector(NodeValueTable *output, NodeValue::Type type,
const QVector4D &vec) const;
void ValueInternal(Operation operation, Pairing pairing,
void value_internal(Operation operation, Pairing pairing,
const QString &param_a_in, const NodeValue &val_a,
const QString &param_b_in, const NodeValue &val_b,
const NodeGlobals &globals,
NodeValueTable *output) const;
void ProcessSamplesInternal(const NodeValueRow &values, Operation operation,
void process_samples_internal(const NodeValueRow &values, Operation operation,
const QString &param_a_in,
const QString &param_b_in,
const SampleBuffer &input, SampleBuffer &output,
@@ -138,4 +138,4 @@ protected:
}
#endif // MATHNODEBASE_H
#endif // OAK_MATHNODEBASE_H
+24 -24
View File
@@ -26,23 +26,23 @@
namespace olive
{
const QString MergeNode::kBaseIn = QStringLiteral("base_in");
const QString MergeNode::kBlendIn = QStringLiteral("blend_in");
const QString MergeNode::k_base_in = QStringLiteral("base_in");
const QString MergeNode::k_blend_in = QStringLiteral("blend_in");
#define super Node
MergeNode::MergeNode()
{
AddInput(kBaseIn, NodeValue::kTexture,
InputFlags(kInputFlagNotKeyframable));
add_input(k_base_in, NodeValue::k_texture,
InputFlags(k_input_flag_not_keyframable));
AddInput(kBlendIn, NodeValue::kTexture,
InputFlags(kInputFlagNotKeyframable));
add_input(k_blend_in, NodeValue::k_texture,
InputFlags(k_input_flag_not_keyframable));
SetFlag(kDontShowInParamView);
set_flag(k_dont_show_in_param_view);
}
QString MergeNode::Name() const
QString MergeNode::name() const
{
return tr("Merge");
}
@@ -52,49 +52,49 @@ QString MergeNode::id() const
return QStringLiteral("org.olivevideoeditor.Olive.merge");
}
QVector<Node::CategoryID> MergeNode::Category() const
QVector<Node::CategoryID> MergeNode::category() const
{
return { kCategoryMath };
return { k_category_math };
}
QString MergeNode::Description() const
QString MergeNode::description() const
{
return tr("Merge two textures together.");
}
void MergeNode::Retranslate()
void MergeNode::retranslate()
{
super::Retranslate();
super::retranslate();
SetInputName(kBaseIn, tr("Base"));
set_input_name(k_base_in, tr("Base"));
SetInputName(kBlendIn, tr("Blend"));
set_input_name(k_blend_in, tr("Blend"));
}
ShaderCode MergeNode::GetShaderCode(const ShaderRequest &request) const
ShaderCode MergeNode::get_shader_code(const ShaderRequest &request) const
{
Q_UNUSED(request)
return ShaderCode(
FileFunctions::ReadFileAsString(":/shaders/alphaover.frag"));
FileFunctions::read_file_as_string(":/shaders/alphaover.frag"));
}
void MergeNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
void MergeNode::value(const NodeValueRow &value, const NodeGlobals &globals,
NodeValueTable *table) const
{
TexturePtr base_tex = value[kBaseIn].toTexture();
TexturePtr blend_tex = value[kBlendIn].toTexture();
TexturePtr base_tex = value[k_base_in].to_texture();
TexturePtr blend_tex = value[k_blend_in].to_texture();
if (base_tex || blend_tex) {
if (!base_tex || (blend_tex && blend_tex->channel_count() <
VideoParams::kRGBAChannelCount)) {
VideoParams::k_rgba_channel_count)) {
// We only have a blend texture or the blend texture is RGB only, no need to alpha over
table->Push(value[kBlendIn]);
table->push(value[k_blend_in]);
} else if (!blend_tex) {
// We only have a base texture, no need to alpha over
table->Push(value[kBaseIn]);
table->push(value[k_base_in]);
} else {
table->Push(NodeValue::kTexture, base_tex->toJob(ShaderJob(value)),
table->push(NodeValue::k_texture, base_tex->to_job(ShaderJob(value)),
this);
}
}
+11 -11
View File
@@ -19,8 +19,8 @@
***/
#ifndef MERGENODE_H
#define MERGENODE_H
#ifndef OAK_MERGENODE_H
#define OAK_MERGENODE_H
#include "node/node.h"
@@ -34,20 +34,20 @@ public:
NODE_DEFAULT_FUNCTIONS(MergeNode)
virtual QString Name() const override;
virtual QString name() const override;
virtual QString id() const override;
virtual QVector<CategoryID> Category() const override;
virtual QString Description() const override;
virtual QVector<CategoryID> category() const override;
virtual QString description() const override;
virtual void Retranslate() override;
virtual void retranslate() override;
virtual ShaderCode
GetShaderCode(const ShaderRequest &request) const override;
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
get_shader_code(const ShaderRequest &request) const override;
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
NodeValueTable *table) const override;
static const QString kBaseIn;
static const QString kBlendIn;
static const QString k_base_in;
static const QString k_blend_in;
private:
NodeInput *base_in_;
@@ -57,4 +57,4 @@ private:
}
#endif // MERGENODE_H
#endif // OAK_MERGENODE_H
+27 -27
View File
@@ -24,20 +24,20 @@
namespace olive
{
const QString TrigonometryNode::kMethodIn = QStringLiteral("method_in");
const QString TrigonometryNode::kXIn = QStringLiteral("x_in");
const QString TrigonometryNode::k_method_in = QStringLiteral("method_in");
const QString TrigonometryNode::k_x_in = QStringLiteral("x_in");
#define super Node
TrigonometryNode::TrigonometryNode()
{
AddInput(kMethodIn, NodeValue::kCombo,
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
add_input(k_method_in, NodeValue::k_combo,
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
AddInput(kXIn, NodeValue::kFloat, 0.0);
add_input(k_x_in, NodeValue::k_float, 0.0);
}
QString TrigonometryNode::Name() const
QString TrigonometryNode::name() const
{
return tr("Trigonometry");
}
@@ -47,19 +47,19 @@ QString TrigonometryNode::id() const
return QStringLiteral("org.olivevideoeditor.Olive.trigonometry");
}
QVector<Node::CategoryID> TrigonometryNode::Category() const
QVector<Node::CategoryID> TrigonometryNode::category() const
{
return { kCategoryMath };
return { k_category_math };
}
QString TrigonometryNode::Description() const
QString TrigonometryNode::description() const
{
return tr("Perform a trigonometry operation on a value.");
}
void TrigonometryNode::Retranslate()
void TrigonometryNode::retranslate()
{
super::Retranslate();
super::retranslate();
QStringList strings = { tr("Sine"),
tr("Cosine"),
@@ -71,50 +71,50 @@ void TrigonometryNode::Retranslate()
tr("Hyperbolic Cosine"),
tr("Hyperbolic Tangent") };
SetComboBoxStrings(kMethodIn, strings);
set_combo_box_strings(k_method_in, strings);
SetInputName(kMethodIn, tr("Method"));
set_input_name(k_method_in, tr("Method"));
SetInputName(kXIn, tr("Value"));
set_input_name(k_x_in, tr("Value"));
}
void TrigonometryNode::Value(const NodeValueRow &value,
void TrigonometryNode::value(const NodeValueRow &value,
const NodeGlobals &globals,
NodeValueTable *table) const
{
double x = value[kXIn].toDouble();
double x = value[k_x_in].to_double();
switch (static_cast<Operation>(GetStandardValue(kMethodIn).toInt())) {
case kOpSine:
switch (static_cast<Operation>(get_standard_value(k_method_in).toInt())) {
case k_op_sine:
x = std::sin(x);
break;
case kOpCosine:
case k_op_cosine:
x = std::cos(x);
break;
case kOpTangent:
case k_op_tangent:
x = std::tan(x);
break;
case kOpArcSine:
case k_op_arc_sine:
x = std::asin(x);
break;
case kOpArcCosine:
case k_op_arc_cosine:
x = std::acos(x);
break;
case kOpArcTangent:
case k_op_arc_tangent:
x = std::atan(x);
break;
case kOpHypSine:
case k_op_hyp_sine:
x = std::sinh(x);
break;
case kOpHypCosine:
case k_op_hyp_cosine:
x = std::cosh(x);
break;
case kOpHypTangent:
case k_op_hyp_tangent:
x = std::tanh(x);
break;
}
table->Push(NodeValue::kFloat, x, this);
table->push(NodeValue::k_float, x, this);
}
}
+19 -19
View File
@@ -19,8 +19,8 @@
***/
#ifndef TRIGNODE_H
#define TRIGNODE_H
#ifndef OAK_TRIGNODE_H
#define OAK_TRIGNODE_H
#include "node/node.h"
@@ -34,33 +34,33 @@ public:
NODE_DEFAULT_FUNCTIONS(TrigonometryNode)
virtual QString Name() const override;
virtual QString name() const override;
virtual QString id() const override;
virtual QVector<CategoryID> Category() const override;
virtual QString Description() const override;
virtual QVector<CategoryID> category() const override;
virtual QString description() const override;
virtual void Retranslate() override;
virtual void retranslate() override;
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
NodeValueTable *table) const override;
static const QString kMethodIn;
static const QString kXIn;
static const QString k_method_in;
static const QString k_x_in;
private:
enum Operation {
kOpSine,
kOpCosine,
kOpTangent,
kOpArcSine,
kOpArcCosine,
kOpArcTangent,
kOpHypSine,
kOpHypCosine,
kOpHypTangent
k_op_sine,
k_op_cosine,
k_op_tangent,
k_op_arc_sine,
k_op_arc_cosine,
k_op_arc_tangent,
k_op_hyp_sine,
k_op_hyp_cosine,
k_op_hyp_tangent
};
};
}
#endif // TRIGNODE_H
#endif // OAK_TRIGNODE_H