summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qstyle_p.h
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2012-11-20 11:34:52 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-01 08:33:20 +0100
commit5e61bbe586519c3d9bc636153d32e810da4e59a3 (patch)
tree67d67ef644be72ee5b3d685c9a22538d7ec1e01d /src/widgets/styles/qstyle_p.h
parentc8dc41bacdc30026cb79d0d6c72255312084bfe3 (diff)
Basic high-dpi "retina" support for Qt 5.
Bring Qt 5 on par with Qt 4, prepare for more comprehensive support later on. Introduce device independent pixels (dips), device pixels, and devicePixelRatio. Add high-dpi support to QPainter, QGLWidget, the cocoa platform plugin, mac and fusion styles. Dips are similar to CSS pixels, Apple points and Android density-independent pixels. Device pixels are pixels in the backing store/physical pixels on screen. devicePixelRatio is the ratio between them, which is 1.0 on standard displays and 2.0 on "retina" displays. New API: QImage::devicePixelRatio() and setDevicePixelRatio() QPixmap::devicePixelRatio() and setDevicePixelRatio() QWindow::devicePixelRatio() QScreen::devicePixelRatio() QGuiApplicaiton::devicePixelRatio() Change-Id: If98c3ca9bfdf0e1bdbcf7574cd5b912c9ff63856 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/widgets/styles/qstyle_p.h')
-rw-r--r--src/widgets/styles/qstyle_p.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/widgets/styles/qstyle_p.h b/src/widgets/styles/qstyle_p.h
index 85e8e54b16..78dfc6fed9 100644
--- a/src/widgets/styles/qstyle_p.h
+++ b/src/widgets/styles/qstyle_p.h
@@ -43,6 +43,7 @@
#define QSTYLE_P_H
#include "private/qobject_p.h"
+#include <QtGui/qguiapplication.h>
#include <QtWidgets/qstyle.h>
QT_BEGIN_NAMESPACE
@@ -74,12 +75,18 @@ public:
inline QImage styleCacheImage(const QSize &size)
{
- return QImage(size, QImage::Format_ARGB32_Premultiplied);
+ const qreal pixelRatio = qApp->devicePixelRatio();
+ QImage cacheImage = QImage(size * pixelRatio, QImage::Format_ARGB32_Premultiplied);
+ cacheImage.setDevicePixelRatio(pixelRatio);
+ return cacheImage;
}
inline QPixmap styleCachePixmap(const QSize &size)
{
- return QPixmap(size);
+ const qreal pixelRatio = qApp->devicePixelRatio();
+ QPixmap cachePixmap = QPixmap(size * pixelRatio);
+ cachePixmap.setDevicePixelRatio(pixelRatio);
+ return cachePixmap;
}
#define BEGIN_STYLE_PIXMAPCACHE(a) \