#define FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT
#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
-void _RestoreContext(void);
+void __RestoreContext(void);
void _PostRenderCallback(Ecore_Evas* ee);
void _SaveCurrentContext(_SglInfo* pSglInfo);
void _UnregisterRenderCallback(Evas_Object* pObject);
int __registerCallbackCount = 0;
_SglInfo* __pPreviousSglInfo = null;
+bool __needRestoreContext = false;
#endif
#if !defined (_OSP_EMUL_)
eglMakeCurrent(eglDisplay, drawSurface, readSurface, eglContext);
}
+#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
+ __needRestoreContext = false;
+#endif
+
return;
}
if (engineName.Contains(String("opengl_x11")))
{
_DisplayManager* pDisplayManger = _DisplayManager::GetInstance();
- pDisplayManger->SetRestoreContextCallback(_RestoreContext);
+#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
+ pDisplayManger->SetRestoreContextCallback(__RestoreContext);
+#endif
return ENGINE_TYPE_OPENGL_X11;
}
else
if (engineName.Contains(String("opengl_x11")))
{
_DisplayManager* pDisplayManger = _DisplayManager::GetInstance();
- pDisplayManger->SetRestoreContextCallback(_RestoreContext);
+#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
+ pDisplayManger->SetRestoreContextCallback(__RestoreContext);
+#endif
return ENGINE_TYPE_OPENGL_X11;
}
else if (engineName.Contains(String("software_x11")))
#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
void
-_RestoreContext(void)
+__RestoreContext(void)
{
- if (__pPreviousSglInfo != null)
- {
- EGLDisplay display = __pPreviousSglInfo->display;
- EGLSurface surface = __pPreviousSglInfo->surface;
- EGLContext context = __pPreviousSglInfo->context;
-
- if (__isDoublePixmapEnabled)
- {
- _SglInfo* pBackSglInfo = null;
- _SglInfo* pFrontSglInfo = null;
-
- if (__pPreviousSglInfo->isBackbuffer)
- {
- pBackSglInfo = __pPreviousSglInfo;
- pFrontSglInfo = __pPreviousSglInfo->pSecondSglInfo;
- }
- else
- {
- pBackSglInfo = __pPreviousSglInfo->pSecondSglInfo;
- pFrontSglInfo = __pPreviousSglInfo;
- }
-
- surface = pBackSglInfo->surface;
- }
-
- EGLBoolean ret = eglMakeCurrent(display, surface, surface, context);
- SysTryLog(NID_GRP, ret == EGL_TRUE, "fail to restore previous surface and context. %#x %#x %#x %#x egl error:%#x"
- , (unsigned int)display
- , (unsigned int)surface
- , (unsigned int)surface
- , (unsigned int)context
- , (unsigned int)eglGetError());
- }
+ __needRestoreContext = true;
}
void
, (unsigned int)surface
, (unsigned int)context
, (unsigned int)eglGetError());
+
+#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
+ __needRestoreContext = false;
+#endif
}
}
}
}
}
+
#endif //#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
}
+#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
+void _RestoreContext(void)
+{
+ if (__needRestoreContext && __pPreviousSglInfo != null)
+ {
+ EGLDisplay display = __pPreviousSglInfo->display;
+ EGLSurface surface = __pPreviousSglInfo->surface;
+ EGLContext context = __pPreviousSglInfo->context;
+
+ if (__isDoublePixmapEnabled)
+ {
+ _SglInfo* pBackSglInfo = null;
+ _SglInfo* pFrontSglInfo = null;
+
+ if (__pPreviousSglInfo->isBackbuffer)
+ {
+ pBackSglInfo = __pPreviousSglInfo;
+ pFrontSglInfo = __pPreviousSglInfo->pSecondSglInfo;
+ }
+ else
+ {
+ pBackSglInfo = __pPreviousSglInfo->pSecondSglInfo;
+ pFrontSglInfo = __pPreviousSglInfo;
+ }
+
+ surface = pBackSglInfo->surface;
+ }
+
+ EGLBoolean ret = eglMakeCurrent(display, surface, surface, context);
+ SysTryLog(NID_GRP, ret == EGL_TRUE, "fail to restore previous surface and context. %#x %#x %#x %#x egl error:%#x"
+ , (unsigned int)display
+ , (unsigned int)surface
+ , (unsigned int)surface
+ , (unsigned int)context
+ , (unsigned int)eglGetError());
+
+ __needRestoreContext = false;
+ }
+}
+#endif
+
#ifdef __cplusplus
extern "C"
{
pSglInfoDraw->context = ctx;
EGLBoolean ret = eglMakeCurrent(dpy, pSglInfoDraw->surface, sglInfoReadSurface, ctx);
+#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
+ __needRestoreContext = false;
+#endif
#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
if (draw != EGL_NO_SURFACE)