aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-27 15:28:00 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-27 19:17:17 +0900
commita5106227c3c9ddbe2b07fbc2ecfc4e2ae1e4de74 (patch)
tree94d568f2af40af4a8c92387a659e1351853834e2
parent0a414d1909a0f356e195d81593eb6b50d470daab (diff)
Update wm_layer
Change-Id: Ia8277ba20a97a0a5b3617ae14a447e0e962afafd Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/wm_layer.cpp90
-rw-r--r--src/wm_layer.hpp45
-rw-r--r--src/wm_layer_control.cpp22
-rw-r--r--src/wm_layer_control.hpp5
4 files changed, 72 insertions, 90 deletions
diff --git a/src/wm_layer.cpp b/src/wm_layer.cpp
index 773b5c2..f02a5b6 100644
--- a/src/wm_layer.cpp
+++ b/src/wm_layer.cpp
@@ -15,7 +15,8 @@
*/
#include <regex>
-
+#include <ilm/ilm_control.h>
+#include <stdlib.h>
#include "wm_client.hpp"
#include "wm_layer.hpp"
#include "json_helper.hpp"
@@ -58,23 +59,29 @@ const vector<unsigned> LayerState::getIviIdList()
return this->render_order;
}
-LayerSetting::LayerSetting(const string& name, MANAGEMENT_TYPE type, unsigned begin, unsigned end)
- : name(name), type(type),
- role_list(), area_list(), id_list(),
- id_begin(begin), id_end(end)
-{}
-
-void LayerSetting::setRoleList(const string& role)
+WMLayer::WMLayer(json_object* j) : before_state(), state()
{
- this->role_list = role;
-}
+ this->name = jh::getStringFromJson(j, "name");
+ this->role_list = jh::getStringFromJson(j, "role");
+ const char* type = jh::getStringFromJson(j, "type");
+ this->id_begin = static_cast<unsigned>(jh::getIntFromJson(j, "id_range_begin"));
+ this->id_end = static_cast<unsigned>(jh::getIntFromJson(j, "id_range_end"));
-void LayerSetting::appendArea(const string& area)
-{
- this->area_list.push_back(area);
+ if (name.size() == 0 || type || this->id_begin == 0 || this->id_end == 0)
+ {
+ HMI_ERROR("Parse Error!!");
+ exit(1);
+ }
+ if(this->id_begin > this->id_end)
+ {
+ HMI_ERROR("INVALID");
+ exit(1);
+ }
+ string str_type = type;
+ this->type = (str_type == "tile") ? MANAGEMENT_TYPE::TILE : MANAGEMENT_TYPE::STACK;
}
-unsigned LayerSetting::getNewLayerID(const string& role)
+unsigned WMLayer::getNewLayerID(const string& role)
{
unsigned ret = 0;
auto re = std::regex(this->role_list);
@@ -118,61 +125,34 @@ unsigned LayerSetting::getNewLayerID(const string& role)
return ret;
}
-void LayerSetting::removeLayerID(unsigned id)
-{
- auto fwd_itr = std::remove_if(this->id_list.begin(), this->id_list.end(),
- [id](unsigned elm) {
- return elm == id;
- });
- this->id_list.erase(fwd_itr, this->id_list.end());
-}
-
-WMLayer::WMLayer()
- : before_state(),
- state(),
- setting{}
+const string& WMLayer::layerName()
{
- // this->setting = std::make_unique<LayerSetting>(name, type, begin, end);
+ return this->name;
}
-WMLayer::WMLayer(json_object* j) : before_state(), state()
+WMError WMLayer::setLayerState(const LayerState& l)
{
- LayerSetting::MANAGEMENT_TYPE t;
- const char* layer_name = jh::getStringFromJson(j, "name");
- const char* roles = jh::getStringFromJson(j, "role");
- const char* type = jh::getStringFromJson(j, "type");
- int begin = jh::getIntFromJson(j, "id_range_begin");
- int end = jh::getIntFromJson(j, "id_range_end");
- string name = layer_name;
-
- if (layer_name || type || begin < 0 || end < 0)
- {
- HMI_ERROR("Parse Error!!");
- }
- if(begin > end)
- {
- HMI_ERROR("INVALID.");
- }
- string str_type = type;
- t = (str_type == "tile") ? LayerSetting::TILE : LayerSetting::STACK;
- this->setting = std::make_unique<LayerSetting>(name, t, begin, end);
- this->setting->setRoleList(roles);
+ this->before_state = l;
+ return WMError::SUCCESS;
}
-unsigned WMLayer::getNewLayerID(const std::string& role)
+void WMLayer::appendArea(const string& area)
{
- return this->setting->getNewLayerID(role);
+ this->area_list.push_back(area);
}
-WMError WMLayer::setLayerState(const LayerState& l)
+void WMLayer::removeLayerID(unsigned id)
{
- this->before_state = l;
- return WMError::SUCCESS;
+ auto fwd_itr = std::remove_if(this->id_list.begin(), this->id_list.end(),
+ [id](unsigned elm) {
+ return elm == id;
+ });
+ this->id_list.erase(fwd_itr, this->id_list.end());
}
bool WMLayer::checkIDBelongTo(unsigned id)
{
- return (id > this->setting->idBegin() && id < this->setting->idEnd());
+ return (id > this->idBegin() && id < this->idEnd());
}
/* WMError WMLayer::commitChange()
diff --git a/src/wm_layer.hpp b/src/wm_layer.hpp
index 001134a..3362ba7 100644
--- a/src/wm_layer.hpp
+++ b/src/wm_layer.hpp
@@ -44,7 +44,7 @@ class LayerState
std::unordered_map<std::string, std::string> area2appid;
};
-class LayerSetting
+class WMLayer
{
public:
enum MANAGEMENT_TYPE
@@ -53,26 +53,21 @@ class LayerSetting
STACK
};
- explicit LayerSetting(const std::string& name, MANAGEMENT_TYPE type, unsigned begin, unsigned end);
- ~LayerSetting() = default;
-
- const std::string& layerName() { return this->name; }
- MANAGEMENT_TYPE layerType() { return this->type; };
- void setRoleList(const std::string& role);
- void appendArea(const std::string& area);
+ explicit WMLayer(json_object* j);
+ ~WMLayer() = default;
+ unsigned getNewLayerID(const std::string& role);
unsigned idBegin() { return this->id_begin; }
unsigned idEnd() { return this->id_end; }
- unsigned getNewLayerID(const std::string& role);
+ const std::string& layerName();
+ MANAGEMENT_TYPE layerType() { return this->type; }
+ void appendArea(const std::string& area);
void removeLayerID(unsigned id);
-
-/* unsigned getNewID(const std::string& role);
- void remove(unsigned ivi_layer_id);
- void clear();
- bool attach(unsigned ivi_layer_id, const std::string& area);
- void stack(unsigned ivi_layer_id, const std::string& area);
- bool updateRenderOrder(const std::vector<unsigned> list); */
-
+ LayerState getLayerState() const { return before_state; }
+ WMError setLayerState(const LayerState& l);
+ bool checkIDBelongTo(unsigned id);
private:
+ LayerState before_state;
+ LayerState state;
std::string name = ""; // Layer name
MANAGEMENT_TYPE type;
std::string role_list;
@@ -82,22 +77,6 @@ class LayerSetting
unsigned id_end;
};
-class WMLayer
-{
- public:
- WMLayer();
- WMLayer(json_object* j);
- ~WMLayer() = default;
- unsigned getNewLayerID(const std::string& role);
- LayerState getLayerState() const { return before_state; }
- WMError setLayerState(const LayerState& l);
- bool checkIDBelongTo(unsigned id);
- private:
- LayerState before_state;
- LayerState state;
- std::unique_ptr<LayerSetting> setting;
-};
-
} // namespace wm
#endif // WM_LAYERS_H
diff --git a/src/wm_layer_control.cpp b/src/wm_layer_control.cpp
index 0e72fab..9c60286 100644
--- a/src/wm_layer_control.cpp
+++ b/src/wm_layer_control.cpp
@@ -21,6 +21,7 @@
#define LC_AREA_PATH "/etc/areas.db"
#define LC_LAYER_SETTING_PATH "/etc/layer_setting.json"
+#define LC_DEFAULT_AREA "normal.full"
using std::string;
using std::vector;
@@ -112,7 +113,19 @@ lc_init_error:
return WMError::FAIL;
}
-unsigned LayerControl::getNewLayerID(const string& role)
+void LayerControl::createNewLayer(unsigned id)
+{
+ HMI_INFO("create new ID :%d", id);
+ struct rect rct = this->area2size[LC_DEFAULT_AREA];
+ ilm_layerCreateWithDimension(&id, rct.w, rct.h);
+ ilm_layerSetSourceRectangle(id, rct.x, rct.y, rct.w, rct.h);
+ ilm_layerSetDestinationRectangle(id, rct.x, rct.y, rct.w, rct.h);
+ ilm_layerSetOpacity(id, 1.0);
+ ilm_layerSetVisibility(id, ILM_TRUE);
+ ilm_commitChanges();
+}
+
+unsigned LayerControl::getNewLayerID(const string& role, string* layer_name)
{
unsigned ret = 0;
for(const auto& l: this->wm_layers)
@@ -120,6 +133,7 @@ unsigned LayerControl::getNewLayerID(const string& role)
ret = l->getNewLayerID(role);
if(ret != 0)
{
+ *layer_name = l->layerName();
break;
}
}
@@ -134,6 +148,7 @@ struct rect LayerControl::getAreaSize(const std::string& area)
void LayerControl::setupArea(double scaling)
{
struct rect rct;
+ this->scaling = scaling;
rct = this->area2size["normal.full"];
this->area2size["normalfull"] = rct;
@@ -156,6 +171,11 @@ Screen LayerControl::getScreenInfo()
return Screen(this->screen_prop.screenWidth, this->screen_prop.screenHeight);
}
+double LayerControl::scale()
+{
+ return this->scaling;
+}
+
WMError LayerControl::updateLayer(LayerState& layer_state)
{
return WMError::SUCCESS;
diff --git a/src/wm_layer_control.hpp b/src/wm_layer_control.hpp
index 647a5c7..db482bf 100644
--- a/src/wm_layer_control.hpp
+++ b/src/wm_layer_control.hpp
@@ -60,10 +60,12 @@ class LayerControl
explicit LayerControl(const std::string& root);
~LayerControl() = default;
WMError init(const LayerControlCallbacks& cb);
- unsigned getNewLayerID(const std::string& role);
+ void createNewLayer(unsigned id);
+ unsigned getNewLayerID(const std::string& role, std::string* layer_name);
struct rect getAreaSize(const std::string& area);
void setupArea(double scaling);
Screen getScreenInfo();
+ double scale();
// void setRenderOrder(const std::vector<unsigned> layer_render_order);
// std::vector<unsigned> getAllRenderOrder();
// std::vector<std::shared_ptr<WMLayer>>& getAllLayers();
@@ -84,6 +86,7 @@ class LayerControl
std::unordered_map<std::string, struct rect> area2size;
unsigned screenID;
struct ilmScreenProperties screen_prop;
+ double scaling;
LayerControlCallbacks cb;
};