{
_VisualElementEnvironment::Initialize();
- _VisualElementSurfaceManager::Initialize();
+
__layers.Construct();
_GlRenderManager::CreateInstance();
//_GlRenderManager::GetInstance()->SyncRenderManager();
+
#ifndef _WIN32
#ifdef ECORE_X_NATIVE
_EcoreXLooper* pLooper = static_cast<_EcoreXLooper*>(_Looper::GetInstance());
#ifdef _OSP_ARMEL_
#define USE_EGL_IMAGE
#endif
+#ifndef _OSP_EMUL_
+#define __SHARED_CONTEXT__
+#endif
namespace Tizen { namespace Ui { namespace Animations
{
class _GlContext
{
public:
- static _GlContext* CreateN(Handle nativeDisplay, Handle window);
+ static _GlContext* CreateN(Handle nativeDisplay, Handle window, _GlContext* pSharedContext);
#ifndef VE_USE_GL_MULTI_CONTEXT
static _GlContext* GetInstance(void)
ShaderProgram* GetTextureShaderAlphaMaskExtra1(const ShaderProgramIndex& index);
ShaderProgram* GetTextureShaderAlphaMaskExtra2(const ShaderProgramIndex& index);
+ Handle GetNativeDisplay(void) const {return __nativeDisplay;}
+
protected:
_GlContext(Handle nativeDisplay, Handle window);
virtual ~_GlContext(void);
#endif
friend class _GlRenderManager;
+ friend class _VisualElementSurfaceManager;
};
}}} //namespace Tizen { namespace Ui { namespace Animations
#include "FUiAnim_AnimationManager.h"
#include "FUiAnim_DisplayManager.h"
#include "FUiAnim_GlRenderManager.h"
+#include "FUiAnim_VisualElementSurfaceManager.h"
#include "FUi_Math.h"
using namespace Tizen;
_GlLayer::~_GlLayer(void)
{
+#ifdef __SHARED_CONTEXT__
+ _VisualElementSurfaceManager::GetInstance()->FinalizeGLLayer(this);
+#endif
_GlRenderManager::GetInstance()->FinalizeGLLayer(this);
+
}
return E_INVALID_STATE; // CHECKME:
}
+#ifdef __SHARED_CONTEXT__
+ if (!_VisualElementSurfaceManager::GetInstance()->InitializeGLLayer(this))
+ {
+ return E_INVALID_STATE; // CHECKME:
+ }
+#endif
__reconfigureNeeded = true;
// SetShowState(true);
#endif
friend class _GlRenderManager;
+ friend class _VisualElementSurfaceManager;
};
}}} //namespace Tizen { namespace Ui { namespace Animations
//#define PRINT(...) fprintf(stderr, __VA_ARGS__)
#define PRINT(...)
+static bool __checkCondition(bool condition)
+{
+ bool bCond = condition;
+ if(bCond == false)
+ {
+ return bCond;
+ }
+ return bCond;
+}
+//#define ASSERT(__CONDITION__,...) {__checkCondition(__CONDITION__); SysAssertf(__CONDITION__,__VA_ARGS__);}
+#define ASSERT(...) SysAssertf(__VA_ARGS__)
+
#ifdef VE_USE_GL_MULTI_CONTEXT
-#define CHECK_GL_CONTEXT(pGlContext) SysAssertf(pGlContext, "Invalid render manager status(no context)");
+#define CHECK_GL_CONTEXT(pGlContext) ASSERT(pGlContext, "Invalid render manager status(no context)");
#else
-#define CHECK_GL_CONTEXT() SysAssertf(__pGlContext, "Invalid render manager status(no context)");
+#define CHECK_GL_CONTEXT() ASSERT(__pGlContext, "Invalid render manager status(no context)");
#endif
#define VERTEX_BUFFER_STRIDE 3
memset(&__threadInfo, 0x00, sizeof(pthread_t));
if (pthread_create(&__threadInfo, NULL, _GlRenderManager::RenderProc, this) != 0)
{
- SysAssertf(false, "Creating render-thread failed");
+ ASSERT(false, "Creating render-thread failed");
}
__eyePosition[0] = 0.0f;
_AutoMutex commandTransactionLock(__commandTransaction);
_AutoMutex commandLock(__commandLock);
+ PRINT("ZZZZZZZZZZ-Texture[Type:%d],bounds(%d,%d,%d,%d) textureId(%x)\n",
+ pTextureInfo->type,
+ pTextureInfo->x, pTextureInfo->y, pTextureInfo->width, pTextureInfo->height,
+ pTextureInfo->textureId);
+
__commandId = COMMAND_CREATE_TEXTURE;
__commandArg.__pCommandTextureInfo = pTextureInfo;
__commandRequest.SendSignal();
#ifdef VE_USE_GL_MULTI_CONTEXT
#ifdef ECORE_X_NATIVE
_EcoreXLooper* pLooper = static_cast<_EcoreXLooper*>(_Looper::GetInstance());
- pGlLayer->__pContext = _GlContext::CreateN((Handle)pLooper->GetXDisplay(), (Handle)pGlLayer->GetNativeWindow());
+ pGlLayer->__pContext = _GlContext::CreateN((Handle)pLooper->GetXDisplay(), (Handle)pGlLayer->GetNativeWindow(), null);
PRINT("[DEBUG]-003a _GlRenderManager::CommandHandlerInitializeGLLayer: Create surf... \n" );
#endif
#else
CHECK_GL_CONTEXT();
- SysAssertf(!pGlLayer->__surface, "");
+ ASSERT(!pGlLayer->__surface, "");
PRINT("[DEBUG]-003 _GlRenderManager::CommandHandlerInitializeGLLayer: Create surf... \n" );
// TODO: jinstar
//////////pGlLayer->__surface = __pGlContext->CreateWindowSurface( (Handle)pGlLayer->GetNativeWindow() );
+#ifndef __SHARED_CONTEXT__
pGlLayer->__surface = __pGlContext->CreateWindowSurface( (Handle)pGlLayer->GetWindowHandle() );
+#endif
PRINT(">> CommandHandlerInitializeGLLayer() surface %p \n", (void*)pGlLayer->__surface);
#endif
if (pGlLayer->__surface)
{
+#ifndef __SHARED_CONTEXT__
__pGlContext->DestroySurface((Handle)pGlLayer->__surface);
pGlLayer->__surface = null;
+#endif //__SHARED_CONTEXT__
}
+
#endif
return true;
if (unlikely(pThis->__commandId == COMMAND_UNKNOWN))
{
- SysAssertf(!gotCommand, "No command sent, but got command !");
+ ASSERT(!gotCommand, "No command sent, but got command !");
commandId = COMMAND_COMPOSITE;
commandArg = pThis->__commandArg; // to avoid complier warning
#include "FUiAnim_GlVisualElementSurfaceImpl.h"
#include "FUiAnim_VisualElementSurfaceManager.h"
+#include "FUiAnim_GlContext.h"
+
#ifdef VE_USE_GL_MULTI_CONTEXT
#include "FUiAnim_GlContext.h"
#endif
+//#define PRINT(...) fprintf(stderr, __VA_ARGS__)
+#define PRINT(...)
+
+static bool __checkCondition(bool condition)
+{
+ bool bCond = condition;
+ if(bCond == false)
+ {
+ return bCond;
+ }
+ return bCond;
+}
+//#define ASSERT(__CONDITION__,...) {__checkCondition(__CONDITION__); SysAssertf(__CONDITION__,__VA_ARGS__);}
+#define ASSERT(...) SysAssertf(__VA_ARGS__)
+
using namespace std;
using namespace Tizen::Base;
using namespace Tizen::Graphics;
}
}
+#ifdef __SHARED_CONTEXT__
+void
+_VisualElementSurfaceManager::Initialize(Handle nativeDisplay, Handle window,_GlContext& context)
+{
+ if (!__pInstance)
+ {
+ static _VisualElementSurfaceManager instance;
+ __pInstance = &instance;
+ __pInstance->__nativeDisplay = nativeDisplay;
+ __pInstance->__window = window;
+ __pInstance->InitializeManager(&context);
+
+ }
+}
+#endif
+
+
_VisualElementSurfaceManager::_VisualElementSurfaceManager(void)
+#ifdef __SHARED_CONTEXT__
+ : __pGlContext(null)
+#endif
{
+#ifdef __SHARED_CONTEXT__
+ memset(&__threadInfo, 0x00, sizeof(pthread_t));
+ if (pthread_create(&__threadInfo, NULL, _VisualElementSurfaceManager::ThreadProc, this) != 0)
+ {
+ ASSERT(false, "Creating surface-manager-thread failed");
+ }
+#endif
+
}
_VisualElementSurfaceManager::~_VisualElementSurfaceManager(void)
{
+#ifdef __SHARED_CONTEXT__
+ delete __pGlContext;
+#endif
}
result
pTextureInfo->pPixels = (unsigned long*) new (std::nothrow) unsigned char[pTextureInfo->stride * pTextureInfo->height];
SysTryReturnResult(NID_UI_ANIM, pTextureInfo->pPixels, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
}
+#ifdef __SHARED_CONTEXT__
+ PRINT(">> _VisualElementSurfaceManager::CreateSurface() texture id %u \n", pTextureInfo->textureId);
+ CreateTexture(pTextureInfo);
+#else
_GlRenderManager::GetInstance()->CreateTexture(pTextureInfo);
-
+#endif
return E_SUCCESS;
}
_VisualElementSurfaceManager::DestroySurface(_GlVisualElementSurfaceImpl* pGlSurface)
{
TextureInfo* pTextureInfo = (TextureInfo*)pGlSurface->GetNativeHandle();
+#ifdef __SHARED_CONTEXT__
+ PRINT(">> _VisualElementSurfaceManager::DestroySurface() texture id %u \n", pTextureInfo->textureId);
+ DeleteTexture(pTextureInfo);
+#else
_GlRenderManager::GetInstance()->DeleteTexture(pTextureInfo);
+#endif
if (pTextureInfo->type == TEXTURE_NORMAL)
{
return E_SUCCESS;
}
+
+#ifdef __SHARED_CONTEXT__
+void*
+_VisualElementSurfaceManager::ThreadProc(void* pData)
+{
+ PRINT(">> _GlRenderManager::RenderProc starts. \n");
+
+ _VisualElementSurfaceManager* pThis = reinterpret_cast< _VisualElementSurfaceManager* >(pData);
+
+
+ for (;;)
+ {
+ bool needReply = true;
+ SurfaceCommand commandId;
+ CommandArg commandArg;
+ bool gotCommand = true;
+
+ {
+ _AutoMutex commandLock(pThis->__commandLock);
+
+ while (pThis->__commandId == COMMAND_UNKNOWN && gotCommand)
+ {
+ gotCommand = pThis->__commandRequest.WaitForSignal(&pThis->__commandLock, -1);
+ }
+
+ commandId = pThis->__commandId;
+ commandArg = pThis->__commandArg;
+
+
+// PRINT(">> command = %d, gotCommand = %d\n", pThis->__commandId, gotCommand);
+
+ // clear command
+ pThis->__commandId = COMMAND_UNKNOWN;
+ }
+
+ // ...........
+ switch (commandId)
+ {
+ case COMMAND_INITIALIZE_MANAGER:
+ pThis->CommandHandlerInitializeManager(commandArg.__pCommandGlContext);
+ break;
+ case COMMAND_INITIALIZE_GLLAYER:
+ pThis->CommandHandlerInitializeGLLayer(commandArg.__pCommandGlLayer);
+ break;
+
+ case COMMAND_FINALIZE_GLLAYER:
+ pThis->CommandHandlerFinalizeGLLayer(commandArg.__pCommandGlLayer);
+ break;
+
+ case COMMAND_CREATE_TEXTURE:
+ pThis->CommandHandlerCreateTexture(commandArg.__pCommandTextureInfo);
+ break;
+
+ case COMMAND_DELETE_TEXTURE:
+ pThis->CommandHandlerDeleteTexture(commandArg.__pCommandTextureInfo);
+ break;
+ default:
+ PRINT("UNKNOWN COMMAND (%d)\n", commandId);
+ needReply = false;
+ break;
+ case COMMAND_EXIT:
+ PRINT("COMMAND_EXIT\n");
+ goto exit_renderer;
+ }
+
+ if (needReply)
+ {
+ _AutoMutex commandLock(pThis->__commandLock);
+
+ pThis->__commandResult = E_SUCCESS;
+ pThis->__commandReply.SendSignal();
+ }
+ }
+exit_renderer:
+
+ delete pThis->__pGlContext;
+
+ {
+ _AutoMutex commandLock(pThis->__commandLock);
+
+ pThis->__commandResult = E_SUCCESS;
+ pThis->__commandReply.SendSignal();
+ }
+
+ return null;
+
+}
+bool
+_VisualElementSurfaceManager::InitializeManager(_GlContext* pContext)
+{
+ if (unlikely(IsSelfThread()))
+ {
+ return CommandHandlerInitializeManager(pContext);
+ }
+
+ _AutoMutex commandTransactionLock(__commandTransaction);
+ _AutoMutex commandLock(__commandLock);
+
+ __commandId = COMMAND_INITIALIZE_MANAGER;
+ __commandArg.__pCommandGlContext = pContext;
+ __commandRequest.SendSignal();
+ __commandReply.WaitForSignal(&__commandLock);
+ return (__commandResult == E_SUCCESS);
+}
+
+bool
+_VisualElementSurfaceManager::InitializeGLLayer(_GlLayer* pGlLayer)
+{
+ _AutoMutex commandTransactionLock(__commandTransaction);
+ _AutoMutex commandLock(__commandLock);
+
+ __commandId = COMMAND_INITIALIZE_GLLAYER;
+ __commandArg.__pCommandGlLayer = pGlLayer;
+ __commandRequest.SendSignal();
+
+ __commandReply.WaitForSignal(&__commandLock);
+ return (__commandResult == E_SUCCESS);
+}
+
+bool
+_VisualElementSurfaceManager::FinalizeGLLayer(_GlLayer* pGlLayer)
+{
+ _AutoMutex commandTransactionLock(__commandTransaction);
+ _AutoMutex commandLock(__commandLock);
+
+ __commandId = COMMAND_FINALIZE_GLLAYER;
+ __commandArg.__pCommandGlLayer = pGlLayer;
+ __commandRequest.SendSignal();
+
+ __commandReply.WaitForSignal(&__commandLock);
+ return (__commandResult == E_SUCCESS);
+}
+
+bool
+_VisualElementSurfaceManager::CreateTexture(TextureInfo* pTextureInfo)
+{
+ _AutoMutex commandTransactionLock(__commandTransaction);
+ _AutoMutex commandLock(__commandLock);
+
+ __commandId = COMMAND_CREATE_TEXTURE;
+ __commandArg.__pCommandTextureInfo = pTextureInfo;
+ __commandRequest.SendSignal();
+ __commandReply.WaitForSignal(&__commandLock);
+ return (__commandResult == E_SUCCESS);
+}
+
+bool
+_VisualElementSurfaceManager::DeleteTexture(TextureInfo* pTextureInfo)
+{
+ // WARNING: Surface can be deleted in render thread because of reference-counting
+ // FIXME: Need to add inline method or macro to determine of current thread is render thread
+ if (unlikely(IsSelfThread()))
+ {
+ return CommandHandlerDeleteTexture(pTextureInfo);
+ }
+
+ _AutoMutex commandTransactionLock(__commandTransaction);
+ _AutoMutex commandLock(__commandLock);
+
+ __commandId = COMMAND_DELETE_TEXTURE;
+ __commandArg.__pCommandTextureInfo = pTextureInfo;
+ __commandRequest.SendSignal();
+ __commandReply.WaitForSignal(&__commandLock);
+ return (__commandResult == E_SUCCESS);
+}
+
+bool
+_VisualElementSurfaceManager::CommandHandlerInitializeManager(_GlContext* pContext)
+{
+ __pInstance->__pGlContext = _GlContext::CreateN(__nativeDisplay, __window, pContext);
+ return true;
+}
+
+bool
+_VisualElementSurfaceManager::CommandHandlerInitializeGLLayer(_GlLayer* pGlLayer)
+{
+
+ ASSERT(!pGlLayer->__surface, "");
+
+ PRINT("[DEBUG]-003 _VisualElementSurfaceManager::CommandHandlerInitializeGLLayer: Create surf... \n" );
+
+ // TODO: jinstar
+ //////////pGlLayer->__surface = __pGlContext->CreateWindowSurface( (Handle)pGlLayer->GetNativeWindow() );
+ __pGlContext->MakeCurrent();
+
+ pGlLayer->__surface = __pGlContext->CreateWindowSurface( (Handle)pGlLayer->GetWindowHandle() );
+
+ PRINT(">> CommandHandlerInitializeGLLayer() surface %p \n", (void*)pGlLayer->__surface);
+
+
+ return true;
+}
+
+bool
+_VisualElementSurfaceManager::CommandHandlerFinalizeGLLayer(_GlLayer* pGlLayer)
+{
+
+ PRINT(">> CommandHandlerFinalizeGLLayer() surface %p \n", (void*)pGlLayer->__surface);
+ __pGlContext->MakeCurrent();
+
+ if (pGlLayer->__surface)
+ {
+ __pGlContext->DestroySurface((Handle)pGlLayer->__surface);
+ pGlLayer->__surface = null;
+ }
+ return true;
+}
+
+bool
+_VisualElementSurfaceManager::CommandHandlerCreateTexture(TextureInfo* pTextureInfo)
+{
+
+ PRINT(">> CommandHandlerCreateTexture() \n");
+ __pGlContext->MakeCurrent();
+
+ return __pGlContext->CreateTexture(pTextureInfo);
+
+}
+
+bool
+_VisualElementSurfaceManager::CommandHandlerDeleteTexture(TextureInfo* pTextureInfo)
+{
+
+ PRINT(">> CommandHandlerDeleteTexture() texture id %u \n", pTextureInfo->textureId);
+
+ __pGlContext->MakeCurrent();
+ __pGlContext->DeleteTexture(pTextureInfo);
+
+
+ return true;
+}
+#endif //__SHARED_CONTEXT__
}}} // Tizen::Ui::Animations
#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_SURFACE_MANAGER_H_
#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_SURFACE_MANAGER_H_
+
+
+
+
#include <FBaseColArrayListT.h>
+#include "FUiAnim_GlContext.h"
+
+#ifdef __SHARED_CONTEXT__
+#include <pthread.h>
+#include "FUiAnim_Waiter.h"
+#endif
namespace Tizen { namespace Base
{
namespace Tizen { namespace Ui { namespace Animations
{
-
+class _GlContext;
class _GlVisualElementSurfaceImpl;
+
//struct TextureInfo;
class _VisualElementSurfaceManager
virtual ~_VisualElementSurfaceManager(void);
public:
+#ifdef __SHARED_CONTEXT__
+ enum SurfaceCommand
+ {
+ COMMAND_UNKNOWN,
+ COMMAND_INITIALIZE_MANAGER,
+ COMMAND_EXIT,
+ COMMAND_INITIALIZE_GLLAYER,
+ COMMAND_FINALIZE_GLLAYER,
+ COMMAND_CREATE_TEXTURE,
+ COMMAND_DELETE_TEXTURE
+ };
+#endif //__SHARED_CONTEXT__
+
static void Initialize(void);
+#ifdef __SHARED_CONTEXT__
+ static void Initialize(Handle nativeDisplay, Handle window,_GlContext& context);
+#endif
static _VisualElementSurfaceManager* GetInstance(void)
{
result CreateSurface(_GlVisualElementSurfaceImpl* pGlSurface);
result DestroySurface(_GlVisualElementSurfaceImpl* pGlSurface);
+#ifdef __SHARED_CONTEXT__
+ static void* ThreadProc(void* pData);
+ bool InitializeManager(_GlContext* pContext);
+ bool InitializeGLLayer(_GlLayer* pGlLayer);
+ bool FinalizeGLLayer(_GlLayer* pGlLayer);
+ bool CreateTexture(TextureInfo* pTextureInfo);
+ bool DeleteTexture(TextureInfo* pTextureInfo);
+private:
+ bool IsSelfThread(void){ return pthread_equal(__threadInfo, pthread_self()); }
+ bool CommandHandlerInitializeManager(_GlContext* pContext);
+ bool CommandHandlerInitializeGLLayer(_GlLayer* pGlLayer);
+ bool CommandHandlerFinalizeGLLayer(_GlLayer* pGlLayer);
+
+ bool CommandHandlerCreateTexture(TextureInfo* pTextureInfo);
+ bool CommandHandlerDeleteTexture(TextureInfo* pTextureInfo);
+
+#endif
private:
_VisualElementSurfaceManager(void);
_VisualElementSurfaceManager(const _VisualElementSurfaceManager& rhs);
AtlasListT __atlasList;
#endif
+#ifdef __SHARED_CONTEXT__
+ typedef union
+ {
+ _GlLayer* __pCommandGlLayer;
+ TextureInfo* __pCommandTextureInfo;
+ _GlContext* __pCommandGlContext;
+ } CommandArg;
+ pthread_t __threadInfo;
+ _GlContext* __pGlContext;
+ SurfaceCommand __commandId;
+ CommandArg __commandArg;
+ result __commandResult;
+
+ _Mutex __commandTransaction;
+ _Mutex __commandLock;
+ _Waiter __commandRequest;
+ _Waiter __commandReply;
+
+ Handle __nativeDisplay;
+ Handle __window;
+#endif //__SHARED_CONTEXT__
}; // _VisualElementSurfaceManager
}}} // Tizen::Ui::Animations
#define NATIVE_PIXMAP_PADDING_VALUE 2 // Redwood old target
//#define NATIVE_PIXMAP_PADDING_VALUE 32 // Redwood 8974
-_Egl::_Egl(Handle nativeDisplay, Handle window)
+_Egl::_Egl(Handle nativeDisplay, Handle window, _Egl* pSharedContext)
: _GlContext(nativeDisplay, window)
, __display(EGL_NO_DISPLAY)
, __context(EGL_NO_CONTEXT)
SysAssertf(nativeDisplay, "Invalid display");
SysAssertf(GetDisplay(nativeDisplay), "Failed to get display.");
- SysAssertf(CreateContext(), "Failed to create context.");
+ SysAssertf(CreateContext((pSharedContext)?pSharedContext->__context : EGL_NO_CONTEXT), "Failed to create context.");
if (window)
{
}
bool
-_Egl::CreateContext(void)
+_Egl::CreateContext(EGLContext sharedContext)
{
if (__context != EGL_NO_CONTEXT)
return true;
- EGLint eglContextList[] =
+ EGLint eglAttributeList[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
return false;
}
- __context = eglCreateContext(__display, __config, EGL_NO_CONTEXT, eglContextList);
+ __context = eglCreateContext(__display, __config, sharedContext/*EGL_NO_CONTEXT*/, eglAttributeList);
if (__context == EGL_NO_CONTEXT || eglGetError() != EGL_SUCCESS)
{
SysLog(NID_UI_ANIM, "eglCreateContext failed.");
pPixmapInfo = CreateNativePixmap(pTextureInfo);
SysTryReturn(NID_UI_ANIM, pPixmapInfo, false, E_INVALID_STATE, "Creating native pixmap failed.");
+ EGLContext context = EGL_NO_CONTEXT;//__context;
#ifdef VE_USE_NATIVE_BUFFER
- pPixmapInfo->__eglImage = funcEglCreateImageKHR(__display, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_TIZEN, (EGLClientBuffer)pPixmapInfo->__pNativeBuffer, NULL);
+ pPixmapInfo->__eglImage = funcEglCreateImageKHR(__display, context, EGL_NATIVE_BUFFER_TIZEN, (EGLClientBuffer)pPixmapInfo->__pNativeBuffer, NULL);
#else
- pPixmapInfo->__eglImage = funcEglCreateImageKHR(__display, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)pPixmapInfo->__nativePixmap, NULL);
+ pPixmapInfo->__eglImage = funcEglCreateImageKHR(__display, context, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)pPixmapInfo->__nativePixmap, NULL);
#endif
+
SysTryReturn(NID_UI_ANIM, pPixmapInfo->__eglImage != (EGLImageKHR)0, false, E_INVALID_STATE, "Creating ImageKHR failed.");
funcGlEglImageTargetTexture2DOES(GL_TEXTURE_2D, pPixmapInfo->__eglImage);
pNativeDisplay = (Display*)__nativeDisplay;
nativeWindow = DefaultRootWindow(pNativeDisplay);
+ PRINT("XXXXXXX-ERROR1 size(%d,%d)\n", pTextureInfo->width, pTextureInfo->height);
pPixmapInfo->__nativePixmap = XCreatePixmap(pNativeDisplay, nativeWindow, pTextureInfo->width, pTextureInfo->height, pTextureInfo->bitsPerPixel);
if (pPixmapInfo->__nativePixmap == (Pixmap)0)
{
PRINT("Error 1!\n");
goto CATCH_01;
}
+ PRINT("XXXXXXX-ERROR2\n");
DRI2CreateDrawable(pNativeDisplay, pPixmapInfo->__nativePixmap);
+ PRINT("XXXXXXX-ERROR3\n");
XSync(pNativeDisplay, False);
+ PRINT("XXXXXXX-ERROR4\n");
+
ret = DRI2Connect(pNativeDisplay, nativeWindow, &pDriverName, &pDeviceName);
+ PRINT("XXXXXXX-ERROR5\n");
free(pDriverName);
+ PRINT("XXXXXXX-ERROR6\n");
if (!ret || pDeviceName == null)
{
PRINT("Error 2!\n");
}
pPixmapInfo->__drmFd = open(pDeviceName, O_RDWR);
+ PRINT("XXXXXXX-ERROR7\n");
free(pDeviceName);
if (pPixmapInfo->__drmFd < 0)
{
goto CATCH_02;
}
+ PRINT("XXXXXXX-ERROR8\n");
+
drmGetMagic(pPixmapInfo->__drmFd, &magic);
ret = DRI2Authenticate(pNativeDisplay, nativeWindow, (unsigned int)magic);
if (!ret)
goto CATCH_03;
}
+ PRINT("XXXXXXX-ERROR9\n");
+
pPixmapInfo->__pTbmBufMgr = (void*)tbm_bufmgr_init(pPixmapInfo->__drmFd);
if (pPixmapInfo->__pTbmBufMgr == null)
{
goto CATCH_03;
}
+ PRINT("XXXXXXX-ERROR10\n");
+
pDri2Buffer = DRI2GetBuffers(pNativeDisplay, pPixmapInfo->__nativePixmap, &dri2Width, &dri2Height, attachments, 1, &dri2BufferCount);
if (pDri2Buffer == null)
{
goto CATCH_04;
}
+ PRINT("XXXXXXX-ERROR11\n");
pPixmapInfo->__pTbmBufferObject = (void*)tbm_bo_import((tbm_bufmgr)pPixmapInfo->__pTbmBufMgr, pDri2Buffer->name);
free(pDri2Buffer);
if (pPixmapInfo->__pTbmBufferObject == null)
goto CATCH_04;
}
+ PRINT("XXXXXXX-ERROR12\n");
+
tbmData = tbm_bo_get_handle((tbm_bo)pPixmapInfo->__pTbmBufferObject, TBM_DEVICE_CPU);
if (tbmData.ptr == null)
{
goto CATCH_05;
}
+ PRINT("XXXXXXX-ERROR13\n");
+
pTextureInfo->pPixels = (unsigned long*)tbmData.ptr;
if (pTextureInfo->pPixels == null)
{
: public _GlContext
{
public:
- _Egl(Handle nativeDisplay, Handle window);
+ _Egl(Handle nativeDisplay, Handle window, _Egl* pSharedContext);
virtual ~_Egl(void);
virtual bool MakeCurrent(Handle surface = 0);
};
bool GetDisplay(Handle nativeDisplay);
- bool CreateContext(void);
+ bool CreateContext(EGLContext sharedContext);
EGLConfig GetConfig(bool useAlpha, bool useStencil, bool useDepth) const;
virtual Handle CreateWindowSurface(Handle window);
#endif
_GlContext*
-_GlContext::CreateN(Handle nativeDisplay, Handle window)
+_GlContext::CreateN(Handle nativeDisplay, Handle window, _GlContext* pSharedContext)
{
SysAssertf(nativeDisplay, "Invalid display");
_GlContext* pGlContext = null;
#ifndef BUILD_UI_CORE
- pGlContext = new (std::nothrow) _Egl(nativeDisplay, window);
+ pGlContext = new (std::nothrow) _Egl(nativeDisplay, window, dynamic_cast<_Egl*>(pSharedContext));
#elif _WIN32
pGlContext = new (std::nothrow) _Wgl(nativeDisplay, window);
#elif LINUX
//#elif
// pGlContext = new (std::nothrow) _Agl(nativeDisplay, window);
#endif
-
+ if(_VisualElementSurfaceManager::GetInstance() == null)
+ {
+#ifdef __SHARED_CONTEXT__
+ _VisualElementSurfaceManager::Initialize(nativeDisplay,window, *pGlContext);
+#else
+ _VisualElementSurfaceManager::Initialize();
+#endif
+ }
return pGlContext;
}
__pTextureShaderAlphaMaskExtra2[i] = null;
}
+
PRINT(">> _GlContext:_GlContext() \n");
}
{
SysTryReturnResult(NID_UI_ANIM, !__pInstance, E_OBJ_ALREADY_EXIST, "The GL context already created.");
- __pInstance = _GlContext::CreateN(nativeDisplay, null);
+ __pInstance = _GlContext::CreateN(nativeDisplay, null, null);
if (!__pInstance)
{
return E_OUT_OF_MEMORY;