diff options
author | Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> | 2018-07-31 01:33:02 +0000 |
---|---|---|
committer | Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> | 2018-08-02 06:45:12 +0000 |
commit | 744df8b7c6ccb4e2254e452eec82f5d0703417cf (patch) | |
tree | 59f1987bf66688a154bc81d2eae5723e18c66ae1 | |
parent | cddefc7651d54fd99d4b1c1c17834f604de01b88 (diff) |
Add an interface to scalable rendering with multiple resolutionguppy_6.90.0guppy/6.90.0flounder_5.99.6flounder_5.99.5flounder_5.99.4flounder_5.99.3flounder/5.99.6flounder/5.99.5flounder/5.99.4flounder/5.99.36.90.05.99.65.99.55.99.45.99.3
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: I1dc4dd13c17ae66a706b6fd8ef937fbaab937c9e
Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
-rw-r--r-- | src/qlibwindowmanager.cpp | 34 | ||||
-rw-r--r-- | src/qlibwindowmanager.h | 41 |
2 files changed, 72 insertions, 3 deletions
diff --git a/src/qlibwindowmanager.cpp b/src/qlibwindowmanager.cpp index b264c94..df17f47 100644 --- a/src/qlibwindowmanager.cpp +++ b/src/qlibwindowmanager.cpp @@ -28,7 +28,37 @@ using namespace std; int QLibWindowmanager::init(int port, const QString &token) { string ctoken = token.toStdString(); - return this->wm->init(port, ctoken.c_str()); + int ret_init = this->wm->init(port, ctoken.c_str()); + + // initialize dpyinfo + json_object *obj = json_object_new_object(); + + int ret = this->wm->getDisplayInfo(obj); + + this->screen_info = new AGLScreenInfoPrivate; + + if (!ret) { + json_object *j_val; + if (json_object_object_get_ex(obj, "width_pixel", &j_val)) { + this->screen_info->set_width_dp(json_object_get_double(j_val)); + } + if (json_object_object_get_ex(obj, "height_pixel", &j_val)) { + this->screen_info->set_height_dp(json_object_get_double(j_val)); + } + if (json_object_object_get_ex(obj, "width_mm", &j_val)) { + this->screen_info->set_width_mm(json_object_get_double(j_val)); + } + if (json_object_object_get_ex(obj, "height_mm", &j_val)) { + this->screen_info->set_height_mm(json_object_get_double(j_val)); + } + if (json_object_object_get_ex(obj, "scale", &j_val)) { + this->screen_info->set_scale_factor(json_object_get_double(j_val)); + } + } + + json_object_put(obj); + + return ret_init; } int QLibWindowmanager::requestSurface(const QString &label) { @@ -120,7 +150,7 @@ void QLibWindowmanager::slotActivateSurface(){ } QLibWindowmanager::QLibWindowmanager(QObject *parent) - :QObject(parent), isActive(false) + :QObject(parent), isActive(false), screen_info(nullptr) { wm = new LibWindowmanager(); } diff --git a/src/qlibwindowmanager.h b/src/qlibwindowmanager.h index 8fb653d..3a720a1 100644 --- a/src/qlibwindowmanager.h +++ b/src/qlibwindowmanager.h @@ -21,6 +21,42 @@ #include <QObject> #include <string> +class AGLScreenInfo : public QObject +{ + Q_OBJECT + + public: + AGLScreenInfo(double scale = 1.0) { _scale_factor = scale; }; + + Q_INVOKABLE double scale_factor() const { return _scale_factor; }; + + private: + double _scale_factor; +}; + +class AGLScreenInfoPrivate +{ + public: + unsigned long width_dp(void) const { return _width_dp; }; + unsigned long height_dp(void) const { return _height_dp; }; + unsigned long width_mm(void) const { return _width_mm; }; + unsigned long height_mm(void) const { return _height_mm; }; + double scale_factor(void) const { return _scale; }; + + void set_width_dp(unsigned long w) { _width_dp = w; }; + void set_height_dp(unsigned long h) { _height_dp = h; }; + void set_width_mm(unsigned long w) { _width_mm = w; }; + void set_height_mm(unsigned long h) { _height_mm = h; }; + void set_scale_factor(double scale) { _scale = scale; }; + + private: + unsigned long _width_dp; + unsigned long _height_dp; + unsigned long _width_mm; + unsigned long _height_mm; + double _scale = 1.0; +}; + class QLibWindowmanager : public QObject{ Q_OBJECT public: @@ -58,8 +94,11 @@ public: Q_INVOKABLE int activateWindow(const QString &label, const QString &drawing_area); Q_INVOKABLE int deactivateWindow(const QString &label); Q_INVOKABLE int endDraw(const QString &label); + void set_event_handler(enum QEventType et, handler_fun f); + double get_scale_factor() const { return screen_info->scale_factor(); }; + // These APIs are deprecated, please use new API THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int activateSurface(const QString &label)); THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int activateSurface(const QString &label, const QString &drawing_area)); @@ -75,6 +114,6 @@ private: LibWindowmanager* wm; const char* applabel; bool isActive; - + AGLScreenInfoPrivate* screen_info; }; #endif // LIBWINDOWMANAGER_H |