Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-94941

EGLFS calculates a wrong logical DPI?

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: QPA: EGLFS, QPA: KMS
    • Labels:
      None

      Description

      I have a board using EGLFS with the eglfs_kms integration.

      The physical display is 65x120mm, with a resolution of 720x1280 pixels. That's ~300dpi. The physical size is passed to Qt using the QT_QPA_EGLFS_PHYSICAL_WIDTH / HEIGHT env variables.

      The problem is that, by default, EGLFS reports this resolution as a logical DPI, not just as a physical DPI. It seems that the relative code is indeed calculating this logical DPI here:

      https://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp?h=5.15#n161

      QDpi QEglFSKmsScreen::logicalDpi() const
      {
          const QSizeF ps = physicalSize();
          const QSize s = geometry().size();
      
          if (!ps.isEmpty() && !s.isEmpty())
              return QDpi(25.4 * s.width() / ps.width(),
                          25.4 * s.height() / ps.height());
          else
              return QDpi(100, 100);
      }
      

      This causes font sizes specified in points to become N times bigger than they should be. Forcing that code to return a fake logical DPI (like 96,96) makes the font point sizes to work again. Quick hack:

      diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
      index 959f17eba3..508b02ecd8 100644
      --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
      +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
      @@ -160,6 +160,9 @@ QSizeF QEglFSKmsScreen::physicalSize() const
       
       QDpi QEglFSKmsScreen::logicalDpi() const
       {
      +    if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_DPI_OVERRIDE"))
      +        return QDpi(96, 96);
      +
           const QSizeF ps = physicalSize();
           const QSize s = geometry().size();
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            lagocs Laszlo Agocs
            Reporter:
            peppe Giuseppe D'Angelo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes