nodes: rework so that jobs can be completely deferred
Big optimization requiring a lot of refactoring.
This commit is contained in:
@@ -69,40 +69,39 @@ void CornerPinDistortNode::Retranslate()
|
||||
|
||||
void CornerPinDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
job.Insert(value);
|
||||
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
|
||||
|
||||
// Convert slider values to their pixel values and then convert to clip space (-1.0 ... 1.0) for overriding the
|
||||
// vertex coordinates.
|
||||
const QVector2D &resolution = globals.resolution();
|
||||
QVector2D half_resolution = resolution * 0.5;
|
||||
QVector2D top_left = QVector2D(ValueToPixel(0, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
QVector2D top_right = QVector2D(ValueToPixel(1, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_right = QVector2D(ValueToPixel(2, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_left = QVector2D(ValueToPixel(3, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
|
||||
// Override default vertex coordinates.
|
||||
QVector<float> adjusted_vertices = {top_left.x(), top_left.y(), 0.0f,
|
||||
top_right.x(), top_right.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f,
|
||||
|
||||
top_left.x(), top_left.y(), 0.0f,
|
||||
bottom_left.x(), bottom_left.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f};
|
||||
job.SetVertexCoordinates(adjusted_vertices);
|
||||
|
||||
// If no texture do nothing
|
||||
if (job.Get(kTextureInput).toTexture()) {
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
// In the special case that all sliders are in their default position just
|
||||
// push the texture.
|
||||
if (!(job.Get(kTopLeftInput).toVec2().isNull()
|
||||
&& job.Get(kTopRightInput).toVec2().isNull() &&
|
||||
job.Get(kBottomRightInput).toVec2().isNull() &&
|
||||
job.Get(kBottomLeftInput).toVec2().isNull())) {
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
|
||||
if (!(value[kTopLeftInput].toVec2().isNull()
|
||||
&& value[kTopRightInput].toVec2().isNull() &&
|
||||
value[kBottomRightInput].toVec2().isNull() &&
|
||||
value[kBottomLeftInput].toVec2().isNull())) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, tex->virtual_resolution(), this));
|
||||
|
||||
// Convert slider values to their pixel values and then convert to clip space (-1.0 ... 1.0) for overriding the
|
||||
// vertex coordinates.
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
QVector2D half_resolution = resolution * 0.5;
|
||||
QVector2D top_left = QVector2D(ValueToPixel(0, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
QVector2D top_right = QVector2D(ValueToPixel(1, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_right = QVector2D(ValueToPixel(2, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_left = QVector2D(ValueToPixel(3, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
|
||||
// Override default vertex coordinates.
|
||||
QVector<float> adjusted_vertices = {top_left.x(), top_left.y(), 0.0f,
|
||||
top_right.x(), top_right.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f,
|
||||
|
||||
top_left.x(), top_left.y(), 0.0f,
|
||||
bottom_left.x(), bottom_left.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f};
|
||||
job.SetVertexCoordinates(adjusted_vertices);
|
||||
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
} else {
|
||||
table->Push(job.Get(kTextureInput));
|
||||
table->Push(value[kTextureInput]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,27 +150,29 @@ void CornerPinDistortNode::GizmoDragMove(double x, double y, const Qt::KeyboardM
|
||||
|
||||
void CornerPinDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals)
|
||||
{
|
||||
const QVector2D &resolution = globals.resolution();
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
|
||||
QPointF top_left = ValueToPixel(0, row, resolution);
|
||||
QPointF top_right = ValueToPixel(1, row, resolution);
|
||||
QPointF bottom_right = ValueToPixel(2, row, resolution);
|
||||
QPointF bottom_left = ValueToPixel(3, row, resolution);
|
||||
QPointF top_left = ValueToPixel(0, row, resolution);
|
||||
QPointF top_right = ValueToPixel(1, row, resolution);
|
||||
QPointF bottom_right = ValueToPixel(2, row, resolution);
|
||||
QPointF bottom_left = ValueToPixel(3, row, resolution);
|
||||
|
||||
// Add the correct offset to each slider
|
||||
SetInputProperty(kTopLeftInput, QStringLiteral("offset"), QVector2D(0.0, 0.0));
|
||||
SetInputProperty(kTopRightInput, QStringLiteral("offset"), QVector2D(resolution.x() , 0.0));
|
||||
SetInputProperty(kBottomRightInput, QStringLiteral("offset"), resolution);
|
||||
SetInputProperty(kBottomLeftInput, QStringLiteral("offset"), QVector2D(0.0, resolution.y()));
|
||||
// Add the correct offset to each slider
|
||||
SetInputProperty(kTopLeftInput, QStringLiteral("offset"), QVector2D(0.0, 0.0));
|
||||
SetInputProperty(kTopRightInput, QStringLiteral("offset"), QVector2D(resolution.x() , 0.0));
|
||||
SetInputProperty(kBottomRightInput, QStringLiteral("offset"), resolution);
|
||||
SetInputProperty(kBottomLeftInput, QStringLiteral("offset"), QVector2D(0.0, resolution.y()));
|
||||
|
||||
// Draw bounding box
|
||||
gizmo_whole_rect_->SetPolygon(QPolygonF({top_left, top_right, bottom_right, bottom_left, top_left}));
|
||||
// Draw bounding box
|
||||
gizmo_whole_rect_->SetPolygon(QPolygonF({top_left, top_right, bottom_right, bottom_left, top_left}));
|
||||
|
||||
// Create handles
|
||||
gizmo_resize_handle_[0]->SetPoint(top_left);
|
||||
gizmo_resize_handle_[1]->SetPoint(top_right);
|
||||
gizmo_resize_handle_[2]->SetPoint(bottom_right);
|
||||
gizmo_resize_handle_[3]->SetPoint(bottom_left);
|
||||
// Create handles
|
||||
gizmo_resize_handle_[0]->SetPoint(top_left);
|
||||
gizmo_resize_handle_[1]->SetPoint(top_right);
|
||||
gizmo_resize_handle_[2]->SetPoint(bottom_right);
|
||||
gizmo_resize_handle_[3]->SetPoint(bottom_left);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ void CropDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global
|
||||
{
|
||||
ShaderJob job;
|
||||
job.Insert(value);
|
||||
job.SetWillChangeImageSize(false);
|
||||
|
||||
if (TexturePtr texture = job.Get(kTextureInput).toTexture()) {
|
||||
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, QVector2D(texture->params().width(), texture->params().height()), this));
|
||||
@@ -88,7 +87,7 @@ void CropDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global
|
||||
|| !qIsNull(job.Get(kRightInput).toDouble())
|
||||
|| !qIsNull(job.Get(kTopInput).toDouble())
|
||||
|| !qIsNull(job.Get(kBottomInput).toDouble())) {
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
|
||||
table->Push(NodeValue::kTexture, texture->toJob(job), this);
|
||||
} else {
|
||||
table->Push(job.Get(kTextureInput));
|
||||
}
|
||||
@@ -103,32 +102,35 @@ ShaderCode CropDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
|
||||
void CropDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals)
|
||||
{
|
||||
const QVector2D &resolution = globals.resolution();
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
const QVector2D &resolution = tex->virtual_resolution();
|
||||
temp_resolution_ = resolution;
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
point_gizmo_[kGizmoScaleTopLeft]->SetPoint(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopCenter]->SetPoint(QPointF(center_x_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopRight]->SetPoint(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleBottomLeft]->SetPoint(QPointF(left_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomCenter]->SetPoint(QPointF(center_x_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomRight]->SetPoint(QPointF(right_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleCenterLeft]->SetPoint(QPointF(left_pt, center_y_pt));
|
||||
point_gizmo_[kGizmoScaleCenterRight]->SetPoint(QPointF(right_pt, center_y_pt));
|
||||
point_gizmo_[kGizmoScaleTopLeft]->SetPoint(QPointF(left_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopCenter]->SetPoint(QPointF(center_x_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleTopRight]->SetPoint(QPointF(right_pt, top_pt));
|
||||
point_gizmo_[kGizmoScaleBottomLeft]->SetPoint(QPointF(left_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomCenter]->SetPoint(QPointF(center_x_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleBottomRight]->SetPoint(QPointF(right_pt, bottom_pt));
|
||||
point_gizmo_[kGizmoScaleCenterLeft]->SetPoint(QPointF(left_pt, center_y_pt));
|
||||
point_gizmo_[kGizmoScaleCenterRight]->SetPoint(QPointF(right_pt, center_y_pt));
|
||||
|
||||
poly_gizmo_->SetPolygon(QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt));
|
||||
poly_gizmo_->SetPolygon(QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt));
|
||||
}
|
||||
}
|
||||
|
||||
void CropDistortNode::GizmoDragMove(double x_diff, double y_diff, const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
DraggableGizmo *gizmo = static_cast<DraggableGizmo*>(sender());
|
||||
|
||||
QVector2D res = gizmo->GetGlobals().resolution();
|
||||
QVector2D res = temp_resolution_;
|
||||
x_diff /= res.x();
|
||||
y_diff /= res.y();
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ private:
|
||||
// Gizmo variables
|
||||
PointGizmo *point_gizmo_[kGizmoScaleCount];
|
||||
PolygonGizmo *poly_gizmo_;
|
||||
QVector2D temp_resolution_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -77,18 +77,14 @@ ShaderCode FlipDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
|
||||
void FlipDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
|
||||
job.Insert(value);
|
||||
|
||||
// If there's no texture, no need to run an operation
|
||||
if (job.Get(kTextureInput).toTexture()) {
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (job.Get(kHorizontalInput).toBool() || job.Get(kVerticalInput).toBool()) {
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
|
||||
if (value[kHorizontalInput].toBool() || value[kVerticalInput].toBool()) {
|
||||
table->Push(NodeValue::kTexture, tex->toJob(ShaderJob(value)), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(job.Get(kTextureInput));
|
||||
table->Push(value[kTextureInput]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,16 +64,19 @@ void MaskDistortNode::Retranslate()
|
||||
|
||||
void MaskDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
NodeValue job(NodeValue::kTexture, GetGenerateJob(value), this);
|
||||
TexturePtr texture = value[kBaseInput].toTexture();
|
||||
|
||||
VideoParams job_params = texture ? texture->params() : globals.vparams();
|
||||
NodeValue job(NodeValue::kTexture, Texture::Job(job_params, GetGenerateJob(value, job_params)), this);
|
||||
|
||||
if (value[kInvertInput].toBool()) {
|
||||
ShaderJob invert;
|
||||
invert.SetShaderID(QStringLiteral("invert"));
|
||||
invert.Insert(QStringLiteral("tex_in"), job);
|
||||
job.set_value(invert);
|
||||
job.set_value(Texture::Job(job_params, invert));
|
||||
}
|
||||
|
||||
if (value[kBaseInput].toTexture()) {
|
||||
if (texture) {
|
||||
// Push as merge node
|
||||
ShaderJob merge;
|
||||
|
||||
@@ -92,14 +95,14 @@ void MaskDistortNode::Value(const NodeValueRow &value, const NodeGlobals &global
|
||||
feather.Insert(BlurFilterNode::kRepeatEdgePixelsInput, NodeValue(NodeValue::kBoolean, true, this));
|
||||
feather.Insert(BlurFilterNode::kRadiusInput, NodeValue(NodeValue::kFloat, value[kFeatherInput].toDouble(), this));
|
||||
feather.SetIterations(2, BlurFilterNode::kTextureInput);
|
||||
feather.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
|
||||
feather.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, texture ? texture->virtual_resolution() : globals.square_resolution(), this));
|
||||
|
||||
merge.Insert(QStringLiteral("tex_b"), NodeValue(NodeValue::kTexture, feather, this));
|
||||
merge.Insert(QStringLiteral("tex_b"), NodeValue(NodeValue::kTexture, Texture::Job(job_params, feather), this));
|
||||
} else {
|
||||
merge.Insert(QStringLiteral("tex_b"), job);
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kTexture, merge, this);
|
||||
table->Push(NodeValue::kTexture, Texture::Job(job_params, merge), this);
|
||||
} else {
|
||||
table->Push(job);
|
||||
}
|
||||
|
||||
@@ -94,28 +94,26 @@ ShaderCode RippleDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
|
||||
void RippleDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
|
||||
job.Insert(value);
|
||||
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
|
||||
|
||||
// If there's no texture, no need to run an operation
|
||||
if (job.Get(kTextureInput).toTexture()) {
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(job.Get(kIntensityInput).toDouble())) {
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
|
||||
if (!qIsNull(value[kIntensityInput].toDouble())) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, tex->virtual_resolution(), this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(job.Get(kTextureInput));
|
||||
table->Push(value[kTextureInput]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RippleDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals)
|
||||
{
|
||||
QPointF half_res(globals.resolution_by_par().x()/2, globals.resolution_by_par().y()/2);
|
||||
|
||||
gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF());
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
QPointF half_res(tex->virtual_resolution().x()/2, tex->virtual_resolution().y()/2);
|
||||
gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF());
|
||||
}
|
||||
}
|
||||
|
||||
void RippleDistortNode::GizmoDragMove(double x, double y, const Qt::KeyboardModifiers &modifiers)
|
||||
|
||||
@@ -89,26 +89,23 @@ ShaderCode SwirlDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
|
||||
void SwirlDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
|
||||
job.Insert(value);
|
||||
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
|
||||
|
||||
// If there's no texture, no need to run an operation
|
||||
if (job.Get(kTextureInput).toTexture()) {
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(job.Get(kAngleInput).toDouble()) && !qIsNull(job.Get(kRadiusInput).toDouble())) {
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
|
||||
if (!qIsNull(value[kAngleInput].toDouble()) && !qIsNull(value[kRadiusInput].toDouble())) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, tex->virtual_resolution(), this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(job.Get(kTextureInput));
|
||||
table->Push(value[kTextureInput]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SwirlDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals)
|
||||
{
|
||||
QPointF half_res(globals.resolution_by_par().x()/2, globals.resolution_by_par().y()/2);
|
||||
QPointF half_res(globals.square_resolution().x()/2, globals.square_resolution().y()/2);
|
||||
|
||||
gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF());
|
||||
}
|
||||
|
||||
@@ -110,47 +110,46 @@ ShaderCode TileDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
|
||||
void TileDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
|
||||
job.Insert(value);
|
||||
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
|
||||
|
||||
// If there's no texture, no need to run an operation
|
||||
if (job.Get(kTextureInput).toTexture()) {
|
||||
if (TexturePtr tex = value[kTextureInput].toTexture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qFuzzyCompare(job.Get(kScaleInput).toDouble(), 1.0)) {
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
|
||||
if (!qFuzzyCompare(value[kScaleInput].toDouble(), 1.0)) {
|
||||
ShaderJob job(value);
|
||||
job.Insert(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, tex->virtual_resolution(), this));
|
||||
table->Push(NodeValue::kTexture, tex->toJob(job), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(job.Get(kTextureInput));
|
||||
table->Push(value[kTextureInput]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TileDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals)
|
||||
{
|
||||
QPointF res = globals.resolution_by_par().toPointF();
|
||||
QPointF pos = row[kPositionInput].toVec2().toPointF();
|
||||
qreal x = pos.x();
|
||||
qreal y = pos.y();
|
||||
if (TexturePtr tex = row[kTextureInput].toTexture()) {
|
||||
QPointF res = tex->virtual_resolution().toPointF();
|
||||
QPointF pos = row[kPositionInput].toVec2().toPointF();
|
||||
qreal x = pos.x();
|
||||
qreal y = pos.y();
|
||||
|
||||
Anchor a = static_cast<Anchor>(row[kAnchorInput].toInt());
|
||||
if (a == kTopLeft || a == kTopCenter || a == kTopRight) {
|
||||
// Do nothing
|
||||
} else if (a == kMiddleLeft || a == kMiddleCenter || a == kMiddleRight) {
|
||||
y += res.y()/2;
|
||||
} else if (a == kBottomLeft || a == kBottomCenter || a == kBottomRight) {
|
||||
y += res.y();
|
||||
}
|
||||
if (a == kTopLeft || a == kMiddleLeft || a == kBottomLeft) {
|
||||
// Do nothing
|
||||
} else if (a == kTopCenter || a == kMiddleCenter || a == kBottomCenter) {
|
||||
x += res.x()/2;
|
||||
} else if (a == kTopRight || a == kMiddleRight || a == kBottomRight) {
|
||||
x += res.x();
|
||||
}
|
||||
Anchor a = static_cast<Anchor>(row[kAnchorInput].toInt());
|
||||
if (a == kTopLeft || a == kTopCenter || a == kTopRight) {
|
||||
// Do nothing
|
||||
} else if (a == kMiddleLeft || a == kMiddleCenter || a == kMiddleRight) {
|
||||
y += res.y()/2;
|
||||
} else if (a == kBottomLeft || a == kBottomCenter || a == kBottomRight) {
|
||||
y += res.y();
|
||||
}
|
||||
if (a == kTopLeft || a == kMiddleLeft || a == kBottomLeft) {
|
||||
// Do nothing
|
||||
} else if (a == kTopCenter || a == kMiddleCenter || a == kBottomCenter) {
|
||||
x += res.x()/2;
|
||||
} else if (a == kTopRight || a == kMiddleRight || a == kBottomRight) {
|
||||
x += res.x();
|
||||
}
|
||||
|
||||
gizmo_->SetPoint(QPointF(x, y));
|
||||
gizmo_->SetPoint(QPointF(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
void TileDistortNode::GizmoDragMove(double x, double y, const Qt::KeyboardModifiers &modifiers)
|
||||
|
||||
@@ -89,7 +89,7 @@ void TransformDistortNode::Value(const NodeValueRow &value, const NodeGlobals &g
|
||||
// Pop texture
|
||||
NodeValue texture_meta = value[kTextureInput];
|
||||
|
||||
QVariant job_to_push;
|
||||
TexturePtr job_to_push = nullptr;
|
||||
|
||||
// If we have a texture, generate a matrix and make it happen
|
||||
if (TexturePtr texture = texture_meta.toTexture()) {
|
||||
@@ -99,17 +99,18 @@ void TransformDistortNode::Value(const NodeValueRow &value, const NodeGlobals &g
|
||||
if (!real_matrix.isIdentity()) {
|
||||
// The matrix will transform things
|
||||
ShaderJob job;
|
||||
job.Insert(QStringLiteral("ove_maintex"), NodeValue(NodeValue::kTexture, QVariant::fromValue(texture), this));
|
||||
job.Insert(QStringLiteral("ove_maintex"), texture_meta);
|
||||
job.Insert(QStringLiteral("ove_mvpmat"), NodeValue(NodeValue::kMatrix, real_matrix, this));
|
||||
job.SetInterpolation(QStringLiteral("ove_maintex"), static_cast<Texture::Interpolation>(value[kInterpolationInput].toInt()));
|
||||
|
||||
job_to_push = QVariant::fromValue(job);
|
||||
// Use global resolution rather than texture resolution because this may result in a size change
|
||||
job_to_push = Texture::Job(globals.vparams(), job);
|
||||
}
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kMatrix, QVariant::fromValue(generated_matrix), this);
|
||||
|
||||
if (job_to_push.isNull()) {
|
||||
if (!job_to_push) {
|
||||
// Re-push whatever value we received
|
||||
table->Push(texture_meta);
|
||||
} else {
|
||||
@@ -142,7 +143,7 @@ void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x, dou
|
||||
}
|
||||
|
||||
gizmo_scale_uniform_ = row[kUniformScaleInput].toBool();
|
||||
gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() + gizmo->GetGlobals().resolution()/2).toPointF();
|
||||
gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() + gizmo->GetGlobals().nonsquare_resolution()/2).toPointF();
|
||||
|
||||
if (gizmo == point_gizmo_[kGizmoScaleTopLeft] || gizmo == point_gizmo_[kGizmoScaleTopRight]
|
||||
|| gizmo == point_gizmo_[kGizmoScaleBottomLeft] || gizmo == point_gizmo_[kGizmoScaleBottomRight]) {
|
||||
@@ -177,7 +178,7 @@ void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x, dou
|
||||
|
||||
} else if (gizmo == rotation_gizmo_) {
|
||||
|
||||
gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() + gizmo->GetGlobals().resolution()/2).toPointF();
|
||||
gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() + gizmo->GetGlobals().nonsquare_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());
|
||||
@@ -343,7 +344,7 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const N
|
||||
}
|
||||
|
||||
// Get the sequence resolution
|
||||
const QVector2D &sequence_res = globals.resolution();
|
||||
const QVector2D &sequence_res = globals.nonsquare_resolution();
|
||||
QVector2D sequence_half_res = sequence_res * 0.5;
|
||||
QPointF sequence_half_res_pt = sequence_half_res.toPointF();
|
||||
|
||||
@@ -418,7 +419,7 @@ QPointF TransformDistortNode::CreateScalePoint(double x, double y, const QPointF
|
||||
|
||||
QMatrix4x4 TransformDistortNode::GenerateAutoScaledMatrix(const QMatrix4x4& generated_matrix, const NodeValueRow& value, const NodeGlobals &globals, const VideoParams& texture_params) const
|
||||
{
|
||||
const QVector2D &sequence_res = globals.resolution();
|
||||
const QVector2D &sequence_res = globals.nonsquare_resolution();
|
||||
QVector2D texture_res(texture_params.square_pixel_width(), texture_params.height());
|
||||
AutoScaleType autoscale = static_cast<AutoScaleType>(value[kAutoscaleInput].toInt());
|
||||
|
||||
|
||||
@@ -84,18 +84,14 @@ ShaderCode WaveDistortNode::GetShaderCode(const ShaderRequest &request) const
|
||||
|
||||
void WaveDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
|
||||
job.Insert(value);
|
||||
|
||||
// If there's no texture, no need to run an operation
|
||||
if (job.Get(kTextureInput).toTexture()) {
|
||||
if (TexturePtr texture = value[kTextureInput].toTexture()) {
|
||||
// Only run shader if at least one of flip or flop are selected
|
||||
if (!qIsNull(job.Get(kIntensityInput).toDouble())) {
|
||||
table->Push(NodeValue::kTexture, QVariant::fromValue(job), this);
|
||||
if (!qIsNull(value[kIntensityInput].toDouble())) {
|
||||
table->Push(NodeValue::kTexture, Texture::Job(texture->params(), ShaderJob(value)), this);
|
||||
} else {
|
||||
// If we're not flipping or flopping just push the texture
|
||||
table->Push(job.Get(kTextureInput));
|
||||
table->Push(value[kTextureInput]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user