From 58c4600d04beec906e0e56ca7e8dbefb51ce8f13 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 9 May 2022 13:07:34 -0700 Subject: [PATCH] nodevalue: begin abstracting qvariant --- app/node/audio/pan/pan.cpp | 4 +- app/node/block/transition/transition.cpp | 4 +- app/node/color/ociobase/ociobase.cpp | 4 +- .../ociogradingtransformlinear.cpp | 14 ++-- .../cornerpin/cornerpindistortnode.cpp | 47 ++++++------ app/node/distort/crop/cropdistortnode.cpp | 20 ++--- app/node/distort/flip/flipdistortnode.cpp | 4 +- app/node/distort/mask/mask.cpp | 2 +- .../transform/transformdistortnode.cpp | 22 +++--- app/node/effect/opacity/opacityeffect.cpp | 4 +- app/node/filter/blur/blur.cpp | 16 ++-- app/node/filter/mosaic/mosaicfilternode.cpp | 8 +- app/node/filter/stroke/stroke.cpp | 6 +- app/node/generator/matrix/matrix.cpp | 26 +++---- app/node/generator/polygon/polygon.cpp | 14 ++-- .../generator/shape/generatorwithmerge.cpp | 2 +- app/node/generator/shape/shapenodebase.cpp | 4 +- app/node/generator/text/textv1.cpp | 14 ++-- app/node/generator/text/textv2.cpp | 18 ++--- app/node/generator/text/textv3.cpp | 12 +-- app/node/hashtraverser.cpp | 4 +- app/node/keying/chromakey/chromakey.cpp | 4 +- .../colordifferencekey/colordifferencekey.cpp | 2 +- app/node/keying/despill/despill.cpp | 2 +- app/node/math/math/mathbase.cpp | 34 ++++----- app/node/math/merge/merge.cpp | 8 +- app/node/math/trigonometry/trigonometry.cpp | 2 +- app/node/project/footage/footage.cpp | 4 +- app/node/traverser.cpp | 39 +++++----- app/node/value.cpp | 4 +- app/node/value.h | 73 +++++++++++-------- app/render/job/samplejob.h | 4 +- app/render/opengl/openglrenderer.cpp | 22 +++--- app/render/renderprocessor.cpp | 13 ++-- app/widget/nodetableview/nodetableview.cpp | 2 +- app/widget/nodevaluetree/nodevaluetree.cpp | 2 +- 36 files changed, 235 insertions(+), 229 deletions(-) diff --git a/app/node/audio/pan/pan.cpp b/app/node/audio/pan/pan.cpp index c6311e67a..10661f30a 100644 --- a/app/node/audio/pan/pan.cpp +++ b/app/node/audio/pan/pan.cpp @@ -76,7 +76,7 @@ void PanNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeV if (job.samples()->audio_params().channel_count() == 2) { // If the input is static, we can just do it now which will be faster if (IsInputStatic(kPanningInput)) { - float pan_volume = job.GetValue(kPanningInput).data().toFloat(); + float pan_volume = job.GetValue(kPanningInput).toDouble(); if (!qIsNull(pan_volume)) { if (pan_volume > 0) { job.samples()->transform_volume_for_channel(0, 1.0f - pan_volume); @@ -96,7 +96,7 @@ void PanNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeV void PanNode::ProcessSamples(const NodeValueRow &values, const SampleBufferPtr input, SampleBufferPtr output, int index) const { - float pan_val = values[kPanningInput].data().toFloat(); + float pan_val = values[kPanningInput].toDouble(); for (int i=0;iaudio_params().channel_count();i++) { output->data(i)[index] = input->data(i)[index]; diff --git a/app/node/block/transition/transition.cpp b/app/node/block/transition/transition.cpp index 97f97a31b..9cfaf24c2 100644 --- a/app/node/block/transition/transition.cpp +++ b/app/node/block/transition/transition.cpp @@ -206,8 +206,8 @@ void TransitionBlock::Value(const NodeValueRow &value, const NodeGlobals &global push_job = QVariant::fromValue(job); } else if (data_type == NodeValue::kSamples) { // This must be an audio transition - SampleBufferPtr from_samples = out_buffer.data().value(); - SampleBufferPtr to_samples = in_buffer.data().value(); + SampleBufferPtr from_samples = out_buffer.toSamples(); + SampleBufferPtr to_samples = in_buffer.toSamples(); if (from_samples || to_samples) { double time_in = globals.time().in().toDouble(); diff --git a/app/node/color/ociobase/ociobase.cpp b/app/node/color/ociobase/ociobase.cpp index 22e03f3ba..7ce711050 100644 --- a/app/node/color/ociobase/ociobase.cpp +++ b/app/node/color/ociobase/ociobase.cpp @@ -56,11 +56,11 @@ void OCIOBaseNode::ParentChanged(NodeGraph *graph) void OCIOBaseNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (!value[kTextureInput].data().isNull() && processor_) { + if (value[kTextureInput].toTexture() && processor_) { ColorTransformJob job; job.SetColorProcessor(processor_); - job.SetInputTexture(value[kTextureInput].data().value()); + job.SetInputTexture(value[kTextureInput].toTexture()); table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } diff --git a/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.cpp b/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.cpp index 7a8bc1c74..ba2ab8e1c 100644 --- a/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.cpp +++ b/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.cpp @@ -155,11 +155,11 @@ void OCIOGradingTransformLinearNode::GenerateProcessor() void OCIOGradingTransformLinearNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (!value[kTextureInput].data().isNull() && processor()) { + if (value[kTextureInput].toTexture() && processor()) { ColorTransformJob job; job.SetColorProcessor(processor()); - job.SetInputTexture(value[kTextureInput].data().value()); + job.SetInputTexture(value[kTextureInput].toTexture()); job.InsertValue(value); @@ -172,29 +172,29 @@ void OCIOGradingTransformLinearNode::Value(const NodeValueRow &value, const Node // Even more oddly, the conversion from RGBM to vec3 does not appear to have a public API. // Therefore, this code has been duplicated from OCIO here: // https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/3abbe5b20521169580fcfe3692aca81859859953/src/OpenColorIO/ops/gradingprimary/GradingPrimary.cpp#L157 - QVector4D offset = value[kOffsetInput].value(); + QVector4D offset = value[kOffsetInput].toVec4(); offset[RED_CHANNEL] += offset[MASTER_CHANNEL]; offset[GREEN_CHANNEL] += offset[MASTER_CHANNEL]; offset[BLUE_CHANNEL] += offset[MASTER_CHANNEL]; job.InsertValue(kOffsetInput, NodeValue(NodeValue::kVec3, QVector3D(offset[RED_CHANNEL], offset[GREEN_CHANNEL], offset[BLUE_CHANNEL]))); - QVector4D exposure = value[kExposureInput].value(); + QVector4D exposure = value[kExposureInput].toVec4(); exposure[RED_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] + exposure[RED_CHANNEL]); exposure[GREEN_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] + exposure[GREEN_CHANNEL]); exposure[BLUE_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] + exposure[BLUE_CHANNEL]); job.InsertValue(kExposureInput, NodeValue(NodeValue::kVec3, QVector3D(exposure[RED_CHANNEL], exposure[GREEN_CHANNEL], exposure[BLUE_CHANNEL]))); - QVector4D contrast = value[kContrastInput].value(); + QVector4D contrast = value[kContrastInput].toVec4(); contrast[RED_CHANNEL] *= contrast[MASTER_CHANNEL]; contrast[GREEN_CHANNEL] *= contrast[MASTER_CHANNEL]; contrast[BLUE_CHANNEL] *= contrast[MASTER_CHANNEL]; job.InsertValue(kContrastInput, NodeValue(NodeValue::kVec3, QVector3D(contrast[RED_CHANNEL], contrast[GREEN_CHANNEL], contrast[BLUE_CHANNEL]))); - if (!value[kClampBlackEnableInput].data().toBool()) { + if (!value[kClampBlackEnableInput].toBool()) { job.InsertValue(kClampBlackInput, NodeValue(NodeValue::kFloat, OCIO::GradingPrimary::NoClampBlack())); } - if (!value[kClampWhiteEnableInput].data().toBool()) { + if (!value[kClampWhiteEnableInput].toBool()) { job.InsertValue(kClampWhiteInput, NodeValue(NodeValue::kFloat, OCIO::GradingPrimary::NoClampWhite())); } diff --git a/app/node/distort/cornerpin/cornerpindistortnode.cpp b/app/node/distort/cornerpin/cornerpindistortnode.cpp index aa3d0e97d..f7500505b 100644 --- a/app/node/distort/cornerpin/cornerpindistortnode.cpp +++ b/app/node/distort/cornerpin/cornerpindistortnode.cpp @@ -94,16 +94,16 @@ void CornerPinDistortNode::Value(const NodeValueRow &value, const NodeGlobals &g job.SetVertexCoordinates(adjusted_vertices); // If no texture do nothing - if (!job.GetValue(kTextureInput).data().isNull()) { + if (job.GetValue(kTextureInput).toTexture()) { // In the special case that all sliders are in their default position just // push the texture. - if (!(job.GetValue(kTopLeftInput).data().value().isNull() - && job.GetValue(kTopRightInput).data().value().isNull() && - job.GetValue(kBottomRightInput).data().value().isNull() && - job.GetValue(kBottomLeftInput).data().value().isNull())) { + if (!(job.GetValue(kTopLeftInput).toVec2().isNull() + && job.GetValue(kTopRightInput).toVec2().isNull() && + job.GetValue(kBottomRightInput).toVec2().isNull() && + job.GetValue(kBottomLeftInput).toVec2().isNull())) { table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } else { - table->Push(NodeValue::kTexture, job.GetValue(kTextureInput).data(), this); + table->Push(job.GetValue(kTextureInput)); } } } @@ -119,25 +119,24 @@ ShaderCode CornerPinDistortNode::GetShaderCode(const ShaderRequest &request) con QPointF CornerPinDistortNode::ValueToPixel(int value, const NodeValueRow& row, const QVector2D &resolution) const { Q_ASSERT(value >= 0 && value <= 3); + + QVector2D v; + switch (value) { - case 0: // Top left - return QPointF(row[kTopLeftInput].data().value().x(), - row[kTopLeftInput].data().value().y()); - break; - case 1: // Top right - return QPointF(resolution.x() + row[kTopRightInput].data().value().x(), - row[kTopRightInput].data().value().y()); - break; - case 2: // Bottom right - return QPointF(resolution.x() + row[kBottomRightInput].data().value().x(), - resolution.y() + row[kBottomRightInput].data().value().y()); - break; - case 3: //Bottom left - return QPointF(row[kBottomLeftInput].data().value().x(), - row[kBottomLeftInput].data().value().y() + resolution.y()); - break; - default: // We should never get here - return QPointF(); + case 0: // Top left + v = row[kTopLeftInput].toVec2(); + return QPointF(v.x(), v.y()); + case 1: // Top right + v = row[kTopRightInput].toVec2(); + return QPointF(resolution.x() + v.x(), v.y()); + case 2: // Bottom right + v = row[kBottomRightInput].toVec2(); + return QPointF(resolution.x() + v.x(), resolution.y() + v.y()); + case 3: //Bottom left + v = row[kBottomLeftInput].toVec2(); + return QPointF(v.x(), v.y() + resolution.y()); + default: // We should never get here + return QPointF(); } } diff --git a/app/node/distort/crop/cropdistortnode.cpp b/app/node/distort/crop/cropdistortnode.cpp index 847a4a139..05b487abd 100644 --- a/app/node/distort/crop/cropdistortnode.cpp +++ b/app/node/distort/crop/cropdistortnode.cpp @@ -82,14 +82,14 @@ void CropDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global job.InsertValue(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this)); job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn); - if (!job.GetValue(kTextureInput).data().isNull()) { - if (!qIsNull(job.GetValue(kLeftInput).data().toDouble()) - || !qIsNull(job.GetValue(kRightInput).data().toDouble()) - || !qIsNull(job.GetValue(kTopInput).data().toDouble()) - || !qIsNull(job.GetValue(kBottomInput).data().toDouble())) { + if (job.GetValue(kTextureInput).toTexture()) { + if (!qIsNull(job.GetValue(kLeftInput).toDouble()) + || !qIsNull(job.GetValue(kRightInput).toDouble()) + || !qIsNull(job.GetValue(kTopInput).toDouble()) + || !qIsNull(job.GetValue(kBottomInput).toDouble())) { table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } else { - table->Push(NodeValue::kTexture, job.GetValue(kTextureInput).data(), this); + table->Push(job.GetValue(kTextureInput)); } } } @@ -104,10 +104,10 @@ void CropDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGl { const QVector2D &resolution = globals.resolution(); - double left_pt = resolution.x() * row[kLeftInput].data().toDouble(); - double top_pt = resolution.y() * row[kTopInput].data().toDouble(); - double right_pt = resolution.x() * (1.0 - row[kRightInput].data().toDouble()); - double bottom_pt = resolution.y() * (1.0 - row[kBottomInput].data().toDouble()); + double left_pt = resolution.x() * row[kLeftInput].toDouble(); + double top_pt = resolution.y() * row[kTopInput].toDouble(); + double right_pt = resolution.x() * (1.0 - row[kRightInput].toDouble()); + double bottom_pt = resolution.y() * (1.0 - row[kBottomInput].toDouble()); double center_x_pt = mid(left_pt, right_pt); double center_y_pt = mid(top_pt, bottom_pt); diff --git a/app/node/distort/flip/flipdistortnode.cpp b/app/node/distort/flip/flipdistortnode.cpp index 10b90e0ac..efd9ad75f 100644 --- a/app/node/distort/flip/flipdistortnode.cpp +++ b/app/node/distort/flip/flipdistortnode.cpp @@ -82,9 +82,9 @@ void FlipDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global job.InsertValue(value); // If there's no texture, no need to run an operation - if (!job.GetValue(kTextureInput).data().isNull()) { + if (job.GetValue(kTextureInput).toTexture()) { // Only run shader if at least one of flip or flop are selected - if (job.GetValue(kHorizontalInput).data().toBool() || job.GetValue(kVerticalInput).data().toBool()) { + if (job.GetValue(kHorizontalInput).toBool() || job.GetValue(kVerticalInput).toBool()) { table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } else { // If we're not flipping or flopping just push the texture diff --git a/app/node/distort/mask/mask.cpp b/app/node/distort/mask/mask.cpp index df0a41cef..1f1e3d832 100644 --- a/app/node/distort/mask/mask.cpp +++ b/app/node/distort/mask/mask.cpp @@ -47,7 +47,7 @@ void MaskDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global { GenerateJob job = GetGenerateJob(value); - if (!value[kBaseInput].data().isNull()) { + if (value[kBaseInput].toTexture()) { // Push as merge node ShaderJob merge; diff --git a/app/node/distort/transform/transformdistortnode.cpp b/app/node/distort/transform/transformdistortnode.cpp index 9987e1526..cc98174e7 100644 --- a/app/node/distort/transform/transformdistortnode.cpp +++ b/app/node/distort/transform/transformdistortnode.cpp @@ -92,7 +92,7 @@ void TransformDistortNode::Value(const NodeValueRow &value, const NodeGlobals &g bool pushed_job = false; // If we have a texture, generate a matrix and make it happen - if (TexturePtr texture = texture_meta.data().value()) { + if (TexturePtr texture = texture_meta.toTexture()) { // Adjust our matrix by the resolutions involved QMatrix4x4 real_matrix = GenerateAutoScaledMatrix(generated_matrix, value, globals, texture->params()); @@ -101,7 +101,7 @@ void TransformDistortNode::Value(const NodeValueRow &value, const NodeGlobals &g ShaderJob job; job.InsertValue(QStringLiteral("ove_maintex"), NodeValue(NodeValue::kTexture, QVariant::fromValue(texture), this)); job.InsertValue(QStringLiteral("ove_mvpmat"), NodeValue(NodeValue::kMatrix, real_matrix, this)); - job.SetInterpolation(QStringLiteral("ove_maintex"), static_cast(value[kInterpolationInput].data().toInt())); + job.SetInterpolation(QStringLiteral("ove_maintex"), static_cast(value[kInterpolationInput].toInt())); // FIXME: This should be optimized, we can use matrix math to determine if this operation will // end up with gaps in the screen that will require an alpha channel. @@ -140,7 +140,7 @@ void TransformDistortNode::Hash(QCryptographicHash &hash, const NodeGlobals &glo traverser.SetCacheVideoParams(video_params); NodeValueRow db = traverser.GenerateRow(this, globals.time()); - TexturePtr tex = db[kTextureInput].data().value(); + TexturePtr tex = db[kTextureInput].toTexture(); if (tex) { VideoParams tex_params = tex->params(); QMatrix4x4 matrix = GenerateMatrix(db, true, false, false, false); @@ -167,13 +167,13 @@ void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x, dou } else if (IsAScaleGizmo(gizmo)) { // Dragging scale handle - TexturePtr tex = row[kTextureInput].data().value(); + TexturePtr tex = row[kTextureInput].toTexture(); if (!tex) { return; } - gizmo_scale_uniform_ = row[kUniformScaleInput].data().toBool(); - gizmo_anchor_pt_ = (row[kAnchorInput].data().value() + gizmo->GetGlobals().resolution()/2).toPointF(); + gizmo_scale_uniform_ = row[kUniformScaleInput].toBool(); + gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() + gizmo->GetGlobals().resolution()/2).toPointF(); if (gizmo == point_gizmo_[kGizmoScaleTopLeft] || gizmo == point_gizmo_[kGizmoScaleTopRight] || gizmo == point_gizmo_[kGizmoScaleBottomLeft] || gizmo == point_gizmo_[kGizmoScaleBottomRight]) { @@ -187,7 +187,7 @@ void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x, dou // Store texture size VideoParams texture_params = tex->params(); QVector2D texture_sz(texture_params.square_pixel_width(), texture_params.height()); - gizmo_scale_anchor_ = row[kAnchorInput].data().value() + texture_sz/2; + gizmo_scale_anchor_ = row[kAnchorInput].toVec2() + texture_sz/2; if (gizmo == point_gizmo_[kGizmoScaleTopRight] || gizmo == point_gizmo_[kGizmoScaleBottomRight] @@ -208,7 +208,7 @@ void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x, dou } else if (gizmo == rotation_gizmo_) { - gizmo_anchor_pt_ = (row[kAnchorInput].data().value() + gizmo->GetGlobals().resolution()/2).toPointF(); + gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() + gizmo->GetGlobals().resolution()/2).toPointF(); gizmo_start_angle_ = qAtan2(y - gizmo_anchor_pt_.y(), x - gizmo_anchor_pt_.x()); gizmo_last_angle_ = gizmo_start_angle_; gizmo_last_alt_angle_ = qAtan2(x - gizmo_anchor_pt_.x(), y - gizmo_anchor_pt_.y()); @@ -368,7 +368,7 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(const QMatrix4x4 &mat void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals) { - TexturePtr tex = row[kTextureInput].data().value(); + TexturePtr tex = row[kTextureInput].toTexture(); if (!tex) { return; } @@ -384,7 +384,7 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const N QVector2D tex_offset = tex_params.offset(); // Retrieve autoscale value - AutoScaleType autoscale = static_cast(row[kAutoscaleInput].data().toInt()); + AutoScaleType autoscale = static_cast(row[kAutoscaleInput].toInt()); // Fold values into a matrix for the rectangle QMatrix4x4 rectangle_matrix; @@ -441,7 +441,7 @@ QMatrix4x4 TransformDistortNode::GenerateAutoScaledMatrix(const QMatrix4x4& gene { const QVector2D &sequence_res = globals.resolution(); QVector2D texture_res(texture_params.square_pixel_width(), texture_params.height()); - AutoScaleType autoscale = static_cast(value[kAutoscaleInput].data().toInt()); + AutoScaleType autoscale = static_cast(value[kAutoscaleInput].toInt()); return AdjustMatrixByResolutions(generated_matrix, sequence_res, diff --git a/app/node/effect/opacity/opacityeffect.cpp b/app/node/effect/opacity/opacityeffect.cpp index 4fe76014f..334641174 100644 --- a/app/node/effect/opacity/opacityeffect.cpp +++ b/app/node/effect/opacity/opacityeffect.cpp @@ -50,8 +50,8 @@ void OpacityEffect::Value(const NodeValueRow &value, const NodeGlobals &globals, job.InsertValue(value); // If there's no texture, no need to run an operation - if (!job.GetValue(kTextureInput).data().isNull()) { - if (!qFuzzyCompare(job.GetValue(kValueInput).data().toDouble(), 1.0)) { + if (job.GetValue(kTextureInput).toTexture()) { + if (!qFuzzyCompare(job.GetValue(kValueInput).toDouble(), 1.0)) { job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn); table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } else { diff --git a/app/node/filter/blur/blur.cpp b/app/node/filter/blur/blur.cpp index de9bcbaf9..86f950893 100644 --- a/app/node/filter/blur/blur.cpp +++ b/app/node/filter/blur/blur.cpp @@ -124,22 +124,22 @@ void BlurFilterNode::Value(const NodeValueRow &value, const NodeGlobals &globals job.InsertValue(value); job.InsertValue(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this)); - Method method = static_cast(job.GetValue(kMethodInput).data().toInt()); + Method method = static_cast(job.GetValue(kMethodInput).toInt()); // If there's no texture, no need to run an operation - if (!job.GetValue(kTextureInput).data().isNull()) { + if (job.GetValue(kTextureInput).toTexture()) { bool can_push_job = true; // Check if radius is > 0 - if (job.GetValue(kRadiusInput).data().toDouble() > 0.0) { + if (job.GetValue(kRadiusInput).toDouble() > 0.0) { // Method-specific considerations switch (method) { case kBox: case kGaussian: { - bool horiz = job.GetValue(kHorizInput).data().toBool(); - bool vert = job.GetValue(kVertInput).data().toBool(); + bool horiz = job.GetValue(kHorizInput).toBool(); + bool vert = job.GetValue(kVertInput).toBool(); if (!horiz && !vert) { // Disable job if horiz and vert are unchecked @@ -160,7 +160,7 @@ void BlurFilterNode::Value(const NodeValueRow &value, const NodeGlobals &globals if (can_push_job) { // If we're not repeating pixels, expect an alpha channel to appear - if (!job.GetValue(kRepeatEdgePixelsInput).data().toBool()) { + if (!job.GetValue(kRepeatEdgePixelsInput).toBool()) { job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn); } @@ -175,12 +175,12 @@ void BlurFilterNode::Value(const NodeValueRow &value, const NodeGlobals &globals void BlurFilterNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals) { - if (row[kMethodInput].data().toInt() == kRadial) { + if (row[kMethodInput].toInt() == kRadial) { const QVector2D &sequence_res = globals.resolution(); QVector2D sequence_half_res = sequence_res * 0.5; radial_center_gizmo_->SetVisible(true); - radial_center_gizmo_->SetPoint(sequence_half_res.toPointF() + row[kRadialCenterInput].value().toPointF()); + radial_center_gizmo_->SetPoint(sequence_half_res.toPointF() + row[kRadialCenterInput].toVec2().toPointF()); SetInputProperty(kRadialCenterInput, QStringLiteral("offset"), sequence_half_res); } else{ diff --git a/app/node/filter/mosaic/mosaicfilternode.cpp b/app/node/filter/mosaic/mosaicfilternode.cpp index 4e77a524d..31a14f28f 100644 --- a/app/node/filter/mosaic/mosaicfilternode.cpp +++ b/app/node/filter/mosaic/mosaicfilternode.cpp @@ -60,12 +60,12 @@ void MosaicFilterNode::Value(const NodeValueRow &value, const NodeGlobals &globa // Mipmapping makes this look weird, so we just use bilinear for finding the color of each block job.SetInterpolation(kTextureInput, Texture::kLinear); - if (!job.GetValue(kTextureInput).data().isNull()) { - TexturePtr texture = job.GetValue(kTextureInput).data().value(); + if (job.GetValue(kTextureInput).toTexture()) { + TexturePtr texture = job.GetValue(kTextureInput).toTexture(); if (texture - && job.GetValue(kHorizInput).data().toInt() != texture->width() - && job.GetValue(kVertInput).data().toInt() != texture->height()) { + && job.GetValue(kHorizInput).toInt() != texture->width() + && job.GetValue(kVertInput).toInt() != texture->height()) { table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } else { table->Push(job.GetValue(kTextureInput)); diff --git a/app/node/filter/stroke/stroke.cpp b/app/node/filter/stroke/stroke.cpp index 5a8ac7da7..32996ea9b 100644 --- a/app/node/filter/stroke/stroke.cpp +++ b/app/node/filter/stroke/stroke.cpp @@ -91,9 +91,9 @@ void StrokeFilterNode::Value(const NodeValueRow &value, const NodeGlobals &globa job.InsertValue(value); job.InsertValue(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this)); - if (!job.GetValue(kTextureInput).data().isNull()) { - if (job.GetValue(kRadiusInput).data().toDouble() > 0.0 - && job.GetValue(kOpacityInput).data().toDouble() > 0.0) { + if (job.GetValue(kTextureInput).toTexture()) { + if (job.GetValue(kRadiusInput).toDouble() > 0.0 + && job.GetValue(kOpacityInput).toDouble() > 0.0) { table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } else { table->Push(job.GetValue(kTextureInput)); diff --git a/app/node/generator/matrix/matrix.cpp b/app/node/generator/matrix/matrix.cpp index 0d5184335..d545ab2d9 100644 --- a/app/node/generator/matrix/matrix.cpp +++ b/app/node/generator/matrix/matrix.cpp @@ -103,47 +103,47 @@ QMatrix4x4 MatrixGenerator::GenerateMatrix(const NodeValueRow &value, bool take, if (!ignore_anchor) { if (take) { // Take and store - anchor = value[kAnchorInput].data().value(); + anchor = value[kAnchorInput].toVec2(); } else { // Get and store - anchor = value[kAnchorInput].data().value(); + anchor = value[kAnchorInput].toVec2(); } } else if (take) { // Just take - value[kAnchorInput].data().value(); + value[kAnchorInput].toVec2(); } if (!ignore_scale) { if (take) { - scale = value[kScaleInput].data().value(); + scale = value[kScaleInput].toVec2(); } else { - scale = value[kScaleInput].data().value(); + scale = value[kScaleInput].toVec2(); } } else if (take) { - value[kScaleInput].data().value(); + value[kScaleInput].toVec2(); } if (!ignore_position) { if (take) { - position = value[kPositionInput].data().value(); + position = value[kPositionInput].toVec2(); } else { - position = value[kPositionInput].data().value(); + position = value[kPositionInput].toVec2(); } } else if (take) { - value[kPositionInput].data().value(); + value[kPositionInput].toVec2(); } if (take) { return GenerateMatrix(position, - value[kRotationInput].data().toFloat(), + value[kRotationInput].toDouble(), scale, - value[kUniformScaleInput].data().toBool(), + value[kUniformScaleInput].toBool(), anchor); } else { return GenerateMatrix(position, - value[kRotationInput].data().toFloat(), + value[kRotationInput].toDouble(), scale, - value[kUniformScaleInput].data().toBool(), + value[kUniformScaleInput].toBool(), anchor); } diff --git a/app/node/generator/polygon/polygon.cpp b/app/node/generator/polygon/polygon.cpp index 65c1c8f58..412299df1 100644 --- a/app/node/generator/polygon/polygon.cpp +++ b/app/node/generator/polygon/polygon.cpp @@ -116,7 +116,7 @@ void PolygonGenerator::GenerateFrame(FramePtr frame, const GenerateJob &job) con QImage img(frame->width(), frame->height(), QImage::Format_Grayscale8); img.fill(Qt::transparent); - QVector points = job.GetValue(kPointsInput).data().value< QVector >(); + QVector points = job.GetValue(kPointsInput).value< QVector >(); QPainterPath path = GeneratePath(points); @@ -130,7 +130,7 @@ void PolygonGenerator::GenerateFrame(FramePtr frame, const GenerateJob &job) con p.drawPath(path); // Transplant alpha channel to frame - Color rgba = job.GetValue(kColorInput).data().value(); + Color rgba = job.GetValue(kColorInput).toColor(); #if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM) __m128 sse_color = _mm_loadu_ps(rgba.data()); #endif @@ -196,7 +196,7 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row, const NodeG { QPointF half_res(globals.resolution_by_par().x()/2, globals.resolution_by_par().y()/2); - QVector points = row[kPointsInput].data().value< QVector >(); + QVector points = row[kPointsInput].value< QVector >(); int current_pos_sz = gizmo_position_handles_.size(); @@ -223,7 +223,7 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row, const NodeG if (!points.isEmpty()) { for (int i=0; i(); + const Bezier &pt = points.at(i).toBezier(); QPointF main = pt.ToPointF() + half_res; QPointF cp1 = main + pt.ControlPoint1ToPointF(); @@ -267,14 +267,14 @@ QPainterPath PolygonGenerator::GeneratePath(const QVector &points) QPainterPath path; if (!points.isEmpty()) { - const Bezier &first_pt = points.first().data().value(); + const Bezier &first_pt = points.first().toBezier(); path.moveTo(first_pt.ToPointF()); for (int i=1; i(), points.at(i).data().value()); + AddPointToPath(&path, points.at(i-1).toBezier(), points.at(i).toBezier()); } - AddPointToPath(&path, points.last().data().value(), first_pt); + AddPointToPath(&path, points.last().toBezier(), first_pt); } return path; diff --git a/app/node/generator/shape/generatorwithmerge.cpp b/app/node/generator/shape/generatorwithmerge.cpp index fac36b0ff..47ae76e88 100644 --- a/app/node/generator/shape/generatorwithmerge.cpp +++ b/app/node/generator/shape/generatorwithmerge.cpp @@ -53,7 +53,7 @@ ShaderCode GeneratorWithMerge::GetShaderCode(const ShaderRequest &request) const void GeneratorWithMerge::PushMergableJob(const NodeValueRow &value, const QVariant &job, NodeValueTable *table) const { - if (!value[kBaseInput].data().isNull()) { + if (value[kBaseInput].toTexture()) { // Push as merge node ShaderJob merge; diff --git a/app/node/generator/shape/shapenodebase.cpp b/app/node/generator/shape/shapenodebase.cpp index 4eb411079..77a25f5e3 100644 --- a/app/node/generator/shape/shapenodebase.cpp +++ b/app/node/generator/shape/shapenodebase.cpp @@ -79,8 +79,8 @@ void ShapeNodeBase::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlob QVector2D center_pt = globals.resolution() * 0.5; SetInputProperty(kPositionInput, QStringLiteral("offset"), center_pt); - QVector2D pos = row[kPositionInput].data().value(); - QVector2D sz = row[kSizeInput].data().value(); + QVector2D pos = row[kPositionInput].toVec2(); + QVector2D sz = row[kSizeInput].toVec2(); QVector2D half_sz = sz * 0.5; double left_pt = pos.x() + center_pt.x() - half_sz.x(); diff --git a/app/node/generator/text/textv1.cpp b/app/node/generator/text/textv1.cpp index 516c7bd31..395783dfa 100644 --- a/app/node/generator/text/textv1.cpp +++ b/app/node/generator/text/textv1.cpp @@ -96,7 +96,7 @@ void TextGeneratorV1::Value(const NodeValueRow &value, const NodeGlobals &global job.InsertValue(value); job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn); - if (!job.GetValue(kTextInput).data().toString().isEmpty()) { + if (!job.GetValue(kTextInput).toString().isEmpty()) { table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } } @@ -114,15 +114,15 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame, const GenerateJob& job) cons // Set default font QFont default_font; - default_font.setFamily(job.GetValue(kFontInput).data().toString()); - default_font.setPointSizeF(job.GetValue(kFontSizeInput).data().toFloat()); + default_font.setFamily(job.GetValue(kFontInput).toString()); + default_font.setPointSizeF(job.GetValue(kFontSizeInput).toDouble()); text_doc.setDefaultFont(default_font); // Center by default text_doc.setDefaultTextOption(QTextOption(Qt::AlignCenter)); - QString html = job.GetValue(kTextInput).data().toString(); - if (job.GetValue(kHtmlInput).data().toBool()) { + QString html = job.GetValue(kTextInput).toString(); + if (job.GetValue(kHtmlInput).toBool()) { html.replace('\n', QStringLiteral("
")); text_doc.setHtml(html); } else { @@ -140,7 +140,7 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame, const GenerateJob& job) cons // Push 10% inwards to compensate for title safe area p.translate(tenth_of_width, 0); - TextVerticalAlign valign = static_cast(job.GetValue(kVAlignInput).data().toInt()); + TextVerticalAlign valign = static_cast(job.GetValue(kVAlignInput).toInt()); int doc_height = text_doc.size().height(); switch (valign) { @@ -163,7 +163,7 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame, const GenerateJob& job) cons text_doc.documentLayout()->draw(&p, ctx); // Transplant alpha channel to frame - Color rgb = job.GetValue(kColorInput).data().value(); + Color rgb = job.GetValue(kColorInput).toColor(); for (int x=0; xwidth(); x++) { for (int y=0; yheight(); y++) { uchar src_alpha = img.bits()[img.bytesPerLine() * y + x]; diff --git a/app/node/generator/text/textv2.cpp b/app/node/generator/text/textv2.cpp index 788f80bbd..0d607715d 100644 --- a/app/node/generator/text/textv2.cpp +++ b/app/node/generator/text/textv2.cpp @@ -100,7 +100,7 @@ void TextGeneratorV2::Value(const NodeValueRow &value, const NodeGlobals &global job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn); job.SetRequestedFormat(VideoParams::kFormatFloat32); - if (!job.GetValue(kTextInput).data().toString().isEmpty()) { + if (!job.GetValue(kTextInput).toString().isEmpty()) { table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } } @@ -124,19 +124,19 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame, const GenerateJob& job) cons // Set default font QFont default_font; - default_font.setFamily(job.GetValue(kFontInput).data().toString()); - default_font.setPointSizeF(job.GetValue(kFontSizeInput).data().toFloat()); + default_font.setFamily(job.GetValue(kFontInput).toString()); + default_font.setPointSizeF(job.GetValue(kFontSizeInput).toDouble()); text_doc.setDefaultFont(default_font); - QString html = job.GetValue(kTextInput).data().toString(); - if (job.GetValue(kHtmlInput).data().toBool()) { + QString html = job.GetValue(kTextInput).toString(); + if (job.GetValue(kHtmlInput).toBool()) { html.replace('\n', QStringLiteral("
")); text_doc.setHtml(html); } else { text_doc.setPlainText(html); } - QVector2D size = job.GetValue(kSizeInput).data().value(); + QVector2D size = job.GetValue(kSizeInput).toVec2(); text_doc.setTextWidth(size.x()); // Draw rich text onto image @@ -144,12 +144,12 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame, const GenerateJob& job) cons p.scale(1.0 / frame->video_params().divider(), 1.0 / frame->video_params().divider()); - QVector2D pos = job.GetValue(kPositionInput).data().value(); + QVector2D pos = job.GetValue(kPositionInput).toVec2(); p.translate(pos.x() - size.x()/2, pos.y() - size.y()/2); p.translate(frame->video_params().width()/2, frame->video_params().height()/2); p.setClipRect(0, 0, size.x(), size.y()); - TextVerticalAlign valign = static_cast(job.GetValue(kVAlignInput).data().toInt()); + TextVerticalAlign valign = static_cast(job.GetValue(kVAlignInput).toInt()); int doc_height = text_doc.size().height(); switch (valign) { @@ -171,7 +171,7 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame, const GenerateJob& job) cons text_doc.documentLayout()->draw(&p, ctx); // Transplant alpha channel to frame - Color rgba = job.GetValue(kColorInput).data().value(); + Color rgba = job.GetValue(kColorInput).toColor(); #if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM) __m128 sse_color = _mm_loadu_ps(rgba.data()); #endif diff --git a/app/node/generator/text/textv3.cpp b/app/node/generator/text/textv3.cpp index 4413d6f65..d01c1b93d 100644 --- a/app/node/generator/text/textv3.cpp +++ b/app/node/generator/text/textv3.cpp @@ -88,9 +88,9 @@ void TextGeneratorV3::Value(const NodeValueRow &value, const NodeGlobals &global // FIXME: Provide user override for this job.SetColorspace(project()->color_manager()->GetDefaultInputColorSpace()); - if (!job.GetValue(kTextInput).data().toString().isEmpty()) { + if (!job.GetValue(kTextInput).toString().isEmpty()) { PushMergableJob(value, QVariant::fromValue(job), table); - } else if (!value[kBaseInput].data().isNull()) { + } else if (value[kBaseInput].toTexture()) { table->Push(value[kBaseInput]); } } @@ -108,17 +108,17 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame, const GenerateJob& job) cons QTextDocument text_doc; text_doc.documentLayout()->setPaintDevice(&img); - QString html = job.GetValue(kTextInput).data().toString(); + QString html = job.GetValue(kTextInput).toString(); Html::HtmlToDoc(&text_doc, html); - QVector2D size = job.GetValue(kSizeInput).data().value(); + QVector2D size = job.GetValue(kSizeInput).toVec2(); text_doc.setTextWidth(size.x()); // Draw rich text onto image QPainter p(&img); p.scale(1.0 / frame->video_params().divider(), 1.0 / frame->video_params().divider()); - QVector2D pos = job.GetValue(kPositionInput).data().value(); + QVector2D pos = job.GetValue(kPositionInput).toVec2(); p.translate(pos.x() - size.x()/2, pos.y() - size.y()/2); p.translate(frame->video_params().width()/2, frame->video_params().height()/2); p.setClipRect(0, 0, size.x(), size.y()); @@ -136,7 +136,7 @@ void TextGeneratorV3::UpdateGizmoPositions(const NodeValueRow &row, const NodeGl QRectF rect = poly_gizmo()->GetPolygon().boundingRect(); text_gizmo_->SetRect(rect); - text_gizmo_->SetHtml(row[kTextInput].data().toString()); + text_gizmo_->SetHtml(row[kTextInput].toString()); } } diff --git a/app/node/hashtraverser.cpp b/app/node/hashtraverser.cpp index fe469535e..cff52dd77 100644 --- a/app/node/hashtraverser.cpp +++ b/app/node/hashtraverser.cpp @@ -144,10 +144,10 @@ void HashTraverser::HashNodeValue(const NodeValue &value) if (value_type == NodeValue::kSamples || value_type == NodeValue::kTexture) { QByteArray id_for_buffer; if (value_type == NodeValue::kTexture) { - TexturePtr texture = value.data().value(); + TexturePtr texture = value.toTexture(); id_for_buffer = texture_ids_.value(texture.get()); } else { - SampleBufferPtr samples = value.data().value(); + SampleBufferPtr samples = value.toSamples(); id_for_buffer = texture_ids_.value(samples.get()); } diff --git a/app/node/keying/chromakey/chromakey.cpp b/app/node/keying/chromakey/chromakey.cpp index 18910e886..3dbc1f56e 100644 --- a/app/node/keying/chromakey/chromakey.cpp +++ b/app/node/keying/chromakey/chromakey.cpp @@ -128,13 +128,13 @@ void ChromaKeyNode::GenerateProcessor() void ChromaKeyNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (!value[kTextureInput].data().isNull() && processor()) { + if (value[kTextureInput].toTexture() && processor()) { ColorTransformJob job; job.InsertValue(value); job.SetAlphaChannelRequired(ColorTransformJob::kAlphaForceOn); job.SetColorProcessor(processor()); - job.SetInputTexture(value[kTextureInput].data().value()); + job.SetInputTexture(value[kTextureInput].toTexture()); job.SetNeedsCustomShader(this); job.SetFunctionName(QStringLiteral("SceneLinearToCIEXYZ_d65")); diff --git a/app/node/keying/colordifferencekey/colordifferencekey.cpp b/app/node/keying/colordifferencekey/colordifferencekey.cpp index aaf9b77f0..bd1113518 100644 --- a/app/node/keying/colordifferencekey/colordifferencekey.cpp +++ b/app/node/keying/colordifferencekey/colordifferencekey.cpp @@ -98,7 +98,7 @@ void ColorDifferenceKeyNode::Value(const NodeValueRow &value, const NodeGlobals job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn); // If there's no texture, no need to run an operation - if (!job.GetValue(kTextureInput).data().isNull()) { + if (job.GetValue(kTextureInput).toTexture()) { table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } } diff --git a/app/node/keying/despill/despill.cpp b/app/node/keying/despill/despill.cpp index 364e04a1f..577cfbab5 100644 --- a/app/node/keying/despill/despill.cpp +++ b/app/node/keying/despill/despill.cpp @@ -91,7 +91,7 @@ void DespillNode::Value(const NodeValueRow &value, const NodeGlobals &globals, N NodeValue(NodeValue::kVec3, QVector3D(luma_coeffs[0], luma_coeffs[1], luma_coeffs[2]))); // If there's no texture, no need to run an operation - if (!job.GetValue(kTextureInput).data().isNull()) { + if (job.GetValue(kTextureInput).toTexture()) { table->Push(NodeValue::kTexture, QVariant::fromValue(job), this); } } diff --git a/app/node/math/math/mathbase.cpp b/app/node/math/math/mathbase.cpp index 00c0b7ce4..9a78b1f97 100644 --- a/app/node/math/math/mathbase.cpp +++ b/app/node/math/math/mathbase.cpp @@ -141,12 +141,12 @@ QVector4D MathNodeBase::RetrieveVector(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 val.data().value(); + return val.toVec2(); case NodeValue::kVec3: - return val.data().value(); + return val.toVec3(); case NodeValue::kVec4: default: - return val.data().value(); + return val.toVec4(); } } @@ -225,7 +225,7 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt if (val_a.type() == NodeValue::kRational && val_b.type() == NodeValue::kRational && operation != kOpPower) { // Preserve rationals output->Push(NodeValue::kRational, - QVariant::fromValue(PerformAddSubMultDiv(operation, val_a.data().value(), val_b.data().value())), + QVariant::fromValue(PerformAddSubMultDiv(operation, val_a.toRational(), val_b.toRational())), this); } else { output->Push(NodeValue::kFloat, @@ -247,7 +247,7 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt case kPairMatrixVec: { - QMatrix4x4 matrix = (val_a.type() == NodeValue::kMatrix) ? val_a.data().value() : val_b.data().value(); + 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); // Only valid operation is multiply @@ -269,16 +269,16 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt case kPairMatrixMatrix: { - QMatrix4x4 mat_a = val_a.data().value(); - QMatrix4x4 mat_b = val_b.data().value(); + QMatrix4x4 mat_a = val_a.toMatrix(); + QMatrix4x4 mat_b = val_b.toMatrix(); output->Push(NodeValue::kMatrix, PerformAddSubMult(operation, mat_a, mat_b), this); break; } case kPairColorColor: { - Color col_a = val_a.data().value(); - Color col_b = val_b.data().value(); + Color col_a = val_a.toColor(); + Color col_b = val_b.toColor(); // Only add and subtract are valid operations output->Push(NodeValue::kColor, QVariant::fromValue(PerformAddSub(operation, col_a, col_b)), this); @@ -288,8 +288,8 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt case kPairNumberColor: { - Color col = (val_a.type() == NodeValue::kColor) ? val_a.data().value() : val_b.data().value(); - float num = (val_a.type() == NodeValue::kColor) ? val_b.data().toFloat() : val_a.data().toFloat(); + 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(); // Only multiply and divide are valid operations output->Push(NodeValue::kColor, QVariant::fromValue(PerformMult(operation, col, num)), this); @@ -298,8 +298,8 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt case kPairSampleSample: { - SampleBufferPtr samples_a = val_a.data().value(); - SampleBufferPtr samples_b = val_b.data().value(); + SampleBufferPtr samples_a = val_a.toSamples(); + SampleBufferPtr samples_b = val_b.toSamples(); int max_samples = qMax(samples_a->sample_count(), samples_b->sample_count()); int min_samples = qMin(samples_a->sample_count(), samples_b->sample_count()); @@ -348,7 +348,7 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt const NodeValue& number_val = val_a.type() == NodeValue::kTexture ? val_b : val_a; const NodeValue& texture_val = val_a.type() == NodeValue::kTexture ? val_a : val_b; - TexturePtr texture = texture_val.data().value(); + TexturePtr texture = texture_val.toTexture(); if (!texture) { operation_is_noop = true; @@ -361,7 +361,7 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt const QVector2D &sequence_res = globals.resolution(); QVector2D texture_res(texture->params().width() * texture->pixel_aspect_ratio().toDouble(), texture->params().height()); - QMatrix4x4 adjusted_matrix = TransformDistortNode::AdjustMatrixByResolutions(number_val.data().value(), + QMatrix4x4 adjusted_matrix = TransformDistortNode::AdjustMatrixByResolutions(number_val.toMatrix(), sequence_res, texture->params().offset(), texture_res); @@ -449,9 +449,9 @@ void MathNodeBase::ProcessSamplesInternal(const NodeValueRow &values, MathNodeBa float MathNodeBase::RetrieveNumber(const NodeValue &val) { if (val.type() == NodeValue::kRational) { - return val.data().value().toDouble(); + return val.toRational().toDouble(); } else { - return val.data().toFloat(); + return val.toDouble(); } } diff --git a/app/node/math/merge/merge.cpp b/app/node/math/merge/merge.cpp index 335cb9e74..02506c9f3 100644 --- a/app/node/math/merge/merge.cpp +++ b/app/node/math/merge/merge.cpp @@ -79,8 +79,8 @@ void MergeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, Nod ShaderJob job; job.InsertValue(value); - TexturePtr base_tex = job.GetValue(kBaseIn).data().value(); - TexturePtr blend_tex = job.GetValue(kBlendIn).data().value(); + TexturePtr base_tex = job.GetValue(kBaseIn).toTexture(); + TexturePtr blend_tex = job.GetValue(kBlendIn).toTexture(); if (base_tex || blend_tex) { if (!base_tex || (blend_tex && blend_tex->channel_count() < VideoParams::kRGBAChannelCount)) { @@ -108,8 +108,8 @@ void MergeNode::Hash(QCryptographicHash &hash, const NodeGlobals &globals, const NodeValueDatabase db = traverser.GenerateDatabase(this, globals.time()); - TexturePtr base_tex = db[kBaseIn].Get(NodeValue::kTexture).value(); - TexturePtr blend_tex = db[kBlendIn].Get(NodeValue::kTexture).value(); + TexturePtr base_tex = db[kBaseIn].Get(NodeValue::kTexture).toTexture(); + TexturePtr blend_tex = db[kBlendIn].Get(NodeValue::kTexture).toTexture(); if (base_tex || blend_tex) { bool passthrough_base = !blend_tex; diff --git a/app/node/math/trigonometry/trigonometry.cpp b/app/node/math/trigonometry/trigonometry.cpp index 461ba538a..426604ca1 100644 --- a/app/node/math/trigonometry/trigonometry.cpp +++ b/app/node/math/trigonometry/trigonometry.cpp @@ -79,7 +79,7 @@ void TrigonometryNode::Retranslate() void TrigonometryNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - double x = value[kXIn].data().toFloat(); + double x = value[kXIn].toDouble(); switch (static_cast(GetStandardValue(kMethodIn).toInt())) { case kOpSine: diff --git a/app/node/project/footage/footage.cpp b/app/node/project/footage/footage.cpp index 59d520d96..825470782 100644 --- a/app/node/project/footage/footage.cpp +++ b/app/node/project/footage/footage.cpp @@ -322,9 +322,9 @@ void Footage::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeV Q_UNUSED(globals) // Pop filename from table - QString file = value[kFilenameInput].data().toString(); + QString file = value[kFilenameInput].toString(); - LoopMode loop_mode = static_cast(value[kLoopModeInput].data().toInt()); + LoopMode loop_mode = static_cast(value[kLoopModeInput].toInt()); // If the file exists and the reference is valid, push a footage job to the renderer if (QFileInfo(file).exists()) { diff --git a/app/node/traverser.cpp b/app/node/traverser.cpp index 7c5c0e37f..54cd8758c 100644 --- a/app/node/traverser.cpp +++ b/app/node/traverser.cpp @@ -71,7 +71,7 @@ NodeValue NodeTraverser::GenerateRowValue(const Node *node, const QString &input if (value.array()) { // Resolve each element of array - QVector tables = value.data().value >(); + QVector tables = value.value >(); QVector output(tables.size()); for (int i=0; i(); - if (tex) { + if (TexturePtr tex = it.value().toTexture()) { max_channel_count = qMax(max_channel_count, tex->channel_count()); } } @@ -304,11 +303,9 @@ QVector2D NodeTraverser::GenerateResolution() const void NodeTraverser::ResolveJobs(NodeValue &val, const TimeRange &range) { if (val.type() == NodeValue::kTexture || val.type() == NodeValue::kSamples) { - const QVariant &v = val.data(); + if (val.canConvert()) { - if (v.canConvert()) { - - ShaderJob job = v.value(); + ShaderJob job = val.value(); VideoParams tex_params = GetCacheVideoParams(); tex_params.set_channel_count(GetChannelCountFromJob(job)); @@ -318,11 +315,11 @@ void NodeTraverser::ResolveJobs(NodeValue &val, const TimeRange &range) PreProcessRow(range, job.GetValues()); ProcessShader(tex, val.source(), range, job); - val.set_data(QVariant::fromValue(tex)); + val.set_value(tex); - } else if (v.canConvert()) { + } else if (val.canConvert()) { - GenerateJob job = v.value(); + GenerateJob job = val.value(); VideoParams tex_params = GetCacheVideoParams(); tex_params.set_channel_count(GetChannelCountFromJob(job)); @@ -346,11 +343,11 @@ void NodeTraverser::ResolveJobs(NodeValue &val, const TimeRange &range) tex = dest; } - val.set_data(QVariant::fromValue(tex)); + val.set_value(tex); - } else if (v.canConvert()) { + } else if (val.canConvert()) { - ColorTransformJob job = v.value(); + ColorTransformJob job = val.value(); VideoParams src_params = job.GetInputTexture()->params(); src_params.set_channel_count(GetChannelCountFromJob(job)); @@ -359,11 +356,11 @@ void NodeTraverser::ResolveJobs(NodeValue &val, const TimeRange &range) ProcessColorTransform(dest, val.source(), job); - val.set_data(QVariant::fromValue(dest)); + val.set_value(dest); - } else if (v.canConvert()) { + } else if (val.canConvert()) { - FootageJob job = v.value(); + FootageJob job = val.value(); if (job.type() == Track::kVideo) { @@ -399,22 +396,22 @@ void NodeTraverser::ResolveJobs(NodeValue &val, const TimeRange &range) ProcessVideoFootage(tex, job, footage_time); } - val.set_data(QVariant::fromValue(tex)); + val.set_value(tex); } else if (job.type() == Track::kAudio) { SampleBufferPtr buffer = CreateSampleBuffer(GetCacheAudioParams(), range.length()); ProcessAudioFootage(buffer, job, range); - val.set_data(QVariant::fromValue(buffer)); + val.set_value(buffer); } - } else if (v.canConvert()) { + } else if (val.canConvert()) { - SampleJob job = v.value(); + SampleJob job = val.value(); SampleBufferPtr output_buffer = CreateSampleBuffer(job.samples()->audio_params(), job.samples()->sample_count()); ProcessSamples(output_buffer, val.source(), range, job); - val.set_data(QVariant::fromValue(output_buffer)); + val.set_value(QVariant::fromValue(output_buffer)); } diff --git a/app/node/value.cpp b/app/node/value.cpp index cdafe2151..d103b1973 100644 --- a/app/node/value.cpp +++ b/app/node/value.cpp @@ -418,7 +418,7 @@ NodeValue::Type NodeValue::GetDataTypeFromName(const QString &n) return NodeValue::kNone; } -NodeValue NodeValueTable::GetWithMeta(const QVector &type, const QString &tag) const +NodeValue NodeValueTable::Get(const QVector &type, const QString &tag) const { int value_index = GetValueIndex(type, tag); @@ -429,7 +429,7 @@ NodeValue NodeValueTable::GetWithMeta(const QVector &type, cons return NodeValue(); } -NodeValue NodeValueTable::TakeWithMeta(const QVector &type, const QString &tag) +NodeValue NodeValueTable::Take(const QVector &type, const QString &tag) { int value_index = GetValueIndex(type, tag); diff --git a/app/node/value.h b/app/node/value.h index e16fc1055..bb5b56dbe 100644 --- a/app/node/value.h +++ b/app/node/value.h @@ -21,10 +21,16 @@ #ifndef NODEVALUE_H #define NODEVALUE_H +#include #include #include #include +#include "codec/samplebuffer.h" +#include "common/bezier.h" +#include "node/splitvalue.h" +#include "render/color.h" +#include "render/texture.h" #include "undo/undocommand.h" namespace olive { @@ -209,14 +215,16 @@ public: return data_.value(); } - const QVariant& data() const + template + void set_value(const T &v) { - return data_; + data_ = QVariant::fromValue(v); } - void set_data(const QVariant& data) + template + bool canConvert() const { - data_ = data; + return data_.canConvert(); } const QString& tag() const @@ -245,6 +253,10 @@ public: static NodeValue::Type GetDataTypeFromName(const QString &n); static QString ValueToString(Type data_type, const QVariant& value, bool value_is_a_key_track); + static QString ValueToString(const NodeValue &v, bool value_is_a_key_track) + { + return ValueToString(v.type_, v.data_, value_is_a_key_track); + } static QVariant StringToValue(Type data_type, const QString &string, bool value_is_a_key_track); @@ -254,13 +266,18 @@ public: static QByteArray ValueToBytes(Type type, const QVariant& value); static QByteArray ValueToBytes(const NodeValue &value) { - return ValueToBytes(value.type(), value.data()); + return ValueToBytes(value.type(), value.data_); } static QVector split_normal_value_into_track_values(Type type, const QVariant &value); static QVariant combine_track_values_into_normal_value(Type type, const QVector& split); + SplitValue to_split_value() const + { + return split_normal_value_into_track_values(type_, data_); + } + /** * @brief Returns whether a data type can be interpolated or not */ @@ -289,6 +306,22 @@ public: static void ValidateVectorString(QStringList* list, int count); + TexturePtr toTexture() const { return value(); } + SampleBufferPtr toSamples() const { return value(); } + bool toBool() const { return value(); } + double toDouble() const { return value(); } + int64_t toInt() const { return value(); } + rational toRational() const { return value(); } + QString toString() const { return value(); } + Color toColor() const { return value(); } + QMatrix4x4 toMatrix() const { return value(); } + VideoParams toVideoParams() const { return value(); } + AudioParams toAudioParams() const { return value(); } + QVector2D toVec2() const { return value(); } + QVector3D toVec3() const { return value(); } + QVector4D toVec4() const { return value(); } + Bezier toBezier() const { return value(); } + private: Type type_; QVariant data_; @@ -303,43 +336,21 @@ class NodeValueTable public: NodeValueTable() = default; - QVariant Get(NodeValue::Type type, const QString& tag = QString()) const + NodeValue Get(NodeValue::Type type, const QString& tag = QString()) const { QVector types = {type}; return Get(types, tag); } - QVariant Get(const QVector& type, const QString& tag = QString()) const - { - return GetWithMeta(type, tag).data(); - } + NodeValue Get(const QVector& type, const QString& tag = QString()) const; - NodeValue GetWithMeta(NodeValue::Type type, const QString& tag = QString()) const - { - QVector types = {type}; - return GetWithMeta(types, tag); - } - - NodeValue GetWithMeta(const QVector& type, const QString& tag = QString()) const; - - QVariant Take(NodeValue::Type type, const QString& tag = QString()) + NodeValue Take(NodeValue::Type type, const QString& tag = QString()) { QVector types = {type}; return Take(types, tag); } - QVariant Take(const QVector& type, const QString& tag = QString()) - { - return TakeWithMeta(type, tag).data(); - } - - NodeValue TakeWithMeta(NodeValue::Type type, const QString& tag = QString()) - { - QVector types = {type}; - return TakeWithMeta(types, tag); - } - - NodeValue TakeWithMeta(const QVector& type, const QString& tag = QString()); + NodeValue Take(const QVector& type, const QString& tag = QString()); void Push(const NodeValue& value) { diff --git a/app/render/job/samplejob.h b/app/render/job/samplejob.h index ad78bb6d2..65aca18f5 100644 --- a/app/render/job/samplejob.h +++ b/app/render/job/samplejob.h @@ -35,12 +35,12 @@ public: SampleJob(const NodeValue& value) { - samples_ = value.data().value(); + samples_ = value.toSamples(); } SampleJob(const QString& from, const NodeValueRow& row) { - samples_ = row[from].data().value(); + samples_ = row[from].toSamples(); } SampleBufferPtr samples() const diff --git a/app/render/opengl/openglrenderer.cpp b/app/render/opengl/openglrenderer.cpp index 628ed8f15..d5553704d 100644 --- a/app/render/opengl/openglrenderer.cpp +++ b/app/render/opengl/openglrenderer.cpp @@ -449,48 +449,48 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video case NodeValue::kInt: // kInt technically specifies a LongLong, but OpenGL doesn't support those. This may lead to // over/underflows if the number is large enough, but the likelihood of that is quite low. - functions_->glUniform1i(variable_location, value.data().toInt()); + functions_->glUniform1i(variable_location, value.toInt()); break; case NodeValue::kFloat: // kFloat technically specifies a double but as above, OpenGL doesn't support those. - functions_->glUniform1f(variable_location, value.data().toFloat()); + functions_->glUniform1f(variable_location, value.toDouble()); break; case NodeValue::kVec2: { - QVector2D v = value.data().value(); + QVector2D v = value.toVec2(); functions_->glUniform2fv(variable_location, 1, reinterpret_cast(&v)); break; } case NodeValue::kVec3: { - QVector3D v = value.data().value(); + QVector3D v = value.toVec3(); functions_->glUniform3fv(variable_location, 1, reinterpret_cast(&v)); break; } case NodeValue::kVec4: { - QVector4D v = value.data().value(); + QVector4D v = value.toVec4(); functions_->glUniform4fv(variable_location, 1, reinterpret_cast(&v)); break; } case NodeValue::kMatrix: - functions_->glUniformMatrix4fv(variable_location, 1, false, value.data().value().constData()); + functions_->glUniformMatrix4fv(variable_location, 1, false, value.toMatrix().constData()); break; case NodeValue::kCombo: - functions_->glUniform1i(variable_location, value.data().value()); + functions_->glUniform1i(variable_location, value.toInt()); break; case NodeValue::kColor: { - Color color = value.data().value(); + Color color = value.toColor(); functions_->glUniform4f(variable_location, color.red(), color.green(), color.blue(), color.alpha()); break; } case NodeValue::kBoolean: - functions_->glUniform1i(variable_location, value.data().toBool()); + functions_->glUniform1i(variable_location, value.toBool()); break; case NodeValue::kTexture: { - TexturePtr texture = value.data().value(); + TexturePtr texture = value.toTexture(); // Set value to bound texture functions_->glUniform1i(variable_location, textures_to_bind.size()); @@ -552,7 +552,7 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video // Ensure matrix is set, at least to identity GLint mvpmat_location = functions_->glGetUniformLocation(shader, "ove_mvpmat"); if (mvpmat_location > -1) { - functions_->glUniformMatrix4fv(mvpmat_location, 1, false, job.GetValue(QStringLiteral("ove_mvpmat")).data().value().constData()); + functions_->glUniformMatrix4fv(mvpmat_location, 1, false, job.GetValue(QStringLiteral("ove_mvpmat")).toMatrix().constData()); } // Set the viewport to the "physical" resolution of the destination diff --git a/app/render/renderprocessor.cpp b/app/render/renderprocessor.cpp index c5586022b..e81a056f7 100644 --- a/app/render/renderprocessor.cpp +++ b/app/render/renderprocessor.cpp @@ -55,11 +55,11 @@ TexturePtr RenderProcessor::GenerateTexture(const rational &time, const rational table = GenerateTable(texture_output, viewer->GetValueHintForInput(ViewerOutput::kTextureInput), range); } - NodeValue tex_val = table.GetWithMeta(NodeValue::kTexture); + NodeValue tex_val = table.Get(NodeValue::kTexture); ResolveJobs(tex_val, range); - return tex_val.data().value(); + return tex_val.toTexture(); } FramePtr RenderProcessor::GenerateFrame(TexturePtr texture, const rational& time) @@ -196,12 +196,11 @@ void RenderProcessor::Run() table = GenerateTable(texture_output, viewer->GetValueHintForInput(ViewerOutput::kSamplesInput),time); } - NodeValue sample_val = table.GetWithMeta(NodeValue::kSamples); + NodeValue sample_val = table.Get(NodeValue::kSamples); ResolveJobs(sample_val, time); - QVariant sample_variant = sample_val.data(); - SampleBufferPtr samples = sample_variant.value(); + SampleBufferPtr samples = sample_val.toSamples(); if (samples && ticket_->property("enablewaveforms").toBool()) { AudioVisualWaveform vis; vis.set_channel_count(samples->audio_params().channel_count()); @@ -212,7 +211,7 @@ void RenderProcessor::Run() if (ticket_->IsCancelled()) { ticket_->Finish(); } else { - ticket_->Finish(sample_variant); + ticket_->Finish(QVariant::fromValue(samples)); } break; } @@ -293,7 +292,7 @@ NodeValueTable RenderProcessor::GenerateBlockTable(const Track *track, const Tim // Destination buffer NodeValueTable table = GenerateTable(b, track->GetValueHintForInput(Track::kBlockInput, track->GetArrayIndexFromBlock(b)),Track::TransformRangeForBlock(b, range_for_block)); - SampleBufferPtr samples_from_this_block = table.Take(NodeValue::kSamples).value(); + SampleBufferPtr samples_from_this_block = table.Take(NodeValue::kSamples).toSamples(); ClipBlock *clip_cast = dynamic_cast(b); if (samples_from_this_block) { diff --git a/app/widget/nodetableview/nodetableview.cpp b/app/widget/nodetableview/nodetableview.cpp index 174b3df3e..8981552fa 100644 --- a/app/widget/nodetableview/nodetableview.cpp +++ b/app/widget/nodetableview/nodetableview.cpp @@ -151,7 +151,7 @@ void NodeTableView::SetTime(const rational &time) } default: { - QVector split_values = NodeValue::split_normal_value_into_track_values(node->GetInputDataType(l.key()), value.data()); + QVector split_values = value.to_split_value(); for (int k=0;ksetText(2 + k, NodeValue::ValueToString(value.type(), split_values.at(k), true)); } diff --git a/app/widget/nodevaluetree/nodevaluetree.cpp b/app/widget/nodevaluetree/nodevaluetree.cpp index 689330237..2f263b125 100644 --- a/app/widget/nodevaluetree/nodevaluetree.cpp +++ b/app/widget/nodevaluetree/nodevaluetree.cpp @@ -53,7 +53,7 @@ void NodeValueTree::SetNode(const NodeInput &input, const rational &time) setItemWidget(item, 0, radio); item->setText(1, NodeValue::GetPrettyDataTypeName(value.type())); - item->setText(2, NodeValue::ValueToString(value.type(), value.data(), false)); + item->setText(2, NodeValue::ValueToString(value, false)); item->setText(3, value.source()->GetLabelAndName()); } }