From b5d693654aba5bde72ccf8576f5391ae6d9f7c62 Mon Sep 17 00:00:00 2001 From: Sukwon Suh Date: Wed, 15 May 2013 15:54:45 +0900 Subject: [PATCH] rollback - support evas engine type Change-Id: I4b0a3dfd48f2361c44e65e2572f2f6182db309c5 Signed-off-by: Sukwon Suh --- src/graphics/opengl/FGrpEgl.cpp | 269 +++++++++++++++------------------------- 1 file changed, 100 insertions(+), 169 deletions(-) diff --git a/src/graphics/opengl/FGrpEgl.cpp b/src/graphics/opengl/FGrpEgl.cpp index 944a626..85b9aba 100644 --- a/src/graphics/opengl/FGrpEgl.cpp +++ b/src/graphics/opengl/FGrpEgl.cpp @@ -133,16 +133,10 @@ _SglInfo* __pPreviousSglInfo = null; #if !defined (_OSP_EMUL_) #define FGRAPHICS_INTERNAL_USE_DOUBLE_PIXMAP #endif +bool isDoublePixmapEnabled = false; -enum _engineType -{ - ENGINE_TYPE_SOFEWARE_X11 = 0, - ENGINE_TYPE_OPENGL_X11, - ENGINE_TYPE_ETC, -}; - -_engineType __evasEngineType = ENGINE_TYPE_SOFEWARE_X11; -bool __isDoublePixmapEnabled = false; +#define FGRAPHICS_INTERNAL_USE_EVAS_NATIVE_SURFACE +bool isEvasNativeSetEnabled = false; void _OnBoundsChanged(void* pData); @@ -187,10 +181,7 @@ public: } #endif - if (pObject == null) - { - return; - } + SysTryReturnVoidResult(NID_GRP, pObject != null, E_OPERATION_FAILED, "Invalid object."); if (pVisualElement != null) { @@ -209,11 +200,14 @@ public: delete pBitmap; bool needAllocateObject = true; - if (__isDoublePixmapEnabled) + if (isEvasNativeSetEnabled) { - if (!isBackbuffer) + if (isDoublePixmapEnabled) { - needAllocateObject = false; + if (!isBackbuffer) + { + needAllocateObject = false; + } } } if (needAllocateObject) @@ -398,7 +392,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."); @@ -462,7 +456,7 @@ _OnDestroyed(void* pData) { pSglInfo->pVisualElement = null; - if (__isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) + if (isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) { pSglInfo->pSecondSglInfo->pVisualElement = null; } @@ -710,106 +704,57 @@ _PixmapUnlockCallBack(void* pCallbackParam) } #endif -_engineType -_GetEvasEngineType(Evas_Object* pObject) +bool +_IsEvasGlEnabled(void) { - if (pObject == null) - { - const char* pString = elm_config_preferred_engine_get(); - String engineName(pString); - SysLog(NID_GRP, "evas backend : %s", pString); + const char* pString = elm_config_preferred_engine_get(); + String engineName(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; - } - } + if (engineName.Contains(String("opengl_x11"))) + { + SysLog(NID_GRP, "gl backend : %s", pString); + return true; + } + else if (engineName.Contains(String("software_x11"))) + { + SysLog(NID_GRP, "sw backend : %s", pString); + return false; } else { - 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); + pString = elm_config_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 - { - return ENGINE_TYPE_ETC; + SysLog(NID_GRP, "system gl backend : %s", pString); + return true; } } + + SysLog(NID_GRP, "system sw backend : %s", pString); + return false; } void _EvasObjectImageChange(_SglInfo* pSglInfo) { - if(__evasEngineType == ENGINE_TYPE_SOFEWARE_X11 || __evasEngineType == ENGINE_TYPE_OPENGL_X11) + Evas* pEvas = evas_object_evas_get(pSglInfo->pObject); + if (pEvas == null) { - 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_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); + return; } - else + + Evas_Engine_Info_GL_X11* pEvasInfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(pEvas); + if (pEvasInfo == null) { - BufferInfo bufferInfo; - pSglInfo->pBitmap->Lock(bufferInfo); - evas_object_image_data_set(pSglInfo->pObject, bufferInfo.pPixels); - pSglInfo->pBitmap->Unlock(); + return; } + 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) @@ -822,7 +767,7 @@ _PostRenderCallback(Ecore_Evas* ee) EGLSurface surface = __pPreviousSglInfo->surface; EGLContext context = __pPreviousSglInfo->context; - if (__isDoublePixmapEnabled) + if (isDoublePixmapEnabled) { _SglInfo* pBackSglInfo = null; _SglInfo* pFrontSglInfo = null; @@ -957,7 +902,7 @@ _SglTerminate(EGLDisplay dpy) _SglInfoTableManipulator::GetInstance()->DestroySglInfoTable(); - if (!__isDoublePixmapEnabled) + if (!_IsEvasGlEnabled()) { eglTerminate(dpy); } @@ -1009,7 +954,7 @@ _SglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType wi _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); #if 0//!defined(_OSP_EMUL_) - if (pFrame != null && _GetEvasEngineType(null) != ENGINE_TYPE_OPENGL_X11) + if (pFrame != null && !_IsEvasGlEnabled()) { _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl); _WindowImpl* pWindowImpl = dynamic_cast<_WindowImpl*> (pControlImpl); @@ -1055,6 +1000,18 @@ _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(); @@ -1129,22 +1086,7 @@ _SglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType wi pSglInfo->pVisualElementSurface = pVisualElementSurface; pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); - __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) + if (isDoublePixmapEnabled) { pObject = evas_object_image_filled_add(pEvas); SysTryReturn(NID_GRP, pObject != null, EGL_NO_SURFACE, E_OPERATION_FAILED, "Invalid object."); @@ -1692,7 +1634,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); @@ -1893,7 +1835,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; } @@ -1910,7 +1852,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; } @@ -2008,7 +1950,7 @@ _SglSwapBuffers(EGLDisplay dpy, EGLSurface surface) #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER) _SglUpdateBufferOSP(dpy, surface); #else - if(__evasEngineType == ENGINE_TYPE_OPENGL_X11) + if (isEvasNativeSetEnabled) { if (pSglInfo->glVersion == 1) { @@ -2025,67 +1967,56 @@ _SglSwapBuffers(EGLDisplay dpy, EGLSurface surface) } #endif - if(__evasEngineType == ENGINE_TYPE_SOFEWARE_X11 || __evasEngineType == ENGINE_TYPE_OPENGL_X11) + if (isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) { - if (__isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null) + if (pSglInfo->swapDone || pSglInfo->pSecondSglInfo->swapDone) { - if (pSglInfo->swapDone || pSglInfo->pSecondSglInfo->swapDone) + _SglInfo* pBackSglInfo = null; + _SglInfo* pFrontSglInfo = null; + + if (pSglInfo->isBackbuffer) { - _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(); - } + pBackSglInfo = pSglInfo; + pFrontSglInfo = pSglInfo->pSecondSglInfo; } - } - else - { - if (pSglInfo->pObject != null) + else { - evas_object_image_pixels_dirty_set(pSglInfo->pObject, EINA_TRUE); + 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 { - if (pSglInfo->pVisualElement != null) + if (pSglInfo->pObject != null) { - pSglInfo->pVisualElement->SetFlushNeeded(); + evas_object_image_pixels_dirty_set(pSglInfo->pObject, EINA_TRUE); } } - pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); return EGL_TRUE; } -- 2.7.4