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:
Rolf Eike Beer 2014-05-07 11:02:23 +02:00 committed by The Qt Project
parent c82668d39d
commit 9c4996b709
3 changed files with 8 additions and 16 deletions

View File

@ -85,8 +85,7 @@ QKmsDevice::~QKmsDevice()
void QKmsDevice::createScreens()
{
drmModeRes *resources = 0;
resources = drmModeGetResources(m_fd);
drmModeRes *resources = drmModeGetResources(m_fd);
if (!resources)
qFatal("drmModeGetResources failed");
@ -95,7 +94,7 @@ void QKmsDevice::createScreens()
drmModeConnector *connector = 0;
connector = drmModeGetConnector(m_fd, resources->connectors[i]);
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);
}

View File

@ -63,18 +63,18 @@ static drmModeModeInfo builtin_1024x768 = {
"1024x768"
};
QKmsScreen::QKmsScreen(QKmsDevice *device, int connectorId)
QKmsScreen::QKmsScreen(QKmsDevice *device, const drmModeRes *resources, const drmModeConnector *connector)
: m_device(device),
m_current_bo(0),
m_next_bo(0),
m_connectorId(connectorId),
m_connectorId(connector->connector_id),
m_depth(32),
m_format(QImage::Format_Invalid),
m_eglWindowSurface(EGL_NO_SURFACE),
m_modeSet(false)
{
m_cursor = new QKmsCursor(this);
initializeScreenMode();
initializeScreenMode(resources, connector);
}
QKmsScreen::~QKmsScreen()
@ -114,14 +114,9 @@ QPlatformCursor *QKmsScreen::cursor() const
return m_cursor;
}
void QKmsScreen::initializeScreenMode()
void QKmsScreen::initializeScreenMode(const drmModeRes *resources, const drmModeConnector *connector)
{
//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;
for (int i = 0; i < connector->count_modes; ++i) {
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;
//Cleanup
drmModeFreeEncoder(encoder);
drmModeFreeConnector(connector);
drmModeFreeResources(resources);
}
QSurfaceFormat QKmsScreen::tweakFormat(const QSurfaceFormat &format)

View File

@ -68,7 +68,7 @@ class QKmsContext;
class QKmsScreen : public QPlatformScreen
{
public:
QKmsScreen(QKmsDevice *device, int connectorId);
QKmsScreen(QKmsDevice *device, const drmModeRes *resources, const drmModeConnector *connector);
~QKmsScreen();
QRect geometry() const;
@ -94,7 +94,7 @@ public:
private:
void performPageFlip();
void initializeScreenMode();
void initializeScreenMode(const drmModeRes *resources, const drmModeConnector *connector);
QKmsDevice *m_device;
gbm_bo *m_current_bo;