e_hwc: add API for set/get property on the E_Hwc
authorSooChan Lim <sc1.lim@samsung.com>
Sun, 24 Feb 2019 06:06:09 +0000 (15:06 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 12 Apr 2019 10:00:22 +0000 (19:00 +0900)
E_API Eina_Bool       e_hwc_available_properties_get(E_Hwc *hwc, const hwc_prop **props, int *count);
E_API Eina_Bool       e_hwc_property_get(E_Hwc *hwc, unsigned int id, hwc_value *value);
E_API Eina_Bool       e_hwc_property_set(E_Hwc *hwc, unsigned int id, hwc_value value);

Change-Id: Idc1991a453ed9a8003966a5727605d9a07ff26ce

src/bin/e_hwc.c
src/bin/e_hwc.h

index f49a3614c235c8c3e41e06d73b3f6a04844910ea..7378e5a721aa3435daee65f5773fdbdd46f245d8 100644 (file)
@@ -474,6 +474,90 @@ e_hwc_client_is_above_hwc(E_Client *ec, E_Client *hwc_ec)
    return EINA_FALSE;
 }
 
+const char *
+_e_hwc_prop_name_get_by_id(E_Hwc *hwc, unsigned int id)
+{
+   const hwc_prop *props;
+   int i, count = 0;
+
+   if (!e_hwc_available_properties_get(hwc, &props, &count))
+     {
+        ERR("e_hwc_available_properties_get failed.");
+        return EINA_FALSE;
+     }
+
+   for (i = 0; i < count; i++)
+     {
+        if (props[i].id == id)
+          return props[i].name;
+     }
+
+   ERR("No available property: id %d", id);
+
+   return NULL;
+}
+
+E_API Eina_Bool
+e_hwc_available_properties_get(E_Hwc *hwc, const hwc_prop **props, int *count)
+{
+   const tdm_prop *tprops;
+   int i;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
+
+   if (!e_hwc_windows_get_available_properties(hwc, &tprops, count))
+     {
+        ERR("e_hwc_windows_get_available_properties failed");
+        return EINA_FALSE;
+     }
+
+   *props = (hwc_prop *)tprops;
+
+   ELOGF("HWC", ">>>>>>>> Available HWC props : count = %d", NULL, NULL, *count);
+   for (i = 0; i < *count; i++)
+     ELOGF("HWC", "   [%d] %s, %u", NULL, NULL, i, tprops[i].name, tprops[i].id);
+
+   return EINA_TRUE;
+}
+
+E_API Eina_Bool
+e_hwc_property_get(E_Hwc *hwc, unsigned int id, hwc_value *value)
+{
+   tdm_value tvalue;
+   tdm_error ret;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
+
+   ret = tdm_hwc_get_property(hwc->thwc, id, &tvalue);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(ret != TDM_ERROR_NONE, EINA_FALSE);
+
+   memcpy(&value->ptr, &tvalue.ptr, sizeof(tdm_value));
+
+   return EINA_TRUE;
+}
+
+E_API Eina_Bool
+e_hwc_property_set(E_Hwc *hwc, unsigned int id, hwc_value value)
+{
+   const char *name;
+   tdm_value tvalue;
+   tdm_error ret;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
+
+   name = _e_hwc_prop_name_get_by_id(hwc, id);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
+
+   memcpy(&tvalue.ptr, &value.ptr, sizeof(hwc_value));
+
+   ret = tdm_hwc_set_property(hwc->thwc, id, tvalue);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(ret != TDM_ERROR_NONE, EINA_FALSE);
+
+   return EINA_TRUE;
+}
+
 E_API Eina_Bool
 e_client_hwc_available_properties_get(E_Client *ec, const hwc_prop **props, int *count)
 {
index 5775b082771c1d395114bb528efb1eb0d105fcf4..b4964e0076bda358e1e530d382e057acc84b3eed 100644 (file)
@@ -136,6 +136,10 @@ E_API E_Hwc_Policy    e_hwc_policy_get(E_Hwc *hwc);
 E_API E_Hwc_Intercept_Hook   *e_hwc_intercept_hook_add(E_Hwc_Intercept_Hook_Point hookpoint, E_Hwc_Intercept_Hook_Cb func, const void *data);
 E_API void                    e_hwc_intercept_hook_del(E_Hwc_Intercept_Hook *ch);
 
+E_API Eina_Bool       e_hwc_available_properties_get(E_Hwc *hwc, const hwc_prop **props, int *count);
+E_API Eina_Bool       e_hwc_property_get(E_Hwc *hwc, unsigned int id, hwc_value *value);
+E_API Eina_Bool       e_hwc_property_set(E_Hwc *hwc, unsigned int id, hwc_value value);
+
 E_API Eina_Bool       e_client_hwc_available_properties_get(E_Client *ec, const hwc_prop **props, int *count);
 E_API Eina_Bool       e_client_hwc_property_get(E_Client *ec, unsigned int id, hwc_value *value);
 E_API Eina_Bool       e_client_hwc_property_set(E_Client *ec, unsigned int id, hwc_value value);