summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaegeun Park <haegeun.park@samsung.com>2017-01-04 15:17:56 +0900
committerHaegeun Park <haegeun.park@samsung.com>2017-01-11 18:20:34 +0900
commit5ec982aca97e00f86620d3d2ecac20cab82655b0 (patch)
tree5e0af27b7c7e2d64324fb6e7122ed25065b516f8
parentfee2a55b27667680a376b0e5c0e88d4371ff458b (diff)
downloadefl-5ec982aca97e00f86620d3d2ecac20cab82655b0.tar.gz
evas: (GL thread) Moved thread creation to initializing (sw or gl) backend
Now GL threads are created only when use GL backend. (Minimized consuming resource) Change-Id: Icd7d5068fa048a2bf71f157892e9746e11adea20
-rw-r--r--src/lib/evas/canvas/evas_main.c8
-rw-r--r--src/lib/evas/common/evas_thread_render.c67
-rw-r--r--src/lib/evas/include/evas_common_private.h6
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c2
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c2
5 files changed, 60 insertions, 25 deletions
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index d89104ed41..76a4694d51 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -83,20 +83,13 @@ evas_init(void)
_evas_preload_thread_init();
evas_filter_init();
- if (!evas_threads_init())
- goto shutdown_filter;
-
eina_log_timing(_evas_log_dom_global,
EINA_LOG_STATE_STOP,
EINA_LOG_STATE_INIT);
return _evas_init_count;
- shutdown_filter:
- evas_filter_shutdown();
- _evas_preload_thread_shutdown();
#ifdef EVAS_CSERVE2
- if (cs2) evas_cserve2_shutdown();
shutdown_async_events:
#endif
evas_async_events_shutdown();
@@ -160,7 +153,6 @@ evas_shutdown(void)
evas_object_filter_cow = NULL;
evas_object_mask_cow = NULL;
- evas_threads_shutdown();
_evas_preload_thread_shutdown();
evas_async_events_shutdown();
evas_module_shutdown();
diff --git a/src/lib/evas/common/evas_thread_render.c b/src/lib/evas/common/evas_thread_render.c
index ae7362faa3..4abe068bc1 100644
--- a/src/lib/evas/common/evas_thread_render.c
+++ b/src/lib/evas/common/evas_thread_render.c
@@ -20,7 +20,8 @@ typedef struct
Eina_Bool exit_thread;
} Evas_Thread;
-static int evas_threads_init_count = 0;
+static int evas_threads_sw_init_count = 0;
+static int evas_threads_gl_init_count = 0;
static Evas_Thread evas_thread_software;
static Evas_Thread evas_thread_gl;
@@ -304,11 +305,11 @@ timeout_shutdown:
eina_inarray_flush(&ev_thread->queue);
}
-int
-evas_threads_init(void)
+EAPI int
+evas_threads_sw_init(void)
{
- if (evas_threads_init_count++)
- return evas_threads_init_count;
+ if (evas_threads_sw_init_count++)
+ return evas_threads_sw_init_count;
if (!eina_threads_init())
{
@@ -318,37 +319,73 @@ evas_threads_init(void)
if (!evas_thread_init(&evas_thread_software, "Evas-thread-wk-sw"))
goto fail_on_software_thread_init;
+ return evas_threads_sw_init_count;
+
+fail_on_software_thread_init:
+ eina_threads_shutdown();
+fail_on_eina_thread_init:
+ return --evas_threads_gl_init_count;
+ }
+
+EAPI int
+evas_threads_gl_init(void)
+{
+ if (evas_threads_gl_init_count++)
+ return evas_threads_gl_init_count;
+
+ if (!eina_threads_init())
+ {
+ CRI("Could not init eina threads");
+ goto fail_on_eina_thread_init;
+ }
+
if (!evas_thread_init(&evas_thread_gl, "Evas-thread-wk-gl"))
goto fail_on_gl_thread_init;
if (!evas_thread_init(&evas_thread_evgl, "Evas-thread-wk-evgl"))
goto fail_on_evgl_thread_init;
- return evas_threads_init_count;
+ return evas_threads_gl_init_count;
fail_on_evgl_thread_init:
evas_thread_shutdown(&evas_thread_gl);
fail_on_gl_thread_init:
- evas_thread_shutdown(&evas_thread_software);
-fail_on_software_thread_init:
eina_threads_shutdown();
fail_on_eina_thread_init:
- return --evas_threads_init_count;
+ return --evas_threads_gl_init_count;
}
-int
-evas_threads_shutdown(void)
+EAPI int
+evas_threads_sw_shutdown(void)
{
- if (evas_threads_init_count <= 0)
+ if (evas_threads_sw_init_count <= 0)
{
ERR("Too many calls to shutdown, ignored.");
return 0;
}
- if (--evas_threads_init_count)
- return evas_threads_init_count;
+ if (--evas_threads_sw_init_count)
+ return evas_threads_sw_init_count;
+
+ evas_thread_shutdown(&evas_thread_software);
+
+ eina_threads_shutdown();
+
+ return 0;
+}
+
+EAPI int
+evas_threads_gl_shutdown(void)
+{
+ if (evas_threads_gl_init_count <= 0)
+ {
+ ERR("Too many calls to shutdown, ignored.");
+ return 0;
+ }
+
+ if (--evas_threads_gl_init_count)
+ return evas_threads_gl_init_count;
evas_thread_shutdown(&evas_thread_evgl);
evas_thread_shutdown(&evas_thread_gl);
- evas_thread_shutdown(&evas_thread_software);
eina_threads_shutdown();
diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h
index 38a2981e31..15db75b437 100644
--- a/src/lib/evas/include/evas_common_private.h
+++ b/src/lib/evas/include/evas_common_private.h
@@ -1332,8 +1332,10 @@ void evas_all_sync(void);
#define EVAS_GL_THREAD_MODE_FLUSH 1
#define EVAS_GL_THREAD_MODE_ENQUEUE 2
-int evas_threads_init(void);
-int evas_threads_shutdown(void);
+EAPI int evas_threads_sw_init(void);
+EAPI int evas_threads_gl_init(void);
+EAPI int evas_threads_sw_shutdown(void);
+EAPI int evas_threads_gl_shutdown(void);
EAPI void evas_thread_cmd_enqueue(Evas_Thread_Command_Cb cb, void *data);
EAPI void evas_thread_queue_flush(Evas_Thread_Command_Cb cb, void *data);
EAPI void evas_gl_thread_cmd_enqueue(int thread_type, Evas_Thread_Command_Cb cb, void *data, int thread_mode);
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index e0e3f6dfa7..6673b76572 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -3156,6 +3156,7 @@ static int
module_open(Evas_Module *em)
{
if (!em) return 0;
+ if (!evas_threads_gl_init()) return 0;
if (!evas_gl_common_module_open()) return 0;
/* get whatever engine module we inherit from */
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
@@ -3335,6 +3336,7 @@ module_close(Evas_Module *em EINA_UNUSED)
_evas_engine_GL_log_dom = -1;
}
evas_gl_common_module_close();
+ evas_threads_gl_shutdown();
}
static Evas_Module_Api evas_modapi =
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index 039459c9a2..ca30652cd0 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -5881,6 +5881,7 @@ static int
module_open(Evas_Module *em)
{
if (!em) return 0;
+ if (!evas_threads_sw_init()) return 0;
_evas_soft_gen_log_dom = eina_log_domain_register
("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
if(_evas_soft_gen_log_dom<0)
@@ -5943,6 +5944,7 @@ module_close(Evas_Module *em EINA_UNUSED)
eina_log_domain_unregister(_evas_soft_gen_log_dom);
_evas_soft_gen_log_dom = -1;
}
+ evas_threads_sw_shutdown();
}
static Evas_Module_Api evas_modapi =