summaryrefslogtreecommitdiffstats
path: root/src/util.cpp
diff options
context:
space:
mode:
authorTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-05-16 09:48:31 +0000
committerTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-05-18 15:57:15 +0900
commit443b9523b2e82352be9261d65f55bff9b0a5e4de (patch)
tree0966db2fe6dd8bae5b8f74df24e362d3b92eb0cf /src/util.cpp
parent33ee7d8a99c540749dd9691362f109c5b884e588 (diff)
Enable scaling to fit various screen resolutionseel_5.1.0eel_5.0.3eel/5.1.0eel/5.0.35.1.05.0.3eel
Since the AGL HomeScreen of CES2018 assumes that the screen resolution is 1080x1920px, the graphics of it partially corrupted with others. To fix this issue, now the AGL window manager automatically scales size of HomeScreen to fit the resolution of the display. By default, this scaling keeps HomeScreen's original aspect rate (9:16). To ignore it, set the environment variable, 'HMI_SCALING_IGNORE_ASPECT'. (E.g. set it in any file under /etc/afm/unit.env.d/) Bug-AGL: SPEC-1138 Change-Id: Id11a07560fe254712aaab42018bfb4d1d87ad1df Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 2ae856f..1fb6ac8 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -37,3 +37,30 @@ unique_fd::~unique_fd() {
close(this->fd);
}
}
+
+void rectangle::scale(int to_w, int to_h, bool keep_aspect)
+{
+ if (!keep_aspect) {
+ w = to_w;
+ h = to_h;
+ return;
+ }
+
+ int64_t resized_w = int64_t(to_h) * int64_t(w) / int64_t(h);
+
+ if (resized_w <= to_w) {
+ /* use aspect by height */
+ w = resized_w;
+ h = to_h;
+ } else {
+ /* use aspect by width */
+ w = to_h;
+ h = int64_t(to_w) * int64_t(h) / int64_t(w);
+ }
+}
+
+void rectangle::center(int outer_w, int outer_h)
+{
+ x = (outer_w - w) / 2;
+ y = (outer_h - h) / 2;
+}