nodevalue: begin abstracting qvariant

This commit is contained in:
itsmattkc
2022-05-09 13:07:34 -07:00
parent 839f63d78f
commit 58c4600d04
36 changed files with 235 additions and 229 deletions
@@ -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<TexturePtr>()) {
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<Texture::Interpolation>(value[kInterpolationInput].data().toInt()));
job.SetInterpolation(QStringLiteral("ove_maintex"), static_cast<Texture::Interpolation>(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>();
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>();
TexturePtr tex = row[kTextureInput].toTexture();
if (!tex) {
return;
}
gizmo_scale_uniform_ = row[kUniformScaleInput].data().toBool();
gizmo_anchor_pt_ = (row[kAnchorInput].data().value<QVector2D>() + 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<QVector2D>() + 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<QVector2D>() + 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>();
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<AutoScaleType>(row[kAutoscaleInput].data().toInt());
AutoScaleType autoscale = static_cast<AutoScaleType>(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<AutoScaleType>(value[kAutoscaleInput].data().toInt());
AutoScaleType autoscale = static_cast<AutoScaleType>(value[kAutoscaleInput].toInt());
return AdjustMatrixByResolutions(generated_matrix,
sequence_res,