FrameSvg: Do not wreck shared mask frames
ClosedPublic

Authored by zzag on Jun 6 2018, 6:42 PM.

Details

Summary

When trying to update the maskFrame, there is a chance that it is already
shared by several instances of FrameSvg. In that case, do not wreck maskFrame
and instead act as follows:

  • deref it
  • try to lookup a matching frame in the shared frames
  • if there is the matching frame, use it
  • otherwise create a new one

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.Jun 6 2018, 6:42 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 6 2018, 6:42 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
zzag requested review of this revision.Jun 6 2018, 6:42 PM
zzag edited the summary of this revision. (Show Details)Jun 6 2018, 6:43 PM
zzag edited the summary of this revision. (Show Details)Jun 6 2018, 6:46 PM
zzag edited the summary of this revision. (Show Details)Jun 6 2018, 6:58 PM

Sorry for the nasty diff. Caching is hard. :(

zzag updated this revision to Diff 35704.Jun 6 2018, 7:12 PM

Do not invalidate looked up frames.

zzag updated this revision to Diff 35705.Jun 6 2018, 7:16 PM

Move maskFrame->cachedBackground = QPixmap(); to the maskFrame->refcount() == 1
branch. Do we really need this assignment?

zzag added a comment.Jun 7 2018, 11:41 AM

Corner case: what if only need to update cachedBackground(i.e. enabledBorders and frameSize are okay)?

zzag added a comment.Jun 7 2018, 11:51 AM
In D13384#275224, @zzag wrote:

Corner case: what if only need to update cachedBackground(i.e. enabledBorders and frameSize are okay)?

Delete shouldUpdate and wrap if (refcount() == 1) {} into another if statement, e.g.

if (maskFrame->enabledBorders != frame->enabledBorders || maskFrame->frameSize != frameSize(frame)) {
    if (maskFrame->refcount() == 1) {
        // ...
    } else {
        // ...
    }
    updateSizes(maskFrame);
}

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

return maskFrame->cachedBackground;

?

zzag updated this revision to Diff 35749.Jun 7 2018, 12:09 PM

Update sizes only if enabled borders or frame size have been changed

zzag planned changes to this revision.Jun 7 2018, 12:10 PM

Add comments describing CFG.

zzag updated this revision to Diff 35806.Jun 7 2018, 9:36 PM

Rename shouldUpdateSizes back to shouldUpdate

That's for a possible future diff: the mask frame should be updated
if maskFrame->imagePath != frame->imagePath. That's an unrelated
change because this diff tries to address the problem of corrupting
already shared mask frames.

zzag added a comment.Jun 7 2018, 9:43 PM
In D13384#275246, @zzag wrote:

Add comments describing CFG.

As it turns out, that's not necessary. The code is pretty much "self-explanatory".

Anyway, I'd like to proceed with code review.

zzag updated this revision to Diff 36056.Jun 12 2018, 4:46 PM

Use frame's imagePath.

mart accepted this revision.Jun 27 2018, 11:45 AM
mart added a subscriber: mart.

sorry for making you wait too long on those framesvg changes, looks like i have to tune up phab notifications a bit more as they didn't show up :/
(anyways, adding Plasma in tags should maximize the amount of people looking at it)

This revision is now accepted and ready to land.Jun 27 2018, 11:45 AM
This revision was automatically updated to reflect the committed changes.