Fix text scaling with non-integer scale factors when PLASMA_USE_QT_SCALING=1 is set
ClosedPublic

Authored by ngraham on Mar 11 2018, 6:52 PM.

Details

Summary

When PLASMA_USE_QT_SCALING=1 is set, Plasma uses native Qt scaling. This works fine for integer scale factors, and fixes a lot of bugs (see Bug 356446) but it introduces a new one: with non-integer scale factors, text becomes blurry and pixellated because of a bug in Text.NativeRendering: https://bugreports.qt.io/browse/QTBUG-67007

QQC2-desktop-style forces the use of Text.QtRendering rendering for non-integer scale factors, successfully working around the problem. But PlasmaComponents QML objects don't implement the same workaround, so we see the issue in Plasma. This patch fixes that, and gets us one step closer to being able to use Qt scaling in Plasmashell.

There is no effect when PLASMA_USE_QT_SCALING=1 is not being used.

FIXED-IN 5.13
BUG: 391691
BUG: 384031
CCBUG: 386216
CCBUG: 391695
CCBUG: 391694
CCBUG: 385547
CCBUG: 391692
CCBUG: 356446

Test Plan

Before: PLASMA_USE_QT_SCALING=1 set, 1.2 scale factor: Plasma text looks awful:

After: PLASMA_USE_QT_SCALING=1 set, 1.2 scale factor: Plasma text looks amazing!

Note that we still get sub-pixel anti-aliasing and good kerning. There appear to be no layout regressions.

Without both PLASMA_USE_QT_SCALING=1 and a non-integer scale factor set, there is no visual change compared to the status quo.

Diff Detail

Repository
R242 Plasma Framework (Library)
Branch
arcpatch-D11244
Lint
No Linters Available
Unit
No Unit Test Coverage
ngraham created this revision.Mar 11 2018, 6:52 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMar 11 2018, 6:52 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
ngraham requested review of this revision.Mar 11 2018, 6:52 PM

Working round a Qt bug always needs a Qt bug report referenced in a code comment.

ngraham edited the summary of this revision. (Show Details)Mar 11 2018, 6:55 PM
ngraham edited the test plan for this revision. (Show Details)

The original workaround from QQC2-desktop-style (which I copied here) doesn't have that, sadly. I'm looking for it...

The closest I could find was https://bugreports.qt.io/browse/QTBUG-42606, which Kai filed for this exact issue, but only for 2x scale factors. It was closed as Cannot Reproduce. I have filed a new one: https://bugreports.qt.io/browse/QTBUG-67007

ngraham updated this revision to Diff 29270.Mar 11 2018, 7:51 PM

Add the Qt bug we're working around into the coments

ngraham edited the summary of this revision. (Show Details)Mar 11 2018, 7:52 PM
ngraham edited the summary of this revision. (Show Details)Mar 11 2018, 8:02 PM
ngraham edited the test plan for this revision. (Show Details)

Did you actually properly test this, ie. without scaling? I can't see how this would be working:
1.) You're missing import QtQuick.Window 2.2
2.) There's no such property Window.devicePixelRatio, it's Screen.devicePixelRatio (which is also in the Window import, but that seems also wrong in the qqc2-desktop-style you got this from)

Thanks for finding bug report.

+1 from me.

You prompted me to look https://codereview.qt-project.org/222827 turns out it was a ridiculously easy fix.

Has the advantage that it'll fix the QQC1 desktop theme labels; but I'm ok with an interim fix.

Did you actually properly test this, ie. without scaling? I can't see how this would be working:
1.) You're missing import QtQuick.Window 2.2
2.) There's no such property Window.devicePixelRatio, it's Screen.devicePixelRatio (which is also in the Window import, but that seems also wrong in the qqc2-desktop-style you got this from)

Yes, I did fully test with:

  • No scale factor
  • 1.2x scale factor
  • 2x scale factor
  • PLASMA_USE_QT_SCALING=1 both on and off for each one

Everything seemed to work fine. Window.devicePixelRatio is what QQC2-desktop-style used, so I just copied it. If there's something else more appropriate, I'm happy to use that instead, or fix the imports, or whatever. Again, this patch does work--though maybe by accident?

Thanks for finding the bug report.

+1 from me.

You prompted me to look https://codereview.qt-project.org/222827; turns out it was a ridiculously easy fix.

Has the advantage that it'll fix the QQC1 desktop theme labels; but I'm ok with an interim fix.

Wow, fantastic! I look forward to the day when we can remove all of this code, then. :)

ngraham edited the summary of this revision. (Show Details)Mar 12 2018, 3:49 AM
ngraham edited the summary of this revision. (Show Details)
davidedmundson requested changes to this revision.Mar 12 2018, 9:00 AM

Kai's right. The patch doesn't work as indented. You're (accidentally) just always enabling Text.QtRendering

If we take your code in Label and change it to the color line

color: QtQuickControlsPrivate.Settings.isMobile ||Window.devicePixelRatio % 1 !== 0 ? "red" : "blue"

It should change depending on QT_SCREEN_SCALE_FACTORS. Yet I always get red.
It does imply the code in QQC2-desktop-style is wrong too.

This revision now requires changes to proceed.Mar 12 2018, 9:00 AM
ngraham planned changes to this revision.Mar 12 2018, 4:51 PM

Hah, that's funny. That also implies that there's absolutely nothing wrong with Text.QtRendering, if QQC2-using non-Plasma apps been accidentally using it for years and nobody has found any issues.

Here's the bug tracking the QQC2 issue: https://bugs.kde.org/show_bug.cgi?id=391780

FWIW, by coincidence someone in the VDG room today actually independently noticed the difference between the two rendering styles (In Discover, which uses Kirigami, which uses the QQC2 label). You can see it in the following image:

Qt on the top, Native on the bottom. So yeah, we do want to make sure we're always using NativeRendering unless using QtRendering is required to avoid an even worse visual issue.

If and when David's Qt patch is merged, we can #ifdef this here and in QQC2-desktop-style so eventually even people who use non-integer scale factors can have the nicest possible text rendering.

ngraham updated this revision to Diff 29366.Mar 13 2018, 2:08 AM

Actually fix the problem, using the same fix as in qqc-desktop-style (D11274)

ngraham edited the summary of this revision. (Show Details)Mar 13 2018, 2:13 AM

You've added a load of bug reports about the kcms.
This patch won't change them at all.

mart added a subscriber: mart.Mar 13 2018, 11:51 AM

if they're somewhat related but not risolutive for some of those bugs, use CCBUG: instead

ngraham updated this revision to Diff 29408.Mar 13 2018, 2:24 PM

"You missed a spot"

ngraham edited the summary of this revision. (Show Details)Mar 13 2018, 2:30 PM
ngraham added a comment.EditedMar 13 2018, 2:35 PM

So this is weird. I thought this patch fixes those KCMs, because I can get them into a fixed state, but it doesn't persist after a reboot. Steps to reproduce:

  • Start with no scale factor
  • Open System SettingsDisplay & MonitorDisplayScale and turn on 1.3x scaling
  • Restart system settings (and optionally KWin, to get bigger titlebars
  • Navigate to L&f KCM. It looks amazing!
  • Reboot the machine
  • Navigate to L&f KCM again.Text is once again ugly and pixellated, boo!

Either way, that's probably a separate issue that I'll have to dig into later and address in a separate patch. I think this one is ready for final review now.

Friendly ping!

davidedmundson accepted this revision.Mar 16 2018, 9:50 PM
This revision is now accepted and ready to land.Mar 16 2018, 9:50 PM
This revision was automatically updated to reflect the committed changes.