0.0f, 1.0f
};
-PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = NULL;
-PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = NULL;
-PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = NULL;
-
SharedIndicatorInfo shared_info;
GLuint textureID;
GLuint indicator_vbo, indicator_ibo;
for (n=0; n < SHARED_FILE_NUMBER; n++)
Tizen_Indicator_SharedFile_Free(&shared_info, n);
- if(shared_info.eglImage_Indicator != NULL)
- eglDestroyImageKHR(SDL_GetVideoDevice()->egl_data->egl_display, shared_info.eglImage_Indicator);
-
- if (shared_info.tizen_rs)
- tizen_remote_surface_destroy(shared_info.tizen_rs);
- if (shared_info.tbm_client)
- wayland_tbm_client_deinit(shared_info.tbm_client);
- if (shared_info.tizen_rsm)
- tizen_remote_surface_manager_destroy(shared_info.tizen_rsm);
GLES2_Context Mainctx;
LoadContext(&Mainctx);
return SDL_TRUE;
}
-SDL_bool Tizen_remote_surface_init(void)
-{
- Eina_Inlist *globals;
- Ecore_Wl_Global *global;
- struct wl_registry *registry;
- if (!shared_info.tizen_rsm)
- {
- registry = ecore_wl_registry_get();
- globals = ecore_wl_globals_get();
-
- if (!registry || !globals)
- {
- SDL_Log( "Could not get registry(%p) or global list(%p)\n", registry, globals);
- return SDL_FALSE;
- }
-
- EINA_INLIST_FOREACH(globals, global)
- {
- if (!strcmp(global->interface, "tizen_remote_surface_manager"))
- {
- shared_info.tizen_rsm = wl_registry_bind(registry, global->id,
- &tizen_remote_surface_manager_interface, global->version<2? global->version : 2);
- SDL_Log("[SDL] Create tizen_rsm : %p",shared_info.tizen_rsm);
- }
- }
- shared_info.tizen_rs = NULL;
- }
- if (!shared_info.tizen_rsm)
- {
- SDL_Log("Could not bind tizen_remote_surface_manager");
- return SDL_FALSE;
- }
-
- if(!shared_info.tbm_client)
- {
- shared_info.tbm_client = (struct wayland_tbm_client *)wayland_tbm_client_init(ecore_wl_display_get());
- shared_info.wl_tbm = (struct wl_tbm *)wayland_tbm_client_get_wl_tbm(shared_info.tbm_client);
- if (!shared_info.wl_tbm)
- {
- SDL_Log("[SDL]wl_tbm is NULL");
- return SDL_FALSE;
- }
- }
-
- eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)SDL_GetVideoDevice()->egl_data->eglGetProcAddress("eglCreateImageKHR");
- eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)SDL_GetVideoDevice()->egl_data->eglGetProcAddress("eglDestroyImageKHR");
- glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)SDL_GetVideoDevice()->egl_data->eglGetProcAddress("glEGLImageTargetTexture2DOES");
-
- return SDL_TRUE;
-}
-
-struct wl_buffer *pre_buffer; //pre_buffer for tizen remote surface
-
-static void
-_tizen_rs_cb_buffer_update(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time)
-{
- tizen_remote_surface_transfer_visibility(trs, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE);
- tbm_surface_h tbmSurface= wl_buffer_get_user_data(buffer);
- if(eglCreateImageKHR != NULL && glEGLImageTargetTexture2DOES != NULL && eglDestroyImageKHR != NULL)
- {
- SDL_VideoDevice *_this = SDL_GetVideoDevice();
-
- if(shared_info.eglImage_Indicator != NULL)
- eglDestroyImageKHR(_this->egl_data->egl_display, shared_info.eglImage_Indicator);
-
- shared_info.eglImage_Indicator = eglCreateImageKHR(_this->egl_data->egl_display,
- EGL_NO_CONTEXT, EGL_NATIVE_SURFACE_TIZEN, tbmSurface, NULL);
-
- if(shared_info.eglImage_Indicator == NULL)
- {
- SDL_Log("[SDL] eglImage is NULL");
- return;
- }
- SDL_Log("[SDL] eglImage : %p", shared_info.eglImage_Indicator);
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, shared_info.eglImage_Indicator);
- }
- else
- {
- tbm_surface_info_s info;
- tbm_surface_map(tbmSurface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info);
-
- SDL_Log("[SDL] Buffer Update %p %p (%dx%d), format:%d", buffer, tbmSurface, info.width, info.height, info.format);
- SDL_Log("[SDL] Info size:%d, offset:%d, stride:%d", info.planes[0].size, info.planes[0].offset, info.planes[0].stride);
-
- GLES2_Context Mainctx;
- LoadContext(&Mainctx);
-
- Mainctx.glActiveTexture(GL_TEXTURE0);
-
- Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
- Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, info.planes[0].stride/4, info.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned int*)info.planes[0].ptr);
-
- if (tbm_surface_unmap (tbmSurface) != TBM_SURFACE_ERROR_NONE)
- SDL_Log("Failed to unmap tbm_surface\n");
- }
-
- if( pre_buffer)
- {
- if (tizen_remote_surface_get_version(trs) >= TIZEN_REMOTE_SURFACE_RELEASE_SINCE_VERSION)
- tizen_remote_surface_release(trs, pre_buffer);
- }
- pre_buffer = buffer;
-
- if (tbm_surface_destroy (tbmSurface) != TBM_SURFACE_ERROR_NONE)
- SDL_Log("Failed to destroy tbm_surface\n");
-
-}
-
-static void
-_tizen_rs_cb_missing(void *data, struct tizen_remote_surface *trs)
-{
- SDL_Log("Plug is missing...! ");
-}
-
-static const struct tizen_remote_surface_listener _extn_gl_plug_listener =
-{
- _tizen_rs_cb_buffer_update,
- _tizen_rs_cb_missing,
-};
-
-void Tizen_remote_indicator(int res_id)
-{
- if(!shared_info.tizen_rs) {
- //create tizen_remote_surface
- shared_info.tizen_rs = tizen_remote_surface_manager_create_surface(shared_info.tizen_rsm, res_id, shared_info.wl_tbm);
- if(!shared_info.tizen_rs)
- {
- SDL_Log("tizen_rs is NULL");
- return;
- }
- tizen_remote_surface_add_listener(shared_info.tizen_rs, &_extn_gl_plug_listener, NULL);
- tizen_remote_surface_redirect(shared_info.tizen_rs);
- }
-}
#endif /* SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL */