merge from tizen.2.1
authorSukwon Suh <sukwon.suh@samsung.com>
Mon, 10 Jun 2013 01:25:02 +0000 (10:25 +0900)
committerSukwon Suh <sukwon.suh@samsung.com>
Mon, 10 Jun 2013 01:25:02 +0000 (10:25 +0900)
Change-Id: I542d0cac6a83603c57232401cb9e9a1f023d4c87
Signed-off-by: Sukwon Suh <sukwon.suh@samsung.com>
src/graphics/opengl/FGrpEgl.cpp

index 59e3210..9925c9b 100644 (file)
@@ -27,6 +27,7 @@
 #include <X11/Xlib.h>
 #include <X11/Xmd.h>
 #include <EGL/egl.h>
+#include <EGL/eglext.h>
 
 #if defined(_OSP_EMUL_)
 #define FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER
@@ -173,6 +174,8 @@ public:
        , swapDone(false)
        , isFirstSwap(true)
        , pSecondSglInfo(null)
+       , pBitmapPointer(null)
+       , pBitmapLocked(null)
        {
        }
 
@@ -267,6 +270,8 @@ public:
        bool swapDone;
        bool isFirstSwap;
        _SglInfo* pSecondSglInfo;
+       void* pBitmapPointer;
+       Bitmap* pBitmapLocked;
 
 private:
        _SglInfo(const _SglInfo& sglInfo);
@@ -1699,7 +1704,17 @@ _SglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* p
                return eglQuerySurface(dpy, EGL_NO_SURFACE, attribute, pValue);
        }
 
-       EGLBoolean ret = eglQuerySurface(dpy, pSglInfo->surface, attribute, pValue);
+       EGLBoolean ret = EGL_FALSE;
+       if (attribute == EGL_BITMAP_POINTER_KHR)
+       {
+               *pValue = (EGLint)pSglInfo->pBitmapPointer;
+               ret = EGL_TRUE;
+       }
+       else
+       {
+               ret = eglQuerySurface(dpy, pSglInfo->surface, attribute, pValue);
+       }
+
        pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
 
        return ret;
@@ -2086,9 +2101,73 @@ _SglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
 
 typedef void (*__EglMustCastToProperFunctionPointerType)(void);
 
+EGLBoolean _SglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
+{
+       _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
+
+       _SglIndex sglIndex = (_SglIndex)surface;
+       _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
+
+       if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null || pSglInfo->pBitmap == null || pSglInfo->pBitmapLocked != null)
+       {
+               pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
+               SysLog(NID_GRP, "_SglLockSurfaceKHR failed!! dpy:%#x sglIndex:%#x", (unsigned int)display
+                               , (unsigned int)surface);
+               return EGL_FALSE;
+       }
+
+       _SglInfo* pSglInfoLock = pSglInfo;
+       BufferInfo bufferInfo;
+       if(!pSglInfo->isBackbuffer && pSglInfo->pSecondSglInfo != null)
+       {
+               pSglInfoLock = pSglInfo->pSecondSglInfo;
+       }
+
+       pSglInfoLock->pBitmap->Lock(bufferInfo);
+       pSglInfo->pBitmapPointer = bufferInfo.pPixels;
+       pSglInfo->pBitmapLocked = pSglInfoLock->pBitmap;
+       pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
+
+       return EGL_TRUE;
+}
+
+EGLBoolean _SglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
+{
+       _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
+
+       _SglIndex sglIndex = (_SglIndex)surface;
+       _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
+
+       if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null || pSglInfo->pBitmap == null || pSglInfo->pBitmapLocked == null)
+       {
+               pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
+               SysLog(NID_GRP, "_SglUnlockSurfaceKHR failed!! dpy:%#x sglIndex:%#x", (unsigned int)display
+                               , (unsigned int)surface);
+               return EGL_FALSE;
+       }
+
+       pSglInfo->pBitmapLocked->Unlock();
+       pSglInfo->pBitmapPointer = null;
+       pSglInfo->pBitmapLocked = null;
+       pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
+
+       return EGL_TRUE;
+}
+
 __EglMustCastToProperFunctionPointerType
 _SglGetProcAddress(const char* pProcName)
 {
+       String name(pProcName);
+
+       if (name.CompareTo(String("eglLockSurfaceKHR")) == 0)
+       {
+               return (__EglMustCastToProperFunctionPointerType)_SglLockSurfaceKHR;
+       }
+       else if (name.CompareTo(String("eglUnlockSurfaceKHR")) == 0)
+       {
+               return (__EglMustCastToProperFunctionPointerType)_SglUnlockSurfaceKHR;
+       }
+
        return eglGetProcAddress(pProcName);
 }