Elm caching settings exposed, part I.
authorGustavo Lima Chaves <glima@profusion.mobi>
Mon, 22 Nov 2010 06:56:06 +0000 (06:56 +0000)
committerGustavo Lima Chaves <glima@profusion.mobi>
Mon, 22 Nov 2010 06:56:06 +0000 (06:56 +0000)
Now working on exposing edje caching too, and having a cache dumping
poller.  Patch also replaces some focus_overalay object functions,
too.

SVN revision: 54770

legacy/elementary/src/bin/config.c
legacy/elementary/src/lib/Elementary.h.in
legacy/elementary/src/lib/elm_config.c
legacy/elementary/src/lib/elm_main.c
legacy/elementary/src/lib/elm_priv.h

index 4ab0b13..b20d651 100644 (file)
@@ -119,6 +119,46 @@ config_exit(void *data       __UNUSED__,
 }
 
 static void
+fc_round(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+{
+   double val = elm_slider_value_get(obj);
+   double v;
+
+   v = ((double)((int)(val * 10.0))) / 10.0;
+   if (v != val) elm_slider_value_set(obj, v);
+}
+
+static void
+fc_change(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+{
+   double font_cache = elm_font_cache_get();
+   double val = elm_slider_value_get(obj);
+
+   if (font_cache == val) return;
+   elm_font_cache_all_set(val * 1024);
+}
+
+static void
+ic_round(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+{
+   double val = elm_slider_value_get(obj);
+   double v;
+
+   v = ((double)((int)(val * 10.0))) / 10.0;
+   if (v != val) elm_slider_value_set(obj, v);
+}
+
+static void
+ic_change(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+{
+   double image_cache = elm_image_cache_get();
+   double val = elm_slider_value_get(obj);
+
+   if (image_cache == val) return;
+   elm_image_cache_all_set(val * 1024);
+}
+
+static void
 sc_round(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
 {
    double val = elm_slider_value_get(obj);
@@ -1993,7 +2033,80 @@ _status_config_rendering(Evas_Object *win, Evas_Object *pager)
 static void
 _status_config_caches(Evas_Object *win, Evas_Object *pager)
 {
-   _unimplemented(win, pager, "caches");
+   Evas_Object *lb, *pd, *bx, *sl, *sp;
+
+   bx = elm_box_add(win);
+   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
+
+   pd = elm_frame_add(win);
+   evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5);
+   elm_object_style_set(pd, "pad_medium");
+   elm_box_pack_end(bx, pd);
+   evas_object_show(pd);
+
+   lb = elm_label_add(win);
+   evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5);
+   elm_label_label_set(lb,"<hilight>Font Cache Size</>");
+   elm_frame_content_set(pd, lb);
+   evas_object_show(lb);
+
+   sl = elm_slider_add(win);
+   evas_object_data_set(win, "font_cache_slider", sl);
+   evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
+   elm_slider_span_size_set(sl, 120);
+   elm_slider_unit_format_set(sl, "%1.1f");
+   elm_slider_indicator_format_set(sl, "%1.1f MB");
+   elm_slider_min_max_set(sl, 0.0, 4.0);
+   elm_slider_value_set(sl, (double)elm_font_cache_get() / 1024);
+   elm_box_pack_end(bx, sl);
+   evas_object_show(sl);
+
+   evas_object_smart_callback_add(sl, "changed", fc_round, NULL);
+   evas_object_smart_callback_add(sl, "delay,changed", fc_change, NULL);
+
+   sp = elm_separator_add(win);
+   elm_separator_horizontal_set(sp, 1);
+   evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
+   elm_box_pack_end(bx, sp);
+   evas_object_show(sp);
+
+   pd = elm_frame_add(win);
+   evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5);
+   elm_object_style_set(pd, "pad_medium");
+   elm_box_pack_end(bx, pd);
+   evas_object_show(pd);
+
+   lb = elm_label_add(win);
+   evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5);
+   elm_label_label_set(lb, "<hilight>Image Cache Size</><br>");
+   elm_frame_content_set(pd, lb);
+   evas_object_show(lb);
+
+   sl = elm_slider_add(win);
+   evas_object_data_set(win, "image_cache_slider", sl);
+   evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
+   elm_slider_span_size_set(sl, 120);
+   elm_slider_unit_format_set(sl, "%1.0f");
+   elm_slider_indicator_format_set(sl, "%1.0f MB");
+   elm_slider_min_max_set(sl, 0, 32);
+   elm_slider_value_set(sl, (double)elm_image_cache_get() / 1024);
+   elm_box_pack_end(bx, sl);
+   evas_object_show(sl);
+
+   evas_object_smart_callback_add(sl, "changed", ic_round, NULL);
+   evas_object_smart_callback_add(sl, "delay,changed", ic_change, NULL);
+
+   evas_object_data_set(win, "caches", bx);
+
+   elm_pager_content_push(pager, bx);
 }
 
 static void
index 666b695..4339075 100644 (file)
@@ -251,6 +251,12 @@ extern "C" {
    EAPI int          elm_policy_get(unsigned int policy);
 
    EAPI void         elm_all_flush(void);
+   EAPI int          elm_font_cache_get(void);
+   EAPI void         elm_font_cache_set(int size);
+   EAPI void         elm_font_cache_all_set(int size);
+   EAPI int          elm_image_cache_get(void);
+   EAPI void         elm_image_cache_set(int size);
+   EAPI void         elm_image_cache_all_set(int size);
 
    EAPI void         elm_object_scale_set(Evas_Object *obj, double scale);
    EAPI double       elm_object_scale_get(const Evas_Object *obj);
index 803203f..722e5c6 100644 (file)
@@ -62,7 +62,7 @@ static size_t _elm_user_dir_snprintf(char *dst, size_t size, const char *fmt, ..
 #ifdef HAVE_ELEMENTARY_X
 static Ecore_Event_Handler *_prop_change_handler = NULL;
 static Ecore_X_Window _root_1st = 0;
-#define ATOM_COUNT 6
+#define ATOM_COUNT 8
 static Ecore_X_Atom _atom[ATOM_COUNT];
 static Ecore_X_Atom _atom_config = 0;
 static const char *_atom_names[ATOM_COUNT] =
@@ -72,6 +72,8 @@ static const char *_atom_names[ATOM_COUNT] =
     "ENLIGHTENMENT_THEME",
     "ENLIGHTENMENT_PROFILE",
     "ENLIGHTENMENT_FONT_OVERLAY",
+    "ENLIGHTENMENT_FONT_CACHE",
+    "ENLIGHTENMENT_IMAGE_CACHE",
     "ENLIGHTENMENT_CONFIG"
   };
 #define ATOM_E_SCALE 0
@@ -79,7 +81,9 @@ static const char *_atom_names[ATOM_COUNT] =
 #define ATOM_E_THEME 2
 #define ATOM_E_PROFILE 3
 #define ATOM_E_FONT_OVERLAY 4
-#define ATOM_E_CONFIG 5
+#define ATOM_E_FONT_CACHE 5
+#define ATOM_E_IMAGE_CACHE 6
+#define ATOM_E_CONFIG 7
 
 static Eina_Bool _prop_config_get(void);
 static Eina_Bool _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev);
@@ -231,6 +235,38 @@ _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
                   _elm_rescale();
                }
           }
