summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-08-02 12:04:35 +0000
committerTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-08-02 12:04:35 +0000
commitd02981a5b4229a045e382b61b4fa2a2fc337963b (patch)
treef478d24b72d16356de989a1a94495c758c1741c6
parenta8ad46a081925f258229328a24ae2828f1c9a454 (diff)
Add an interface to scalable rendering with multiple resolution
To support rendering which fits screen resolution, new class AGLScreenInfo is introduced to get 'scale_factor' from AGL HMI framework. If AGL HMI framework doesn't support multi-resolution, scale is set 1.0 for backward compatibility. Bug-AGL: SPEC-1611 Change-Id: I565f9b29b7b2953b5908901faa36c7339d9e7755 Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
-rw-r--r--src/aglextras/hmi/aglapplication.cpp4
-rw-r--r--src/aglextras/hmi/aglapplication.h13
-rw-r--r--src/aglextras/hmi/aglapplication_p.h2
-rw-r--r--src/aglextras/hmi/aglwmclient.cpp18
-rw-r--r--src/aglextras/hmi/aglwmclient.h1
-rw-r--r--src/aglextras/hmi/aglwmclient_p.h1
6 files changed, 38 insertions, 1 deletions
diff --git a/src/aglextras/hmi/aglapplication.cpp b/src/aglextras/hmi/aglapplication.cpp
index 82e49bf..320aa17 100644
--- a/src/aglextras/hmi/aglapplication.cpp
+++ b/src/aglextras/hmi/aglapplication.cpp
@@ -31,7 +31,6 @@ QT_BEGIN_NAMESPACE
AGLApplicationPrivate::AGLApplicationPrivate (AGLApplication *app)
: binding_address(new QUrl)
, engine(new QQmlApplicationEngine(app))
-
{
;
}
@@ -108,6 +107,9 @@ AGLApplication::exec (void)
void AGLApplication::setupApplicationRole (const QString &role)
{
d_ptr->wmclient = new AGLWmClient(role, d_ptr->port, d_ptr->secret);
+ d_ptr->screen_info = new AGLScreenInfo(this, d_ptr->wmclient->get_scale_factor());
+ d_ptr->engine->rootContext()->setContextProperty(QStringLiteral("screenInfo"),
+ d_ptr->screen_info);
}
QT_END_NAMESPACE
diff --git a/src/aglextras/hmi/aglapplication.h b/src/aglextras/hmi/aglapplication.h
index df68979..f9d17a0 100644
--- a/src/aglextras/hmi/aglapplication.h
+++ b/src/aglextras/hmi/aglapplication.h
@@ -43,6 +43,19 @@ private:
friend class AGLApplicationPrivate;
QSharedPointer<AGLApplicationPrivate> d_ptr;
};
+
+class AGLScreenInfo : public QObject
+{
+ Q_OBJECT
+
+public:
+ AGLScreenInfo(QObject* parent = 0, double scale = 1.0) : QObject(parent), _scale_factor(scale) {};
+
+ Q_INVOKABLE double scale_factor() const { return _scale_factor; };
+
+private:
+ double _scale_factor;
+};
QT_END_NAMESPACE
#endif // AGLAPPLICATION_H
diff --git a/src/aglextras/hmi/aglapplication_p.h b/src/aglextras/hmi/aglapplication_p.h
index 93e5976..6cc1880 100644
--- a/src/aglextras/hmi/aglapplication_p.h
+++ b/src/aglextras/hmi/aglapplication_p.h
@@ -23,6 +23,7 @@ class QUrl;
class QQmlApplicationEngine;
class AGLWmClient;
class AGLApplication;
+class AGLScreenInfo;
class AGLApplicationPrivate
{
public:
@@ -35,6 +36,7 @@ class AGLApplicationPrivate
QUrl* binding_address;
QQmlApplicationEngine *engine;
AGLWmClient* wmclient;
+ AGLScreenInfo* screen_info;
friend class AGLApplication;
};
QT_END_NAMESPACE
diff --git a/src/aglextras/hmi/aglwmclient.cpp b/src/aglextras/hmi/aglwmclient.cpp
index cb80e17..3baf6c7 100644
--- a/src/aglextras/hmi/aglwmclient.cpp
+++ b/src/aglextras/hmi/aglwmclient.cpp
@@ -63,6 +63,11 @@ void AGLWmClient::disconnect_frame_swapped (void)
#endif // USE_AGL_HMI_LOWLEVEL_API
}
+double AGLWmClient::get_scale_factor (void)
+{
+ return d_ptr->scale_factor;
+}
+
#ifdef USE_AGL_HMI_LOWLEVEL_API
void AGLWmClient::attach (QQmlApplicationEngine* engine)
{
@@ -104,6 +109,19 @@ AGLWmClient::AGLWmClient (const QString&, int port, QString)
return;
}
+ // Get information of screen
+ {
+ json_object *obj = json_object_new_object();
+ int ret = w_ptr->getDisplayInfo(obj);
+ if (!ret) {
+ json_object *j_val;
+ if (json_object_object_get_ex(obj, "scale", &j_val)) {
+ d_ptr->scale_factor = json_object_get_double(j_val);
+ }
+ }
+ json_object_put(obj);
+ }
+
d_ptr->binding = true;
d_ptr->layout = layout;
diff --git a/src/aglextras/hmi/aglwmclient.h b/src/aglextras/hmi/aglwmclient.h
index 4603610..d6132aa 100644
--- a/src/aglextras/hmi/aglwmclient.h
+++ b/src/aglextras/hmi/aglwmclient.h
@@ -33,6 +33,7 @@ class AGLEXTRAS_EXPORT AGLWmClient : public QObject
public:
AGLWmClient (const QString& layout, int port, QString secret);
void attach (QQmlApplicationEngine* engine);
+ double get_scale_factor (void);
private slots:
void disconnect_frame_swapped (void);
diff --git a/src/aglextras/hmi/aglwmclient_p.h b/src/aglextras/hmi/aglwmclient_p.h
index 239a4ae..ff5cd1f 100644
--- a/src/aglextras/hmi/aglwmclient_p.h
+++ b/src/aglextras/hmi/aglwmclient_p.h
@@ -29,6 +29,7 @@ class AGLWmClientPrivate
QString layout; // id of layaout which is managed by AGL WM
QMetaObject::Connection loading;
bool binding = false;
+ double scale_factor = 1.0;
friend class AGLWmClient;
};
QT_END_NAMESPACE