Fix missed scale calculation for tdm output 87/116287/4
authorMinJeong Kim <minjjj.kim@samsung.com>
Thu, 23 Feb 2017 12:01:59 +0000 (21:01 +0900)
committerJuyeon Lee <juyeonne.lee@samsung.com>
Fri, 24 Feb 2017 06:03:45 +0000 (22:03 -0800)
Change-Id: I061cc308d80c1f9827fe9698dfff09027e0efc1a
Signed-off-by: MinJeong Kim <minjjj.kim@samsung.com>
src/bin/e_comp_screen.c
src/bin/e_config.c
src/bin/e_config.h
src/bin/e_scale.c

index e9f9346fe3b11012874d8eb02b836efc377ee88c..bec4c21305b6b88b431e9a1ade23b96f64df16e6 100644 (file)
@@ -127,7 +127,13 @@ _e_comp_screen_cb_output_drm(void *data EINA_UNUSED, int type EINA_UNUSED, void
     * there were no sufficient information to calculate dpi.
     * so it's considerable to re-calculate e_scale with output geometry.
     */
-   e_scale_manual_update(((e->w * 254 / e->phys_width) + 5) / 10);
+   double target_inch;
+   int dpi;
+
+   target_inch = (round((sqrt(e->phys_width * e->phys_width + e->phys_height * e->phys_height) / 25.4) * 10) / 10);
+   dpi = (round((sqrt(e->w * e->w + e->h * e->h) / target_inch) * 10) / 10);
+
+   e_scale_manual_update(dpi);
 
 end:
    return ECORE_CALLBACK_PASS_ON;
@@ -340,6 +346,7 @@ _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
    tdm_display *tdisplay = e_comp_screen->tdisplay;
    int num_outputs;
    int i;
+   Eina_Bool scale_updated = EINA_FALSE;
 
    /* init e_output */
    if (!e_output_init())
@@ -392,6 +399,19 @@ _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
              ERR("fail to e_output_dpms.");
              goto fail;
           }
+
+        /* update e_scale with first available output size */
+        if ((e_config->scale.for_tdm) && (!scale_updated))
+          {
+             double target_inch;
+             int dpi;
+
+             target_inch = (round((sqrt(output->info.size.w * output->info.size.w + output->info.size.h * output->info.size.h) / 25.4) * 10) / 10);
+             dpi = (round((sqrt(mode->w * mode->w + mode->h * mode->h) / target_inch) * 10) / 10);
+
+             e_scale_manual_update(dpi);
+             scale_updated = EINA_TRUE;
+          }
      }
 
    //TODO: if there is no output connected, make the fake output which is connected.
index 8f21a5a2de8ad9751ded7d4db3fdc366d38eb3e8..3ed0c23732c7e930801e95ed58732204b3e1e221 100644 (file)
@@ -227,9 +227,13 @@ _e_config_edd_init(Eina_Bool old)
    E_CONFIG_VAL(D, T, scale.min, DOUBLE);
    E_CONFIG_VAL(D, T, scale.max, DOUBLE);
    E_CONFIG_VAL(D, T, scale.factor, DOUBLE);
+   E_CONFIG_VAL(D, T, scale.profile_factor, DOUBLE);
+   E_CONFIG_VAL(D, T, scale.inch_correction, DOUBLE);
+   E_CONFIG_VAL(D, T, scale.inch_correction_bound, DOUBLE);
    E_CONFIG_VAL(D, T, scale.base_dpi, INT);
    E_CONFIG_VAL(D, T, scale.use_dpi, UCHAR);
    E_CONFIG_VAL(D, T, scale.use_custom, UCHAR);
+   E_CONFIG_VAL(D, T, scale.for_tdm, UCHAR);
    E_CONFIG_VAL(D, T, show_cursor, UCHAR);
    E_CONFIG_VAL(D, T, idle_cursor, UCHAR);
    E_CONFIG_LIST(D, T, env_vars, _e_config_env_var_edd);
index 7ae372b2bef86a7af6ff8a7874f9f2184e03803b..723134dff1c8a2f7b9aa1ab70d12d624328cb6a2 100644 (file)
@@ -111,9 +111,13 @@ struct _E_Config
       double        min;
       double        max;
       double        factor;
+      double        profile_factor;
+      double        inch_correction;
+      double        inch_correction_bound;
       int           base_dpi;
       unsigned char use_dpi;
       unsigned char use_custom;
+      unsigned char for_tdm;
    } scale;
    unsigned char show_cursor;
    unsigned char idle_cursor;
index abee544f4add84c2a205446673d5bf84e44eea68..0ad5c03e1a495d48c1eec5b8aa05885a0ddbac12 100644 (file)
@@ -32,8 +32,26 @@ e_scale_update(void)
 
    if (e_config->scale.use_dpi)
      {
+        double profile_factor = 1.0;
+        double inch = 0.0;
+
+        if (e_config->scale.profile_factor > 0.0)
+          {
+             if (e_config->scale.inch_correction > 0.0)
+               {
+                  inch = floor(sqrt((e_comp->w * e_comp->w) + (e_comp->h * e_comp->h)) / BASE_DPI * 10 + 0.5) / 10;
+
+                  if (inch <= e_config->scale.inch_correction_bound)
+                    profile_factor = e_config->scale.profile_factor;
+                  else
+                    profile_factor = e_config->scale.profile_factor + e_config->scale.inch_correction;
+               }
+             else
+               profile_factor = e_config->scale.profile_factor;
+          }
+
         if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
-          e_scale = (double)BASE_DPI / (double)e_config->scale.base_dpi;
+          e_scale = floor((double)BASE_DPI * profile_factor / (double)e_config->scale.base_dpi * 10 + 0.5) / 10;
 
         if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
         else if (e_scale < e_config->scale.min)
@@ -58,6 +76,8 @@ E_API void
 e_scale_manual_update(int dpi)
 {
    char buf[128];
+   double profile_factor = 1.0;
+   double inch = 0.0;
 
    if (!_initted)
      {
@@ -65,7 +85,22 @@ e_scale_manual_update(int dpi)
         return;
      }
 
-   e_scale = (double)dpi / (double)e_config->scale.base_dpi;
+   if (e_config->scale.profile_factor > 0.0)
+     {
+        if (e_config->scale.inch_correction > 0.0)
+          {
+             inch = floor(sqrt((e_comp->w * e_comp->w) + (e_comp->h * e_comp->h)) / dpi * 10 + 0.5) / 10;
+
+             if (inch <= e_config->scale.inch_correction_bound)
+               profile_factor = e_config->scale.profile_factor;
+             else
+               profile_factor = e_config->scale.profile_factor + e_config->scale.inch_correction;
+          }
+        else
+          profile_factor = e_config->scale.profile_factor;
+     }
+
+   e_scale = floor((double)dpi * profile_factor / (double)e_config->scale.base_dpi * 10 + 0.5) / 10;
 
    if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
    else if (e_scale < e_config->scale.min)