QtGui: de-duplicate calls and cache results
Change-Id: Iaf232c31d6780b49dc6a3d0faafb9717f3c36e65 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
434f2b8968
commit
a3def2869d
|
|
@ -474,8 +474,9 @@ QVector<T> fromNativePixels(const QVector<T> &pixelValues, const QWindow *window
|
|||
|
||||
QVector<T> pointValues;
|
||||
pointValues.reserve(pixelValues.size());
|
||||
const auto factor = QHighDpiScaling::factor(window);
|
||||
for (const T &pixelValue : pixelValues)
|
||||
pointValues.append(pixelValue / QHighDpiScaling::factor(window));
|
||||
pointValues.append(pixelValue / factor);
|
||||
return pointValues;
|
||||
}
|
||||
|
||||
|
|
@ -488,8 +489,9 @@ QVector<T> toNativePixels(const QVector<T> &pointValues, const QWindow *window)
|
|||
|
||||
QVector<T> pixelValues;
|
||||
pixelValues.reserve(pointValues.size());
|
||||
const auto factor = QHighDpiScaling::factor(window);
|
||||
for (const T &pointValue : pointValues)
|
||||
pixelValues.append(pointValue * QHighDpiScaling::factor(window));
|
||||
pixelValues.append(pointValue * factor);
|
||||
return pixelValues;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,9 +252,10 @@ void QOpenGLWindowPrivate::beginPaint(const QRegion ®ion)
|
|||
if (!fbo || fbo->size() != deviceSize) {
|
||||
QOpenGLFramebufferObjectFormat fboFormat;
|
||||
fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
||||
if (q->requestedFormat().samples() > 0) {
|
||||
const int samples = q->requestedFormat().samples();
|
||||
if (samples > 0) {
|
||||
if (updateBehavior != QOpenGLWindow::PartialUpdateBlend)
|
||||
fboFormat.setSamples(q->requestedFormat().samples());
|
||||
fboFormat.setSamples(samples);
|
||||
else
|
||||
qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -499,9 +499,10 @@ QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) co
|
|||
if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) {
|
||||
const auto screens = currentScreen->virtualSiblings();
|
||||
for (QPlatformScreen *screen : screens) {
|
||||
if (screen->geometry().contains(center))
|
||||
const QRect screenGeometry = screen->geometry();
|
||||
if (screenGeometry.contains(center))
|
||||
return screen;
|
||||
if (screen->geometry().intersects(newGeometry))
|
||||
if (screenGeometry.intersects(newGeometry))
|
||||
fallback = screen;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,8 +73,9 @@ public:
|
|||
void beginPaint(const QRegion ®ion) Q_DECL_OVERRIDE
|
||||
{
|
||||
Q_Q(QRasterWindow);
|
||||
if (backingstore->size() != q->size()) {
|
||||
backingstore->resize(q->size());
|
||||
const QSize size = q->size();
|
||||
if (backingstore->size() != size) {
|
||||
backingstore->resize(size);
|
||||
markWindowAsDirty();
|
||||
}
|
||||
backingstore->beginPaint(region);
|
||||
|
|
|
|||
|
|
@ -1469,9 +1469,9 @@ void QWindow::setGeometry(const QRect &rect)
|
|||
{
|
||||
Q_D(QWindow);
|
||||
d->positionAutomatic = false;
|
||||
if (rect == geometry())
|
||||
const QRect oldRect = geometry();
|
||||
if (rect == oldRect)
|
||||
return;
|
||||
QRect oldRect = geometry();
|
||||
|
||||
d->positionPolicy = QWindowPrivate::WindowFrameExclusive;
|
||||
if (d->platformWindow) {
|
||||
|
|
|
|||
|
|
@ -824,14 +824,15 @@ QZipReader::QZipReader(const QString &archive, QIODevice::OpenMode mode)
|
|||
QScopedPointer<QFile> f(new QFile(archive));
|
||||
f->open(mode);
|
||||
QZipReader::Status status;
|
||||
if (f->error() == QFile::NoError)
|
||||
const QFileDevice::FileError error = f->error();
|
||||
if (error == QFile::NoError)
|
||||
status = NoError;
|
||||
else {
|
||||
if (f->error() == QFile::ReadError)
|
||||
if (error == QFile::ReadError)
|
||||
status = FileReadError;
|
||||
else if (f->error() == QFile::OpenError)
|
||||
else if (error == QFile::OpenError)
|
||||
status = FileOpenError;
|
||||
else if (f->error() == QFile::PermissionsError)
|
||||
else if (error == QFile::PermissionsError)
|
||||
status = FilePermissionsError;
|
||||
else
|
||||
status = FileError;
|
||||
|
|
|
|||
|
|
@ -328,17 +328,17 @@ QString QDesktopServices::storageLocationImpl(QStandardPaths::StandardLocation t
|
|||
// * Unix data location is under the "data/" subdirectory
|
||||
const QString compatAppName = qt_applicationName_noFallback();
|
||||
const QString baseDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||
const QString organizationName = QCoreApplication::organizationName();
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||
QString result = baseDir;
|
||||
if (!QCoreApplication::organizationName().isEmpty())
|
||||
result += QLatin1Char('/') + QCoreApplication::organizationName();
|
||||
if (!organizationName.isEmpty())
|
||||
result += QLatin1Char('/') + organizationName;
|
||||
if (!compatAppName.isEmpty())
|
||||
result += QLatin1Char('/') + compatAppName;
|
||||
return result;
|
||||
#elif defined(Q_OS_UNIX)
|
||||
return baseDir + QLatin1String("/data/")
|
||||
+ QCoreApplication::organizationName() + QLatin1Char('/')
|
||||
+ compatAppName;
|
||||
+ organizationName + QLatin1Char('/') + compatAppName;
|
||||
#endif
|
||||
}
|
||||
return QStandardPaths::writableLocation(type);
|
||||
|
|
|
|||
Loading…
Reference in New Issue