elm_cache_all_flush() is separated from appcore_base_flush_memory().
And, trim_memory() callback function type is added to add entry point.
appcore_base_on_trim_memory() is also added.
Change-Id: Ie2485468554d4e573e049f03d62ed5cb9ac78eaa
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
void (*exit)(void *data);
void (*set_event)(enum appcore_base_event event, void *data);
void (*unset_event)(enum appcore_base_event event, void *data);
+ void (*trim_memory)(void *data);
} appcore_base_ops;
int appcore_base_on_receive(aul_type type, bundle *b);
int appcore_base_on_set_i18n(void);
void appcore_base_on_set_event(enum appcore_base_event event);
void appcore_base_on_unset_event(enum appcore_base_event event);
+int appcore_base_on_trim_memory(void);
int appcore_base_init(appcore_base_ops ops, int argc, char **argv, void *data);
void appcore_base_fini(void);
appcore_base_ops appcore_base_get_default_ops(void);
int appcore_efl_base_on_pause(void);
int appcore_efl_base_on_resume(void);
int appcore_efl_base_on_control(bundle *b);
+int appcore_efl_base_on_trim_memory(void);
void appcore_efl_base_window_on_show(int type, void *event);
void appcore_efl_base_window_on_hide(int type, void *event);
void appcore_efl_base_window_on_lower(int type, void *event);
int appcore_multiwindow_base_on_create(void);
int appcore_multiwindow_base_on_terminate(void);
int appcore_multiwindow_base_on_control(bundle *b);
+int appcore_multiwindow_base_on_trim_memory(void);
void appcore_multiwindow_base_window_on_show(int type, void *event);
void appcore_multiwindow_base_window_on_hide(int type, void *event);
void appcore_multiwindow_base_window_on_lower(int type, void *event);
void appcore_multiwindow_base_window_on_pre_visibility(int type, void *event);
void appcore_multiwindow_base_window_bind(appcore_multiwindow_base_instance_h h, Ecore_Wl2_Window *wl_win);
void appcore_multiwindow_base_window_unbind(appcore_multiwindow_base_instance_h h);
+bool appcore_multiwindow_base_window_is_resumed(void);
appcore_multiwindow_base_class appcore_multiwindow_base_class_get_default(void);
void appcore_multiwindow_base_class_add(appcore_multiwindow_base_class cls);
int appcore_ui_base_on_pause(void);
int appcore_ui_base_on_resume(void);
int appcore_ui_base_on_control(bundle *b);
+int appcore_ui_base_on_trim_memory(void);
void appcore_ui_base_window_on_show(int type, void *event);
void appcore_ui_base_window_on_hide(int type, void *event);
void appcore_ui_base_window_on_lower(int type, void *event);
{
int suspend = APPCORE_BASE_SUSPENDED_STATE_WILL_ENTER_SUSPEND;
- appcore_base_flush_memory();
+ if (__context.ops.trim_memory)
+ __context.ops.trim_memory(__context.data);
+
__context.tid = 0;
if (!__context.allowed_bg && !__context.suspended_state) {
EXPORT_API int appcore_base_flush_memory(void)
{
- int (*sqlite3_free_heap_memory)(int);
- void (*elm_free_all_cache)(void);
+ if (__context.ops.trim_memory)
+ __context.ops.trim_memory(__context.data);
- elm_free_all_cache = dlsym(RTLD_DEFAULT, "elm_cache_all_flush");
- if (elm_free_all_cache)
- elm_free_all_cache();
-
- sqlite3_free_heap_memory = dlsym(RTLD_DEFAULT,
- "sqlite3_release_memory");
- if (sqlite3_free_heap_memory)
- sqlite3_free_heap_memory(SQLITE_FLUSH_MAX);
-
- malloc_trim(0);
return 0;
}
}
}
+EXPORT_API int appcore_base_on_trim_memory(void)
+{
+ int (*sqlite3_free_heap_memory)(int);
+
+ sqlite3_free_heap_memory = dlsym(RTLD_DEFAULT,
+ "sqlite3_release_memory");
+ if (sqlite3_free_heap_memory)
+ sqlite3_free_heap_memory(SQLITE_FLUSH_MAX);
+
+ malloc_trim(0);
+
+ return 0;
+}
+
EXPORT_API appcore_base_event_h appcore_base_add_event(enum appcore_base_event event,
appcore_base_event_cb cb, void *data)
{
static void __on_set_event(enum appcore_base_event event, void *data)
{
- return appcore_base_on_set_event(event);
+ appcore_base_on_set_event(event);
}
static void __on_unset_event(enum appcore_base_event event, void *data)
{
- return appcore_base_on_unset_event(event);
+ appcore_base_on_unset_event(event);
+}
+
+static void __on_trim_memory(void *data)
+{
+ appcore_base_on_trim_memory();
}
EXPORT_API appcore_base_ops appcore_base_get_default_ops(void)
ops.exit = NULL;
ops.set_event = __on_set_event;
ops.unset_event = __on_unset_event;
+ ops.trim_memory = __on_trim_memory;
return ops;
}
elm_exit();
}
+static void __efl_app_trim_memory(void *data)
+{
+ _DBG("Trim memory");
+ elm_cache_all_flush();
+ appcore_base_on_trim_memory();
+}
+
EXPORT_API int appcore_efl_base_init(appcore_efl_base_ops ops, int argc,
char **argv, void *data, unsigned int hint)
{
ops.ui_base.base.finish = __efl_app_finish;
ops.ui_base.base.run = __efl_app_run;
ops.ui_base.base.exit = __efl_app_exit;
+ ops.ui_base.base.trim_memory = __efl_app_trim_memory;
return ops;
}
return appcore_ui_base_on_control(b);
}
+EXPORT_API int appcore_efl_base_on_trim_memory(void)
+{
+ return appcore_ui_base_on_trim_memory();
+}
+
EXPORT_API void appcore_efl_base_window_on_show(int type, void *event)
{
appcore_ui_base_window_on_show(type, event);
#include "appcore_multiwindow_base_private.h"
appcore_multiwindow_base_context _appcore_mw_context;
+static guint __flush_timer = 0;
+
+static gboolean __flush_memory(gpointer data)
+{
+ _DBG("Flush memory");
+ if (_appcore_mw_context.ops.base.trim_memory)
+ _appcore_mw_context.ops.base.trim_memory(_appcore_mw_context.data);
+ __flush_timer = 0;
+ return G_SOURCE_REMOVE;
+}
+
+static void __add_flush_timer(void)
+{
+ if (__flush_timer)
+ return;
+
+ __flush_timer = g_timeout_add(5000, __flush_memory, NULL);
+}
+
+static void __remove_flush_timer(void)
+{
+ if (!__flush_timer)
+ return;
+
+ g_source_remove(__flush_timer);
+ __flush_timer = 0;
+}
static Eina_Bool __stub_show_cb(void *data, int type, void *event)
{
static Eina_Bool __stub_visibility_cb(void *data, int type, void *event)
{
+ Ecore_Wl2_Event_Window_Visibility_Change *ev = event;
+
if (_appcore_mw_context.ops.window.visibility)
_appcore_mw_context.ops.window.visibility(type, event, _appcore_mw_context.data);
+ if (ev && ev->fully_obscured) {
+ if (!appcore_multiwindow_base_window_is_resumed())
+ __add_flush_timer();
+ } else {
+ __remove_flush_timer();
+ }
+
return ECORE_CALLBACK_RENEW;
}
static Eina_Bool __stub_pre_visibility_cb(void *data, int type, void *event)
{
+ Ecore_Wl2_Event_Window_Pre_Visibility_Change *ev = event;
+
if (_appcore_mw_context.ops.window.pre_visibility)
_appcore_mw_context.ops.window.pre_visibility(type, event, _appcore_mw_context.data);
+ if (ev->type == ECORE_WL2_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED)
+ __remove_flush_timer();
+
return ECORE_CALLBACK_RENEW;
}
return appcore_multiwindow_base_on_terminate();
}
+static void __on_trim_memory(void *data)
+{
+ appcore_multiwindow_base_on_trim_memory();
+}
+
static void __window_on_show(int type, void *event, void *data)
{
appcore_multiwindow_base_window_on_show(type, event);
ops.base.finish = NULL;
ops.base.run = NULL;
ops.base.exit = NULL;
+ ops.base.trim_memory = __on_trim_memory;
ops.window.show = __window_on_show;
ops.window.hide = __window_on_hide;
return 0;
}
+EXPORT_API int appcore_multiwindow_base_on_trim_memory(void)
+{
+ return appcore_base_on_trim_memory();
+}
} win_context;
static GList *__win_contexts;
-static guint __flush_timer;
static gint __comp(gconstpointer a, gconstpointer b)
{
return node->data;
}
-static bool __is_resumed(void)
+EXPORT_API bool appcore_multiwindow_base_window_is_resumed(void)
{
win_context *ctx;
GList *iter;
return false;
}
-static gboolean __flush_memory(gpointer data)
-{
- _DBG("Flush memory");
- appcore_base_flush_memory();
- __flush_timer = 0;
- return G_SOURCE_REMOVE;
-}
-
-static void __add_flush_timer(void)
-{
- if (__flush_timer)
- return;
-
- __flush_timer = g_timeout_add(5000, __flush_memory, NULL);
-}
-
-static void __remove_flush_timer(void)
-{
- if (!__flush_timer)
- return;
-
- g_source_remove(__flush_timer);
- __flush_timer = 0;
-}
-
EXPORT_API void appcore_multiwindow_base_window_on_show(int type, void *event)
{
}
if (!cxt)
return;
- if (ev->fully_obscured) {
+ if (ev->fully_obscured)
appcore_multiwindow_base_instance_pause(cxt->inst);
- if (!__is_resumed())
- __add_flush_timer();
- } else {
+ else
appcore_multiwindow_base_instance_resume(cxt->inst);
- __remove_flush_timer();
- }
}
EXPORT_API void appcore_multiwindow_base_window_on_pre_visibility(int type, void *event)
if (!cxt)
return;
- if (ev->type == ECORE_WL2_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED) {
+ if (ev->type == ECORE_WL2_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED)
appcore_multiwindow_base_instance_resume(cxt->inst);
- __remove_flush_timer();
- }
}
EXPORT_API void appcore_multiwindow_base_window_bind(appcore_multiwindow_base_instance_h h, Ecore_Wl2_Window *wl_win)
return 0;
}
+EXPORT_API int appcore_ui_base_on_trim_memory(void)
+{
+ return appcore_base_on_trim_memory();
+}
+
static void __group_attach()
{
if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL))