2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
20 * @brief This is the implementation file for egl.
30 #include <EGL/eglext.h>
32 #if defined(_OSP_EMUL_)
33 #define FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER
35 #define FGRAPHICS_INTERNAL_USE_DRM
38 #define FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING
39 #if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING)
43 #include <Ecore_Evas.h>
46 #include <FBaseSysLog.h>
47 #include <FGrpBitmap.h>
48 #include <FGrpCoordinateSystem.h>
49 #include <FUiControl.h>
50 #include <FUiCtrlForm.h>
51 #include <FUiCtrlFrame.h>
52 #include <FUiWindow.h>
54 #include <FUi_EcoreEvasMgr.h>
55 #include <FUi_EcoreEvas.h>
57 #include <FGrp_BitmapTool.h>
58 #include <FGrp_BitmapImpl.h>
59 #include <FUi_ControlImpl.h>
60 #include <FUi_Control.h>
61 #include <FUi_WindowImpl.h>
62 #include <FUiAnim_VisualElementSurfaceImpl.h>
63 #include <FUiAnim_VisualElementImpl.h>
71 #include <elm_config.h>
73 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
77 #include <tbm_bufmgr.h>
81 typedef int _SglIndex;
84 _SglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* pAttribList);
85 EGLSurface _SglGetCurrentSurface(EGLint readDraw);
86 EGLNativePixmapType _CreateNativePixmap(_SglIndex sglIndex, Tizen::Graphics::Bitmap* pixmap);
87 EGLNativePixmapType _CreateNativePixmapEx(Tizen::Graphics::Bitmap* pBitmap, Tizen::Graphics::BufferInfo bufferInfo);
89 #if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING)
90 void _GlesInterfaceTerminate_1();
91 void _GlesInterfaceTerminate_2();
94 #include <GLES2/gl2.h>
96 void _GlFlush_1(void);
97 void _GlFlush_2(void);
98 void _GlClear_1(GLbitfield mask);
99 void _GlClear_2(GLbitfield mask);
101 EGLBoolean _SglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
103 using namespace Tizen::Ui::Controls;
109 using namespace Tizen::Ui::Animations;
110 using namespace Tizen::Ui;
111 using namespace Tizen::Base;
113 namespace Tizen { namespace Graphics
124 #define FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT
125 #if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
126 void _PostRenderCallback(Ecore_Evas* ee);
127 void _SaveCurrentContext(_SglInfo* pSglInfo);
128 void _UnregisterRenderCallback(Evas_Object* pObject);
129 int __registerCallbackCount = 0;
130 _SglInfo* __pPreviousSglInfo = null;
133 #if !defined (_OSP_EMUL_)
134 #define FGRAPHICS_INTERNAL_USE_DOUBLE_PIXMAP
139 ENGINE_TYPE_SOFEWARE_X11 = 0,
140 ENGINE_TYPE_OPENGL_X11,
144 _engineType __evasEngineType = ENGINE_TYPE_SOFEWARE_X11;
145 bool __isDoublePixmapEnabled = false;
147 void _OnBoundsChanged(void* pData);
149 const int INVALID_SGL_INDEX = 0;
150 const int MAX_SGL_INDEX = 100;
156 : sglIndex(INVALID_SGL_INDEX)
157 , display(EGL_NO_DISPLAY)
158 , surface(EGL_NO_SURFACE)
159 , context(EGL_NO_CONTEXT)
160 , config((EGLConfig)0)
163 , nativePixmap((EGLNativePixmapType)0)
164 , pVisualElement(null)
165 , pVisualElementSurface(null)
168 #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
176 , pSecondSglInfo(null)
177 , pBitmapPointer(null)
178 , pBitmapLocked(null)
182 virtual ~_SglInfo(void)
184 #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
185 if (pEcoreImage != null)
187 ecore_x_image_free(pEcoreImage);
196 if (pVisualElement != null)
198 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*pVisualElement);
199 if (pVisualElementImpl != null)
201 pVisualElementImpl->SetDestroyedCallback(null, null);
205 #if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
206 _UnregisterRenderCallback(pObject);
208 evas_object_del(pObject);
209 delete pVisualElementSurface;
212 bool needAllocateObject = true;
213 if (__isDoublePixmapEnabled)
217 needAllocateObject = false;
220 if (needAllocateObject)
222 if (pVisualElement != null)
224 pVisualElement->SetSurface(null);
228 sglIndex = INVALID_SGL_INDEX;
229 display = EGL_NO_DISPLAY;
230 surface = EGL_NO_SURFACE;
231 context = EGL_NO_CONTEXT;
232 config = (EGLConfig)0;
235 nativePixmap = (EGLNativePixmapType)0;
236 pVisualElement = null;
237 pVisualElementSurface = null;
240 #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
248 pSecondSglInfo = null;
258 Evas_Object* pObject;
259 EGLNativePixmapType nativePixmap;
260 VisualElement* pVisualElement;
261 VisualElementSurface* pVisualElementSurface;
263 Tizen::Ui::Window* pWindow;
264 #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
265 Ecore_X_Image* pEcoreImage;
272 _SglInfo* pSecondSglInfo;
273 void* pBitmapPointer;
274 Bitmap* pBitmapLocked;
277 _SglInfo(const _SglInfo& sglInfo);
278 _SglInfo& operator =(const _SglInfo& rhs);
285 : nativePixmap((Pixmap)0)
286 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
288 , pTbmBufferObject(null)
294 virtual ~_PixmapInfo(void)
296 Display* pDisplay = (Display*)ecore_x_display_get();
297 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
298 tbm_bo_unmap(pTbmBufferObject);
299 tbm_bo_unref(pTbmBufferObject);
305 tbm_bufmgr_deinit(pTbmBufMgr);
306 DRI2DestroyDrawable(pDisplay, nativePixmap);
308 XFreePixmap(pDisplay, nativePixmap);
310 nativePixmap = (Pixmap)0;
311 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
313 pTbmBufferObject = null;
320 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
321 tbm_bufmgr pTbmBufMgr;
322 tbm_bo pTbmBufferObject;
327 void _EvasObjectImageChange(_SglInfo* pSglInfo);
330 _OnBoundsChanged(void* pData)
332 _SglInfo* pSglInfo = dynamic_cast<_SglInfo*> ((_SglInfo*)pData);
333 SysTryReturnVoidResult(NID_GRP, pSglInfo != null
334 && pSglInfo->sglIndex > INVALID_SGL_INDEX
335 && pSglInfo->pVisualElement != null
336 && pSglInfo->pWindow != null
337 , E_INVALID_STATE, "Invalid state.");
339 if (pSglInfo == __pPreviousSglInfo || pSglInfo->pSecondSglInfo == __pPreviousSglInfo)
341 __pPreviousSglInfo = null;
344 bool needSglMakeCurrent = false;
345 EGLDisplay eglDisplay = eglGetCurrentDisplay();
346 EGLSurface drawSurface = _SglGetCurrentSurface(EGL_DRAW);
347 EGLSurface readSurface = _SglGetCurrentSurface(EGL_READ);
348 EGLSurface eglContext = eglGetCurrentContext();
350 if (drawSurface != EGL_NO_SURFACE && readSurface != EGL_NO_SURFACE)
352 needSglMakeCurrent = true;
356 drawSurface = eglGetCurrentSurface(EGL_DRAW);
357 readSurface = eglGetCurrentSurface(EGL_READ);
360 eglMakeCurrent(pSglInfo->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
361 EGLBoolean ret = eglDestroySurface(pSglInfo->display, pSglInfo->surface);
362 pSglInfo->surface = null;
363 SysTryReturnVoidResult(NID_GRP, ret == EGL_TRUE, E_OPERATION_FAILED, "eglDestroySurface failed.");
365 #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
366 if (pSglInfo->pEcoreImage != null)
368 ecore_x_image_free(pSglInfo->pEcoreImage);
369 pSglInfo->pEcoreImage = null;
373 FloatRectangle rect = pSglInfo->pVisualElement->GetBounds();
374 int width = int(rect.width);
375 int height = int(rect.height);
376 SysTryReturnVoidResult(NID_GRP, width > 0 && height > 0, E_OUT_OF_RANGE, "Invalid size. w:%d h:%d", width, height);
377 int widthPhysical = static_cast<int> (CoordinateSystem::ConvertToPhysicalX(rect.width));
378 int heightPhysical = static_cast<int> (CoordinateSystem::ConvertToPhysicalY(rect.height));
379 SysTryReturnVoidResult(NID_GRP, widthPhysical > 0 && heightPhysical > 0, E_OUT_OF_RANGE, "Invalid size. w:%d h:%d", widthPhysical, heightPhysical);
381 evas_object_image_size_set(pSglInfo->pObject, widthPhysical, heightPhysical);
382 evas_object_resize(pSglInfo->pObject, widthPhysical, heightPhysical);
384 delete pSglInfo->pBitmap;
385 pSglInfo->pBitmap = null;
386 std::auto_ptr <Bitmap> bitmap(new (std::nothrow) Bitmap);
387 SysTryReturnVoidResult(NID_GRP, bitmap.get() != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
388 result r = bitmap.get()->Construct(Rectangle(0, 0, width, height));
389 SysTryReturnVoidResult(NID_GRP, r == E_SUCCESS, r, "Propagating.");
390 EGLNativePixmapType nativePixmap = _CreateNativePixmap(pSglInfo->sglIndex, bitmap.get());
391 SysTryReturnVoidResult(NID_GRP, nativePixmap != (EGLNativePixmapType)0, E_OPERATION_FAILED, "Propagating.");
392 EGLSurface eglSurface = eglCreatePixmapSurface(pSglInfo->display, pSglInfo->config, nativePixmap, null);
393 SysTryReturnVoidResult(NID_GRP, eglSurface != EGL_NO_SURFACE, E_OPERATION_FAILED, "eglCreatePixmapSurface failed.");
395 pSglInfo->nativePixmap = nativePixmap;
396 pSglInfo->surface = eglSurface;
397 pSglInfo->isBackbuffer = true;
398 pSglInfo->swapDone = false;
399 pSglInfo->isFirstSwap = true;
401 if (__isDoublePixmapEnabled)
403 _SglInfo* pSglInfoSecond = pSglInfo->pSecondSglInfo;
404 SysTryReturnVoidResult(NID_GRP, pSglInfoSecond != null, E_INVALID_STATE, "Invalid pSecondSglInfo.");
406 eglMakeCurrent(pSglInfo->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
407 ret = eglDestroySurface(pSglInfoSecond->display, pSglInfoSecond->surface);
408 pSglInfoSecond->surface = null;
409 SysTryReturnVoidResult(NID_GRP, ret == EGL_TRUE, E_OPERATION_FAILED, "eglDestroySurface failed.");
411 evas_object_image_size_set(pSglInfoSecond->pObject, widthPhysical, heightPhysical);
412 evas_object_resize(pSglInfoSecond->pObject, widthPhysical, heightPhysical);
414 delete pSglInfoSecond->pBitmap;
415 pSglInfoSecond->pBitmap = null;
416 std::auto_ptr <Bitmap> bitmapSecond(new (std::nothrow) Bitmap);
417 SysTryReturnVoidResult(NID_GRP, bitmapSecond.get() != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
418 r = bitmapSecond.get()->Construct(Rectangle(0, 0, width, height));
419 SysTryReturnVoidResult(NID_GRP, r == E_SUCCESS, r, "Propagating.");
420 EGLNativePixmapType nativePixmap = _CreateNativePixmap(pSglInfoSecond->sglIndex, bitmapSecond.get());
421 SysTryReturnVoidResult(NID_GRP, nativePixmap != (EGLNativePixmapType)0, E_OPERATION_FAILED, "Propagating.");
422 EGLSurface eglSurface = eglCreatePixmapSurface(pSglInfoSecond->display, pSglInfoSecond->config, nativePixmap, null);
423 SysTryReturnVoidResult(NID_GRP, eglSurface != EGL_NO_SURFACE, E_OPERATION_FAILED, "eglCreatePixmapSurface failed.");
425 pSglInfoSecond->nativePixmap = nativePixmap;
426 pSglInfoSecond->surface = eglSurface;
427 pSglInfoSecond->pBitmap = bitmapSecond.release();
428 pSglInfoSecond->isBackbuffer = true;
429 pSglInfoSecond->swapDone = true;
431 pSglInfo->isFirstSwap = true;
433 _EvasObjectImageChange(pSglInfoSecond);
436 pSglInfo->pBitmap = bitmap.release();
437 _EvasObjectImageChange(pSglInfo);
439 BufferInfo bufferInfo;
440 pSglInfo->pBitmap->Lock(bufferInfo);
441 pSglInfo->pBitmap->Unlock();
443 if (needSglMakeCurrent)
445 _SglMakeCurrent(eglDisplay, drawSurface, readSurface, eglContext);
449 eglMakeCurrent(eglDisplay, drawSurface, readSurface, eglContext);
456 _OnDestroyed(void* pData)
458 _SglInfo* pSglInfo = dynamic_cast<_SglInfo*> ((_SglInfo*)pData);
460 if (pSglInfo != null)
462 pSglInfo->pVisualElement = null;
464 if (__isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null)
466 pSglInfo->pSecondSglInfo->pVisualElement = null;
471 class _SglInfoTableManipulator
474 _SglInfoTableManipulator()
476 result r = __SglMutex.Create();
477 SysTryLog(NID_GRP, r == E_SUCCESS, "Failed to create mutex. [%s]", GetErrorMessage(r));
478 __SglIndexLastUsed = INVALID_SGL_INDEX;
479 __SglInitialized = false;
482 ~_SglInfoTableManipulator()
487 FindNextEmptySlotOfSglInfoTable()
489 if (!__SglInitialized)
491 if (CreateSglInfoTable() == false)
493 return INVALID_SGL_INDEX;
497 _SglIndex sglIndex = INVALID_SGL_INDEX;
498 _SglIndex index = __SglIndexLastUsed;
500 __SglMutex.Acquire();
501 for (int i = 1; i < MAX_SGL_INDEX; i++)
505 if (index >= MAX_SGL_INDEX)
510 if (__SglInfoTable[index] == null)
513 __SglIndexLastUsed = index;
517 __SglMutex.Release();
520 if (sglIndex <= INVALID_SGL_INDEX)
522 return INVALID_SGL_INDEX;
533 __SglMutex.Acquire();
535 for (int i = 0 ; i < MAX_SGL_INDEX; i++)
537 __SglInfoTable[i] = null;
540 __SglInfoTable[0] = new (std::nothrow) _SglInfo;
541 if (__SglInfoTable[0] != null)
544 __SglInitialized = true;
545 __SglInfoTable[0]->glVersion = 2;
548 __SglMutex.Release();
554 DestroySglInfoTable()
556 __SglMutex.Acquire();
558 for (int i = 0 ; i < MAX_SGL_INDEX; i++)
560 if (__SglInfoTable[i] != null)
562 delete __SglInfoTable[i];
563 __SglInfoTable[i] = null;
566 __SglInitialized = false;
568 __SglMutex.Release();
572 LockSglInfoTable(_SglIndex index)
574 __SglMutex.Acquire();
576 if (index < INVALID_SGL_INDEX || index >= MAX_SGL_INDEX)
581 return __SglInfoTable[index];
587 __SglMutex.Release();
593 _SglInfo* newSglInfo = new (std::nothrow) _SglInfo;
594 if (newSglInfo == null)
596 SysLog(NID_GRP, "CreateSglIndex fail to allocate _SglInfo!!");
597 return INVALID_SGL_INDEX;
600 int sglIndex = FindNextEmptySlotOfSglInfoTable();
601 if (sglIndex == INVALID_SGL_INDEX)
605 SysLog(NID_GRP, "CreateSglIndex failed!!");
606 return INVALID_SGL_INDEX;
609 __SglMutex.Acquire();
610 __SglInfoTable[sglIndex] = newSglInfo;
611 __SglMutex.Release();
617 DestroySglIndex(_SglIndex sglIndex)
619 if (sglIndex < 1 || sglIndex >= MAX_SGL_INDEX)
621 SysLog(NID_GRP, "sglIndex:%#x is out of range.", (unsigned int)sglIndex);
625 __SglMutex.Acquire();
627 if (sglIndex <= INVALID_SGL_INDEX || __SglInfoTable[sglIndex] == null)
629 __SglMutex.Release();
631 SysLog(NID_GRP, "DestroySglIndex failed!! sglIndex:%#x", (unsigned int)sglIndex);
635 delete __SglInfoTable[sglIndex];
636 __SglInfoTable[sglIndex] = null;
638 __SglMutex.Release();
644 GetSglIndexForSurface(EGLSurface surface)
646 __SglMutex.Acquire();
649 for (int i = 0; i < MAX_SGL_INDEX; i++)
651 if (__SglInfoTable[i] != null && __SglInfoTable[i]->surface == surface)
658 __SglMutex.Release();
663 static _SglInfoTableManipulator* GetInstance(void)
665 static pthread_once_t once_block = PTHREAD_ONCE_INIT;
669 pthread_once(&once_block, __InitSglInfoTableManipulator);
672 return __pTheInstance;
676 static void __InitSglInfoTableManipulator(void)
678 static _SglInfoTableManipulator instance;
679 __pTheInstance = &instance;
683 Runtime::Mutex __SglMutex;
684 _SglInfo* __SglInfoTable[MAX_SGL_INDEX];
685 _SglIndex __SglIndexLastUsed;
686 bool __SglInitialized;
688 static _SglInfoTableManipulator* __pTheInstance;
690 _SglInfoTableManipulator* _SglInfoTableManipulator::__pTheInstance = null;
693 _PixmapSurfaceDestroyCallback(void* pCallbackParam)
695 delete (_PixmapInfo*)pCallbackParam;
698 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
700 _PixmapLockCallBack(void* pCallbackParam)
702 tbm_bo_map((tbm_bo)pCallbackParam, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
706 _PixmapUnlockCallBack(void* pCallbackParam)
708 tbm_bo_unmap((tbm_bo)pCallbackParam);
713 _GetEvasEngineType(Evas_Object* pObject)
717 const char* pString = elm_config_preferred_engine_get();
718 String engineName(pString);
719 SysLog(NID_GRP, "evas backend : %s", pString);
721 if (engineName.Contains(String("opengl_x11")))
723 return ENGINE_TYPE_OPENGL_X11;
727 return ENGINE_TYPE_SOFEWARE_X11;
732 Evas* pEvas = evas_object_evas_get(pObject);
735 SysLogException(NID_GRP, E_OPERATION_FAILED, "Getting pEvas failed.");
736 return ENGINE_TYPE_SOFEWARE_X11;
739 Ecore_Evas* pEcoreEvas = ecore_evas_ecore_evas_get(pEvas);
740 if (pEcoreEvas == null)
742 SysLogException(NID_GRP, E_OPERATION_FAILED, "Getting pEcoreEvas failed.");
743 return ENGINE_TYPE_SOFEWARE_X11;
746 const char* pString = ecore_evas_engine_name_get(pEcoreEvas);
747 String engineName(pString);
748 SysLog(NID_GRP, "evas backend : %s", pString);
750 if (engineName.Contains(String("opengl_x11")))
752 return ENGINE_TYPE_OPENGL_X11;
754 else if (engineName.Contains(String("software_x11")))
756 return ENGINE_TYPE_SOFEWARE_X11;
760 return ENGINE_TYPE_ETC;
766 _EvasObjectImageChange(_SglInfo* pSglInfo)
768 if(__evasEngineType == ENGINE_TYPE_SOFEWARE_X11 || __evasEngineType == ENGINE_TYPE_OPENGL_X11)
770 Evas* pEvas = evas_object_evas_get(pSglInfo->pObject);
773 SysLogException(NID_GRP, E_OPERATION_FAILED, "Getting pEvas failed.");
777 Evas_Native_Surface nativeSurface = {0, };
778 nativeSurface.type = EVAS_NATIVE_SURFACE_X11;
779 nativeSurface.version = EVAS_NATIVE_SURFACE_VERSION;
780 nativeSurface.data.x11.pixmap = (unsigned long)pSglInfo->nativePixmap;
781 nativeSurface.data.x11.visual = ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get());
782 evas_object_image_native_surface_set(pSglInfo->pObject, &nativeSurface);
786 BufferInfo bufferInfo;
787 pSglInfo->pBitmap->Lock(bufferInfo);
788 evas_object_image_data_set(pSglInfo->pObject, bufferInfo.pPixels);
789 pSglInfo->pBitmap->Unlock();
793 #if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
795 _PostRenderCallback(Ecore_Evas* ee)
797 if (__pPreviousSglInfo != null)
799 EGLDisplay display = __pPreviousSglInfo->display;
800 EGLSurface surface = __pPreviousSglInfo->surface;
801 EGLContext context = __pPreviousSglInfo->context;
803 if (__isDoublePixmapEnabled)
805 _SglInfo* pBackSglInfo = null;
806 _SglInfo* pFrontSglInfo = null;
808 if (__pPreviousSglInfo->isBackbuffer)
810 pBackSglInfo = __pPreviousSglInfo;
811 pFrontSglInfo = __pPreviousSglInfo->pSecondSglInfo;
815 pBackSglInfo = __pPreviousSglInfo->pSecondSglInfo;
816 pFrontSglInfo = __pPreviousSglInfo;
819 if (!pFrontSglInfo->swapDone && __pPreviousSglInfo->pVisualElement != null)
821 pBackSglInfo->isBackbuffer = false;
822 pFrontSglInfo->isBackbuffer = true;
823 pFrontSglInfo->swapDone = true;
825 __pPreviousSglInfo->pVisualElement->SetSurface(pBackSglInfo->pVisualElementSurface);
826 evas_object_image_pixels_dirty_set(pBackSglInfo->pObject, EINA_TRUE);
827 evas_object_hide(pFrontSglInfo->pObject);
830 surface = pFrontSglInfo->surface;
833 EGLBoolean ret = eglMakeCurrent(display, surface, surface, context);
834 SysTryLog(NID_GRP, ret == EGL_TRUE, "fail to restore previous surface and context. %#x %#x %#x %#x egl error:%#x"
835 , (unsigned int)display
836 , (unsigned int)surface
837 , (unsigned int)surface
838 , (unsigned int)context
839 , (unsigned int)eglGetError());
844 _SaveCurrentContext(_SglInfo* pSglInfo)
846 __pPreviousSglInfo = pSglInfo;
850 _RegisterRenderCallback(Evas_Object* pObject)
852 if (__evasEngineType == ENGINE_TYPE_OPENGL_X11 && pObject != null)
854 if (__registerCallbackCount == 0)
856 Evas* pEvas = evas_object_evas_get(pObject);
862 Ecore_Evas* pEcoreEvas = ecore_evas_ecore_evas_get(pEvas);
863 if (pEcoreEvas == null)
868 ecore_evas_callback_post_render_set(pEcoreEvas, _PostRenderCallback);
870 __registerCallbackCount++;
875 _UnregisterRenderCallback(Evas_Object* pObject)
877 if (__evasEngineType == ENGINE_TYPE_OPENGL_X11 && pObject != null)
879 __registerCallbackCount--;
881 if (__registerCallbackCount == 0)
883 Evas* pEvas = evas_object_evas_get(pObject);
889 Ecore_Evas* pEcoreEvas = ecore_evas_ecore_evas_get(pEvas);
890 if (pEcoreEvas == null)
895 ecore_evas_callback_post_render_set(pEcoreEvas, NULL);
899 #endif //#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
911 return eglGetError();
915 _SglGetDisplay(EGLNativeDisplayType displayId)
917 if (displayId == (EGLNativeDisplayType) EGL_DEFAULT_DISPLAY)
919 return eglGetDisplay((EGLNativeDisplayType) ecore_x_display_get());
922 return eglGetDisplay((EGLNativeDisplayType) displayId);
926 _SglInitialize(EGLDisplay dpy, EGLint* pMajor, EGLint* pMinor)
928 __evasEngineType = _GetEvasEngineType(null);
929 return eglInitialize(dpy, pMajor, pMinor);
933 _SglTerminate(EGLDisplay dpy)
935 _GlesInterfaceTerminate_1();
936 _GlesInterfaceTerminate_2();
938 _SglInfoTableManipulator::GetInstance()->DestroySglInfoTable();
940 if (__evasEngineType != ENGINE_TYPE_OPENGL_X11)
945 #if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
946 __registerCallbackCount = 0;
947 __pPreviousSglInfo = null;
955 _SglQueryString(EGLDisplay dpy, EGLint name)
957 return eglQueryString(dpy, name);
961 _SglGetConfigs(EGLDisplay dpy, EGLConfig* pConfigs, EGLint configSize, EGLint* pNumConfig)
963 return eglGetConfigs(dpy, pConfigs, configSize, pNumConfig);
967 _SglChooseConfig(EGLDisplay dpy, const EGLint* pAttribList, EGLConfig* pConfigs, EGLint configSize, EGLint* pNumConfig)
969 return eglChooseConfig(dpy, pAttribList, pConfigs, configSize, pNumConfig);
973 _SglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* pValue)
975 return eglGetConfigAttrib(dpy, config, attribute, pValue);
979 _SglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* pAttribList)
981 _SglIndex sglIndex = INVALID_SGL_INDEX;
982 Object* pObj = (Object*)win;
983 VisualElement* pVisualElement = dynamic_cast<VisualElement*> (pObj);
984 Tizen::Ui::Control* pControl = dynamic_cast<Tizen::Ui::Control*> (pObj);
985 #if 0//!defined(_OSP_EMUL_)
986 Tizen::Ui::Controls::Frame* pFrame = dynamic_cast<Tizen::Ui::Controls::Frame*> (pControl);
988 SysTryReturn(NID_GRP, pControl != null || pVisualElement != null, EGL_NO_SURFACE, E_INVALID_ARG, "Invalid NativeWindow.");
989 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
991 #if 0//!defined(_OSP_EMUL_)
992 if (pFrame != null && _GetEvasEngineType(null) != ENGINE_TYPE_OPENGL_X11)
994 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl);
995 _WindowImpl* pWindowImpl = dynamic_cast<_WindowImpl*> (pControlImpl);
996 SysTryReturn(NID_GRP, pWindowImpl != null, EGL_NO_SURFACE, E_INVALID_STATE, "Invalid window state.");
998 EGLNativeWindowType nativeWindow = (EGLNativeWindowType)pWindowImpl->GetNativeHandle();
999 sglIndex = pSglInfoTableManipulatorInstance->CreateSglIndex();
1000 SysTryReturn(NID_GRP, sglIndex > INVALID_SGL_INDEX, EGL_NO_SURFACE, E_OPERATION_FAILED, "Invalid SglIndex.");
1002 EGLSurface windowSurface = eglCreateWindowSurface(dpy, config, nativeWindow, pAttribList);
1003 if (windowSurface == EGL_NO_SURFACE)
1005 pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex);
1010 VisualElement* pVisualElement = pControlImpl->GetCore().GetVisualElement();
1011 if (pVisualElement == null)
1013 pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex);
1014 return EGL_NO_SURFACE;
1017 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*pVisualElement);
1018 if (pVisualElementImpl == null)
1020 pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex);
1021 return EGL_NO_SURFACE;
1024 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1026 pSglInfo->surface = windowSurface;
1028 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1031 return (EGLSurface)sglIndex;
1034 #endif //#if !defined(_OSP_EMUL_)
1036 result r = E_SUCCESS;
1038 if (pVisualElement == null)
1040 pVisualElement = pControl->GetVisualElement();
1042 SysTryReturn(NID_GRP, pVisualElement != null, EGL_NO_SURFACE, E_OPERATION_FAILED, "Propagating.");
1044 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*pVisualElement);
1045 SysTryReturn(NID_GRP, pVisualElementImpl != null, EGL_NO_SURFACE, E_OPERATION_FAILED, "Propagating.");
1047 FloatRectangle rect = pVisualElement->GetBounds();
1048 int width = int(rect.width);
1049 int height = int(rect.height);
1050 SysTryReturn(NID_GRP, width > 0 && height > 0, EGL_NO_SURFACE, E_OUT_OF_RANGE, "Invalid size. w:%d h:%d", width, height);
1052 Control* pFrame = pControl;
1053 Control* pTemp = pFrame->GetParent();
1054 while(pTemp != null)
1057 pTemp = pTemp->GetParent();
1060 Tizen::Ui::Window* pWindow = dynamic_cast<Tizen::Ui::Window*> (pFrame);
1061 SysTryReturn(NID_GRP, pWindow != null, EGL_NO_SURFACE, E_INVALID_STATE, "Invalid window.");
1063 VisualElementSurface* pVisualElementSurface = pVisualElement->GetSurfaceN();
1064 SysTryReturn(NID_GRP, pVisualElementSurface != null, EGL_NO_SURFACE, E_OPERATION_FAILED, "Propagating.");
1066 _VisualElementSurfaceImpl* pVisualElementSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pVisualElementSurface);
1067 if (pVisualElementSurfaceImpl == null)
1069 SysLogException(NID_GRP, E_OPERATION_FAILED, "Propagating.");
1070 delete pVisualElementSurface;
1071 return EGL_NO_SURFACE;
1074 Evas_Object* pObject = (Evas_Object*)pVisualElementSurfaceImpl->GetNativeHandle();
1075 delete pVisualElementSurface;
1077 Evas* pEvas = evas_object_evas_get(pObject);
1078 pObject = evas_object_image_filled_add(pEvas);
1079 SysTryReturn(NID_GRP, pObject != null, EGL_NO_SURFACE, E_OPERATION_FAILED, "Invalid object.");
1081 int widthPhysical = static_cast<int> (CoordinateSystem::ConvertToPhysicalX(rect.width));
1082 int heightPhysical = static_cast<int> (CoordinateSystem::ConvertToPhysicalY(rect.height));
1084 evas_object_image_alpha_set(pObject, EINA_TRUE);
1085 evas_object_image_size_set(pObject, widthPhysical, heightPhysical);
1086 evas_object_resize(pObject, widthPhysical, heightPhysical);
1087 evas_object_hide(pObject);
1089 pVisualElementSurface = _VisualElementSurfaceImpl::CreateSurfaceUsingExistingObjectN(
1090 *pWindow->GetDisplayContext(), (Handle)pObject, Dimension(width, height));
1091 SysTryReturn(NID_GRP, pVisualElementSurface != null, EGL_NO_SURFACE, E_OPERATION_FAILED, "Propagating.");
1093 std::auto_ptr <Bitmap> bitmap(new (std::nothrow) Bitmap);
1094 SysTryReturn(NID_GRP, bitmap.get() != null, EGL_NO_SURFACE, E_OUT_OF_MEMORY, "The memory is insufficient.");
1096 r = bitmap.get()->Construct(Rectangle(0, 0, width, height));
1097 SysTryReturn(NID_GRP, r == E_SUCCESS, EGL_NO_SURFACE, r, "Propagating.");
1099 sglIndex = (_SglIndex)_SglCreatePixmapSurface(dpy, config, (EGLNativePixmapType)bitmap.get(), null);
1100 SysTryReturn(NID_GRP, sglIndex > INVALID_SGL_INDEX, EGL_NO_SURFACE, E_OPERATION_FAILED, "Propagating.");
1102 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1103 pSglInfo->sglIndex = sglIndex;
1104 pSglInfo->display = dpy;
1105 pSglInfo->config = config;
1106 pSglInfo->pVisualElement = pVisualElement;
1107 pSglInfo->pWindow = pWindow;
1108 pSglInfo->pObject = pObject;
1109 pSglInfo->pVisualElementSurface = pVisualElementSurface;
1110 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1112 __evasEngineType = _GetEvasEngineType(pObject);
1114 #if defined (FGRAPHICS_INTERNAL_USE_DOUBLE_PIXMAP)
1115 if (__evasEngineType == ENGINE_TYPE_OPENGL_X11)
1117 __isDoublePixmapEnabled = true;
1121 __isDoublePixmapEnabled = false;
1124 __isDoublePixmapEnabled = false;
1127 if (__isDoublePixmapEnabled)
1129 pObject = evas_object_image_filled_add(pEvas);
1130 SysTryReturn(NID_GRP, pObject != null, EGL_NO_SURFACE, E_OPERATION_FAILED, "Invalid object.");
1132 evas_object_image_alpha_set(pObject, EINA_TRUE);
1133 evas_object_image_size_set(pObject, widthPhysical, heightPhysical);
1134 evas_object_resize(pObject, widthPhysical, heightPhysical);
1135 evas_object_hide(pObject);
1137 pVisualElementSurface = _VisualElementSurfaceImpl::CreateSurfaceUsingExistingObjectN(
1138 *pWindow->GetDisplayContext(), (Handle)pObject, Dimension(width, height));
1139 SysTryReturn(NID_GRP, pSglInfo->pVisualElementSurface != null, EGL_NO_SURFACE, E_OPERATION_FAILED, "Propagating.");
1141 delete pSglInfo->pBitmap;
1142 pSglInfo->pBitmap = null;
1144 std::auto_ptr <Bitmap> bitmapSecond(new (std::nothrow) Bitmap);
1145 SysTryReturn(NID_GRP, bitmapSecond.get() != null, EGL_NO_SURFACE, E_OUT_OF_MEMORY, "The memory is insufficient.");
1147 r = bitmapSecond.get()->Construct(Rectangle(0, 0, width, height));
1148 SysTryReturn(NID_GRP, r == E_SUCCESS, EGL_NO_SURFACE, r, "Propagating.");
1150 sglIndex = (_SglIndex)_SglCreatePixmapSurface(dpy, config, (EGLNativePixmapType)bitmapSecond.get(), null);
1151 SysTryReturn(NID_GRP, sglIndex > INVALID_SGL_INDEX, EGL_NO_SURFACE, E_OPERATION_FAILED, "Propagating.");
1153 _SglInfo* pSglInfoSecond = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1154 pSglInfoSecond->sglIndex = sglIndex;
1155 pSglInfoSecond->display = dpy;
1156 pSglInfoSecond->config = config;
1157 pSglInfoSecond->pVisualElement = pVisualElement;
1158 pSglInfoSecond->pWindow = pWindow;
1159 pSglInfoSecond->pObject = pObject;
1160 pSglInfoSecond->pVisualElementSurface = pVisualElementSurface;
1161 pSglInfoSecond->swapDone = true;
1162 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1164 pSglInfo->pSecondSglInfo = pSglInfoSecond;
1165 pSglInfoSecond->pSecondSglInfo = pSglInfo;
1167 pSglInfoSecond->pBitmap = bitmapSecond.release();
1168 _EvasObjectImageChange(pSglInfoSecond);
1172 pVisualElement->SetSurface(pSglInfo->pVisualElementSurface);
1175 pSglInfo->pBitmap = bitmap.release();
1176 _EvasObjectImageChange(pSglInfo);
1178 pVisualElementImpl->SetBoundsChangedCallback(_OnBoundsChanged, pSglInfo);
1179 pVisualElementImpl->SetDestroyedCallback(_OnDestroyed, pSglInfo);
1180 #if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
1181 _RegisterRenderCallback(pSglInfo->pObject);
1183 return (EGLSurface)pSglInfo->sglIndex;
1188 _SglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* pAttribList)
1190 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1191 _SglIndex sglIndex = INVALID_SGL_INDEX;
1193 sglIndex = pSglInfoTableManipulatorInstance->CreateSglIndex();
1194 if (sglIndex <= INVALID_SGL_INDEX)
1196 SysLog(NID_GRP, "_SglCreatePbufferSurface failed!! dpy:%#x config:%#x pAttribList:%#x",
1197 (unsigned int)dpy, (unsigned int)config, (unsigned int)pAttribList);
1199 return eglCreatePbufferSurface(EGL_NO_DISPLAY, config, pAttribList);
1202 EGLSurface pbufferSurface = eglCreatePbufferSurface(dpy, config, pAttribList);
1203 if (pbufferSurface == EGL_NO_SURFACE)
1205 pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex);
1210 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1212 pSglInfo->surface = pbufferSurface;
1214 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1217 return (EGLSurface)sglIndex;
1220 _OSP_LOCAL_ EGLNativePixmapType
1221 _CreateNativePixmap(_SglIndex sglIndex, Tizen::Graphics::Bitmap* pBitmap)
1225 int bitsPerPixel = 0;
1226 Display* pNativeDisplay = null;
1227 Drawable nativeWindow = 0;
1228 result r = E_FAILURE;
1229 Tizen::Graphics::BufferInfo bufferInfo;
1230 _PixmapInfo* pPixmapInfo = null;
1231 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
1232 unsigned int attachments[] = { DRI2BufferFrontLeft };
1233 char* pDeviceName = null;
1234 char* pDriverName = null;
1235 DRI2Buffer* pDri2Buffer = null;
1238 int dri2BufferCount = 0;
1239 tbm_bo_handle tbmData = { null, };
1242 drm_magic_t magic = 0;
1244 _SglInfo* pSglInfo = null;
1245 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1247 pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1248 if (pBitmap == null || sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
1250 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1253 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1255 r = pBitmap->Lock(bufferInfo);
1261 width = bufferInfo.width;
1262 height = bufferInfo.height;
1263 bitsPerPixel = bufferInfo.bitsPerPixel;
1265 r = pBitmap->Unlock();
1266 if (r != E_SUCCESS || width <= 0 || height <= 0 || bitsPerPixel <= 0)
1271 pNativeDisplay = (Display*) ecore_x_display_get();
1272 nativeWindow = DefaultRootWindow(pNativeDisplay);
1274 pPixmapInfo = new (std::nothrow) _PixmapInfo;
1275 if (pPixmapInfo == null)
1280 pPixmapInfo->nativePixmap = XCreatePixmap(pNativeDisplay, nativeWindow, width, height,
1281 ecore_x_default_depth_get(pNativeDisplay, ecore_x_default_screen_get()));
1282 if (pPixmapInfo->nativePixmap == (Pixmap)0)
1287 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
1288 DRI2CreateDrawable(pNativeDisplay, pPixmapInfo->nativePixmap);
1289 XSync(pNativeDisplay, False);
1291 ret = DRI2Connect(pNativeDisplay, nativeWindow, &pDriverName, &pDeviceName);
1293 if (!ret || pDeviceName == null)
1298 pPixmapInfo->drmFd = open(pDeviceName, O_RDWR);
1301 if (pPixmapInfo->drmFd < 0)
1306 drmGetMagic(pPixmapInfo->drmFd, &magic);
1307 ret = DRI2Authenticate(pNativeDisplay, nativeWindow, (unsigned int)magic);
1313 pPixmapInfo->pTbmBufMgr = tbm_bufmgr_init(pPixmapInfo->drmFd);
1314 if (pPixmapInfo->pTbmBufMgr == null)
1319 pDri2Buffer = DRI2GetBuffers(pNativeDisplay, pPixmapInfo->nativePixmap, &dri2Width, &dri2Height, attachments, 1, &dri2BufferCount);
1320 if (pDri2Buffer == null)
1325 pPixmapInfo->pTbmBufferObject = tbm_bo_import(pPixmapInfo->pTbmBufMgr, pDri2Buffer->name);
1327 if (pPixmapInfo->pTbmBufferObject == null)
1332 tbmData = tbm_bo_get_handle(pPixmapInfo->pTbmBufferObject, TBM_DEVICE_CPU);
1333 if (tbmData.ptr == null)
1338 r = Tizen::Graphics::_BitmapTool::ChangeBuffer(*pBitmap, tbmData.ptr, width * bitsPerPixel / 8,
1339 _PixmapSurfaceDestroyCallback, (void*)pPixmapInfo);
1345 if (!Tizen::Graphics::_BitmapTool::SetCallback(*pBitmap, _PixmapSurfaceDestroyCallback, pPixmapInfo,
1346 _PixmapLockCallBack, pPixmapInfo->pTbmBufferObject,_PixmapUnlockCallBack, pPixmapInfo->pTbmBufferObject))
1352 #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
1354 pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1356 pSglInfo->pEcoreImage = ecore_x_image_new(width
1358 , ecore_x_default_visual_get(pNativeDisplay, ecore_x_default_screen_get())
1359 , ecore_x_default_depth_get(pNativeDisplay, ecore_x_default_screen_get()));
1361 if (pSglInfo->pEcoreImage == null)
1363 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1367 ecore_x_image_get(pSglInfo->pEcoreImage
1368 , pPixmapInfo->nativePixmap, 0, 0, 0, 0
1376 void* pSource = ecore_x_image_data_get(pSglInfo->pEcoreImage, &bpl, &rows, &bpp);
1378 r = Tizen::Graphics::_BitmapTool::ChangeBuffer(*pBitmap, pSource, width * bitsPerPixel / 8,
1379 _PixmapSurfaceDestroyCallback, (void*)pPixmapInfo);
1382 ecore_x_image_free(pSglInfo->pEcoreImage);
1383 pSglInfo->pEcoreImage = null;
1384 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1386 SysLog(NID_GRP, "change buffer failed! pSource %#x %d %d %d", (unsigned int)pSource, bpl, rows, bpp);
1390 pSglInfo->width = width;
1391 pSglInfo->height = height;
1393 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1395 #endif //#if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
1396 #endif //#if defined(FGRAPHICS_INTERNAL_USE_DRM)
1398 pBitmap->Lock(bufferInfo);
1401 canvas.Construct(bufferInfo);
1402 canvas.SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK));
1407 return (EGLNativePixmapType)pPixmapInfo->nativePixmap;
1410 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
1411 tbm_bo_unmap(pPixmapInfo->pTbmBufferObject);
1412 tbm_bo_unref(pPixmapInfo->pTbmBufferObject);
1416 tbm_bufmgr_deinit(pPixmapInfo->pTbmBufMgr);
1420 close(pPixmapInfo->drmFd);
1424 DRI2DestroyDrawable(pNativeDisplay, pPixmapInfo->nativePixmap);
1426 XFreePixmap(pNativeDisplay, pPixmapInfo->nativePixmap);
1434 SysLog(NID_GRP, "_CreateNativePixmap failed!! pBitmap:%#x", (unsigned int)pBitmap);
1435 return (EGLNativePixmapType)0;
1438 _OSP_LOCAL_ EGLNativePixmapType
1439 _CreateNativePixmapEx(Tizen::Graphics::Bitmap* pBitmap, Tizen::Graphics::BufferInfo bufferInfo)
1443 int bitsPerPixel = 0;
1444 Display* pNativeDisplay = null;
1445 Drawable nativeWindow = 0;
1446 Tizen::Graphics::_BitmapImpl* pBitmapImpl = null;
1447 _PixmapInfo* pPixmapInfo = null;
1448 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
1449 unsigned int attachments[] = { DRI2BufferFrontLeft };
1450 char* pDeviceName = null;
1451 char* pDriverName = null;
1452 DRI2Buffer* pDri2Buffer = null;
1455 int dri2BufferCount = 0;
1456 tbm_bo_handle tbmData = { null, };
1459 result r = E_FAILURE;
1460 drm_magic_t magic = 0;
1462 if (pBitmap == null)
1467 pBitmapImpl = Tizen::Graphics::_BitmapImpl::GetInstance(*pBitmap);
1468 if (pBitmapImpl == null)
1473 width = bufferInfo.width;
1474 height = bufferInfo.height;
1475 bitsPerPixel = bufferInfo.bitsPerPixel;
1477 if (width <= 0 || height <= 0 || bitsPerPixel <= 0)
1482 pNativeDisplay = (Display*) ecore_x_display_get();
1483 nativeWindow = DefaultRootWindow(pNativeDisplay);
1485 pPixmapInfo = new (std::nothrow) _PixmapInfo;
1486 if (pPixmapInfo == null)
1491 pPixmapInfo->nativePixmap = XCreatePixmap(pNativeDisplay, nativeWindow, width, height
1493 if (pPixmapInfo->nativePixmap == (Pixmap)0)
1498 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
1499 DRI2CreateDrawable(pNativeDisplay, pPixmapInfo->nativePixmap);
1500 XSync(pNativeDisplay, False);
1502 ret = DRI2Connect(pNativeDisplay, nativeWindow, &pDriverName, &pDeviceName);
1504 if (!ret || pDeviceName == null)
1509 pPixmapInfo->drmFd = open(pDeviceName, O_RDWR);
1511 if (pPixmapInfo->drmFd < 0)
1516 drmGetMagic(pPixmapInfo->drmFd, &magic);
1517 ret = DRI2Authenticate(pNativeDisplay, nativeWindow, (unsigned int)magic);
1523 pPixmapInfo->pTbmBufMgr = tbm_bufmgr_init(pPixmapInfo->drmFd);
1524 if (pPixmapInfo->pTbmBufMgr == null)
1529 pDri2Buffer = DRI2GetBuffers(pNativeDisplay, pPixmapInfo->nativePixmap, &dri2Width, &dri2Height, attachments, 1, &dri2BufferCount);
1530 if (pDri2Buffer == null)
1535 pPixmapInfo->pTbmBufferObject = tbm_bo_import(pPixmapInfo->pTbmBufMgr, pDri2Buffer->name);
1537 if (pPixmapInfo->pTbmBufferObject == null)
1542 tbmData = tbm_bo_get_handle(pPixmapInfo->pTbmBufferObject, TBM_DEVICE_CPU);
1543 if (tbmData.ptr == null)
1547 bufferInfo.pPixels = tbmData.ptr;
1549 bufferInfo.bitsPerPixel = 32;
1550 bufferInfo.pixelFormat = PIXEL_FORMAT_ARGB8888;
1551 bufferInfo.pitch = bufferInfo.width * bufferInfo.bitsPerPixel / 8;
1552 memset(bufferInfo.pPixels, 0, bufferInfo.pitch * bufferInfo.height);
1553 r = pBitmapImpl->Construct(bufferInfo);
1559 if (!Tizen::Graphics::_BitmapTool::SetCallback(*pBitmap
1560 , _PixmapSurfaceDestroyCallback, pPixmapInfo
1561 , _PixmapLockCallBack, pPixmapInfo->pTbmBufferObject
1562 ,_PixmapUnlockCallBack, pPixmapInfo->pTbmBufferObject))
1566 #endif //#if defined(FGRAPHICS_INTERNAL_USE_DRM)
1568 return (EGLNativePixmapType)pPixmapInfo->nativePixmap;
1570 #if defined(FGRAPHICS_INTERNAL_USE_DRM)
1572 tbm_bo_unmap(pPixmapInfo->pTbmBufferObject);
1573 tbm_bo_unref(pPixmapInfo->pTbmBufferObject);
1577 tbm_bufmgr_deinit(pPixmapInfo->pTbmBufMgr);
1581 close(pPixmapInfo->drmFd);
1585 DRI2DestroyDrawable(pNativeDisplay, pPixmapInfo->nativePixmap);
1586 XFreePixmap(pNativeDisplay, pPixmapInfo->nativePixmap);
1595 SysLog(NID_GRP, "_CreateNativePixmap failed!! pBitmap:%#x", (unsigned int)pBitmap);
1596 return (EGLNativePixmapType)0;
1600 _SglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* pAttribList)
1602 _SglIndex sglIndex = INVALID_SGL_INDEX;
1603 Tizen::Graphics::Bitmap* pBitmap = dynamic_cast<Tizen::Graphics::Bitmap*>((Tizen::Graphics::Bitmap*)pixmap);
1604 EGLNativePixmapType eglNativePixmap = 0;
1605 EGLSurface pixmapSurface = EGL_NO_SURFACE;
1606 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1608 if (pBitmap == null)
1613 sglIndex = pSglInfoTableManipulatorInstance->CreateSglIndex();
1614 if (sglIndex <= INVALID_SGL_INDEX)
1619 eglNativePixmap = _CreateNativePixmap(sglIndex, pBitmap);
1620 if (eglNativePixmap == 0)
1625 pixmapSurface = eglCreatePixmapSurface(dpy, config, eglNativePixmap, pAttribList);
1626 if (pixmapSurface == EGL_NO_SURFACE)
1628 pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex);
1633 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1635 pSglInfo->nativePixmap = eglNativePixmap;
1636 pSglInfo->surface = pixmapSurface;
1638 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1641 return (EGLSurface)sglIndex;
1644 pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex);
1648 SysLog(NID_GRP, "_SglCreatePixmapSurface failed!! dpy:%#x config:%#x pixmap:%#x pAttribList:%#x",
1649 (unsigned int)dpy, (unsigned int)config, (unsigned int)pixmap, (unsigned int)pAttribList);
1650 return eglCreatePixmapSurface(EGL_NO_DISPLAY, config, (EGLNativePixmapType) 0, pAttribList);
1654 _SglDestroySurface(EGLDisplay dpy, EGLSurface surface)
1656 EGLBoolean ret = EGL_FALSE;
1657 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1659 _SglIndex sglIndex = (_SglIndex)surface;
1660 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1662 if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
1664 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1665 SysLog(NID_GRP, "_SglDestroySurface failed!! dpy:%#x sglIndex:%#x", (unsigned int)dpy
1666 , (unsigned int)surface);
1667 return eglDestroySurface(dpy, EGL_NO_SURFACE);
1670 #if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
1671 if (pSglInfo == __pPreviousSglInfo || pSglInfo->pSecondSglInfo == __pPreviousSglInfo)
1673 __pPreviousSglInfo = null;
1677 ret = eglDestroySurface(dpy, pSglInfo->surface);
1678 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1680 if (__isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null)
1682 eglDestroySurface(dpy, pSglInfo->pSecondSglInfo->surface);
1683 pSglInfoTableManipulatorInstance->DestroySglIndex(pSglInfo->pSecondSglInfo->sglIndex);
1686 pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex);
1692 _SglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* pValue)
1694 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1696 _SglIndex sglIndex = (_SglIndex)surface;
1697 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1699 if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
1701 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1702 SysLog(NID_GRP, "_SglQuerySurface failed!! dpy:%#x sglIndex:%#x attribute:%#x pValue:%#x",
1703 (unsigned int)dpy, (unsigned int)sglIndex, (unsigned int)attribute, (unsigned int)pValue);
1704 return eglQuerySurface(dpy, EGL_NO_SURFACE, attribute, pValue);
1707 EGLBoolean ret = EGL_FALSE;
1708 if (attribute == EGL_BITMAP_POINTER_KHR)
1710 *pValue = (EGLint)pSglInfo->pBitmapPointer;
1715 ret = eglQuerySurface(dpy, pSglInfo->surface, attribute, pValue);
1718 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1724 _SglBindAPI(EGLenum api)
1726 return eglBindAPI(api);
1732 return eglQueryAPI();
1738 return eglWaitClient();
1742 _SglReleaseThread(void)
1744 return eglReleaseThread();
1748 _SglCreatePbufferFromClientBuffer(
1749 EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint* pAttribList)
1751 _SglIndex sglIndex = INVALID_SGL_INDEX;
1752 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1754 sglIndex = pSglInfoTableManipulatorInstance->CreateSglIndex();
1755 if (sglIndex <= INVALID_SGL_INDEX)
1757 SysLog(NID_GRP, "_SglCreatePbufferFromClientBuffer failed!!"
1758 " dpy:%#x buftype:%#x buffer:%#x config:%#x pAttribList:%#x",
1759 (unsigned int)dpy, (unsigned int)buftype, (unsigned int)buffer, (unsigned int)config, (unsigned int)pAttribList);
1761 return eglCreatePbufferFromClientBuffer(null, (EGLenum)0, null, null, null);
1764 EGLSurface pbufferFromClientBuffer = eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, pAttribList);
1765 if (pbufferFromClientBuffer == EGL_NO_SURFACE)
1767 pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex);
1772 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1774 pSglInfo->surface = pbufferFromClientBuffer;
1776 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1779 return (EGLSurface)sglIndex;
1783 _SglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
1785 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1787 _SglIndex sglIndex = (_SglIndex)surface;
1788 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1790 if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
1792 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1793 SysLog(NID_GRP, "_SglCreatePbufferFromClientBuffer failed!! "
1794 "dpy:%#x surface:%#x attribute:%#x value:%#x",
1795 (unsigned int)dpy, (unsigned int)surface, (unsigned int)attribute, (unsigned int)value);
1797 return eglSurfaceAttrib(dpy, EGL_NO_SURFACE, attribute, value);
1800 EGLBoolean ret = eglSurfaceAttrib(dpy, pSglInfo->surface, attribute, value);
1801 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1807 _SglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
1809 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1811 _SglIndex sglIndex = (_SglIndex)surface;
1812 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1814 if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
1816 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1817 SysLog(NID_GRP, "_SglBindTexImage failed!! dpy:%#x surface:%#x buffer:%#x",
1818 (unsigned int)dpy, (unsigned int)surface, (unsigned int)buffer);
1820 return eglBindTexImage(dpy, EGL_NO_SURFACE, buffer);
1823 EGLBoolean ret = eglBindTexImage(dpy, pSglInfo->surface, buffer);
1824 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1830 _SglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
1832 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1834 _SglIndex sglIndex = (_SglIndex)surface;
1835 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1837 if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
1839 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1840 SysLog(NID_GRP, "_SglReleaseTexImage failed!! dpy:%#x surface:%#x buffer:%#x",
1841 (unsigned int)dpy, (unsigned int)surface, (unsigned int)buffer);
1843 return eglReleaseTexImage(dpy, EGL_NO_SURFACE, buffer);
1846 EGLBoolean ret = eglReleaseTexImage(dpy, pSglInfo->surface, buffer);
1847 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1853 _SglSwapInterval(EGLDisplay dpy, EGLint interval)
1855 return eglSwapInterval(dpy, interval);
1859 _SglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareContext, const EGLint* pAttribList)
1861 return eglCreateContext(dpy, config, shareContext, pAttribList);
1865 _SglDestroyContext(EGLDisplay dpy, EGLContext ctx)
1867 return eglDestroyContext(dpy, ctx);
1871 _SglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
1873 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1875 _SglIndex sglIndexDraw = (_SglIndex)draw;
1876 _SglIndex sglIndexRead = (_SglIndex)read;
1878 EGLSurface sglInfoReadSurface;
1880 _SglInfo* sglInfoRead = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndexRead);
1882 if (sglInfoRead == null)
1884 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1885 SysLog(NID_GRP, "_SglMakeCurrent failed!! dpy:%#x draw:%#x read:%#x ctx:%#x",
1886 (unsigned int)dpy, (unsigned int)draw, (unsigned int)read, (unsigned int)ctx);
1887 return eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx);
1889 sglInfoReadSurface = sglInfoRead->surface;
1891 if (__isDoublePixmapEnabled && !sglInfoRead->isBackbuffer && sglInfoRead->pSecondSglInfo != null)
1893 sglInfoReadSurface = sglInfoRead->pSecondSglInfo->surface;
1896 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1899 _SglInfo* pSglInfoDraw = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndexDraw);
1900 if (pSglInfoDraw == null)
1902 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1903 SysLog(NID_GRP, "_SglMakeCurrent failed!! dpy:%#x draw:%#x read:%#x ctx:%#x",
1904 (unsigned int)dpy, (unsigned int)draw, (unsigned int)read, (unsigned int)ctx);
1905 return eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx);
1908 if (__isDoublePixmapEnabled && !pSglInfoDraw->isBackbuffer && pSglInfoDraw->pSecondSglInfo != null)
1910 pSglInfoDraw = pSglInfoDraw->pSecondSglInfo;
1913 pSglInfoDraw->context = ctx;
1915 EGLBoolean ret = eglMakeCurrent(dpy, pSglInfoDraw->surface, sglInfoReadSurface, ctx);
1917 #if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT)
1918 if (draw != EGL_NO_SURFACE)
1920 _SaveCurrentContext(pSglInfoDraw);
1924 if (pSglInfoDraw->glVersion == 0 && ctx != EGL_NO_CONTEXT)
1926 eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &pSglInfoDraw->glVersion);
1929 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1935 _SglGetCurrentContext()
1937 return eglGetCurrentContext();
1941 _SglGetCurrentSurface(EGLint readDraw)
1943 EGLSurface surface = EGL_NO_SURFACE;
1944 _SglIndex sglIndex = INVALID_SGL_INDEX;
1946 surface = eglGetCurrentSurface(readDraw);
1947 sglIndex = _SglInfoTableManipulator::GetInstance()->GetSglIndexForSurface(surface);
1949 if (sglIndex < INVALID_SGL_INDEX)
1951 SysLog(NID_GRP, "_SglGetCurrentSurface failed!! readDraw:%#x", (unsigned int)readDraw);
1952 return EGL_NO_SURFACE;
1955 return (EGLSurface)sglIndex;
1959 _SglGetCurrentDisplay(void)
1961 return eglGetCurrentDisplay();
1965 _SglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* pValue)
1967 return eglQueryContext(dpy, ctx, attribute, pValue);
1977 _SglWaitNative(EGLint engine)
1979 return eglWaitNative(engine);
1982 EGLBoolean _SglUpdateBufferOSP(EGLDisplay dpy, EGLSurface surface);
1985 _SglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
1987 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
1989 _SglIndex sglIndex = (_SglIndex)surface;
1990 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
1992 if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
1994 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
1995 SysLog(NID_GRP, "_SglSwapBuffers failed!! dpy:%#x sglIndex:%#x", (unsigned int)dpy
1996 , (unsigned int)sglIndex);
1998 return eglSwapBuffers(dpy, EGL_NO_SURFACE);
2001 if (pSglInfo->pBitmap != null)
2003 #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
2004 _SglUpdateBufferOSP(dpy, surface);
2006 if(__evasEngineType == ENGINE_TYPE_OPENGL_X11)
2008 if (pSglInfo->glVersion == 1)
2023 if(__evasEngineType == ENGINE_TYPE_SOFEWARE_X11 || __evasEngineType == ENGINE_TYPE_OPENGL_X11)
2025 if (__isDoublePixmapEnabled && pSglInfo->pSecondSglInfo != null)
2027 if (pSglInfo->swapDone || pSglInfo->pSecondSglInfo->swapDone)
2029 _SglInfo* pBackSglInfo = null;
2030 _SglInfo* pFrontSglInfo = null;
2032 if (pSglInfo->isBackbuffer)
2034 pBackSglInfo = pSglInfo;
2035 pFrontSglInfo = pSglInfo->pSecondSglInfo;
2039 pBackSglInfo = pSglInfo->pSecondSglInfo;
2040 pFrontSglInfo = pSglInfo;
2043 pFrontSglInfo->swapDone = false;
2045 if (pSglInfo->pVisualElement != null)
2047 pSglInfo->pVisualElement->SetSurface(pFrontSglInfo->pVisualElementSurface);
2049 evas_object_image_pixels_dirty_set(pFrontSglInfo->pObject, EINA_TRUE);
2050 evas_object_hide(pBackSglInfo->pObject);
2052 if (pSglInfo->isFirstSwap)
2054 pBackSglInfo->isFirstSwap = false;
2055 pFrontSglInfo->isFirstSwap = false;
2058 BufferInfo bufferInfo;
2059 pFrontSglInfo->pBitmap->Lock(bufferInfo);
2060 pFrontSglInfo->pBitmap->Merge(Point(0, 0), *pBackSglInfo->pBitmap, Rectangle(0, 0, bufferInfo.width, bufferInfo.height));
2061 pFrontSglInfo->pBitmap->Unlock();
2067 if (pSglInfo->pObject != null)
2069 evas_object_image_pixels_dirty_set(pSglInfo->pObject, EINA_TRUE);
2075 if (pSglInfo->pVisualElement != null)
2077 pSglInfo->pVisualElement->SetFlushNeeded();
2082 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
2087 EGLBoolean ret = eglSwapBuffers(dpy, pSglInfo->surface);
2088 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
2095 _SglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
2097 Tizen::Graphics::Bitmap* pBitmap = (Tizen::Graphics::Bitmap*)target;
2098 EGLNativePixmapType nativePixmap = _CreateNativePixmap((_SglIndex)surface, pBitmap);
2099 return eglCopyBuffers(dpy, surface, nativePixmap);
2102 typedef void (*__EglMustCastToProperFunctionPointerType)(void);
2104 EGLBoolean _SglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
2106 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
2108 _SglIndex sglIndex = (_SglIndex)surface;
2109 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
2111 if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null || pSglInfo->pBitmap == null || pSglInfo->pBitmapLocked != null)
2113 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
2114 SysLog(NID_GRP, "_SglLockSurfaceKHR failed!! dpy:%#x sglIndex:%#x", (unsigned int)display
2115 , (unsigned int)surface);
2119 _SglInfo* pSglInfoLock = pSglInfo;
2120 BufferInfo bufferInfo;
2121 if(!pSglInfo->isBackbuffer && pSglInfo->pSecondSglInfo != null)
2123 pSglInfoLock = pSglInfo->pSecondSglInfo;
2126 pSglInfoLock->pBitmap->Lock(bufferInfo);
2127 pSglInfo->pBitmapPointer = bufferInfo.pPixels;
2128 pSglInfo->pBitmapLocked = pSglInfoLock->pBitmap;
2129 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
2134 EGLBoolean _SglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
2136 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
2138 _SglIndex sglIndex = (_SglIndex)surface;
2139 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
2141 if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null || pSglInfo->pBitmap == null || pSglInfo->pBitmapLocked == null)
2143 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
2144 SysLog(NID_GRP, "_SglUnlockSurfaceKHR failed!! dpy:%#x sglIndex:%#x", (unsigned int)display
2145 , (unsigned int)surface);
2149 pSglInfo->pBitmapLocked->Unlock();
2150 pSglInfo->pBitmapPointer = null;
2151 pSglInfo->pBitmapLocked = null;
2152 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
2157 __EglMustCastToProperFunctionPointerType
2158 _SglGetProcAddress(const char* pProcName)
2160 String name(pProcName);
2162 if (name.CompareTo(String("eglLockSurfaceKHR")) == 0)
2164 return (__EglMustCastToProperFunctionPointerType)_SglLockSurfaceKHR;
2166 else if (name.CompareTo(String("eglUnlockSurfaceKHR")) == 0)
2168 return (__EglMustCastToProperFunctionPointerType)_SglUnlockSurfaceKHR;
2171 return eglGetProcAddress(pProcName);
2175 _SglUpdateBufferOSP(EGLDisplay dpy, EGLSurface surface)
2177 #if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
2178 Tizen::Graphics::BufferInfo bufferInfo;
2179 _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
2181 _SglIndex sglIndex = (_SglIndex)surface;
2182 _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
2184 if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
2186 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
2187 SysLog(NID_GRP, "_SglUpdateBufferOSP failed!!");
2191 eglCopyBuffers(dpy, pSglInfo->surface, pSglInfo->nativePixmap);
2192 ecore_x_image_get(pSglInfo->pEcoreImage, (Ecore_X_Drawable)pSglInfo->nativePixmap,
2193 0, 0, 0, 0, pSglInfo->width, pSglInfo->height);
2195 pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
2206 }} // Tizen::Graphics