Details
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 |
214177,5 | Make BlitFramebuffer rectangles follow Qt conventions | 5.10 | qt/qt3d | Status: MERGED | +2 | 0 |