aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Matsuzawa <tmatsuzawa@xevo.com>2017-07-31 22:06:38 +0900
committerTakashi Matsuzawa <tmatsuzawa@xevo.com>2017-08-31 07:25:53 +0000
commit6f4e56d960719a28cfbebddbc5eb052b5c9df08f (patch)
tree5e2061ef84a065778d9625be4f3d937500ae74ed
parentb28064e1f04eac99995e1462771fb43b7bba8545 (diff)
Bug-AGL: SPEC-791 Avoid demo screen being stretched and distorted on non full-HD display. Instead, we should fit it on target display but also keeping demo screen aspect ratio. This change has no impact on fiull-HD displays since the behavior is the same. In addition to "fit" option (now default), "stretch" (previous default) and "no" modes are provided for convenience. Update: Add content modes that seems to be common. Instead of integer value but string ids are used to specify desired mode. Update2: Do not rely on copmiler for redundant calls to strcmp Use signed type to avoid redundant type casting Update3: Fixing typo, adding comments, error case handling Update4: (Tadao Tanikawa) Calculating the geometry of layer (named root layer) once when WindowManager initialized and each app's layer inherits it. Update5: (Tadao Tanikawa) Clean up compiler warnings Update6: (Tadao Tanikawa) Clean up compiler warnings Change-Id: Ibb797ebea65062fdda7eccc5b7fc246a6b602e98 Signed-off-by: Takashi Matsuzawa <tmatsuzawa@xevo.com> Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> (cherry picked from commit eeedc5e9e67917bd3346dbe5332e667757a3b28d)
-rw-r--r--windowmanager/src/windowmanager.cpp139
-rw-r--r--windowmanager/src/windowmanager.hpp18
2 files changed, 123 insertions, 34 deletions
diff --git a/windowmanager/src/windowmanager.cpp b/windowmanager/src/windowmanager.cpp
index ea5a279..588f7d4 100644
--- a/windowmanager/src/windowmanager.cpp
+++ b/windowmanager/src/windowmanager.cpp
@@ -54,10 +54,11 @@ WindowManager::WindowManager(int displayId, QObject *parent) :
mp_layoutAreaToSurfaceIdAssignment(0),
m_currentLayout(-1),
m_screenId(displayId),
- m_screenWidth(0),
- m_screenHeight(0)
+ m_screen()
#ifdef HAVE_IVI_LAYERMANAGEMENT_API
,
+ m_layerSrc(0, 0, WINDOWMANAGER_HOMESCREEN_WIDTH, WINDOWMANAGER_HOMESCREEN_HEIGHT),
+ m_layerDest(),
m_appSurfaces(),
m_appLayers(),
#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION)
@@ -99,7 +100,18 @@ void WindowManager::start()
myThis = this;
- ilm_getScreenResolution(m_screenId, &m_screenWidth, &m_screenHeight);
+ t_ilm_uint width, height;
+ ilm_getScreenResolution(m_screenId, &width, &height);
+ m_screen.setWidth(width);
+ m_screen.setHeight(height);
+
+ const char *mode = secure_getenv("CONTENT_MODE");
+ if (!mode) {
+ qDebug("CONTENT_MODE not specified. Falling back to aspect-fit");
+ mode = "aspect-fit";
+ }
+
+ setRootGeometry(mode);
createNewLayer(WINDOWMANAGER_LAYER_POPUP);
createNewLayer(WINDOWMANAGER_LAYER_HOMESCREEN_OVERLAY);
@@ -207,26 +219,101 @@ void WindowManager::createNewLayer(int layerId)
qDebug(" layerId %d", layerId);
t_ilm_layer newLayerId = layerId;
+
+ // Currently the dimension of layer for apps inherits the root layer's.
ilm_layerCreateWithDimension(&newLayerId,
- WINDOWMANAGER_HOMESCREEN_WIDTH,
- WINDOWMANAGER_HOMESCREEN_HEIGHT);
+ m_layerSrc.width(),
+ m_layerSrc.height());
ilm_commitChanges();
ilm_layerSetSourceRectangle(newLayerId,
- 0,
- 0,
- WINDOWMANAGER_HOMESCREEN_WIDTH,
- WINDOWMANAGER_HOMESCREEN_HEIGHT);
+ m_layerSrc.x(),
+ m_layerSrc.y(),
+ m_layerSrc.width(),
+ m_layerSrc.height());
+
ilm_layerSetDestinationRectangle(newLayerId,
- 0,
- 0,
- m_screenWidth,
- m_screenHeight);
+ m_layerDest.x(),
+ m_layerDest.y(),
+ m_layerDest.width(),
+ m_layerDest.height());
ilm_commitChanges();
ilm_layerSetOpacity(newLayerId, 1.0);
ilm_layerSetVisibility(newLayerId, ILM_TRUE);
ilm_commitChanges();
}
+
+void WindowManager::setRootGeometry(const char *mode)
+{
+ // To calculate layer management parameters
+
+ // Calcurate parameters based on the content mode id given
+ // May return false if parameter check, etc. fails (currently not done).
+
+ if (!strcmp("scale-to-fill", mode)) {
+ // scale, ignore aspect ratio
+ m_layerDest.setRect(0, 0, m_screen.width(), m_screen.height());
+ }
+ else if (!strcmp("aspect-fit", mode) || !strcmp("aspect-fill", mode)) {
+ // scale, keeping aspect ratio
+ QSize size = m_layerSrc.size();
+
+ if (!strcmp("aspect-fit", mode)) {
+ size.scale(m_screen, Qt::KeepAspectRatio);
+ } else {
+ size.scale(m_screen, Qt::KeepAspectRatioByExpanding);
+ }
+
+ m_layerDest.setSize(size);
+ m_layerDest.moveCenter(QPoint(m_screen.width() / 2, m_screen.height() / 2));
+ }
+ else {
+ // other modes without scaling
+ m_layerDest.setSize(m_layerSrc.size());
+
+ // At first, move to center, then move to proper position
+ m_layerDest.moveCenter(QPoint(m_screen.width() / 2, m_screen.height() / 2));
+
+ if (!strcmp("center", mode)) {
+ ;
+ }
+ else if (!strcmp("top", mode)) {
+ m_layerDest.moveTop(0);
+ }
+ else if (!strcmp("bottom", mode)) {
+ m_layerDest.moveBottom(m_screen.height());
+ }
+ else if (!strcmp("left", mode)) {
+ m_layerDest.moveLeft(0);
+ }
+ else if (!strcmp("right", mode)) {
+ m_layerDest.moveRight(m_screen.width());
+ }
+ else if (!strcmp("top-left", mode)) {
+ m_layerDest.moveTo(0,0);
+ }
+ else if (!strcmp("top-right", mode)) {
+ m_layerDest.moveTopRight(QPoint(m_screen.width(), 0));
+ }
+ else if (!strcmp("bottom-left", mode)) {
+ m_layerDest.moveBottomLeft(QPoint(0, m_screen.height()));
+ }
+ else if (!strcmp("bottom-right", mode)) {
+ m_layerDest.moveBottomRight(QPoint(m_screen.width(), m_screen.height()));
+ }
+ else {
+ // fallback
+ qDebug("Mode \"%s\" not known, fallingback to aspect-fit", mode);
+ setRootGeometry("aspect-fit");
+ return;
+ }
+ }
+
+ qDebug("layer src=%dx%d dest=(%d,%d) %dx%d",
+ m_layerSrc.width(), m_layerSrc.height(),
+ m_layerDest.x(), m_layerDest.y(), m_layerDest.width(), m_layerDest.height());
+}
+
t_ilm_layer WindowManager::getAppLayerID(pid_t pid)
{
t_ilm_layer layer_id;
@@ -264,9 +351,7 @@ void WindowManager::addSurface(t_ilm_surface surfaceId)
t_ilm_layer WindowManager::addSurfaceToAppLayer(pid_t pid, int surfaceId)
{
- struct ilmSurfaceProperties surfaceProperties;
t_ilm_layer layer_id;
- int found = 0;
qDebug("-=[addSurfaceToAppLayer]=-");
qDebug(" surfaceId %d", surfaceId);
@@ -330,7 +415,7 @@ void WindowManager::addSurfaceToLayer(int surfaceId, int layerId)
ilm_commitChanges();
}
-void WindowManager::configureHomeScreenMainSurface(t_ilm_surface surface, t_ilm_int width, t_ilm_int height)
+void WindowManager::configureHomeScreenMainSurface(t_ilm_surface surface, t_ilm_uint width, t_ilm_uint height)
{
// homescreen app always fullscreen in the back
ilm_surfaceSetDestinationRectangle(surface, 0, 0,
@@ -343,7 +428,7 @@ void WindowManager::configureHomeScreenMainSurface(t_ilm_surface surface, t_ilm_
ilm_commitChanges();
}
-void WindowManager::configureAppSurface(pid_t pid, t_ilm_surface surface, t_ilm_int width, t_ilm_int height)
+void WindowManager::configureAppSurface(t_ilm_surface surface, t_ilm_uint width, t_ilm_uint height)
{
/* Dirty hack! cut & paste from HomeScreen/src/layouthandler.cpp */
const int SCREEN_WIDTH = 1080;
@@ -354,15 +439,15 @@ void WindowManager::configureAppSurface(pid_t pid, t_ilm_surface surface, t_ilm_
const int TOPAREA_X = 0;
const int TOPAREA_Y = 0;
const int MEDIAAREA_HEIGHT = 215;
- const int MEDIAAREA_WIDTH = SCREEN_WIDTH;
- const int MEDIAAREA_X = 0;
const int MEDIAAREA_Y = SCREEN_HEIGHT - MEDIAAREA_HEIGHT;
- ilm_surfaceSetDestinationRectangle(surface,
- 0,
- TOPAREA_HEIGHT,
- SCREEN_WIDTH,
- SCREEN_HEIGHT - TOPAREA_HEIGHT - MEDIAAREA_HEIGHT);
+ const t_ilm_int APPAREA_X = TOPAREA_X;
+ const t_ilm_int APPAREA_Y = TOPAREA_Y + TOPAREA_HEIGHT;
+ const t_ilm_uint APPAREA_WIDTH = TOPAREA_WIDTH;
+ const t_ilm_uint APPAREA_HEIGHT = MEDIAAREA_Y - APPAREA_Y;
+
+ ilm_surfaceSetDestinationRectangle(surface, APPAREA_X, APPAREA_Y,
+ APPAREA_WIDTH, APPAREA_HEIGHT);
ilm_surfaceSetSourceRectangle(surface, 0, 0, width, height);
ilm_surfaceSetOpacity(surface, 1.0);
ilm_surfaceSetVisibility(surface, ILM_TRUE); /* Hack to avoid blank screen when switch apps */
@@ -395,8 +480,6 @@ void WindowManager::notificationFunc_non_static(ilmObjectType object,
qDebug("Notification from weston!");
if (ILM_SURFACE == object)
{
- struct ilmSurfaceProperties surfaceProperties;
-
if (created)
{
if (WINDOWMANAGER_HOMESCREEN_MAIN_SURFACE_ID == id)
@@ -429,7 +512,7 @@ void WindowManager::notificationFunc_non_static(ilmObjectType object,
void WindowManager::notificationFunc_static(ilmObjectType object,
t_ilm_uint id,
t_ilm_bool created,
- void* user_data)
+ void*)
{
static_cast<WindowManager*>(WindowManager::myThis)->notificationFunc_non_static(object, id, created);
}
@@ -490,7 +573,7 @@ void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface,
t_ilm_layer layer = addSurfaceToAppLayer(pid, surface);
if (layer != 0) {
- configureAppSurface(pid, surface,
+ configureAppSurface(surface,
surfaceProperties->origSourceWidth,
surfaceProperties->origSourceHeight);
diff --git a/windowmanager/src/windowmanager.hpp b/windowmanager/src/windowmanager.hpp
index 12643e7..a06f840 100644
--- a/windowmanager/src/windowmanager.hpp
+++ b/windowmanager/src/windowmanager.hpp
@@ -26,6 +26,7 @@
#ifdef HAVE_IVI_LAYERMANAGEMENT_API
#include <ilm/ilm_control.h>
#endif
+
class WindowManager : public QObject
{
Q_OBJECT
@@ -43,12 +44,15 @@ private:
int m_currentLayout;
int m_screenId;
- unsigned int m_screenWidth;
- unsigned int m_screenHeight;
+ QSize m_screen;
void dumpScene();
#ifdef HAVE_IVI_LAYERMANAGEMENT_API
+ /* The geometry of layer as destination|source */
+ QRect m_layerSrc;
+ QRect m_layerDest;
+
t_ilm_layer* m_showLayers;
QMap<pid_t, t_ilm_surface> m_appSurfaces;
QMap<pid_t, t_ilm_layer> m_appLayers;
@@ -59,20 +63,22 @@ private:
QList<QString> m_keepApps; /* Apps needs to keep rendering */
QList<pid_t> m_bgApps;
+ pid_t m_pending_to_show;
+
+ void setRootGeometry(const char *mode);
+
t_ilm_layer* getLayerRenderOrder(int& num_layers);
void createNewLayer(const int layerId);
t_ilm_layer getAppLayerID(const pid_t pid);
- pid_t m_pending_to_show;
-
void addSurface(const t_ilm_surface surfaceId);
t_ilm_layer addSurfaceToAppLayer(pid_t pid, const int surfaceId);
void addSurfaceToLayer(const int surfaceId, const int layerId);
- void configureHomeScreenMainSurface(const t_ilm_surface surface, const t_ilm_int width, const t_ilm_int height);
- void configureAppSurface(const pid_t pid, const t_ilm_surface surface, const t_ilm_int width, const t_ilm_int height);
+ void configureHomeScreenMainSurface(const t_ilm_surface surface, const t_ilm_uint width, const t_ilm_uint height);
+ void configureAppSurface(const t_ilm_surface surface, const t_ilm_uint width, const t_ilm_uint height);
void renderLayers();
void checkBackgroundApps(const QString &app_id, int app_pid);