FrameSvg: Recache maskFrame if enabledBorders has been changed
ClosedPublic

Authored by zzag on May 30 2018, 2:59 PM.

Details

Summary

In some cases, when rendering frame svg background, measures & margins
do not correspond to enabledBorders. I.e. bottomHeight may be equal to 5,
but the bottom border is disabled. This causes visual artifacts like this

Pay close attention to the bottom of the Task switcher. It has a transparent strip at the bottom, which shouldn't be there.

The cause of this problem is that FrameSVGPrivate::alphaMask doesn't take enabledBorders
into account when it's making decision whether it should update maskFrame.

Just for reference, this is "after"

BUG: 382324
BUG: 390632
BUG: 391659

Test Plan
  • Triggered the Breeze task switcher (with compositing on and off)
  • Didn't see any transparent strips

  • Tried running FrameSvgTest, still passes

Diff Detail

Repository
R242 Plasma Framework (Library)
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
zzag created this revision.May 30 2018, 2:59 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 30 2018, 2:59 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
zzag requested review of this revision.May 30 2018, 2:59 PM
zzag edited the summary of this revision. (Show Details)May 30 2018, 3:03 PM
zzag edited the summary of this revision. (Show Details)

Wow. I wasted hours in FrameSvg trying to find this. Does this also fix the panel mask in non-composited mode, e.g. round corners with Oxygen? (Quickly browsing the bug numbers suggests it does \o/)

zzag added a comment.May 30 2018, 3:10 PM

Wow. I wasted hours in FrameSvg trying to find this. Does this also fix the panel mask in non-composited mode, e.g. round corners with Oxygen? (Quickly browsing the bug numbers suggests it does \o/)

It has nothing to do with compositing. ;-)

I noticed when I was working on this diff that paintCorner is not working _really_ correct. I'll check it with Oxygen.

zzag edited the test plan for this revision. (Show Details)May 30 2018, 4:01 PM
zzag added a comment.EditedMay 30 2018, 4:09 PM

@broulik I tested panels with Oxygen(with compositing on and off) and didn't see any problems.

(Quickly browsing the bug numbers suggests it does \o/)

Not sure about that. All of those bugs are "Breeze-related"(i.e. bug reporters use Breeze desktop theme).

zzag edited the test plan for this revision. (Show Details)May 30 2018, 4:12 PM

+1

Doesn't make a difference in Oxygen's rounded corners on panels but doesn't make it worse either. Please also profile whether it causes any needless recalculations on Plasma startup

zzag added subscribers: aseigo, mart.EditedJun 1 2018, 11:19 AM

+1

Doesn't make a difference in Oxygen's rounded corners on panels but doesn't make it worse either. Please also profile whether it causes any needless recalculations on Plasma startup

I'd like to dig deeper why margins do not correspond to enabled margins. Maybe, because of

if (!d->repaintBlocked) {
   d->updateFrameData();
}

FrameSVG misses to update margins, and so on.

It would be great to get opinion of @mart and @aseigo . Maybe, there is a better way to fix this.

zzag added a comment.EditedJun 1 2018, 12:11 PM
In D13215#271994, @zzag wrote:

Maybe, because of

if (!d->repaintBlocked) {
   d->updateFrameData();
}

FrameSVG misses to update margins, and so on.

OK, I'm wrong about this part.

zzag added a comment.Jun 1 2018, 1:17 PM

I think I got it.

FrameSVGPrivate::updateFrameData updates only frame, maskFrame is updated lazily in alphaMask method, but the alphaMask method ignores previous state of enabledBorders. So, we end up with using stale maskFrame.

E.g.

FrameSVGPrivate::updateFrameData() {
if (!fd) {
    ...
    old key = "10_216_768_1_1__dialogs/background"
    old borders = QFlags<Plasma::FrameSvg::EnabledBorders>(BottomBorder|RightBorder)
    new key = "8_216_768_1_1__dialogs/background"
    new borders = QFlags<Plasma::FrameSvg::EnabledBorders>(RightBorder)

Now, when we call alphaMask,

FrameSVGPrivate::alphaMask() {
    if (maskPrefix.isNull()) {
    } else {
         ...
         oldKey = "10_216_768_1_1_mask-_dialogs/background"
zzag updated this revision to Diff 35336.Jun 1 2018, 1:21 PM

Do not ignore previous maskFrame's enabled borders.

zzag updated this revision to Diff 35338.Jun 1 2018, 1:36 PM

Code cleanup.

zzag edited the summary of this revision. (Show Details)Jun 1 2018, 1:37 PM
zzag added inline comments.Jun 1 2018, 1:41 PM
src/plasma/framesvg.cpp
480

Should it be here?

abetts added a subscriber: abetts.Jun 1 2018, 2:01 PM

+1 on this! Love it!

zzag added a comment.Jun 1 2018, 7:17 PM

Answer to my inline question: updateSizes can be omitted (but I would prefer to leave it). Also, maskFrame->enabledBorders = frame->enabledBorders; above is redundant (maskFrame->enabledBorders is already equal to frame->enabledBorders; it if wasn't the case, then cacheId works incorrectly or FrameData constructor doesn't copy enabledBorders, which isn't the case).

Also,

if (s_sharedFrames[q->theme()->d].contains(oldKey)) {
    s_sharedFrames[q->theme()->d].remove(oldKey);
    s_sharedFrames[q->theme()->d].insert(newKey, maskFrame);
}

ignores refcount, which may cause problems. I won't fix that, because that would be unrelated change.

Yet another "also":

if (maskFrame->cachedBackground.isNull()) {
    return QPixmap();
}

is redundant.

Anyway, I think I finished my work on fixing bugs that are listed in the summary and would like to proceed with review.

zzag added a comment.Jun 1 2018, 7:55 PM

Doesn't make a difference in Oxygen's rounded corners on panels but doesn't make it worse either.

Could you please share a screenshot? I still don't know what's wrong with Oxygen rounded corners.

zzag retitled this revision from Update sizes before generating frame svg background to FrameSVG: Recache maskFrame if enabledBorders has been changed.Jun 2 2018, 11:16 AM
zzag edited the summary of this revision. (Show Details)
zzag updated this revision to Diff 35542.Jun 4 2018, 5:21 PM

Rebase.

zzag retitled this revision from FrameSVG: Recache maskFrame if enabledBorders has been changed to FrameSvg: Recache maskFrame if enabledBorders has been changed.Jun 6 2018, 3:07 PM

Ping.

abetts added a comment.Jun 6 2018, 3:22 PM

What can we do to help this patch move forward @zzag ?

mart added a comment.Jun 6 2018, 4:17 PM
In D13215#270880, @zzag wrote:

Wow. I wasted hours in FrameSvg trying to find this. Does this also fix the panel mask in non-composited mode, e.g. round corners with Oxygen? (Quickly browsing the bug numbers suggests it does \o/)

It has nothing to do with compositing. ;-)

I noticed when I was working on this diff that paintCorner is not working _really_ correct. I'll check it with Oxygen.

it has nothing to do with compositing, but it *should* fix the non composite mask never the less, as it was coming from a misrendering of the framesvg

mart accepted this revision.Jun 6 2018, 4:19 PM
This revision is now accepted and ready to land.Jun 6 2018, 4:19 PM
zzag added a comment.Jun 6 2018, 4:31 PM
In D13215#274782, @mart wrote:

it has nothing to do with compositing, but it *should* fix the non composite mask never the less, as it was coming from a misrendering of the framesvg

Could someone please show me what's wrong with Oxygen corners? (I still don't know what's wrong with them, sorry)

This revision was automatically updated to reflect the committed changes.