+        if (event->atom == _atom[ATOM_E_FONT_CACHE])
+          {
+             unsigned int val = 1000;
+
+             if (ecore_x_window_prop_card32_get(event->win,
+                                                event->atom,
+                                                &val, 1) > 0)
+               {
+                  int font_cache;
+
+                  font_cache = _elm_config->font_cache;
+                    _elm_config->font_cache = val;
+                  if (font_cache != _elm_config->font_cache)
+                    _elm_recache();
+               }
+          }
+        if (event->atom == _atom[ATOM_E_IMAGE_CACHE])
+          {
+             unsigned int val = 1000;
+
+             if (ecore_x_window_prop_card32_get(event->win,
+                                                event->atom,
+                                                &val, 1) > 0)
+               {
+                  int image_cache;
+
+                  image_cache = _elm_config->image_cache;
+                    _elm_config->image_cache = val;
+                  if (image_cache != _elm_config->image_cache)
+                    _elm_recache();
+               }
+          }
         else if (((_atom_config > 0) && (event->atom == _atom_config)) ||
                  (event->atom == _atom[ATOM_E_CONFIG]))
           {
@@ -709,6 +745,22 @@ _config_sub_apply(void)
    if (_elm_config->modules) _elm_module_parse(_elm_config->modules);
 }
 
