D26311: Handle output logical size changes

Roman Gilg noreply at phabricator.kde.org
Wed Jan 1 18:46:01 GMT 2020


romangg added a comment.


  In D26311#585860 <https://phabricator.kde.org/D26311#585860>, @davidedmundson wrote:
  
  > Good start, the general approach is ok, but it needs a little tweak.
  >
  >  ---
  >
  > I don't like OutputDeviceInterface::setLogicalSize.
  >
  > Currently we have a pixel size and a scale, which gives us the logical size.
  >  By adding an explicitly setLogicalSize we have this 3 way binding loop that is very confusing.
  >
  > Having an explicitly set logical size with a scale right now would break that glViewport, and it's semantically confusing as to what the compositor view size is.
  
  
  What do you mean with "compositor view size"? The size of the here introduced view geometry?
  
  If the logical size is set explicitly the scale and mode size become irrelevant to what area the output covers in compositor space. I don't find that too confusing per se. But maybe the name should be changed to `setLogicalSizeOverride` or something like that?
  
  > 
  > 
  >  ----
  > 
  > I think all of this can be remedied if we change the output device method to be
  >  OutputDevice::setVirtualMode(QSize)
  > 
  > Which acts as a clip rect for where we render the plane as you have here, then have geometry() can use that instead of pixelSize.
  > 
  > Then scale/positioning etc. will all just work intuitively without extra semantics, egl_gbm_backend.cpp wouldn't need changing.
  
  Interesting approach. I assume you would like to change the protocol request from a `logical_size` setter to a `virtual_mode` one as well, right?
  
  When using this for replicating one output source onto another (target) the calculation becomes quite difficult I believe though. The client needs to factor in:
  
  - Current logical size of source output
  - Current mode of target output
  - Current scale of target output
  - Current transform of target output
  
  ---
  
  For example let's assume we have two outputs:
  
  1. Ultrabook 13'' source output: 1920x1200, scale 1.2, rotation landscape
  2. TV 50'' target output: 4K, scale 1, rotation portrait
  
  For the setVirtualMode argument we need to find a value such that what is displayed on the source output is also displayed on the target output while respecting the target rotation and scale. But there is another problem: the scale of the target is dependent on the source logical size and target resolution and must be changed as well then.
  
  Logical size of source is 1600x1000. Current mode of target is 3860x2160, but with the rotation what we need to compare the logical size of the source against is actually 2160x3860. To fit it in the virtual mode would be 2160x1350 (by `2160/1600*1000 = 1350`). The scaling factor is 1.35. To have sharp images we need an integer scale factor 2 on one of the outputs. Output (1) has this so we do not need to set it on (2).
  
  //Now user  changes the scale factor of output (1) to 1.//
  
  Logical size of source is now 1920x1200. Virtual mode would still be 2160 x 1350 (by `2160/1920*1200 = 1350`). The scaling factor is 1.125. For sharp images still an integer scale factor of 2 is needed, so either output (1) or (2) needs to be set to this. Since a change of scale in (1)  would alter the depiction overall we need to change it on (2). This would need to be done either via a scale override independent of what is set in OutputDevice or we send this new scale factor via the protocol to KScreen. Should it then ignore this scale factor change?
  
  //Now user  changes rotation of output (2) to landscape.//
  
  Now client needs to fit logical size 1920x1200 into 3860x2160. Virtual mode is now 3456 x 2160  (by `2160/1200*1920 = 3456`). Scale factor is 1.8. Like before integer scale factor of output (2) needs to be set to this.
  
  ---
  
  Let's compare with setting the logical size:
  
  Client sends logical size of 1600x1000 for output (2).
  
  //Now user  changes the scale factor of output (1) to 1.//
  
  Client sends logical size of 1920x1200 for output (2).
  
  //Now user  changes rotation of output (2) to landscape.//
  
  Client sends logical size of 1200x1920 for output (2).
  
  ---
  
  In the use case of output replication the API is simpler because semantically it makes more sense to directly set what area //should be replicated// and not what the end result on the output hardware must look like for that to happen. On a conceptual level weston and mutter do something similar by differentiating between the two separate structs outputs and heads.
  
  Note that above steps I outlined are missing in current patches (setting the wl_output scale factor accordingly when logical size is set and updating logical size on replicas when source output resolution and/or scale is changed).

REPOSITORY
  R108 KWin

REVISION DETAIL
  https://phabricator.kde.org/D26311

To: romangg, #kwin, davidedmundson
Cc: davidedmundson, kwin, LeGast00n, The-Feren-OS-Dev, sbergeron, jraleigh, zachus, fbampaloukas, GB_2, mkulinski, ragreen, jackyalcine, iodelay, crozbo, bwowk, ZrenBot, ngraham, alexeymin, himcesjf, lesliezhai, ali-mohamed, hardening, romangg, jensreuterberg, abetts, sebas, apol, ahiemstra, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kwin/attachments/20200101/19d283b1/attachment-0001.html>


More information about the kwin mailing list