Skip to content

Commit

Permalink
Fix effective interpolation detection
Browse files Browse the repository at this point in the history
It used a malformed quad for the source, so Qt always said that there
was no way to transform it to the destination, leading to the raw
interpolation being used every time. Now it detects trivial transforms
properly and returns to nearest-neighbor interpolation as it should to
avoid pointless blur.
  • Loading branch information
askmeaboutlo0m committed Nov 14, 2024
1 parent 9f4b795 commit 3239bc2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Unreleased Version 2.2.2-pre
* Fix: Disregard hidden layers when layer picking in frame view.
* Feature: Add a search bar to the key frame properties dialog.
* Fix: Reset locale to "C" after Qt messes it up on startup. Thanks Meru for reporting.
* Fix: Don't use bilinear interpolation in transforms unnecessarily.

2024-11-06 Version 2.2.2-beta.4
* Fix: Solve rendering glitches with selection outlines that happen on some systems. Thanks xxxx for reporting.
Expand Down
19 changes: 17 additions & 2 deletions src/libclient/canvas/transformmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ int TransformModel::getEffectiveInterpolation(int interpolation) const
if(interpolation != DP_MSG_TRANSFORM_REGION_MODE_NEAREST &&
m_dstQuadValid) {
QTransform t;
if(QTransform::quadToQuad(
QPolygonF(QRectF(m_srcBounds)), m_dstQuad.polygon(), t)) {
if(QTransform::quadToQuad(srcPolygon(), m_dstQuad.polygon(), t)) {
t.setMatrix(
t.m11(), t.m12(), t.m13(), t.m21(), t.m22(), t.m23(), 0.0, 0.0,
t.m33());
Expand Down Expand Up @@ -779,6 +778,22 @@ bool TransformModel::containsNullMessages(const QVector<net::Message> &msgs)
return false;
}

QPolygonF TransformModel::srcPolygon() const
{
// QRectF::toPolygon returns an excess point, so we can't use that here.
// Also, using width and height is correct! Don't use bottom or right.
qreal x = m_srcBounds.x();
qreal y = m_srcBounds.y();
qreal w = m_srcBounds.width();
qreal h = m_srcBounds.height();
return QPolygonF({
QPointF(x, y),
QPointF(x + w, y),
QPointF(x + w, y + h),
QPointF(x, y + h),
});
}

bool TransformModel::isRightAngleRotationOrReflection(const QTransform &t) const
{
QPoint scales[] = {
Expand Down
1 change: 1 addition & 0 deletions src/libclient/canvas/transformmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class TransformModel : public QObject {
QImage convertMaskToMono() const;
static bool containsNullMessages(const QVector<net::Message> &msgs);

QPolygonF srcPolygon() const;
bool isRightAngleRotationOrReflection(const QTransform &t) const;

static bool isQuadValid(const TransformQuad &quad);
Expand Down

0 comments on commit 3239bc2

Please sign in to comment.