+void
+_elm_recache(void)
+{
+   Eina_List *l;
+   Evas_Object *win;
+
+   elm_all_flush();
+
+   EINA_LIST_FOREACH(_elm_win_list, l, win)
+     {
+        Evas *e = evas_object_evas_get(win);
+        evas_image_cache_set(e, _elm_config->image_cache * 1024);
+        evas_font_cache_set(e, _elm_config->font_cache * 1024);
+     }
+}
+
 static Elm_Config *
 _config_user_load(void)
 {
index d42a924..32e8388 100644 (file)
@@ -1043,26 +1043,6 @@ elm_policy_get(unsigned int policy)
 }
 
 /**
- * Flush all caches & dump all data that can be to lean down to use less memory
- */
-EAPI void
-elm_all_flush(void)
-{
-   const Eina_List *l;
-   Evas_Object *obj;
-   
-   EINA_LIST_FOREACH(_elm_win_list, l, obj)
-     {
-        Evas *e = evas_object_evas_get(obj);
-        edje_file_cache_flush();
-        edje_collection_cache_flush();
-        evas_image_cache_flush(e);
-        evas_font_cache_flush(e);
-        evas_render_dump(e);
-     }
-}
-
-/**
  * @defgroup Scaling Selective Widget Scaling
  *
  * Different widgets can be scaled independently. These functions allow you to
@@ -1777,59 +1757,145 @@ elm_finger_size_all_set(Evas_Coord size)
    if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_FINGER_SIZE");
    ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
                                   atom, &size_i, 1);
-#endif   
+#endif
 }
 
 /**
- * Get the enable status of the focus highlight
+ * @defgroup Caches Caches
  *
- * This gets whether the highlight on focused objects is enabled or not
- * @ingroup Config
+ * These are functions which let one fine-tune some cache values for
+ * Elementary applications, thus allowing for performance adjustments.
  */
-EAPI Eina_Bool
-elm_focus_highlight_enable_get(void)
+
+/**
+ * Flush all caches & dump all data that can be to lean down to use
+ * less memory
+ *
+ * @ingroup Caches
+ */
+EAPI void
+elm_all_flush(void)
 {
-   return _elm_config->focus_highlight_enable;
+   const Eina_List *l;
+   Evas_Object *obj;
+
+   EINA_LIST_FOREACH(_elm_win_list, l, obj)
+     {
+        Evas *e = evas_object_evas_get(obj);
+        edje_file_cache_flush();
+        edje_collection_cache_flush();
+        evas_image_cache_flush(e);
+        evas_font_cache_flush(e);
+        evas_render_dump(e);
+     }
 }
 
 /**
- * Set the enable status of the focus highlight
+ * Get the configured font cache size
  *
- * Set whether to show or not the highlight on focused objects
- * @param enable Enable highlight if EINA_TRUE, disable otherwise
- * @ingroup Config
+ * This gets the globally configured font cache size, in bytes
+ *
+ * @return The font cache size
+ * @ingroup Caches
+ */
+EAPI int
+elm_font_cache_get(void)
+{
+   return _elm_config->font_cache;
+}
+
+/**
+ * Set the configured font cache size
+ *
+ * This sets the globally configured font cache size, in bytes
+ *
+ * @param size The font cache size
+ * @ingroup Caches
  */
 EAPI void
-elm_focus_highlight_enable_set(Eina_Bool enable)
+elm_font_cache_set(int size)
 {
-   _elm_config->focus_highlight_enable = !!enable;
+   if (_elm_config->font_cache == size) return;
+   _elm_config->font_cache = size;
+
+   _elm_recache();
 }
 
 /**
- * Get the enable status of the highlight animation
+ * Set the configured font cache size for all applications on the
+ * display
  *
- * Get whether the focus highlight, if enabled, will animate its switch from
- * one object to the next
- * @ingroup Config
+ * This sets the globally configured font cache size -- in bytes
+ * -- for all applications on the display.
+ *
+ * @param size The font cache size
+ * @ingroup Caches
  */
