summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@digia.com>2013-04-04 18:15:00 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-05 16:26:07 +0200
commit439a6fec84a62b9d166b84dc7574ddc250a38bfb (patch)
tree8cc00b5b3ce8f2af15bc9ba96c3cdd3987e03892 /src/plugins/platforms/android
parent722798a359761a1eb635d18547b076615f192508 (diff)
Android: set logicalDpi based on DisplayMetrics.scaledDensity
The mathematically correct way would be to set logicalDPi to 160*scaledDensity, but then a 12 pt font would be gigantic. On iOS, we use a factor of 72 to be compatible with the native APIs, but that means that a 12 pt font is very small. A factor of 100 means that desktop apps look reasonable by default. Task-number: QTBUG-29674 Change-Id: I607f110150fb95685a6980b92f6f92f2b489f959 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/plugins/platforms/android')
-rw-r--r--src/plugins/platforms/android/src/androidjnimain.cpp11
-rw-r--r--src/plugins/platforms/android/src/androidjnimain.h1
-rw-r--r--src/plugins/platforms/android/src/opengl/qeglfshooks_android.cpp7
-rw-r--r--src/plugins/platforms/android/src/raster/qandroidplatformscreen.cpp6
-rw-r--r--src/plugins/platforms/android/src/raster/qandroidplatformscreen.h1
5 files changed, 24 insertions, 2 deletions
diff --git a/src/plugins/platforms/android/src/androidjnimain.cpp b/src/plugins/platforms/android/src/androidjnimain.cpp
index ae94e75e34..36d95b0816 100644
--- a/src/plugins/platforms/android/src/androidjnimain.cpp
+++ b/src/plugins/platforms/android/src/androidjnimain.cpp
@@ -123,6 +123,7 @@ static QAndroidPlatformIntegration *m_androidPlatformIntegration = 0;
static int m_desktopWidthPixels = 0;
static int m_desktopHeightPixels = 0;
+static double m_scaledDensity = 0;
static volatile bool m_pauseApplication;
@@ -287,6 +288,11 @@ namespace QtAndroid
return m_desktopHeightPixels;
}
+ double scaledDensity()
+ {
+ return m_scaledDensity;
+ }
+
JavaVM *javaVM()
{
return m_javaVM;
@@ -623,10 +629,11 @@ static void destroySurface(JNIEnv *env, jobject /*thiz*/)
static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/,
jint /*widthPixels*/, jint /*heightPixels*/,
jint desktopWidthPixels, jint desktopHeightPixels,
- jdouble xdpi, jdouble ydpi)
+ jdouble xdpi, jdouble ydpi, jdouble scaledDensity)
{
m_desktopWidthPixels = desktopWidthPixels;
m_desktopHeightPixels = desktopHeightPixels;
+ m_scaledDensity = scaledDensity;
if (!m_androidPlatformIntegration) {
QAndroidPlatformIntegration::setDefaultDisplayMetrics(desktopWidthPixels,desktopHeightPixels,
@@ -687,7 +694,7 @@ static JNINativeMethod methods[] = {
{"resumeQtApp", "()V", (void *)resumeQtApp},
{"quitQtAndroidPlugin", "()V", (void *)quitQtAndroidPlugin},
{"terminateQt", "()V", (void *)terminateQt},
- {"setDisplayMetrics", "(IIIIDD)V", (void *)setDisplayMetrics},
+ {"setDisplayMetrics", "(IIIIDDD)V", (void *)setDisplayMetrics},
{"setSurface", "(Ljava/lang/Object;)V", (void *)setSurface},
{"destroySurface", "()V", (void *)destroySurface},
{"lockSurface", "()V", (void *)lockSurface},
diff --git a/src/plugins/platforms/android/src/androidjnimain.h b/src/plugins/platforms/android/src/androidjnimain.h
index 618bd87cdb..f75df55e02 100644
--- a/src/plugins/platforms/android/src/androidjnimain.h
+++ b/src/plugins/platforms/android/src/androidjnimain.h
@@ -81,6 +81,7 @@ namespace QtAndroid
QWindow *topLevelWindowAt(const QPoint &globalPos);
int desktopWidthPixels();
int desktopHeightPixels();
+ double scaledDensity();
JavaVM *javaVM();
jclass findClass(const QString &className, JNIEnv *env);
AAssetManager *assetManager();
diff --git a/src/plugins/platforms/android/src/opengl/qeglfshooks_android.cpp b/src/plugins/platforms/android/src/opengl/qeglfshooks_android.cpp
index cd415843a7..4734d47eb3 100644
--- a/src/plugins/platforms/android/src/opengl/qeglfshooks_android.cpp
+++ b/src/plugins/platforms/android/src/opengl/qeglfshooks_android.cpp
@@ -56,6 +56,7 @@ public:
EGLNativeDisplayType platformDisplay() const;
QSize screenSize() const;
QSizeF physicalScreenSize() const;
+ QDpi logicalDpi() const;
int screenDepth() const;
QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const;
EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format);
@@ -86,6 +87,12 @@ QSizeF QEglFSAndroidHooks::physicalScreenSize() const
return QSizeF(QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth, QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight);
}
+QDpi QEglFSAndroidHooks::logicalDpi() const
+{
+ qreal lDpi = QtAndroid::scaledDensity() * 100;
+ return QDpi(lDpi, lDpi);
+}
+
EGLNativeWindowType QEglFSAndroidHooks::createNativeWindow(const QSize &size, const QSurfaceFormat &format)
{
diff --git a/src/plugins/platforms/android/src/raster/qandroidplatformscreen.cpp b/src/plugins/platforms/android/src/raster/qandroidplatformscreen.cpp
index 2779d7cffd..409c833db3 100644
--- a/src/plugins/platforms/android/src/raster/qandroidplatformscreen.cpp
+++ b/src/plugins/platforms/android/src/raster/qandroidplatformscreen.cpp
@@ -69,3 +69,9 @@ QRegion QAndroidPlatformScreen::doRedraw()
QtAndroid::flushImage(mGeometry.topLeft(), *mScreenImage, touched.boundingRect());
return touched;
}
+
+QDpi QAndroidPlatformScreen::logicalDpi() const
+{
+ qreal lDpi = QtAndroid::scaledDensity() * 100;
+ return QDpi(lDpi, lDpi);
+}
diff --git a/src/plugins/platforms/android/src/raster/qandroidplatformscreen.h b/src/plugins/platforms/android/src/raster/qandroidplatformscreen.h
index df08e43af4..cfd503d611 100644
--- a/src/plugins/platforms/android/src/raster/qandroidplatformscreen.h
+++ b/src/plugins/platforms/android/src/raster/qandroidplatformscreen.h
@@ -50,6 +50,7 @@ class QAndroidPlatformScreen: public QFbScreen
public:
QAndroidPlatformScreen();
void topWindowChanged(QWindow *w);
+ QDpi logicalDpi() const;
public slots:
QRegion doRedraw();