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

BlitFramebuffer coordinate system mismatch

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.10.1
    • 5.10, 5.11
    • Qt3D
    • None
    • d69e2c2b42719e6839f32e8ab796cf22d9f29bfa

    Description

      QBlitFramebuffer's sourceRect and destinationRect were defined as QRectF in the API.

      Under the hood, GraphicsContext blindly passes left(), top(), left()+width() and top()+height() to glBlitFramebuffer. This is pretty bad since glBlitFramebuffer uses the GL coordinate system (Y == bottom left corner). QRect(F) is badly suited for representing such rectangles. So once a non-fullscreen blit is needed, applications will likely attempt to convert their QRectF to a GL-friendly rect using setY, but that will internally alter the QRectF's height.

      Rather, QBlitFramebuffer should state that the rectangles are in Qt coordinates (Y == top left). This would not just allow sane rectangle manipulation on the client side, but would also be more future-proof (given that no other graphics APIs use the Y==bottom left convention)

      Code like the following:

                          QRectF srcRect(data->layerPos, data->layerSize);
                          // blitframebuffer takes GL coords (Y==bottom left), convert since source is a partial area only
                          srcRect.setY(m_outputPixelSize.height() - (srcRect.y() + srcRect.height()));
                          srcRect.setHeight(data->layerSize.height()); // ugh, fix up the height since setY altered it; QRectF is not really suitable for GL rects
                          bgBlit->setSourceRect(srcRect);
      
                          QRectF dstRect(QPointF(0, 0), srcRect.size());
                          bgBlit->setDestinationRect(dstRect);
      

      could then be simplified to a more sane:

                          QRectF srcRect(data->layerPos, data->layerSize);
                          bgBlit->setSourceRect(srcRect);
      
                          QRectF dstRect(QPointF(0, 0), srcRect.size());
                          bgBlit->setDestinationRect(dstRect);
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-65123
          # Subject Branch Project Status CR V

          Activity

            People

              lagocs Laszlo Agocs
              lagocs Laszlo Agocs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes