eglfs: Fix bug determining physical screen size
In the situation that the screenSize EGLFS hook had been defined, but not the physicalScreenSize, the uninitialized contents of fb_var_screeninfo vinfo would be used to calculate the fall-back physical screen size. Since this value is undefined, devices like the Raspberry Pi would end unable to render DPI dependent fonts. Change-Id: Ic9f67c1c646cc7b328b695b76a84d78577fefcd8 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
This commit is contained in:
parent
51a35f5c02
commit
fb7e0e24c4
@ -99,6 +99,7 @@ QSizeF QEglFSHooks::physicalScreenSize() const
|
|||||||
struct fb_var_screeninfo vinfo;
|
struct fb_var_screeninfo vinfo;
|
||||||
int w = -1;
|
int w = -1;
|
||||||
int h = -1;
|
int h = -1;
|
||||||
|
QSize screenResolution;
|
||||||
|
|
||||||
if (framebuffer != -1) {
|
if (framebuffer != -1) {
|
||||||
if (ioctl(framebuffer, FBIOGET_VSCREENINFO, &vinfo) == -1) {
|
if (ioctl(framebuffer, FBIOGET_VSCREENINFO, &vinfo) == -1) {
|
||||||
@ -106,12 +107,15 @@ QSizeF QEglFSHooks::physicalScreenSize() const
|
|||||||
} else {
|
} else {
|
||||||
w = vinfo.width;
|
w = vinfo.width;
|
||||||
h = vinfo.height;
|
h = vinfo.height;
|
||||||
|
screenResolution = QSize(vinfo.xres, vinfo.yres);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
screenResolution = screenSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int defaultPhysicalDpi = 100;
|
const int defaultPhysicalDpi = 100;
|
||||||
size.setWidth(w <= 0 ? vinfo.xres * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w));
|
size.setWidth(w <= 0 ? screenResolution.width() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w));
|
||||||
size.setHeight(h <= 0 ? vinfo.yres * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h));
|
size.setHeight(h <= 0 ? screenResolution.height() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h));
|
||||||
|
|
||||||
if (w <= 0 || h <= 0) {
|
if (w <= 0 || h <= 0) {
|
||||||
qWarning("EGLFS: Unable to query physical screen size, defaulting to %d dpi.\n"
|
qWarning("EGLFS: Unable to query physical screen size, defaulting to %d dpi.\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user