From fd39c8f0a422f0a009bcb3ae1ecab29272c80345 Mon Sep 17 00:00:00 2001 From: Sukwon Suh Date: Mon, 20 May 2013 14:50:52 +0900 Subject: [PATCH] support evas engine type Change-Id: I31032063df63e61fc63300f655c51dd894940cb2 Signed-off-by: Sukwon Suh --- src/graphics/opengl/FGrpEgl.cpp | 269 +++++++++++++++++++++++++--------------- 1 file changed, 169 insertions(+), 100 deletions(-) diff --git a/src/graphics/opengl/FGrpEgl.cpp b/src/graphics/opengl/FGrpEgl.cpp index 85b9aba..944a626 100644 --- a/src/graphics/opengl/FGrpEgl.cpp +++ b/src/graphics/opengl/FGrpEgl.cpp @@ -133,10 +133,16 @@ _SglInfo* __pPreviousSglInfo = null; #if !defined (_OSP_EMUL_) #define FGRAPHICS_INTERNAL_USE_DOUBLE_PIXMAP #endif -bool isDoublePixmapEnabled = false; -#define FGRAPHICS_INTERNAL_USE_EVAS_NATIVE_SURFACE -bool isEvasNativeSetEnabled = false; +enum _engineType +{ + ENGINE_TYPE_SOFEWARE_X11 = 0, + ENGINE_TYPE_OPENGL_X11, + ENGINE_TYPE_ETC, +}; + +_engineType __evasEngineType = ENGINE_TYPE_SOFEWARE_X11; +bool __isDoublePixmapEnabled = false; void _OnBoundsChanged(void* pData); @@ -181,7 +187,10 @@ public: } #endif - SysTryReturnVoidResult(NID_GRP, pObject != null, E_OPERATION_FAILED, "Invalid object."); + if (pObject == null) + { + return; + } if (pVisualElement != null) { @@ -200,14 +209,11 @@ public: delete pBitmap; bool needAllocateObject = true; - if (isEvasNativeSetEnabled) + if (__isDoublePixmapEnabled) { - if (isDoublePixmapEnabled) + if (!isBackbuffer) { - if (!isBackbuffer) - { - needAllocateObject = false; - } + needAllocateObject = false; } } if (needAllocateObject) @@ -392,7 +398,7 @@ _OnBoundsChanged(void* pData) pSglInfo->swapDone = false; pSglInfo->isFirstSwap = true; - if (isDoublePixmapEnabled) + if (__isDoublePixmapEnabled) { _SglInfo* pSglInfoSecond = pSglInfo->pSecondSglInfo; SysTryReturnVoidResult(NID_GRP, pSglInfoSecond != null, E_INVALID_STATE, "Invalid pSecondSglInfo."); @@ -456,7 +462,7 @@ _OnDestroyed(void* pData) { pSglInfo->pVisualElement = null; - if (isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) + if (__isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) { pSglInfo->pSecondSglInfo->pVisualElement = null; } @@ -704,57 +710,106 @@ _PixmapUnlockCallBack(void* pCallbackParam) } #endif -bool -_IsEvasGlEnabled(void) +_engineType +_GetEvasEngineType(Evas_Object* pObject) { - const char* pString = elm_config_preferred_engine_get(); - String engineName(pString); - - if (engineName.Contains(String("opengl_x11"))) - { - SysLog(NID_GRP, "gl backend : %s", pString); - return true; - } - else if (engineName.Contains(String("software_x11"))) + if (pObject == null) { - SysLog(NID_GRP, "sw backend : %s", pString); - return false; + const char* pString = elm_config_preferred_engine_get(); + String engineName(pString); + SysLog(NID_GRP, "evas backend : %s", pString); + + if (engineName.Contains(String("opengl_x11"))) + { + return ENGINE_TYPE_OPENGL_X11; + } + else if (engineName.Contains(String("software_x11"))) + { + return ENGINE_TYPE_SOFEWARE_X11; + } + else + { + pString = elm_config_engine_get(); + String engineName(pString); + SysLog(NID_GRP, "system evas backend : %s", pString); + if (engineName.Contains(String("opengl_x11"))) + { + return ENGINE_TYPE_OPENGL_X11; + } + else + { + return ENGINE_TYPE_SOFEWARE_X11; + } + } } else { - pString = elm_config_engine_get(); + Evas* pEvas = evas_object_evas_get(pObject); + if (pEvas == null) + { + SysLogException(NID_GRP, E_OPERATION_FAILED, "Getting pEvas failed."); + return ENGINE_TYPE_SOFEWARE_X11; + } + + Ecore_Evas* pEcoreEvas = ecore_evas_ecore_evas_get(pEvas); + if (pEcoreEvas == null) + { + SysLogException(NID_GRP, E_OPERATION_FAILED, "Getting pEcoreEvas failed."); + return ENGINE_TYPE_SOFEWARE_X11; + } + + const char* pString = ecore_evas_engine_name_get(pEcoreEvas); String engineName(pString); + SysLog(NID_GRP, "evas backend : %s", pString); + if (engineName.Contains(String("opengl_x11"))) { - SysLog(NID_GRP, "system gl backend : %s", pString); - return true; + return ENGINE_TYPE_OPENGL_X11; + } + else if (engineName.Contains(String("software_x11"))) + { + return ENGINE_TYPE_SOFEWARE_X11; + } + else + { + return ENGINE_TYPE_ETC; } } - - SysLog(NID_GRP, "system sw backend : %s", pString); - return false; } void _EvasObjectImageChange(_SglInfo* pSglInfo) { - Evas* pEvas = evas_object_evas_get(pSglInfo->pObject); - if (pEvas == null) + if(__evasEngineType == ENGINE_TYPE_SOFEWARE_X11 || __evasEngineType == ENGINE_TYPE_OPENGL_X11) { - return; - } + Evas* pEvas = evas_object_evas_get(pSglInfo->pObject); + if (pEvas == null) + { + SysLogException(NID_GRP, E_OPERATION_FAILED, "Getting pEvas failed."); + return; + } + + Evas_Engine_Info_GL_X11* pEvasInfo = (Evas_Engine_Info_GL_X11*)evas_engine_info_get(pEvas); + if (pEvasInfo == null) + { + SysLog(NID_GRP, "Getting evas engine info failed!"); + return; + } - Evas_Engine_Info_GL_X11* pEvasInfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(pEvas); - if (pEvasInfo == null) + Evas_Native_Surface nativeSurface = {0, }; + nativeSurface.type = EVAS_NATIVE_SURFACE_X11; + nativeSurface.version = EVAS_NATIVE_SURFACE_VERSION; + nativeSurface.data.x11.pixmap = (unsigned long)pSglInfo->nativePixmap; + nativeSurface.data.x11.visual = pEvasInfo->info.visual; + evas_object_image_native_surface_set(pSglInfo->pObject, &nativeSurface); + } + else { - return; + BufferInfo bufferInfo; + pSglInfo->pBitmap->Lock(bufferInfo); + evas_object_image_data_set(pSglInfo->pObject, bufferInfo.pPixels); + pSglInfo->pBitmap->Unlock(); } - Evas_Native_Surface nativeSurface = {0, }; - nativeSurface.type = EVAS_NATIVE_SURFACE_X11; - nativeSurface.version = EVAS_NATIVE_SURFACE_VERSION; - nativeSurface.data.x11.pixmap = (unsigned long)pSglInfo->nativePixmap; - nativeSurface.data.x11.visual = pEvasInfo->info.visual; - evas_object_image_native_surface_set(pSglInfo->pObject, &nativeSurface); } #if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) @@ -767,7 +822,7 @@ _PostRenderCallback(Ecore_Evas* ee) EGLSurface surface = __pPreviousSglInfo->surface; EGLContext context = __pPreviousSglInfo->context; - if (isDoublePixmapEnabled) + if (__isDoublePixmapEnabled) { _SglInfo* pBackSglInfo = null; _SglInfo* pFrontSglInfo = null; @@ -902,7 +957,7 @@ _SglTerminate(EGLDisplay dpy) _SglInfoTableManipulator::GetInstance()->DestroySglInfoTable(); - if (!_IsEvasGlEnabled()) + if (!__isDoublePixmapEnabled) { eglTerminate(dpy); } @@ -954,7 +1009,7 @@ _SglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType wi _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); #if 0//!defined(_OSP_EMUL_) - if (pFrame != null && !_IsEvasGlEnabled()) + if (pFrame != null && _GetEvasEngineType(null) != ENGINE_TYPE_OPENGL_X11) { _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl); _WindowImpl* pWindowImpl = dynamic_cast<_WindowImpl*> (pControlImpl); @@ -1000,18 +1055,6 @@ _SglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType wi { result r = E_SUCCESS; -#if defined (FGRAPHICS_INTERNAL_USE_EVAS_NATIVE_SURFACE) - isEvasNativeSetEnabled = _IsEvasGlEnabled(); -#else - isEvasNativeSetEnabled = false; -#endif - -#if defined (FGRAPHICS_INTERNAL_USE_DOUBLE_PIXMAP) - isDoublePixmapEnabled = isEvasNativeSetEnabled; -#else - isDoublePixmapEnabled = false; -#endif - if (pVisualElement == null) { pVisualElement = pControl->GetVisualElement(); @@ -1086,7 +1129,22 @@ _SglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType wi pSglInfo->pVisualElementSurface = pVisualElementSurface; pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); - if (isDoublePixmapEnabled) + __evasEngineType = _GetEvasEngineType(pObject); + +#if defined (FGRAPHICS_INTERNAL_USE_DOUBLE_PIXMAP) + if (__evasEngineType == ENGINE_TYPE_OPENGL_X11) + { + __isDoublePixmapEnabled = true; + } + else + { + __isDoublePixmapEnabled = false; + } +#else + __isDoublePixmapEnabled = false; +#endif + + if (__isDoublePixmapEnabled) { pObject = evas_object_image_filled_add(pEvas); SysTryReturn(NID_GRP, pObject != null, EGL_NO_SURFACE, E_OPERATION_FAILED, "Invalid object."); @@ -1634,7 +1692,7 @@ _SglDestroySurface(EGLDisplay dpy, EGLSurface surface) ret = eglDestroySurface(dpy, pSglInfo->surface); pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); - if (isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) + if (__isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) { eglDestroySurface(dpy, pSglInfo->pSecondSglInfo->surface); pSglInfoTableManipulatorInstance->DestroySglIndex(pSglInfo->pSecondSglInfo->sglIndex); @@ -1835,7 +1893,7 @@ _SglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx } sglInfoReadSurface = sglInfoRead->surface; - if (isDoublePixmapEnabled && !sglInfoRead->isBackbuffer) + if (__isDoublePixmapEnabled && !sglInfoRead->isBackbuffer) { sglInfoReadSurface = sglInfoRead->pSecondSglInfo->surface; } @@ -1852,7 +1910,7 @@ _SglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx return eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx); } - if (isDoublePixmapEnabled && !pSglInfoDraw->isBackbuffer && pSglInfoDraw->pSecondSglInfo != null) + if (__isDoublePixmapEnabled && !pSglInfoDraw->isBackbuffer && pSglInfoDraw->pSecondSglInfo != null) { pSglInfoDraw = pSglInfoDraw->pSecondSglInfo; } @@ -1950,7 +2008,7 @@ _SglSwapBuffers(EGLDisplay dpy, EGLSurface surface) #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER) _SglUpdateBufferOSP(dpy, surface); #else - if (isEvasNativeSetEnabled) + if(__evasEngineType == ENGINE_TYPE_OPENGL_X11) { if (pSglInfo->glVersion == 1) { @@ -1967,56 +2025,67 @@ _SglSwapBuffers(EGLDisplay dpy, EGLSurface surface) } #endif - if (isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) + if(__evasEngineType == ENGINE_TYPE_SOFEWARE_X11 || __evasEngineType == ENGINE_TYPE_OPENGL_X11) { - if (pSglInfo->swapDone || pSglInfo->pSecondSglInfo->swapDone) + if (__isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) { - _SglInfo* pBackSglInfo = null; - _SglInfo* pFrontSglInfo = null; - - if (pSglInfo->isBackbuffer) + if (pSglInfo->swapDone || pSglInfo->pSecondSglInfo->swapDone) { - pBackSglInfo = pSglInfo; - pFrontSglInfo = pSglInfo->pSecondSglInfo; + _SglInfo* pBackSglInfo = null; + _SglInfo* pFrontSglInfo = null; + + if (pSglInfo->isBackbuffer) + { + pBackSglInfo = pSglInfo; + pFrontSglInfo = pSglInfo->pSecondSglInfo; + } + else + { + pBackSglInfo = pSglInfo->pSecondSglInfo; + pFrontSglInfo = pSglInfo; + } + pBackSglInfo->isBackbuffer = false; + pFrontSglInfo->isBackbuffer = true; + + pFrontSglInfo->wasShown = false; + pFrontSglInfo->swapDone = false; + if (pSglInfo->pVisualElement != null) + { + pSglInfo->pVisualElement->SetSurface(pFrontSglInfo->pVisualElementSurface); + } + evas_object_image_pixels_dirty_set(pFrontSglInfo->pObject, EINA_TRUE); + evas_object_hide(pBackSglInfo->pObject); + + if (pSglInfo->isFirstSwap) + { + pBackSglInfo->isFirstSwap = false; + pFrontSglInfo->isFirstSwap = false; + + eglWaitGL(); + BufferInfo bufferInfo; + pFrontSglInfo->pBitmap->Lock(bufferInfo); + pFrontSglInfo->pBitmap->Merge(Point(0, 0), *pBackSglInfo->pBitmap, Rectangle(0, 0, bufferInfo.width, bufferInfo.height)); + pFrontSglInfo->pBitmap->Unlock(); + } } - else - { - pBackSglInfo = pSglInfo->pSecondSglInfo; - pFrontSglInfo = pSglInfo; - } - pBackSglInfo->isBackbuffer = false; - pFrontSglInfo->isBackbuffer = true; - - pFrontSglInfo->wasShown = false; - pFrontSglInfo->swapDone = false; - if (pSglInfo->pVisualElement != null) - { - pSglInfo->pVisualElement->SetSurface(pFrontSglInfo->pVisualElementSurface); - } - evas_object_image_pixels_dirty_set(pFrontSglInfo->pObject, EINA_TRUE); - evas_object_hide(pBackSglInfo->pObject); - - if (pSglInfo->isFirstSwap) + } + else + { + if (pSglInfo->pObject != null) { - pBackSglInfo->isFirstSwap = false; - pFrontSglInfo->isFirstSwap = false; - - eglWaitGL(); - BufferInfo bufferInfo; - pFrontSglInfo->pBitmap->Lock(bufferInfo); - pFrontSglInfo->pBitmap->Merge(Point(0, 0), *pBackSglInfo->pBitmap, Rectangle(0, 0, bufferInfo.width, bufferInfo.height)); - pFrontSglInfo->pBitmap->Unlock(); + evas_object_image_pixels_dirty_set(pSglInfo->pObject, EINA_TRUE); } } } else { - if (pSglInfo->pObject != null) + if (pSglInfo->pVisualElement != null) { - evas_object_image_pixels_dirty_set(pSglInfo->pObject, EINA_TRUE); + pSglInfo->pVisualElement->SetFlushNeeded(); } } + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); return EGL_TRUE; } -- 2.7.4