[platforms/drm] Move cursor dumb buffers to Output
ClosedPublic

Authored by graesslin on Nov 5 2017, 11:02 AM.

Details

Summary

So far all outputs shared the same dumb buffer for the cursor image.
This doesn't work any more when screen rotation is enabled. For rotated
screens the cursor image per output is different. On some it might be
rotated, on some not.

To solve this problem the dumb buffers are moved from the DrmBackend to
the DrmOutput. The DrmOutput now creates the cursor images itself and
can rotate them if needed. Thus we get nicely transformed cursors.

Test Plan

Rotated screens, moved cursor around, image properly rotated

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin created this revision.Nov 5 2017, 11:02 AM
Restricted Application added a project: KWin. · View Herald TranscriptNov 5 2017, 11:02 AM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript

What's now clearly to see is that the cursor hotspot is wrong.

graesslin updated this revision to Diff 21917.Nov 5 2017, 3:11 PM

We need to mirror both x and y

Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptNov 5 2017, 3:11 PM
davidedmundson requested changes to this revision.Nov 5 2017, 4:53 PM
davidedmundson added a subscriber: davidedmundson.

Idea is good. Few minor comments.


I might be wrong, but it looks to me that:

updateCursor now swaps m_cursorIndex which is a signifcant behaviour change from the old separate setCursor/updateCursor

therefore if we ever call

showCursor
updateCursor
updateCursor

you'd end up painting into the front buffer which is bad.

I can see a few code paths that do this.

plugins/platforms/drm/drm_output.cpp
123

This will be much faster is you set a matrix (setWorldTransform) on the QPainter.

Then it will do the transformation inside drawImage and get rid of the intermediate data copy

967

this needs a showCursor() too to be useful

1172

You fill it transparent before every paint anyway

plugins/platforms/drm/drm_output.h
181

Not that you need to, but:

m_cursor[2] = {nullptr,nullptr}

should work just fine instead of doing it in the ctor

This revision now requires changes to proceed.Nov 5 2017, 4:53 PM

updateCursor now swaps m_cursorIndex which is a signifcant behaviour change from the old separate setCursor/updateCursor

Yes, I did it on purpose as I found the code usage weird and difficult to follow. I thought it's much easier to understand if we go for swapping the index whenever we paint into it. I didn't think of the update followed by update case. So this clearly needs fixing - meh :-(

graesslin marked 4 inline comments as done.Nov 6 2017, 3:39 PM
graesslin updated this revision to Diff 21973.Nov 6 2017, 3:40 PM

Incorporated suggested changes. As I didn't like the index manipulation in the
old code base I tried to take the advantages from my failed attempt and track
in a variable whether the cursor changed. Thus we only need one place to modify
the index.

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptNov 6 2017, 3:40 PM
davidedmundson accepted this revision.Nov 6 2017, 3:46 PM
davidedmundson added inline comments.
plugins/platforms/drm/drm_output.cpp
967

you added the showCursor above, but not here.

This revision is now accepted and ready to land.Nov 6 2017, 3:46 PM
graesslin marked an inline comment as done.Nov 6 2017, 3:47 PM
This revision was automatically updated to reflect the committed changes.