aboutsummaryrefslogtreecommitdiffstats
path: root/src/wm_layer_control.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wm_layer_control.cpp')
-rw-r--r--src/wm_layer_control.cpp321
1 files changed, 286 insertions, 35 deletions
diff --git a/src/wm_layer_control.cpp b/src/wm_layer_control.cpp
index 011402d..75c35da 100644
--- a/src/wm_layer_control.cpp
+++ b/src/wm_layer_control.cpp
@@ -56,7 +56,7 @@ static void layerCallback_static(t_ilm_layer layer,
g_lc_ctxt->dispatchLayerPropChangeEvent(layer, layer_prop, mask);
}
-LayerControl::LayerControl(const std::string& root)
+LayerControl::LayerControl(const std::string& root, const std::string& ecu_name)
{
string area_path = root + LC_AREA_PATH;
string layer_path= root + LC_LAYER_SETTING_PATH;
@@ -64,7 +64,7 @@ LayerControl::LayerControl(const std::string& root)
WMError ret = this->loadLayerSetting(layer_path);
assert(ret == WMError::SUCCESS);
// load areas.json
- ret = this->loadAreaDb(area_path);
+ ret = this->loadAreasConfigFile(area_path, ecu_name);
assert(ret == WMError::SUCCESS);
}
@@ -102,6 +102,18 @@ WMError LayerControl::init(const LayerControlCallbacks& cb)
// Currently, 0 is only available
this->screenID = ids[0];
+ if (1 < num)
+ {
+ // TODO: set remote screen id
+ HMI_INFO("There is remote screen (id:%d)", ids[1]);
+ this->remoteScreenID = ids[1];
+ }
+ else
+ {
+ HMI_INFO("There is no remote screen");
+ this->remoteScreenID = -1;
+ }
+
rc = ilm_getPropertiesOfScreen(this->screenID, &this->screen_prop);
if(rc != ILM_SUCCESS) goto lc_init_error;
@@ -131,9 +143,26 @@ void LayerControl::createNewLayer(unsigned id)
auto wm_layer = getWMLayer(id);
wm_layer->addLayerToState(id);
this->renderLayers();
+ this->renderLayersRemote();
+}
+
+void LayerControl::createNewRemoteLayer(unsigned id)
+{
+ HMI_INFO("create new ID :%d (For remote layer)", id);
+ struct rect rct = {640, 720, 0, 0};
+ ilm_layerCreateWithDimension(&id, rct.w, rct.h);
+ //ilm_layerSetSourceRectangle(id, rct.x, rct.y, rct.w, rct.h);
+ ilm_layerSetDestinationRectangle(id, this->offset_x, this->offset_y, rct.w, rct.h);
+ ilm_layerSetOpacity(id, 1.0);
+ ilm_layerSetVisibility(id, ILM_FALSE);
+ ilm_commitChanges();
+ auto wm_layer = getWMLayer(id);
+ wm_layer->addLayerToState(id);
+ this->renderLayers();
+ this->renderLayersRemote();
}
-unsigned LayerControl::getNewLayerID(const string& role)
+unsigned LayerControl::getNewLayerID(const string& role, string* layer_name)
{
unsigned ret = 0;
for(const auto& l: this->wm_layers)
@@ -141,6 +170,7 @@ unsigned LayerControl::getNewLayerID(const string& role)
ret = l->getNewLayerID(role);
if(ret != 0)
{
+ *layer_name = l->layerName();
unsigned wmlid = l->getWMLayerID();
this->lid2wmlid[ret] = wmlid;
break;
@@ -200,6 +230,11 @@ double LayerControl::scale()
return this->scaling;
}
+WMError LayerControl::updateLayer(LayerState& layer_state)
+{
+ return WMError::SUCCESS;
+}
+
WMError LayerControl::renderLayers()
{
HMI_INFO("Commit change");
@@ -252,6 +287,69 @@ WMError LayerControl::renderLayers()
return rc;
}
+WMError LayerControl::renderLayersRemote()
+{
+ HMI_INFO("Commit change");
+ WMError rc = WMError::SUCCESS;
+
+ if (0 > this->remoteScreenID)
+ {
+ return rc;
+ }
+
+ // Check the number of layers
+ vector<unsigned> ivi_l_ids;
+ for(auto& l : this->wm_remote_layers)
+ {
+ auto state = l->getLayerState();
+ HMI_DEBUG("layer %s", l->layerName().c_str());
+ for(const auto& id : state.getIviIdList())
+ {
+ HMI_DEBUG("Add %d", id);
+ ivi_l_ids.push_back(id);
+ }
+ }
+
+ if (0 == ivi_l_ids.size())
+ {
+ ilm_displaySetRenderOrder(this->remoteScreenID, nullptr, 0);
+ return rc;
+ }
+
+ // Create render order
+ t_ilm_layer* id_array = new t_ilm_layer[ivi_l_ids.size()];
+ if(id_array == nullptr)
+ {
+ HMI_WARNING("short memory");
+ this->undoUpdate();
+ return WMError::FAIL;
+ }
+ int count = 0;
+ for(const auto& i : ivi_l_ids)
+ {
+ id_array[count] = i;
+ ++count;
+ }
+
+ // Display
+ ilmErrorTypes ret = ilm_displaySetRenderOrder(this->remoteScreenID, id_array, ivi_l_ids.size());
+ if(ret != ILM_SUCCESS)
+ {
+ this->undoUpdate();
+ rc = WMError::FAIL;
+ }
+ else
+ {
+ for(auto& l : this->wm_remote_layers)
+ {
+ l->update();
+ }
+ }
+ ilm_commitChanges();
+ delete id_array;
+ return rc;
+}
+
WMError LayerControl::setXDGSurfaceOriginSize(unsigned surface)
{
WMError ret = WMError::NOT_REGISTERED;
@@ -309,9 +407,9 @@ WMError LayerControl::loadLayerSetting(const string &path)
return WMError::SUCCESS;
}
-WMError LayerControl::loadAreaDb(const std::string& path)
+WMError LayerControl::loadAreasConfigFile(const std::string& path, const std::string& ecu_name)
{
- // Load area.db
+ // Load areas config file
json_object *json_obj;
int ret = jh::inputJsonFilie(path.c_str(), &json_obj);
if (0 > ret)
@@ -321,54 +419,114 @@ WMError LayerControl::loadAreaDb(const std::string& path)
}
HMI_INFO("json_obj dump:%s", json_object_get_string(json_obj));
- // Perse areas
+ // Parse ecus
json_object *json_cfg;
- if (!json_object_object_get_ex(json_obj, "areas", &json_cfg))
+ if (!json_object_object_get_ex(json_obj, "ecus", &json_cfg))
{
HMI_ERROR("Parse Error!!");
return WMError::FAIL;
}
- int len = json_object_array_length(json_cfg);
- HMI_DEBUG("json_cfg len:%d", len);
+ int num_ecu = json_object_array_length(json_cfg);
+ HMI_DEBUG("json_cfg(ecus) len:%d", num_ecu);
- const char *area;
- for (int i = 0; i < len; i++)
+ const char* c_ecu_name;
+ json_object *json_ecu;
+ for (int i = 0; i < num_ecu; i++)
{
- json_object *json_tmp = json_object_array_get_idx(json_cfg, i);
- HMI_DEBUG("> json_tmp dump:%s", json_object_get_string(json_tmp));
+ json_ecu= json_object_array_get_idx(json_cfg, i);
- area = jh::getStringFromJson(json_tmp, "name");
- if (nullptr == area)
+ c_ecu_name = jh::getStringFromJson(json_ecu, "name");
+ if (nullptr == c_ecu_name)
{
HMI_ERROR("Parse Error!!");
return WMError::FAIL;
}
- HMI_DEBUG("> area:%s", area);
- json_object *json_rect;
- if (!json_object_object_get_ex(json_tmp, "rect", &json_rect))
+ if (ecu_name == string(c_ecu_name))
{
- HMI_ERROR("Parse Error!!");
- return WMError::FAIL;
+ break;
}
- HMI_DEBUG("> json_rect dump:%s", json_object_get_string(json_rect));
+ else
+ {
+ json_ecu = nullptr;
+ }
+ }
- struct rect area_size;
- area_size.x = jh::getIntFromJson(json_rect, "x");
- area_size.y = jh::getIntFromJson(json_rect, "y");
- area_size.w = jh::getIntFromJson(json_rect, "w");
- area_size.h = jh::getIntFromJson(json_rect, "h");
+ if (!json_ecu)
+ {
+ HMI_ERROR("Areas for ecu:%s is NOT exist!!", ecu_name.c_str());
+ return WMError::FAIL;
+ }
- this->area2size[area] = area_size;
+ // Parse screens
+ if (!json_object_object_get_ex(json_ecu, "screens", &json_cfg))
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
}
- // Check
- for (const auto& itr : this->area2size)
+ int num_screen = json_object_array_length(json_cfg);
+ HMI_DEBUG("json_cfg(screens) len:%d", num_screen);
+
+ int screen_id;
+ json_object *json_screen;
+ for (int i = 0; i < num_screen; i++)
{
- HMI_DEBUG("area:%s x:%d y:%d w:%d h:%d",
- itr.first.c_str(), itr.second.x, itr.second.y,
- itr.second.w, itr.second.h);
+ json_screen = json_object_array_get_idx(json_cfg, i);
+ HMI_INFO("json_cfg dump:%s", json_object_get_string(json_cfg));
+
+ // TODO: Currently only one display is connected to a ECU.
+
+ screen_id = jh::getIntFromJson(json_screen, "id");
+
+ // Parse areas
+ json_object *json_tmp;
+ if (!json_object_object_get_ex(json_screen, "areas", &json_tmp))
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+
+ int num_area = json_object_array_length(json_tmp);
+ HMI_DEBUG("json_tmp(areas) len:%d", num_area);
+
+ const char *area;
+ for (int j = 0; j < num_area; j++)
+ {
+ json_object *json_area = json_object_array_get_idx(json_tmp, j);
+
+ area = jh::getStringFromJson(json_area, "name");
+ if (nullptr == area)
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+ HMI_DEBUG("> area:%s", area);
+
+ json_object *json_rect;
+ if (!json_object_object_get_ex(json_area, "rect", &json_rect))
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+
+ struct rect area_size;
+ area_size.x = jh::getIntFromJson(json_rect, "x");
+ area_size.y = jh::getIntFromJson(json_rect, "y");
+ area_size.w = jh::getIntFromJson(json_rect, "w");
+ area_size.h = jh::getIntFromJson(json_rect, "h");
+
+ this->area2size[area] = area_size;
+ }
+
+ // Check
+ for (const auto& itr : this->area2size)
+ {
+ HMI_DEBUG("area:%s x:%d y:%d w:%d h:%d",
+ itr.first.c_str(), itr.second.x, itr.second.y,
+ itr.second.w, itr.second.h);
+ }
}
// Release json_object
@@ -379,7 +537,9 @@ WMError LayerControl::loadAreaDb(const std::string& path)
WMError LayerControl::layoutChange(const WMAction& action)
{
- if (action.visible == TaskVisible::INVISIBLE)
+ if ((action.visible == TaskVisible::INVISIBLE) ||
+ (action.visible == TaskVisible::REQ_REMOTE_VISIBLE) ||
+ (action.visible == TaskVisible::REQ_REMOTE_INVISIBLE))
{
// Visibility is not change -> no redraw is required
return WMError::SUCCESS;
@@ -394,7 +554,19 @@ WMError LayerControl::layoutChange(const WMAction& action)
auto rect = this->getAreaSize(action.area);
HMI_DEBUG("Set layout %d, %d, %d, %d",rect.x, rect.y, rect.w, rect.h);
- ilm_commitChanges();
+
+ // TO BE FIXED:
+ // Sometimes, ivi_wm_surface_size signal doesn't reach window manager,
+ // then, Window Manager can't set source size.
+ // This fixes it but it takes about 200ns(on R-Car M3) wastefully
+ ilmSurfaceProperties sp;
+ ilm_getPropertiesOfSurface(surface, &sp);
+ if(sp.origSourceHeight != sp.sourceHeight) {
+ HMI_SEQ_NOTICE(action.req_num, "WORK AROUND: set source size w:%d h%d", sp.origSourceWidth, sp.origSourceHeight);
+ ilm_surfaceSetSourceRectangle(surface, 0, 0, sp.origSourceWidth, sp.origSourceHeight);
+ ilm_commitChanges();
+ }
+
ilm_surfaceSetDestinationRectangle(surface, rect.x, rect.y, rect.w, rect.h);
ilm_commitChanges();
for(auto &wm_layer: this->wm_layers)
@@ -430,7 +602,20 @@ WMError LayerControl::visibilityChange(const WMAction& action)
{
ret = this->makeInvisible(action.client);
}
- ilm_commitChanges();
+ else if (action.visible == TaskVisible::REMOTE_VISIBLE)
+ {
+ ret = this->makeRemoteVisible(action.client);
+ }
+ else if (action.visible == TaskVisible::REMOTE_INVISIBLE)
+ {
+ ret = this->makeRemoteInvisible(action.client);
+ }
+ else // TaskVisible::REQ_REMOTE_VISIBLE || TaskVisible::REQ_REMOTE_INVISIBLE
+ {
+ // Visibility is not change
+ ret = WMError::SUCCESS;
+ }
+
return ret;
}
@@ -460,6 +645,7 @@ void LayerControl::dispatchCreateEvent(ilmObjectType object, unsigned id, bool c
return;
}
this->cb.surfaceCreated(sp.creatorPid, id);
+ ilm_surfaceSetSourceRectangle(id, 0, 0, sp.origSourceWidth, sp.origSourceHeight);
ilm_surfaceAddNotification(id, surfaceCallback_static);
ilm_surfaceSetVisibility(id, ILM_TRUE);
ilm_surfaceSetType(id, ILM_SURFACETYPE_DESKTOP);
@@ -568,6 +754,71 @@ WMError LayerControl::makeInvisible(const shared_ptr<WMClient> client)
return ret;
}
+WMError LayerControl::makeRemoteVisible(const shared_ptr<WMClient> client)
+{
+ WMError ret = WMError::SUCCESS;
+ unsigned layer = client->layerID(); // Don't check here the client is not nullptr
+
+ if (0 > this->remoteScreenID)
+ {
+ return ret;
+ }
+
+ // TODO: Currently there is only one remote screen.
+ for (auto itr = this->wm_layers.begin(); itr != this->wm_layers.end(); ++itr)
+ {
+ if((*itr)->hasLayerID(layer))
+ {
+ HMI_DEBUG("Add layer:%d to remote screen:%d", layer, this->remoteScreenID);
+ this->wm_remote_layers.push_back(*itr);
+ this->wm_layers.erase(itr);
+ }
+
+ if (this->wm_layers.end() == itr)
+ {
+ HMI_DEBUG("iteretor indicates end of vector of wm_layers");
+ break;
+ }
+ }
+
+ ilm_layerSetVisibility(layer, ILM_TRUE);
+
+ return ret;
+}
+
+WMError LayerControl::makeRemoteInvisible(const shared_ptr<WMClient> client)
+{
+ WMError ret = WMError::SUCCESS;
+ unsigned layer = client->layerID(); // Don't check here the client is not nullptr
+
+ if (0 > this->remoteScreenID)
+ {
+ return ret;
+ }
+
+ // TODO: Currently there is only one remote screen.
+ for (auto itr = this->wm_remote_layers.begin();
+ itr != this->wm_remote_layers.end(); ++itr)
+ {
+ if((*itr)->hasLayerID(layer))
+ {
+ HMI_DEBUG("Remove layer:%d from remote screen:%d", layer, this->remoteScreenID);
+ this->wm_layers.push_back(*itr);
+ this->wm_remote_layers.erase(itr);
+ }
+
+ if (this->wm_remote_layers.end() == itr)
+ {
+ HMI_DEBUG("iteretor indicates end of vector of wm_remote_layers");
+ break;
+ }
+ }
+
+ ilm_layerSetVisibility(layer, ILM_FALSE);
+
+ return ret;
+}
+
bool LayerControl::moveBackGround(const shared_ptr<WMClient> client)
{
bool ret = false;