Track API change in QPlatformNativeInterface
Reviewed-by: Samuel
This commit is contained in:
parent
88e39d8654
commit
481cd6a6b5
@ -73,29 +73,29 @@ public:
|
|||||||
|
|
||||||
Q_GLOBAL_STATIC(QXcbResourceMap, qXcbResourceMap)
|
Q_GLOBAL_STATIC(QXcbResourceMap, qXcbResourceMap)
|
||||||
|
|
||||||
void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
|
void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
|
||||||
{
|
{
|
||||||
QByteArray lowerCaseResource = resourceString.toLower();
|
QByteArray lowerCaseResource = resourceString.toLower();
|
||||||
ResourceType resource = qXcbResourceMap()->value(lowerCaseResource);
|
ResourceType resource = qXcbResourceMap()->value(lowerCaseResource);
|
||||||
void *result = 0;
|
void *result = 0;
|
||||||
switch(resource) {
|
switch(resource) {
|
||||||
case Display:
|
case Display:
|
||||||
result = displayForWidget(widget);
|
result = displayForWindow(window);
|
||||||
break;
|
break;
|
||||||
case EglDisplay:
|
case EglDisplay:
|
||||||
result = eglDisplayForWidget(widget);
|
result = eglDisplayForWindow(window);
|
||||||
break;
|
break;
|
||||||
case Connection:
|
case Connection:
|
||||||
result = connectionForWidget(widget);
|
result = connectionForWindow(window);
|
||||||
break;
|
break;
|
||||||
case Screen:
|
case Screen:
|
||||||
result = qPlatformScreenForWidget(widget);
|
result = qPlatformScreenForWindow(window);
|
||||||
break;
|
break;
|
||||||
case GraphicsDevice:
|
case GraphicsDevice:
|
||||||
result = graphicsDeviceForWidget(widget);
|
result = graphicsDeviceForWindow(window);
|
||||||
break;
|
break;
|
||||||
case EglContext:
|
case EglContext:
|
||||||
result = eglContextForWidget(widget);
|
result = eglContextForWindow(window);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = 0;
|
result = 0;
|
||||||
@ -103,75 +103,70 @@ void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceStr
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QXcbScreen *QXcbNativeInterface::qPlatformScreenForWidget(QWidget *widget)
|
QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
|
||||||
{
|
{
|
||||||
QXcbScreen *screen;
|
QXcbScreen *screen;
|
||||||
if (widget) {
|
if (window) {
|
||||||
screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
|
screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window));
|
||||||
}else {
|
}else {
|
||||||
screen = static_cast<QXcbScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
|
screen = static_cast<QXcbScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
|
||||||
}
|
}
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *QXcbNativeInterface::displayForWidget(QWidget *widget)
|
void *QXcbNativeInterface::displayForWindow(QWindow *window)
|
||||||
{
|
{
|
||||||
#if defined(XCB_USE_XLIB)
|
#if defined(XCB_USE_XLIB)
|
||||||
QXcbScreen *screen = qPlatformScreenForWidget(widget);
|
QXcbScreen *screen = qPlatformScreenForWindow(window);
|
||||||
return screen->connection()->xlib_display();
|
return screen->connection()->xlib_display();
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(window);
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *QXcbNativeInterface::eglDisplayForWidget(QWidget *widget)
|
void *QXcbNativeInterface::eglDisplayForWindow(QWindow *window)
|
||||||
{
|
{
|
||||||
#if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
|
#if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
|
||||||
QXcbScreen *screen = qPlatformScreenForWidget(widget);
|
QXcbScreen *screen = qPlatformScreenForWindow(window);
|
||||||
return screen->connection()->egl_display();
|
return screen->connection()->egl_display();
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(window)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *QXcbNativeInterface::connectionForWidget(QWidget *widget)
|
void *QXcbNativeInterface::connectionForWindow(QWindow *window)
|
||||||
{
|
{
|
||||||
QXcbScreen *screen = qPlatformScreenForWidget(widget);
|
QXcbScreen *screen = qPlatformScreenForWindow(window);
|
||||||
return screen->xcb_connection();
|
return screen->xcb_connection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *QXcbNativeInterface::screenForWidget(QWidget *widget)
|
void *QXcbNativeInterface::screenForWindow(QWindow *window)
|
||||||
{
|
{
|
||||||
QXcbScreen *screen = qPlatformScreenForWidget(widget);
|
QXcbScreen *screen = qPlatformScreenForWindow(window);
|
||||||
return screen->screen();
|
return screen->screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *QXcbNativeInterface::graphicsDeviceForWidget(QWidget *widget)
|
void *QXcbNativeInterface::graphicsDeviceForWindow(QWindow *window)
|
||||||
{
|
{
|
||||||
#if defined(XCB_USE_DRI2)
|
#if defined(XCB_USE_DRI2)
|
||||||
QXcbScreen *screen = qPlatformScreenForWidget(widget);
|
QXcbScreen *screen = qPlatformScreenForWindow(window);
|
||||||
QByteArray deviceName = screen->connection()->dri2DeviceName();
|
QByteArray deviceName = screen->connection()->dri2DeviceName();
|
||||||
return deviceName.data();
|
return deviceName.data();
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(window);
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void * QXcbNativeInterface::eglContextForWidget(QWidget *widget)
|
void * QXcbNativeInterface::eglContextForWindow(QWindow *window)
|
||||||
{
|
{
|
||||||
Q_ASSERT(widget);
|
Q_ASSERT(window);
|
||||||
if (!widget->windowHandle()) {
|
QPlatformGLContext *platformContext = window->glContext()->handle();
|
||||||
qDebug() << "QPlatformWindow does not exist for widget" << widget
|
|
||||||
<< "cannot return EGLContext";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
QPlatformGLContext *platformContext = widget->windowHandle()->glContext()->handle();
|
|
||||||
if (!platformContext) {
|
if (!platformContext) {
|
||||||
qDebug() << "QWindow" << widget->windowHandle() << "does not have a glContext"
|
qDebug() << "QWindow" << window << "does not have a glContext"
|
||||||
<< "cannot return EGLContext";
|
<< "cannot return EGLContext";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -59,17 +59,17 @@ public:
|
|||||||
EglContext
|
EglContext
|
||||||
};
|
};
|
||||||
|
|
||||||
void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget);
|
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
|
||||||
|
|
||||||
void *displayForWidget(QWidget *widget);
|
void *displayForWindow(QWindow *window);
|
||||||
void *eglDisplayForWidget(QWidget *widget);
|
void *eglDisplayForWindow(QWindow *window);
|
||||||
void *connectionForWidget(QWidget *widget);
|
void *connectionForWindow(QWindow *window);
|
||||||
void *screenForWidget(QWidget *widget);
|
void *screenForWindow(QWindow *window);
|
||||||
void *graphicsDeviceForWidget(QWidget *widget);
|
void *graphicsDeviceForWindow(QWindow *window);
|
||||||
void *eglContextForWidget(QWidget *widget);
|
void *eglContextForWindow(QWindow *window);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QXcbScreen *qPlatformScreenForWidget(QWidget *widget);
|
static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QXCBNATIVEINTERFACE_H
|
#endif // QXCBNATIVEINTERFACE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user