-EAPI Eina_Bool
-elm_focus_highlight_animate_get(void)
+EAPI void
+elm_font_cache_all_set(int size)
 {
-   return _elm_config->focus_highlight_animate;
+#ifdef HAVE_ELEMENTARY_X
+   static Ecore_X_Atom atom = 0;
+   unsigned int size_i = (unsigned int)size;
+
+   if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_FONT_CACHE");
+   ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
+                                  atom, &size_i, 1);
+#endif
 }
 
 /**
- * Set the enable status of the highlight animation
+ * Get the configured image cache size
  *
- * Set whether the focus highlight, if enabled, will animate its switch from
- * one object to the next
- * @param animate Enable animation if EINA_TRUE, disable otherwise
- * @ingroup Config
+ * This gets the globally configured image cache size, in bytes
+ *
+ * @return The image cache size
+ * @ingroup Caches
+ */
+EAPI int
+elm_image_cache_get(void)
+{
+   return _elm_config->image_cache;
+}
+
+/**
+ * Set the configured image cache size
+ *
+ * This sets the globally configured image cache size, in bytes
+ *
+ * @param size The image cache size
+ * @ingroup Caches
  */
 EAPI void
-elm_focus_highlight_animate_set(Eina_Bool animate)
+elm_image_cache_set(int size)
 {
-   _elm_config->focus_highlight_animate = !!animate;
+   if (_elm_config->image_cache == size) return;
+   _elm_config->image_cache = size;
+
+   _elm_recache();
+}
+
+/**
+ * Set the configured image cache size for all applications on the
+ * display
+ *
+ * This sets the globally configured image cache size -- in bytes
+ * -- for all applications on the display.
+ *
+ * @param size The image cache size
+ * @ingroup Caches
+ */
+EAPI void
+elm_image_cache_all_set(int size)
+{
+#ifdef HAVE_ELEMENTARY_X
+   static Ecore_X_Atom atom = 0;
+   unsigned int size_i = (unsigned int)size;
+
+   if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_IMAGE_CACHE");
+   ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
+                                  atom, &size_i, 1);
+#endif
 }
 
 /**
@@ -2061,12 +2127,64 @@ elm_object_focus_direction_go(Evas_Object *obj, int x, int y)
 }
 
 /**
+ * Get the enable status of the focus highlight
+ *
+ * This gets whether the highlight on focused objects is enabled or not
+ * @ingroup Focus
+ */
+EAPI Eina_Bool
+elm_focus_highlight_enable_get(void)
+{
+   return _elm_config->focus_highlight_enable;
+}
+
+/**
+ * Set the enable status of the focus highlight
+ *
+ * Set whether to show or not the highlight on focused objects
+ * @param enable Enable highlight if EINA_TRUE, disable otherwise
+ * @ingroup Focus
+ */
+EAPI void
+elm_focus_highlight_enable_set(Eina_Bool enable)
+{
+   _elm_config->focus_highlight_enable = !!enable;
+}
+
+/**
+ * Get the enable status of the highlight animation
+ *
+ * Get whether the focus highlight, if enabled, will animate its switch from
+ * one object to the next
+ * @ingroup Focus
+ */
+EAPI Eina_Bool
+elm_focus_highlight_animate_get(void)
+{
+   return _elm_config->focus_highlight_animate;
+}
+
+/**
+ * Set the enable status of the highlight animation
+ *
+ * Set whether the focus highlight, if enabled, will animate its switch from
+ * one object to the next
+ * @param animate Enable animation if EINA_TRUE, disable otherwise
+ * @ingroup Config
+ */
+EAPI void
+elm_focus_highlight_animate_set(Eina_Bool animate)
+{
+   _elm_config->focus_highlight_animate = !!animate;
+}
+
+/**
  * @defgroup Scrollhints Scrollhints
  *
  * Objects when inside a scroller can scroll, but this may not always be
  * desirable in certain situations. This allows an object to hint to itself
  * and parents to "not scroll" in one of 2 ways.
- * 
+ *
  * 1. To hold on scrolling. This means just flicking and dragging may no
  * longer scroll, but pressing/dragging near an edge of the scroller will
  * still scroll. This is automastically used by the entry object when
index cb39ad3..c3a9c59 100644 (file)
@@ -152,6 +152,8 @@ void                _elm_config_shutdown(void);
 Eina_Bool           _elm_config_save(void);
 void                _elm_config_reload(void);
 
+void                _elm_recache(void);
+
 const char         *_elm_config_current_profile_get(void);
 const char         *_elm_config_profile_dir_get(const char *prof, Eina_Bool is_user);
 Eina_List          *_elm_config_profiles_list(void);