From 8a633e6c6972934b03367906fd61d1606609bbb2 Mon Sep 17 00:00:00 2001 From: Sukwon Suh Date: Wed, 26 Jun 2013 11:59:58 +0900 Subject: [PATCH] modify RestoreContext method for performance Change-Id: I8e927cda526846ea82454b1ee344427dd43e4713 Signed-off-by: Sukwon Suh --- src/graphics/opengl/FGrpEgl.cpp | 100 ++++++++++++++++++++++++-------------- src/graphics/opengl/FGrpGles1.cpp | 9 ++++ src/graphics/opengl/FGrpGles2.cpp | 10 +++- 3 files changed, 81 insertions(+), 38 deletions(-) diff --git a/src/graphics/opengl/FGrpEgl.cpp b/src/graphics/opengl/FGrpEgl.cpp index ba91100..5815706 100644 --- a/src/graphics/opengl/FGrpEgl.cpp +++ b/src/graphics/opengl/FGrpEgl.cpp @@ -123,12 +123,13 @@ class _SglInfo; #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_) @@ -450,6 +451,10 @@ _OnBoundsChanged(void* pData) eglMakeCurrent(eglDisplay, drawSurface, readSurface, eglContext); } +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + __needRestoreContext = false; +#endif + return; } @@ -727,7 +732,9 @@ _GetEvasEngineType(Evas_Object* pObject) 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 @@ -758,7 +765,9 @@ _GetEvasEngineType(Evas_Object* pObject) 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"))) @@ -802,41 +811,9 @@ _EvasObjectImageChange(_SglInfo* pSglInfo) #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 @@ -885,6 +862,10 @@ _PostRenderCallback(Ecore_Evas* ee) , (unsigned int)surface , (unsigned int)context , (unsigned int)eglGetError()); + +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + __needRestoreContext = false; +#endif } } @@ -944,10 +925,52 @@ _UnregisterRenderCallback(Evas_Object* pObject) } } } + #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" { @@ -1961,6 +1984,9 @@ _SglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx 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) diff --git a/src/graphics/opengl/FGrpGles1.cpp b/src/graphics/opengl/FGrpGles1.cpp index d731f5c..7387b69 100644 --- a/src/graphics/opengl/FGrpGles1.cpp +++ b/src/graphics/opengl/FGrpGles1.cpp @@ -1058,6 +1058,11 @@ _GlGenerateMipmapOES_1(GLenum target) return (const GLubyte*) 0; \ } +#define FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) +void _RestoreContext(void); +#endif + namespace // unnamed { @@ -1440,6 +1445,10 @@ _GlesInterfaceInitialize_1(void) } } +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + _RestoreContext(); +#endif + return true; } diff --git a/src/graphics/opengl/FGrpGles2.cpp b/src/graphics/opengl/FGrpGles2.cpp index c204cea..6377041 100644 --- a/src/graphics/opengl/FGrpGles2.cpp +++ b/src/graphics/opengl/FGrpGles2.cpp @@ -41,7 +41,6 @@ #include #endif -#include "../util/FGrp_UtilTemplate.h" using namespace Tizen::Base; using namespace Tizen::Ui; using namespace Tizen::Ui::Controls; @@ -950,6 +949,11 @@ _GlViewport_2(GLint x, GLint y, GLsizei width, GLsizei height) return -1; \ } +#define FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) +void _RestoreContext(void); +#endif + namespace // unnamed { @@ -1295,6 +1299,10 @@ _GlesInterfaceInitialize_2(void) } } +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + _RestoreContext(); +#endif + return true; } -- 2.7.4