Set wayland output scale
ClosedPublic

Authored by davidedmundson on Oct 25 2016, 11:37 PM.

Details

Summary

Provides a virtual method in Screens where backends can supply the scale
of each screen, this is then set on each output.

For the X windowed backend this value is taken from a command line
parameter.

Test Plan

Ran windowed mode with --scale 1 and 2
then kate --platform=wayland from another screen.
On the latter case UI elements were scaled up correctly

Diff Detail

Repository
R108 KWin
Lint
No Linters Available
Unit
No Unit Test Coverage
davidedmundson retitled this revision from to Set wayland output scale.
davidedmundson updated this object.
davidedmundson edited the test plan for this revision. (Show Details)
davidedmundson added a reviewer: Plasma.
Restricted Application added a project: KWin. · View Herald TranscriptOct 25 2016, 11:37 PM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript

I suggest to also implement in the virtual platform in order to be able to auto-test it.

main_wayland.cpp
533

careful here: copy and paste error

643

hmm I'm not sure whether we should implement it as an int factor. Even if Wayland only supports integer scaling, I think that's a bad idea and we should rather go with fractal scaling from the start. Of course towards Wayland we need to expose it as integer scaling. But in case Wayland gets an update we would be prepared.

wayland_server.cpp
355

At the moment KWin doesn't scale yet. I think we should not start to export scale to Wayland as long as we don't support it.

The idea behind the scale in Wayland is that the compositor itself scales up all surfaces which don't provide the correct scale factor. Just mentioning in case you are not aware of it.

davidedmundson added inline comments.Oct 26 2016, 9:32 AM
main_wayland.cpp
643

Makes sense to me. I'll do that change.

wayland_server.cpp
355

I started doing the relevant surface scaling, but that's quite a bit more complex than it might first appear (and the Qt QPA needs multiple patches...) so I need to split this into multiple smaller parts.

Personally, I think setting this now is fine because I haven't implemented anything in the DRM backend, so this is only going to affect kwin when this config option is explicitly set.

davidedmundson marked 3 inline comments as done.

int -> real

Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptOct 26 2016, 9:43 AM
broulik added inline comments.
plugins/platforms/x11/windowed/x11windowed_backend.cpp
477–480

QVector<T> &QVector::fill(const T &value, int size = -1)

Assigns value to all items in the vector. If size is different from -1 (the default), the vector is resized to size size beforehand.

qvector::fill

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptOct 26 2016, 3:11 PM
graesslin accepted this revision.Oct 27 2016, 10:56 AM
graesslin added a reviewer: graesslin.
This revision is now accepted and ready to land.Oct 27 2016, 10:56 AM
davidedmundson edited edge metadata.

WIP: high DPI scaling support in kwin.

Surface events are all normalised by surface_scale
Output is normalised to output_scale

From a kwin POV this means:

  • we need to not assume texture size == client size. It will be off by a factor of surface scale.
  • we need to render at output_scale times the size of the output, to go from output normal to hardware

This branch adds support for qpainter in x11windowed. It will be expanded over time.

DO NOT MERGE AS-IS.

  • Set m_client size in surface normal co-ordinates
  • Scale QPainter x11 windowed backend
  • Scale input on windowed backend so input co-ordinate system matches host
  • Add warning about scene_openGL . Delete me in future squash
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptNov 7 2016, 11:21 AM
graesslin added inline comments.Nov 7 2016, 11:57 AM
plugins/platforms/x11/windowed/x11windowed_backend.cpp
201–202

QPointF supports operator/, so that should be possible to simplify a bit.

232–233

same here

368–369

and here

scene_qpainter.cpp
311–313 ↗(On Diff #7966)

I don't understand how the scaling comes in here?

321 ↗(On Diff #7966)

paintSubSurface probably also needs the adjustment

shell_client.cpp
392 ↗(On Diff #7966)

removing that line will break internal windows such as Alt+Tab, etc. etc on SceneOpenGL

davidedmundson added inline comments.Nov 7 2016, 12:21 PM
scene_qpainter.cpp
311–313 ↗(On Diff #7966)

I'm harnassing QPainter's internal scaling.

The old code:

painter->drawImage(toplevel->clientPos(),
                                 pixmap->image(),
                                 src);

internally is:

painter->drawImage(QRect(toplevel->clientPos(), pixmap->image().size()),
                                   pixmap->image()

My patch changes that to:

painter->drawImage(QRect(toplevel->clientPos(), topLevel->clientSize()),
                                  pixmap->image(),

So no matter how big or small pixmap->image is, it will be scaled to fit the client size.

graesslin added inline comments.Nov 7 2016, 2:15 PM
scene_qpainter.cpp
311–313 ↗(On Diff #7966)

ah so that's basically the "scale everything up" if output has a scale, but not yet the "surface has a scale of 2"?

davidedmundson added inline comments.Nov 7 2016, 3:16 PM
scene_qpainter.cpp
311–313 ↗(On Diff #7966)

What this code is doing is painting in output normalised space; no matter what size buffer the surface happens to have.
This never scales up, it only "scales" down.

Conversion from output normalised to hardware pixels happens in this (pre-existing line)

m_painter->setWindow(geometry);

Previously this was just a translation, however, because I we create the buffer size*scale , this has a scale too.

So for a 2x buffer on a 1x screen, we scale the image down in this line
For a 2x buffer on a 2x screen, we scale the image down, but because the qpainter is scaled up it cancels out losslessly
For a 1x client on a 2x screen, we paint, but the qpainter is scaled up, so it looks twice the size.

davidedmundson marked 4 inline comments as done.
  • Squash with input scaling
  • Squash with client size surface normal commit
  • hopefully fix subsurfaces - squash with qpainter rendering
Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptNov 7 2016, 6:19 PM

Add a scale method to the backends and proxy this to wl_output

Also add a --scale argument for testing

Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptNov 25 2016, 10:17 AM
This revision was automatically updated to reflect the committed changes.