kms plugin: do not needlessly query drm information twice
QKmsDevice already requested the drmModeRes and drmModeConnector information. Simply pass them to the QKmsScreen constructor instead of requesting and freeing them there again. Change-Id: I4897d76d7b13d83297c928b6e10e17ccdfdbd242 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
parent
c82668d39d
commit
9c4996b709
@ -85,8 +85,7 @@ QKmsDevice::~QKmsDevice()
|
|||||||
|
|
||||||
void QKmsDevice::createScreens()
|
void QKmsDevice::createScreens()
|
||||||
{
|
{
|
||||||
drmModeRes *resources = 0;
|
drmModeRes *resources = drmModeGetResources(m_fd);
|
||||||
resources = drmModeGetResources(m_fd);
|
|
||||||
if (!resources)
|
if (!resources)
|
||||||
qFatal("drmModeGetResources failed");
|
qFatal("drmModeGetResources failed");
|
||||||
|
|
||||||
@ -95,7 +94,7 @@ void QKmsDevice::createScreens()
|
|||||||
drmModeConnector *connector = 0;
|
drmModeConnector *connector = 0;
|
||||||
connector = drmModeGetConnector(m_fd, resources->connectors[i]);
|
connector = drmModeGetConnector(m_fd, resources->connectors[i]);
|
||||||
if (connector && connector->connection == DRM_MODE_CONNECTED) {
|
if (connector && connector->connection == DRM_MODE_CONNECTED) {
|
||||||
m_integration->addScreen(new QKmsScreen(this, connector->connector_id));
|
m_integration->addScreen(new QKmsScreen(this, resources, connector));
|
||||||
}
|
}
|
||||||
drmModeFreeConnector(connector);
|
drmModeFreeConnector(connector);
|
||||||
}
|
}
|
||||||
|
@ -63,18 +63,18 @@ static drmModeModeInfo builtin_1024x768 = {
|
|||||||
"1024x768"
|
"1024x768"
|
||||||
};
|
};
|
||||||
|
|
||||||
QKmsScreen::QKmsScreen(QKmsDevice *device, int connectorId)
|
QKmsScreen::QKmsScreen(QKmsDevice *device, const drmModeRes *resources, const drmModeConnector *connector)
|
||||||
: m_device(device),
|
: m_device(device),
|
||||||
m_current_bo(0),
|
m_current_bo(0),
|
||||||
m_next_bo(0),
|
m_next_bo(0),
|
||||||
m_connectorId(connectorId),
|
m_connectorId(connector->connector_id),
|
||||||
m_depth(32),
|
m_depth(32),
|
||||||
m_format(QImage::Format_Invalid),
|
m_format(QImage::Format_Invalid),
|
||||||
m_eglWindowSurface(EGL_NO_SURFACE),
|
m_eglWindowSurface(EGL_NO_SURFACE),
|
||||||
m_modeSet(false)
|
m_modeSet(false)
|
||||||
{
|
{
|
||||||
m_cursor = new QKmsCursor(this);
|
m_cursor = new QKmsCursor(this);
|
||||||
initializeScreenMode();
|
initializeScreenMode(resources, connector);
|
||||||
}
|
}
|
||||||
|
|
||||||
QKmsScreen::~QKmsScreen()
|
QKmsScreen::~QKmsScreen()
|
||||||
@ -114,14 +114,9 @@ QPlatformCursor *QKmsScreen::cursor() const
|
|||||||
return m_cursor;
|
return m_cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QKmsScreen::initializeScreenMode()
|
void QKmsScreen::initializeScreenMode(const drmModeRes *resources, const drmModeConnector *connector)
|
||||||
{
|
{
|
||||||
//Determine optimal mode for screen
|
//Determine optimal mode for screen
|
||||||
drmModeRes *resources = drmModeGetResources(m_device->fd());
|
|
||||||
if (!resources)
|
|
||||||
qFatal("drmModeGetResources failed");
|
|
||||||
|
|
||||||
drmModeConnector *connector = drmModeGetConnector(m_device->fd(), m_connectorId);
|
|
||||||
drmModeModeInfo *mode = 0;
|
drmModeModeInfo *mode = 0;
|
||||||
for (int i = 0; i < connector->count_modes; ++i) {
|
for (int i = 0; i < connector->count_modes; ++i) {
|
||||||
if (connector->modes[i].type & DRM_MODE_TYPE_PREFERRED) {
|
if (connector->modes[i].type & DRM_MODE_TYPE_PREFERRED) {
|
||||||
@ -162,8 +157,6 @@ void QKmsScreen::initializeScreenMode()
|
|||||||
qDebug() << "created gbm surface" << m_gbmSurface << m_mode.hdisplay << m_mode.vdisplay;
|
qDebug() << "created gbm surface" << m_gbmSurface << m_mode.hdisplay << m_mode.vdisplay;
|
||||||
//Cleanup
|
//Cleanup
|
||||||
drmModeFreeEncoder(encoder);
|
drmModeFreeEncoder(encoder);
|
||||||
drmModeFreeConnector(connector);
|
|
||||||
drmModeFreeResources(resources);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSurfaceFormat QKmsScreen::tweakFormat(const QSurfaceFormat &format)
|
QSurfaceFormat QKmsScreen::tweakFormat(const QSurfaceFormat &format)
|
||||||
|
@ -68,7 +68,7 @@ class QKmsContext;
|
|||||||
class QKmsScreen : public QPlatformScreen
|
class QKmsScreen : public QPlatformScreen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QKmsScreen(QKmsDevice *device, int connectorId);
|
QKmsScreen(QKmsDevice *device, const drmModeRes *resources, const drmModeConnector *connector);
|
||||||
~QKmsScreen();
|
~QKmsScreen();
|
||||||
|
|
||||||
QRect geometry() const;
|
QRect geometry() const;
|
||||||
@ -94,7 +94,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void performPageFlip();
|
void performPageFlip();
|
||||||
void initializeScreenMode();
|
void initializeScreenMode(const drmModeRes *resources, const drmModeConnector *connector);
|
||||||
|
|
||||||
QKmsDevice *m_device;
|
QKmsDevice *m_device;
|
||||||
gbm_bo *m_current_bo;
|
gbm_bo *m_current_bo;
|
||||||
|
Loading…
Reference in New Issue
Block a user