}
static void
-evas_thread_queue_append(Evas_Thread *ev_thread, Evas_Thread_Command_Cb cb, void *data, Eina_Bool do_flush EINA_UNUSED, Eina_Bool do_finish)
+evas_thread_queue_append(Evas_Thread *ev_thread, Evas_Thread_Command_Cb cb, void *data, Eina_Bool do_flush EINA_UNUSED, Eina_Bool need_finish, Eina_Bool do_finish)
{
Evas_Thread_Command *cmd;
void *ref;
cmd->cb = cb;
cmd->data = data;
- if (do_finish)
+ if (need_finish)
cmd->finish = EINA_TRUE;
else
cmd->finish = EINA_FALSE;
EAPI void
evas_thread_cmd_enqueue(Evas_Thread_Command_Cb cb, void *data)
{
- evas_thread_queue_append(&evas_thread_software, cb, data, EINA_FALSE, EINA_FALSE);
+ evas_thread_queue_append(&evas_thread_software, cb, data, EINA_FALSE, EINA_FALSE, EINA_FALSE);
}
EAPI void
evas_thread_queue_flush(Evas_Thread_Command_Cb cb, void *data)
{
- evas_thread_queue_append(&evas_thread_software, cb, data, EINA_TRUE, EINA_FALSE);
+ evas_thread_queue_append(&evas_thread_software, cb, data, EINA_TRUE, EINA_FALSE, EINA_FALSE);
}
EAPI void
}
if (thread_mode == EVAS_GL_THREAD_MODE_ENQUEUE)
- evas_thread_queue_append(ev_thread, cb, data, EINA_FALSE, EINA_FALSE);
+ evas_thread_queue_append(ev_thread, cb, data, EINA_FALSE, EINA_FALSE, EINA_FALSE);
else if (thread_mode == EVAS_GL_THREAD_MODE_FLUSH)
- evas_thread_queue_append(ev_thread, cb, data, EINA_TRUE, EINA_FALSE);
+ evas_thread_queue_append(ev_thread, cb, data, EINA_TRUE, EINA_FALSE, EINA_FALSE);
else if (thread_mode == EVAS_GL_THREAD_MODE_FINISH)
- evas_thread_queue_append(ev_thread, cb, data, EINA_TRUE, EINA_TRUE);
+ evas_thread_queue_append(ev_thread, cb, data, EINA_TRUE, EINA_TRUE, EINA_TRUE);
+ else if (thread_mode == EVAS_GL_THREAD_MODE_ASYNC_FINISH)
+ evas_thread_queue_append(ev_thread, cb, data, EINA_TRUE, EINA_TRUE, EINA_FALSE);
else
{
ERR("GL thread mode is invalid");
return;
}
+EAPI void
+evas_gl_thread_cmd_wait(int thread_type, void *data, Eina_Bool *finished_ptr)
+{
+ Evas_Thread *ev_thread = NULL;
+
+ if (thread_type == EVAS_GL_THREAD_TYPE_GL)
+ ev_thread = &evas_thread_gl;
+ else if (thread_type == EVAS_GL_THREAD_TYPE_EVGL)
+ ev_thread = &evas_thread_evgl;
+ else
+ {
+ ERR("GL thread type is invalid");
+ goto out;
+ }
+
+ while (!(*finished_ptr))
+ {
+ void *finish_ref;
+ Evas_Thread_Finish_Reply *rep;
+
+ rep = eina_thread_queue_wait(ev_thread->thread_queue_finish, &finish_ref);
+ if (rep && rep->data == data)
+ {
+ eina_thread_queue_wait_done(ev_thread->thread_queue_finish, finish_ref);
+ return;
+
+
+ }
+ eina_thread_queue_wait_done(ev_thread->thread_queue_finish, finish_ref);
+ }
+
+out:
+ return;
+}
+
EAPI Eina_Thread
evas_gl_thread_get(int thread_type)
{
return EINA_TRUE;
- fail_on_thread_creation:
+fail_on_thread_creation:
ev_thread->worker = 0;
eina_thread_queue_free(ev_thread->thread_queue_finish);
- fail_on_thread_queue_finish_creation:
+fail_on_thread_queue_finish_creation:
eina_thread_queue_free(ev_thread->thread_queue_command);
- fail_on_thread_queue_command_creation:
+fail_on_thread_queue_command_creation:
ev_thread->exit_thread = EINA_TRUE;
ev_thread->exited = 1;
return EINA_FALSE;
#define EVAS_GL_THREAD_MODE_FINISH 0
#define EVAS_GL_THREAD_MODE_FLUSH 1
#define EVAS_GL_THREAD_MODE_ENQUEUE 2
+#define EVAS_GL_THREAD_MODE_ASYNC_FINISH 3
EAPI int evas_threads_sw_init(void);
EAPI int evas_threads_gl_init(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);
+EAPI void evas_gl_thread_cmd_wait(int thread_type, void *data, Eina_Bool *finished_ptr);
EAPI Eina_Thread evas_gl_thread_get(int thread_type);
typedef enum _Evas_Render_Mode
EGLBoolean return_value;
EGLDisplay dpy;
EGLSurface surface;
+ int command_allocated;
} Evas_Thread_Command_eglSwapBuffers;
static void
thread_data->return_value = eglSwapBuffers(thread_data->dpy,
thread_data->surface);
+
+ if (thread_data->command_allocated)
+ eina_mempool_free(_mp_command, thread_data);
}
EAPI EGLBoolean
if (!evas_gl_thread_enabled())
return eglSwapBuffers(dpy, surface);
- Evas_Thread_Command_eglSwapBuffers thread_data;
+ Evas_Thread_Command_eglSwapBuffers thread_data_local;
+ Evas_Thread_Command_eglSwapBuffers *thread_data = &thread_data_local;
+
+ int thread_mode = EVAS_GL_THREAD_MODE_FINISH;
+
+ /* command_allocated flag init. */
+ thread_data->command_allocated = 0;
+
+ if (!evas_gl_thread_force_finish())
+ { /* _flush */
+ Evas_Thread_Command_eglSwapBuffers *thread_data_new;
+ thread_data_new = eina_mempool_malloc(_mp_command,
+ sizeof(Evas_Thread_Command_eglSwapBuffers));
+ if (thread_data_new)
+ {
+ thread_data = thread_data_new;
+ thread_data->command_allocated = 1;
+ thread_mode = EVAS_GL_THREAD_MODE_FLUSH;
+ }
+ }
- thread_data.dpy = dpy;
- thread_data.surface = surface;
+ thread_data->dpy = dpy;
+ thread_data->surface = surface;
evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_GL,
_gl_thread_eglSwapBuffers,
- &thread_data,
- EVAS_GL_THREAD_MODE_FINISH);
+ thread_data,
+ thread_mode);
- return thread_data.return_value;
+ return thread_data->return_value;
}
typedef struct
{
GLuint index;
- int command_allocated;
} EVGL_API_Thread_Command_glDisableVertexAttribArray;
orig_evgl_api_glDisableVertexAttribArray(thread_data->index);
- if (thread_data->command_allocated)
- eina_mempool_free(_mp_command, thread_data);
}
EAPI void
EVGL_API_Thread_Command_glDisableVertexAttribArray thread_data_local;
EVGL_API_Thread_Command_glDisableVertexAttribArray *thread_data = &thread_data_local;
- /* command_allocated flag init. */
- thread_data->command_allocated = 0;
-
- if (!evas_gl_thread_force_finish())
- { /* _flush */
- EVGL_API_Thread_Command_glDisableVertexAttribArray *thread_data_new;
- thread_data_new = eina_mempool_malloc(_mp_command,
- sizeof(EVGL_API_Thread_Command_glDisableVertexAttribArray));
- if (thread_data_new)
- {
- thread_data = thread_data_new;
- thread_data->command_allocated = 1;
- thread_mode = EVAS_GL_THREAD_MODE_FLUSH;
- }
- }
-
thread_data->index = index;
evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_EVGL,
typedef struct
{
GLuint index;
- int command_allocated;
} EVGL_API_Thread_Command_glEnableVertexAttribArray;
orig_evgl_api_glEnableVertexAttribArray(thread_data->index);
- if (thread_data->command_allocated)
- eina_mempool_free(_mp_command, thread_data);
}
EAPI void
EVGL_API_Thread_Command_glEnableVertexAttribArray thread_data_local;
EVGL_API_Thread_Command_glEnableVertexAttribArray *thread_data = &thread_data_local;
- /* command_allocated flag init. */
- thread_data->command_allocated = 0;
-
- if (!evas_gl_thread_force_finish())
- { /* _flush */
- EVGL_API_Thread_Command_glEnableVertexAttribArray *thread_data_new;
- thread_data_new = eina_mempool_malloc(_mp_command,
- sizeof(EVGL_API_Thread_Command_glEnableVertexAttribArray));
- if (thread_data_new)
- {
- thread_data = thread_data_new;
- thread_data->command_allocated = 1;
- thread_mode = EVAS_GL_THREAD_MODE_FLUSH;
- }
- }
-
thread_data->index = index;
evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_EVGL,
typedef struct
{
GLuint index;
- int command_allocated;
} EVGL_Thread_Command_glEnableVertexAttribArray;
glEnableVertexAttribArray(thread_data->index);
- if (thread_data->command_allocated)
- eina_mempool_free(_mp_command, thread_data);
}
EAPI void
EVGL_Thread_Command_glEnableVertexAttribArray thread_data_local;
EVGL_Thread_Command_glEnableVertexAttribArray *thread_data = &thread_data_local;
- /* command_allocated flag init. */
- thread_data->command_allocated = 0;
-
- if (!evas_gl_thread_force_finish())
- { /* _flush */
- EVGL_Thread_Command_glEnableVertexAttribArray *thread_data_new;
- thread_data_new = eina_mempool_malloc(_mp_command,
- sizeof(EVGL_Thread_Command_glEnableVertexAttribArray));
- if (thread_data_new)
- {
- thread_data = thread_data_new;
- thread_data->command_allocated = 1;
- thread_mode = EVAS_GL_THREAD_MODE_FLUSH;
- }
- }
-
thread_data->index = index;
evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_EVGL,
typedef struct
{
GLuint index;
- int command_allocated;
} EVGL_Thread_Command_glDisableVertexAttribArray;
glDisableVertexAttribArray(thread_data->index);
- if (thread_data->command_allocated)
- eina_mempool_free(_mp_command, thread_data);
}
EAPI void
EVGL_Thread_Command_glDisableVertexAttribArray thread_data_local;
EVGL_Thread_Command_glDisableVertexAttribArray *thread_data = &thread_data_local;
- /* command_allocated flag init. */
- thread_data->command_allocated = 0;
-
- if (!evas_gl_thread_force_finish())
- { /* _flush */
- EVGL_Thread_Command_glDisableVertexAttribArray *thread_data_new;
- thread_data_new = eina_mempool_malloc(_mp_command,
- sizeof(EVGL_Thread_Command_glDisableVertexAttribArray));
- if (thread_data_new)
- {
- thread_data = thread_data_new;
- thread_data->command_allocated = 1;
- thread_mode = EVAS_GL_THREAD_MODE_FLUSH;
- }
- }
-
thread_data->index = index;
evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_EVGL,
typedef struct
{
GLenum texture;
- int command_allocated;
} EVGL_Thread_Command_glActiveTexture;
glActiveTexture(thread_data->texture);
- if (thread_data->command_allocated)
- eina_mempool_free(_mp_command, thread_data);
}
EAPI void
EVGL_Thread_Command_glActiveTexture thread_data_local;
EVGL_Thread_Command_glActiveTexture *thread_data = &thread_data_local;
- /* command_allocated flag init. */
- thread_data->command_allocated = 0;
-
- if (!evas_gl_thread_force_finish())
- { /* _flush */
- EVGL_Thread_Command_glActiveTexture *thread_data_new;
- thread_data_new = eina_mempool_malloc(_mp_command,
- sizeof(EVGL_Thread_Command_glActiveTexture));
- if (thread_data_new)
- {
- thread_data = thread_data_new;
- thread_data->command_allocated = 1;
- thread_mode = EVAS_GL_THREAD_MODE_FLUSH;
- }
- }
-
thread_data->texture = texture;
evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_EVGL,
typedef struct
{
GLuint index;
- int command_allocated;
} Evas_Thread_Command_glEnableVertexAttribArray;
glEnableVertexAttribArray(thread_data->index);
- if (thread_data->command_allocated)
- eina_mempool_free(_mp_command, thread_data);
}
EAPI void
Evas_Thread_Command_glEnableVertexAttribArray thread_data_local;
Evas_Thread_Command_glEnableVertexAttribArray *thread_data = &thread_data_local;
- /* command_allocated flag init. */
- thread_data->command_allocated = 0;
-
- if (!evas_gl_thread_force_finish())
- { /* _flush */
- Evas_Thread_Command_glEnableVertexAttribArray *thread_data_new;
- thread_data_new = eina_mempool_malloc(_mp_command,
- sizeof(Evas_Thread_Command_glEnableVertexAttribArray));
- if (thread_data_new)
- {
- thread_data = thread_data_new;
- thread_data->command_allocated = 1;
- thread_mode = EVAS_GL_THREAD_MODE_ENQUEUE;
- }
- }
-
thread_data->index = index;
evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_GL,
typedef struct
{
GLuint index;
- int command_allocated;
} Evas_Thread_Command_glDisableVertexAttribArray;
glDisableVertexAttribArray(thread_data->index);
- if (thread_data->command_allocated)
- eina_mempool_free(_mp_command, thread_data);
}
EAPI void
Evas_Thread_Command_glDisableVertexAttribArray thread_data_local;
Evas_Thread_Command_glDisableVertexAttribArray *thread_data = &thread_data_local;
- /* command_allocated flag init. */
- thread_data->command_allocated = 0;
-
- if (!evas_gl_thread_force_finish())
- { /* _flush */
- Evas_Thread_Command_glDisableVertexAttribArray *thread_data_new;
- thread_data_new = eina_mempool_malloc(_mp_command,
- sizeof(Evas_Thread_Command_glDisableVertexAttribArray));
- if (thread_data_new)
- {
- thread_data = thread_data_new;
- thread_data->command_allocated = 1;
- thread_mode = EVAS_GL_THREAD_MODE_ENQUEUE;
- }
- }
-
thread_data->index = index;
evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_GL,
typedef struct
{
GLenum texture;
- int command_allocated;
} Evas_Thread_Command_glActiveTexture;
glActiveTexture(thread_data->texture);
- if (thread_data->command_allocated)
- eina_mempool_free(_mp_command, thread_data);
}
EAPI void
Evas_Thread_Command_glActiveTexture thread_data_local;
Evas_Thread_Command_glActiveTexture *thread_data = &thread_data_local;
- /* command_allocated flag init. */
- thread_data->command_allocated = 0;
-
- if (!evas_gl_thread_force_finish())
- { /* _flush */
- Evas_Thread_Command_glActiveTexture *thread_data_new;
- thread_data_new = eina_mempool_malloc(_mp_command,
- sizeof(Evas_Thread_Command_glActiveTexture));
- if (thread_data_new)
- {
- thread_data = thread_data_new;
- thread_data->command_allocated = 1;
- thread_mode = EVAS_GL_THREAD_MODE_FLUSH;
- }
- }
-
thread_data->texture = texture;
evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_GL,
# Vertex Arrays
## Vertex Array
| EVAS | void | glVertexAttribPointer | GLuint index,GLint size,GLenum type,GLboolean normalized,GLsizei stride,const void *pointer | finish | noext | | |
-| EVAS | void | glEnableVertexAttribArray | GLuint index | enqueue | noext | | |
-| EVAS | void | glDisableVertexAttribArray | GLuint index | enqueue | noext | | |
+| EVAS | void | glEnableVertexAttribArray | GLuint index | finish | noext | | |
+| EVAS | void | glDisableVertexAttribArray | GLuint index | finish | noext | | |
## Drawing
| EVAS | void | glDrawArrays | GLenum mode,GLint first,GLsizei count | finish | noext | | |
# Texturing
-| EVAS | void | glActiveTexture | GLenum texture | flush | noext | | |
+| EVAS | void | glActiveTexture | GLenum texture | finish | noext | | |
# Texture Objects
| EVAS | void | glGenTextures | GLsizei n,GLuint *textures | finish | noext | | |
# Vertex Arrays
## Vertex Array
| EVAS GL | void | glVertexAttribPointer | GLuint index,GLint size,GLenum type,GLboolean normalized,GLsizei stride,const void *pointer | finish | noext | | |
-| EVAS GL | void | glEnableVertexAttribArray | GLuint index | flush | noext | | |
-| EVAS GL | void | glDisableVertexAttribArray | GLuint index | flush | noext | | |
+| EVAS GL | void | glEnableVertexAttribArray | GLuint index | finish | noext | | |
+| EVAS GL | void | glDisableVertexAttribArray | GLuint index | finish | noext | | |
## Drawing
| EVAS GL | void | glDrawArrays | GLenum mode,GLint first,GLsizei count | finish | noext | | |
# Texturing
-| EVAS GL | void | glActiveTexture | GLenum texture | flush | noext | | |
+| EVAS GL | void | glActiveTexture | GLenum texture | finish | noext | | |
# Texture Objects
| EVAS GL | void | glGenTextures | GLsizei n,GLuint *textures | finish | noext | | |
| EVAS GL API | void | glDepthRangef | GLclampf zNear, GLclampf zFar | finish | noext | | |
| EVAS GL API | void | glDetachShader | GLuint program, GLuint shader | flush | noext | | |
| EVAS GL API | void | glDisable | GLenum cap | flush | noext | | |
-| EVAS GL API | void | glDisableVertexAttribArray | GLuint index | flush | noext | | |
+| EVAS GL API | void | glDisableVertexAttribArray | GLuint index | finish | noext | | |
| EVAS GL API | void | glDrawArrays | GLenum mode, GLint first, GLsizei count | finish | noext | | |
| EVAS GL API | void | glDrawElements | GLenum mode, GLsizei count, GLenum type, const void* indices | finish | noext | | |
| EVAS GL API | void | glEnable | GLenum cap | flush | noext | | |
-| EVAS GL API | void | glEnableVertexAttribArray | GLuint index | flush | noext | | |
+| EVAS GL API | void | glEnableVertexAttribArray | GLuint index | finish | noext | | |
| EVAS GL API | void | glFinish | void | finish | noext | | |
| EVAS GL API | void | glFlush | void | finish | noext | | |
| EVAS GL API | void | glFramebufferRenderbuffer | GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer | flush | noext | | |