Skip to content

Commit

Permalink
kms plugin: do not needlessly query drm information twice
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
DerDakon authored and The Qt Project committed May 8, 2014
1 parent c82668d commit 9c4996b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/plugins/platforms/kms/qkmsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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);
}
Expand Down
15 changes: 4 additions & 11 deletions src/plugins/platforms/kms/qkmsscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/platforms/kms/qkmsscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -94,7 +94,7 @@ class QKmsScreen : public QPlatformScreen

private:
void performPageFlip();
void initializeScreenMode();
void initializeScreenMode(const drmModeRes *resources, const drmModeConnector *connector);

QKmsDevice *m_device;
gbm_bo *m_current_bo;
Expand Down

0 comments on commit 9c4996b

Please sign in to comment.