diff options
Diffstat (limited to 'src/plugins/platforms')
24 files changed, 290 insertions, 116 deletions
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index d2978dd48e..536415339f 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -169,7 +169,7 @@ namespace QtAndroidInput static void longPress(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y) { //### TODO: add proper API for Qt 5.2 - static bool rightMouseFromLongPress = qgetenv("QT_NECESSITAS_COMPATIBILITY_LONG_PRESS").toInt(); + static bool rightMouseFromLongPress = qEnvironmentVariableIntValue("QT_NECESSITAS_COMPATIBILITY_LONG_PRESS"); if (!rightMouseFromLongPress) return; m_ignoreMouseEvents = true; diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 11f0bc5ffe..235e004904 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -425,7 +425,7 @@ namespace QtAndroid bool blockEventLoopsWhenSuspended() { - static bool block = qgetenv("QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED").toInt(); + static bool block = qEnvironmentVariableIntValue("QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED"); return block; } diff --git a/src/plugins/platforms/android/androidjnimenu.cpp b/src/plugins/platforms/android/androidjnimenu.cpp index 8f41d411ab..94454b8912 100644 --- a/src/plugins/platforms/android/androidjnimenu.cpp +++ b/src/plugins/platforms/android/androidjnimenu.cpp @@ -205,7 +205,7 @@ namespace QtAndroidMenu env->DeleteLocalRef(env->CallObjectMethod(menuItem, setEnabledMenuItemMethodID, enabled)); if (!icon.isNull()) { // isNull() only checks the d pointer, not the actual image data. - int sz = qMax(36, qgetenv("QT_ANDROID_APP_ICON_SIZE").toInt()); + int sz = qMax(36, qEnvironmentVariableIntValue("QT_ANDROID_APP_ICON_SIZE")); QImage img = icon.pixmap(QSize(sz,sz), enabled ? QIcon::Normal diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp index 06303cdd10..2010c19bd4 100644 --- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp +++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp @@ -254,7 +254,7 @@ private: AndroidAssetsFileEngineHandler::AndroidAssetsFileEngineHandler() - : m_assetsCache(std::max(5, qgetenv("QT_ANDROID_MAX_ASSETS_CACHE_SIZE").toInt())) + : m_assetsCache(std::max(5, qEnvironmentVariableIntValue("QT_ANDROID_MAX_ASSETS_CACHE_SIZE"))) , m_hasPrepopulatedCache(false) , m_hasTriedPrepopulatingCache(false) { diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 1775b442c4..09e5d7e346 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -84,7 +84,7 @@ QAndroidPlatformScreen::QAndroidPlatformScreen():QObject(),QPlatformScreen() m_size = QSize(QAndroidPlatformIntegration::m_defaultScreenWidth, QAndroidPlatformIntegration::m_defaultScreenHeight); // Raster only apps should set QT_ANDROID_RASTER_IMAGE_DEPTH to 16 // is way much faster than 32 - if (qgetenv("QT_ANDROID_RASTER_IMAGE_DEPTH").toInt() == 16) { + if (qEnvironmentVariableIntValue("QT_ANDROID_RASTER_IMAGE_DEPTH") == 16) { m_format = QImage::Format_RGB16; m_depth = 16; } else { diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index 02974018aa..914de9d270 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -172,7 +172,7 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const { switch (hint) { case StyleNames: - if (qgetenv("QT_USE_ANDROID_NATIVE_STYLE").toInt() + if (qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_STYLE") && (!qgetenv("MINISTRO_ANDROID_STYLE_PATH").isEmpty() || QFileInfo(STYLES_PATH + QLatin1String(qgetenv("QT_ANDROID_THEME_DISPLAY_DPI")) @@ -183,7 +183,7 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const case MouseDoubleClickDistance: { - int minimumDistance = qgetenv("QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE").toInt(); + int minimumDistance = qEnvironmentVariableIntValue("QT_ANDROID_MINIMUM_MOUSE_DOUBLE_CLICK_DISTANCE"); int ret = minimumDistance; QAndroidPlatformIntegration *platformIntegration @@ -227,7 +227,7 @@ QString QAndroidPlatformTheme::standardButtonText(int button) const bool QAndroidPlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const { if (type == MessageDialog) - return qgetenv("QT_USE_ANDROID_NATIVE_DIALOGS").toInt() == 1; + return qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_DIALOGS") == 1; return false; } diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp index 6216fa8575..802699bbd7 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp @@ -62,12 +62,13 @@ void QEglFSContext::swapBuffers(QPlatformSurface *surface) // draw the cursor if (surface->surface()->surfaceClass() == QSurface::Window) { QPlatformWindow *window = static_cast<QPlatformWindow *>(surface); - if (QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(window->screen()->cursor())) + if (QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(window->screen()->cursor())) cursor->paintOnScreen(); } QEglFSHooks::hooks()->waitForVSync(); QEGLPlatformContext::swapBuffers(surface); + QEglFSHooks::hooks()->presentBuffer(); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h index c51af17a56..3fba6409a1 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks.h +++ b/src/plugins/platforms/eglfs/qeglfshooks.h @@ -42,7 +42,6 @@ QT_BEGIN_NAMESPACE -class QEGLPlatformCursor; class QEglFSScreen; class QEglFSHooks @@ -65,9 +64,10 @@ public: const QSurfaceFormat &format); virtual void destroyNativeWindow(EGLNativeWindowType window); virtual bool hasCapability(QPlatformIntegration::Capability cap) const; - virtual QEGLPlatformCursor *createCursor(QPlatformScreen *screen) const; + virtual QPlatformCursor *createCursor(QPlatformScreen *screen) const; virtual bool filterConfig(EGLDisplay display, EGLConfig config) const; virtual void waitForVSync() const; + virtual void presentBuffer(); virtual QByteArray fbDeviceName() const; virtual int framebufferIndex() const; diff --git a/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp b/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp index 9e5d624d87..e9eec7fdc7 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_kms.cpp @@ -43,7 +43,12 @@ #include <QtPlatformSupport/private/qdevicediscovery_p.h> #include <QtCore/private/qcore_unix_p.h> #include <QtCore/QScopedPointer> +#include <QtCore/QJsonDocument> +#include <QtCore/QJsonObject> +#include <QtCore/QJsonArray> #include <QtGui/qpa/qplatformwindow.h> +#include <QtGui/qpa/qplatformcursor.h> +#include <QtGui/QPainter> #include <xf86drm.h> #include <xf86drmMode.h> @@ -51,6 +56,43 @@ QT_USE_NAMESPACE +class QKmsCursor : public QPlatformCursor +{ + Q_OBJECT +public: + QKmsCursor(gbm_device *gbm_device, int dri_fd, uint32_t crtcId); + ~QKmsCursor(); + + // input methods + void pointerEvent(const QMouseEvent & event) Q_DECL_OVERRIDE; +#ifndef QT_NO_CURSOR + void changeCursor(QCursor * windowCursor, QWindow * window) Q_DECL_OVERRIDE; +#endif + QPoint pos() const Q_DECL_OVERRIDE; + void setPos(const QPoint &pos) Q_DECL_OVERRIDE; + +private: + void initCursorAtlas(); + + gbm_device *m_gbm_device; + int m_dri_fd; + uint32_t m_crtc; + gbm_bo *m_bo; + QPoint m_pos; + QPlatformCursorImage m_cursorImage; + bool m_visible; + + // cursor atlas information + struct CursorAtlas { + CursorAtlas() : cursorsPerRow(0), cursorWidth(0), cursorHeight(0) { } + int cursorsPerRow; + int width, height; // width and height of the atlas + int cursorWidth, cursorHeight; // width and height of cursors inside the atlas + QList<QPoint> hotSpots; + QImage image; + } m_cursorAtlas; +}; + class QEglKmsHooks : public QEglFSHooks { public: @@ -68,17 +110,25 @@ public: const QSurfaceFormat &format) Q_DECL_OVERRIDE; void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE; bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE; - void waitForVSync() const Q_DECL_OVERRIDE; + QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE; + void presentBuffer() Q_DECL_OVERRIDE; - void waitForVSyncImpl(); +private: bool setup_kms(); struct FrameBuffer { FrameBuffer() : fb(0) {} uint32_t fb; }; + static void bufferDestroyedHandler(gbm_bo *bo, void *data); FrameBuffer *framebufferForBufferObject(gbm_bo *bo); + static void pageFlipHandler(int fd, + unsigned int sequence, + unsigned int tv_sec, + unsigned int tv_usec, + void *user_data); + private: // device bits QByteArray m_device; @@ -93,6 +143,10 @@ private: // Drawing bits gbm_surface *m_gbm_surface; + gbm_bo *m_gbm_bo_current; + gbm_bo *m_gbm_bo_next; + bool m_flipping; + bool m_mode_set; }; static QEglKmsHooks kms_hooks; @@ -105,6 +159,10 @@ QEglKmsHooks::QEglKmsHooks() , m_drm_encoder(Q_NULLPTR) , m_drm_crtc(0) , m_gbm_surface(Q_NULLPTR) + , m_gbm_bo_current(Q_NULLPTR) + , m_gbm_bo_next(Q_NULLPTR) + , m_flipping(false) + , m_mode_set(false) { } @@ -215,14 +273,19 @@ bool QEglKmsHooks::hasCapability(QPlatformIntegration::Capability cap) const case QPlatformIntegration::ThreadedPixmaps: case QPlatformIntegration::OpenGL: case QPlatformIntegration::ThreadedOpenGL: - case QPlatformIntegration::BufferQueueingOpenGL: return true; default: return false; } } -static void gbm_bo_destroyed_callback(gbm_bo *bo, void *data) +QPlatformCursor *QEglKmsHooks::createCursor(QPlatformScreen *screen) const +{ + Q_UNUSED(screen); + return new QKmsCursor(m_gbm_device, m_dri_fd, m_drm_crtc); +} + +void QEglKmsHooks::bufferDestroyedHandler(gbm_bo *bo, void *data) { QEglKmsHooks::FrameBuffer *fb = static_cast<QEglKmsHooks::FrameBuffer *>(data); @@ -257,95 +320,90 @@ QEglKmsHooks::FrameBuffer *QEglKmsHooks::framebufferForBufferObject(gbm_bo *bo) return Q_NULLPTR; } - gbm_bo_set_user_data(bo, fb.data(), gbm_bo_destroyed_callback); + gbm_bo_set_user_data(bo, fb.data(), bufferDestroyedHandler); return fb.take(); } -static void page_flip_handler(int fd, - unsigned int sequence, - unsigned int tv_sec, - unsigned int tv_usec, - void *user_data) +void QEglKmsHooks::pageFlipHandler(int fd, + unsigned int sequence, + unsigned int tv_sec, + unsigned int tv_usec, + void *user_data) { Q_UNUSED(fd); Q_UNUSED(sequence); Q_UNUSED(tv_sec); Q_UNUSED(tv_usec); - // We are no longer flipping - *static_cast<bool *>(user_data) = false; -} + QEglKmsHooks *hooks = static_cast<QEglKmsHooks *>(user_data); -void QEglKmsHooks::waitForVSync() const -{ - const_cast<QEglKmsHooks*>(this)->waitForVSyncImpl(); + if (hooks->m_gbm_bo_current) + gbm_surface_release_buffer(hooks->m_gbm_surface, + hooks->m_gbm_bo_current); + + hooks->m_gbm_bo_current = hooks->m_gbm_bo_next; + hooks->m_gbm_bo_next = Q_NULLPTR; + + // We are no longer flipping + hooks->m_flipping = false; } -void QEglKmsHooks::waitForVSyncImpl() +void QEglKmsHooks::presentBuffer() { if (!m_gbm_surface) { qWarning("Cannot sync before platform init!"); return; } - if (!gbm_surface_has_free_buffers(m_gbm_surface)) { - qWarning("Out of free GBM buffers!"); - return; - } - - gbm_bo *front_buffer = gbm_surface_lock_front_buffer(m_gbm_surface); - if (!front_buffer) { + m_gbm_bo_next = gbm_surface_lock_front_buffer(m_gbm_surface); + if (!m_gbm_bo_next) { qWarning("Could not lock GBM surface front buffer!"); return; } - QEglKmsHooks::FrameBuffer *fb = framebufferForBufferObject(front_buffer); - - int ret = drmModeSetCrtc(m_dri_fd, - m_drm_crtc, - fb->fb, - 0, 0, - &m_drm_connector->connector_id, 1, - &m_drm_mode); - if (ret) { - qErrnoWarning("Could not set DRM mode!"); - return; + QEglKmsHooks::FrameBuffer *fb = framebufferForBufferObject(m_gbm_bo_next); + + if (!m_mode_set) { + int ret = drmModeSetCrtc(m_dri_fd, + m_drm_crtc, + fb->fb, + 0, 0, + &m_drm_connector->connector_id, 1, + &m_drm_mode); + if (ret) { + qErrnoWarning("Could not set DRM mode!"); + } else { + m_mode_set = true; + } } - bool flipping = true; - ret = drmModePageFlip(m_dri_fd, - m_drm_encoder->crtc_id, - fb->fb, - DRM_MODE_PAGE_FLIP_EVENT, - &flipping); + int ret = drmModePageFlip(m_dri_fd, + m_drm_encoder->crtc_id, + fb->fb, + DRM_MODE_PAGE_FLIP_EVENT, + this); if (ret) { qErrnoWarning("Could not queue DRM page flip!"); return; } + m_flipping = true; + drmEventContext drmEvent = { DRM_EVENT_CONTEXT_VERSION, Q_NULLPTR, // vblank handler - page_flip_handler // page flip handler + pageFlipHandler // page flip handler }; fd_set fds; FD_ZERO(&fds); FD_SET(m_dri_fd, &fds); - time_t start, cur; - time(&start); - - while (flipping && (time(&cur) < start + 1)) { - timespec v; - memset(&v, 0, sizeof(v)); - v.tv_sec = start + 1 - cur; - - ret = qt_safe_select(m_dri_fd + 1, &fds, Q_NULLPTR, Q_NULLPTR, &v); + while (m_flipping) { + ret = qt_safe_select(m_dri_fd + 1, &fds, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); if (ret == 0) { // timeout - break; } else if (ret == -1) { qErrnoWarning("Error while selecting on DRM fd"); break; @@ -353,8 +411,6 @@ void QEglKmsHooks::waitForVSyncImpl() qWarning("Could not handle DRM event!"); } } - - gbm_surface_release_buffer(m_gbm_surface, front_buffer); } bool QEglKmsHooks::setup_kms() @@ -420,3 +476,144 @@ bool QEglKmsHooks::setup_kms() return true; } + + +QKmsCursor::QKmsCursor(gbm_device *gbm_device, int dri_fd, uint32_t crtcId) + : m_gbm_device(gbm_device) + , m_dri_fd(dri_fd) + , m_crtc(crtcId) + , m_bo(gbm_bo_create(gbm_device, 64, 64, GBM_FORMAT_ARGB8888, + GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE)) + , m_cursorImage(0, 0, 0, 0, 0, 0) + , m_visible(true) +{ + if (!m_bo) { + qWarning("Could not create buffer for cursor!"); + } else { + initCursorAtlas(); + } + + drmModeMoveCursor(m_dri_fd, m_crtc, 0, 0); +} + +QKmsCursor::~QKmsCursor() +{ + drmModeSetCursor(m_dri_fd, m_crtc, 0, 0, 0); + drmModeMoveCursor(m_dri_fd, m_crtc, 0, 0); + + gbm_bo_destroy(m_bo); + m_bo = Q_NULLPTR; +} + +void QKmsCursor::pointerEvent(const QMouseEvent &event) +{ + setPos(event.screenPos().toPoint()); +} + +#ifndef QT_NO_CURSOR +void QKmsCursor::changeCursor(QCursor *windowCursor, QWindow *window) +{ + Q_UNUSED(window); + + if (!m_visible) + return; + + const Qt::CursorShape newShape = windowCursor ? windowCursor->shape() : Qt::ArrowCursor; + if (newShape == Qt::BitmapCursor) { + m_cursorImage.set(windowCursor->pixmap().toImage(), + windowCursor->hotSpot().x(), + windowCursor->hotSpot().y()); + } else { + // Standard cursor, look up in atlas + const int width = m_cursorAtlas.cursorWidth; + const int height = m_cursorAtlas.cursorHeight; + const qreal ws = (qreal)m_cursorAtlas.cursorWidth / m_cursorAtlas.width; + const qreal hs = (qreal)m_cursorAtlas.cursorHeight / m_cursorAtlas.height; + + QRect textureRect(ws * (newShape % m_cursorAtlas.cursorsPerRow) * m_cursorAtlas.width, + hs * (newShape / m_cursorAtlas.cursorsPerRow) * m_cursorAtlas.height, + width, + height); + QPoint hotSpot = m_cursorAtlas.hotSpots[newShape]; + m_cursorImage.set(m_cursorAtlas.image.copy(textureRect), + hotSpot.x(), + hotSpot.y()); + } + + if (m_cursorImage.image()->width() > 64 || m_cursorImage.image()->height() > 64) + qWarning("Cursor larger than 64x64, cursor will be clipped."); + + QImage cursorImage(64, 64, QImage::Format_ARGB32); + cursorImage.fill(Qt::transparent); + + QPainter painter; + painter.begin(&cursorImage); + painter.drawImage(0, 0, *m_cursorImage.image()); + painter.end(); + + gbm_bo_write(m_bo, cursorImage.constBits(), cursorImage.byteCount()); + + uint32_t handle = gbm_bo_get_handle(m_bo).u32; + QPoint hot = m_cursorImage.hotspot(); + int status = drmModeSetCursor2(m_dri_fd, m_crtc, handle, 64, 64, hot.x(), hot.y()); + if (status != 0) + qWarning("Could not set cursor: %d", status); +} +#endif // QT_NO_CURSOR + +QPoint QKmsCursor::pos() const +{ + return m_pos; +} + +void QKmsCursor::setPos(const QPoint &pos) +{ + QPoint adjustedPos = pos - m_cursorImage.hotspot(); + int ret = drmModeMoveCursor(m_dri_fd, m_crtc, adjustedPos.x(), adjustedPos.y()); + if (ret == 0) { + m_pos = pos; + } else { + qWarning("Failed to move cursor: %d", ret); + } +} + +void QKmsCursor::initCursorAtlas() +{ + static QByteArray json = qgetenv("QT_QPA_EGLFS_CURSOR"); + if (json.isEmpty()) + json = ":/cursor.json"; + + QFile file(QString::fromUtf8(json)); + if (!file.open(QFile::ReadOnly)) { + drmModeSetCursor(m_dri_fd, m_crtc, 0, 0, 0); + drmModeMoveCursor(m_dri_fd, m_crtc, 0, 0); + m_visible = false; + return; + } + + QJsonDocument doc = QJsonDocument::fromJson(file.readAll()); + QJsonObject object = doc.object(); + + QString atlas = object.value(QLatin1String("image")).toString(); + Q_ASSERT(!atlas.isEmpty()); + + const int cursorsPerRow = object.value(QLatin1String("cursorsPerRow")).toDouble(); + Q_ASSERT(cursorsPerRow); + m_cursorAtlas.cursorsPerRow = cursorsPerRow; + + const QJsonArray hotSpots = object.value(QLatin1String("hotSpots")).toArray(); + Q_ASSERT(hotSpots.count() == Qt::LastCursor + 1); + for (int i = 0; i < hotSpots.count(); i++) { + QPoint hotSpot(hotSpots[i].toArray()[0].toDouble(), hotSpots[i].toArray()[1].toDouble()); + m_cursorAtlas.hotSpots << hotSpot; + } + + QImage image = QImage(atlas).convertToFormat(QImage::Format_ARGB32); + m_cursorAtlas.cursorWidth = image.width() / m_cursorAtlas.cursorsPerRow; + m_cursorAtlas.cursorHeight = image.height() / ((Qt::LastCursor + cursorsPerRow) / cursorsPerRow); + m_cursorAtlas.width = image.width(); + m_cursorAtlas.height = image.height(); + m_cursorAtlas.image = image; +} + +#include "qeglfshooks_kms.moc" diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp index b6b1be9244..d216b015d3 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp @@ -137,7 +137,7 @@ QSurfaceFormat QEglFSHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) { QSurfaceFormat format = inputFormat; - static const bool force888 = qgetenv("QT_QPA_EGLFS_FORCE888").toInt(); + static const bool force888 = qEnvironmentVariableIntValue("QT_QPA_EGLFS_FORCE888"); if (force888) { format.setRedBufferSize(8); format.setGreenBufferSize(8); @@ -173,7 +173,7 @@ bool QEglFSHooks::hasCapability(QPlatformIntegration::Capability cap) const return false; } -QEGLPlatformCursor *QEglFSHooks::createCursor(QPlatformScreen *screen) const +QPlatformCursor *QEglFSHooks::createCursor(QPlatformScreen *screen) const { return new QEGLPlatformCursor(screen); } @@ -181,7 +181,7 @@ QEGLPlatformCursor *QEglFSHooks::createCursor(QPlatformScreen *screen) const void QEglFSHooks::waitForVSync() const { #if defined(FBIO_WAITFORVSYNC) - static const bool forceSync = qgetenv("QT_QPA_EGLFS_FORCEVSYNC").toInt(); + static const bool forceSync = qEnvironmentVariableIntValue("QT_QPA_EGLFS_FORCEVSYNC"); if (forceSync && framebuffer != -1) { int arg = 0; if (ioctl(framebuffer, FBIO_WAITFORVSYNC, &arg) == -1) @@ -190,6 +190,10 @@ void QEglFSHooks::waitForVSync() const #endif } +void QEglFSHooks::presentBuffer() +{ +} + #ifndef EGLFS_PLATFORM_HOOKS QEglFSHooks stubHooks; #endif diff --git a/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp b/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp index b16857297c..8880a2a8a9 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp +++ b/src/plugins/platforms/eglfs/qeglfshooks_x11.cpp @@ -313,7 +313,7 @@ EGLNativeWindowType QEglFSX11Hooks::createNativeWindow(QPlatformWindow *platform xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_window, m_atoms[Atoms::WM_PROTOCOLS], XCB_ATOM_ATOM, 32, 1, &m_atoms[Atoms::WM_DELETE_WINDOW]); - if (qgetenv("EGLFS_X11_FULLSCREEN").toInt()) { + if (qEnvironmentVariableIntValue("EGLFS_X11_FULLSCREEN")) { // Go fullscreen. The QScreen and QWindow size is controlled by EGLFS_X11_SIZE regardless, // this is just the native window. xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_window, diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 2a4eae3fe2..12b8fabdfc 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE QEglFSIntegration::QEglFSIntegration() { - mDisableInputHandlers = qgetenv("QT_QPA_EGLFS_DISABLE_INPUT").toInt(); + mDisableInputHandlers = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DISABLE_INPUT"); initResources(); } diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index cd68540581..60f7347ba5 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -34,7 +34,7 @@ #include "qeglfsscreen.h" #include "qeglfswindow.h" #include "qeglfshooks.h" -#include <QtPlatformSupport/private/qeglplatformcursor_p.h> +#include <QtGui/qpa/qplatformcursor.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h index 4938d66538..c7d8b55b19 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.h +++ b/src/plugins/platforms/eglfs/qeglfsscreen.h @@ -42,7 +42,6 @@ QT_BEGIN_NAMESPACE -class QEGLPlatformCursor; class QEglFSWindow; class QOpenGLContext; @@ -79,7 +78,7 @@ private: EGLDisplay m_dpy; EGLSurface m_surface; - QEGLPlatformCursor *m_cursor; + QPlatformCursor *m_cursor; QEGLPlatformWindow *m_rootWindow; QOpenGLContext *m_rootContext; }; diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index c83b894089..1645d81878 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -116,7 +116,7 @@ void QEglFSWindow::destroy() { QEglFSScreen *screen = this->screen(); if (m_flags.testFlag(HasNativeWindow)) { - QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(screen->cursor()); + QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(screen->cursor()); if (cursor) cursor->resetResources(); diff --git a/src/plugins/platforms/kms/qkmsscreen.cpp b/src/plugins/platforms/kms/qkmsscreen.cpp index acc52ae5da..d14e91a259 100644 --- a/src/plugins/platforms/kms/qkmsscreen.cpp +++ b/src/plugins/platforms/kms/qkmsscreen.cpp @@ -215,7 +215,7 @@ void QKmsScreen::performPageFlip() // Initialize cursor - static int hideCursor = qgetenv("QT_QPA_KMS_HIDECURSOR").toInt(); + static int hideCursor = qEnvironmentVariableIntValue("QT_QPA_KMS_HIDECURSOR"); if (!hideCursor) { QCursor cursor(Qt::ArrowCursor); m_cursor->changeCursor(&cursor, 0); diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index 252f842df4..6bd9d8c96d 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -66,7 +66,7 @@ QMinimalIntegration::QMinimalIntegration(const QStringList ¶meters) , m_options(parseOptions(parameters)) { if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable) - && qgetenv(debugBackingStoreEnvironmentVariable).toInt() > 0) { + && qEnvironmentVariableIntValue(debugBackingStoreEnvironmentVariable) > 0) { m_options |= DebugBackingStore | EnableFonts; } diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index f3f93e7f64..04a6611cc4 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -305,7 +305,7 @@ static int defaultDepth() if (defaultDepth == 0) { // check if display depth was specified in environment variable; // use default value if no valid value found - defaultDepth = qgetenv("QQNX_DISPLAY_DEPTH").toInt(); + defaultDepth = qEnvironmentVariableIntValue("QQNX_DISPLAY_DEPTH"); if (defaultDepth != 16 && defaultDepth != 32) defaultDepth = 32; } @@ -679,7 +679,7 @@ void QQnxScreen::adjustOrientation() return; bool ok = false; - const int rotation = qgetenv("ORIENTATION").toInt(&ok); + const int rotation = qEnvironmentVariableIntValue("ORIENTATION", &ok); if (ok) setRotation(rotation); @@ -858,7 +858,7 @@ void QQnxScreen::setRootWindow(QQnxWindow *window) { // Optionally disable the screen power save bool ok = false; - const int disablePowerSave = qgetenv("QQNX_DISABLE_POWER_SAVE").toInt(&ok); + const int disablePowerSave = qEnvironmentVariableIntValue("QQNX_DISABLE_POWER_SAVE", &ok); if (ok && disablePowerSave) { const int mode = SCREEN_IDLE_MODE_KEEP_AWAKE; int result = screen_set_window_property_iv(window->nativeHandle(), SCREEN_PROPERTY_IDLE_MODE, &mode); diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.h b/src/plugins/platforms/windows/accessible/iaccessible2.h index 351bf2555c..f7f5e022c3 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.h +++ b/src/plugins/platforms/windows/accessible/iaccessible2.h @@ -39,24 +39,7 @@ #include "qwindowsmsaaaccessible.h" #include "comutils.h" -#include "Accessible2.h" -#include "AccessibleAction.h" -#include "AccessibleApplication.h" -#include "AccessibleComponent.h" -#include "AccessibleEditableText.h" -#include "AccessibleHyperlink.h" -#include "AccessibleHypertext.h" -#include "AccessibleImage.h" -#include "AccessibleRelation.h" -#include "AccessibleTable.h" -#include "AccessibleTable2.h" -#include "AccessibleTableCell.h" -#include "AccessibleText.h" -#include "AccessibleValue.h" - -#include "AccessibleEventID.h" -#include "AccessibleRole.h" -#include "AccessibleStates.h" +#include "ia2_api_all.h" #include <servprov.h> diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h index a78d821b1d..c522cf281e 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h @@ -42,7 +42,7 @@ #include <QtGui/qaccessible.h> #ifndef Q_CC_MINGW # include <oleacc.h> -# include "Accessible2.h" // IAccessible2 inherits from IAccessible +# include "ia2_api_all.h" // IAccessible2 inherits from IAccessible #else // MinGW # include <basetyps.h> diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index cfa5914ff8..fd585ee683 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -1183,19 +1183,13 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo return QImage(); } - QImage indexed(mask->width(), mask->height(), QImage::Format_Indexed8); + QImage alphaMap(mask->width(), mask->height(), QImage::Format_Alpha8); - // ### This part is kinda pointless, but we'll crash later if we don't because some - // code paths expects there to be colortables for index8-bit... - QVector<QRgb> colors(256); - for (int i=0; i<256; ++i) - colors[i] = qRgba(0, 0, 0, i); - indexed.setColorTable(colors); // Copy data... Cannot use QPainter here as GDI has messed up the // Alpha channel of the ni.image pixels... for (int y=0; y<mask->height(); ++y) { - uchar *dest = indexed.scanLine(y); + uchar *dest = alphaMap.scanLine(y); if (mask->image().format() == QImage::Format_RGB16) { const qint16 *src = (qint16 *) ((const QImage &) mask->image()).scanLine(y); for (int x=0; x<mask->width(); ++x) @@ -1217,7 +1211,7 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo DeleteObject(font); } - return indexed; + return alphaMap; } #define SPI_GETFONTSMOOTHINGCONTRAST 0x200C diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index 0041a07fb0..d0f23acb07 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -485,15 +485,11 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub { QImage im = imageForGlyph(glyph, subPixelPosition, 0, QTransform()); - QImage indexed(im.width(), im.height(), QImage::Format_Indexed8); - QVector<QRgb> colors(256); - for (int i=0; i<256; ++i) - colors[i] = qRgba(0, 0, 0, i); - indexed.setColorTable(colors); + QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8); for (int y=0; y<im.height(); ++y) { uint *src = (uint*) im.scanLine(y); - uchar *dst = indexed.scanLine(y); + uchar *dst = alphaMap.scanLine(y); for (int x=0; x<im.width(); ++x) { *dst = 255 - (m_fontEngineData->pow_gamma[qGray(0xffffffff - *src)] * 255. / 2047.); ++dst; @@ -501,7 +497,7 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed sub } } - return indexed; + return alphaMap; } bool QWindowsFontEngineDirectWrite::supportsSubPixelPositions() const diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp index f64b47960a..339a658c3e 100644 --- a/src/plugins/platforms/winrt/qwinrttheme.cpp +++ b/src/plugins/platforms/winrt/qwinrttheme.cpp @@ -170,7 +170,7 @@ QWinRTTheme::QWinRTTheme() bool QWinRTTheme::usePlatformNativeDialog(DialogType type) const { static bool useNativeDialogs = qEnvironmentVariableIsSet("QT_USE_WINRT_NATIVE_DIALOGS") - ? qgetenv("QT_USE_WINRT_NATIVE_DIALOGS").toInt() : true; + ? qEnvironmentVariableIntValue("QT_USE_WINRT_NATIVE_DIALOGS") : true; if (type == FileDialog || type == MessageDialog) return useNativeDialogs; diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8bdedba8ac..def6e2ce9a 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -320,7 +320,7 @@ QDpi QXcbScreen::logicalDpi() const qreal QXcbScreen::devicePixelRatio() const { - static int override_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toInt(); + static int override_dpr = qEnvironmentVariableIntValue("QT_DEVICE_PIXEL_RATIO"); static bool auto_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto"; if (override_dpr > 0) return override_dpr; |