namespace Tizen { namespace Ui { namespace Animations
{
-#ifdef _OSP_PERF_
+
int _ElapsedTime::depth = 0;
char _ElapsedTime::logs[500][256];
int _ElapsedTime::maxdepth = 0;
int _ElapsedTime::count = 0;
-#endif
+
#define DIGITATPOSITION(number, digit) static_cast< int >((number % static_cast< int >(powf(10.0f, (digit)))) / powf(10.0f, (digit - 1)))
{
#ifdef VE_DEBUG_MODULE
+class VisualElement;
-#ifdef _OSP_PERF_
class _ElapsedTime
{
public:
long long start_time;
const char* tagName;
}; // _ElapsedTime
-#endif
#define VeLog(UID, ...) \
SysLogInternal(UID, 0, 0, __VA_ARGS__);
using namespace Tizen::Ui;
using namespace Tizen::Ui::Animations;
-//#define PRINT(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
+//#define PRINT(...) fprintf(stderr, __VA_ARGS__)
#define PRINT(...)
#include <stdio.h>
-//#define PRINT(FMT__,...) fprint(stderr, __VA_ARGS__)
+//#define PRINT(...) fprint(__VA_ARGS__)
//#define PRINT(...) SysLog(NID_UI_ANIM, __VA_ARGS__)
#define PRINT(...)
class _GlContext
{
public:
- static _GlContext* CreateN(Handle nativeDisplay, Handle window, _GlContext* pSharedContext);
+ static _GlContext* CreateN(Handle nativeDisplay, Handle window);
+ static _GlContext* CreateN(_GlContext& sharedContext);
#ifndef VE_USE_GL_MULTI_CONTEXT
static _GlContext* GetInstance(void)
protected:
Handle __nativeDisplay; //TODO remove
+ Handle __window;
bool __supportBGRA8888;
#ifndef VE_USE_GL_MULTI_CONTEXT
static _GlContext* __pInstance;
#endif
+ _GlContext* __pSharedContext;
friend class _GlRenderManager;
friend class _VisualElementSurfaceManager;
#include "FUiAnim_ShaderProgramImpl.h"
//#define PRINT(...) fprintf(stderr, __VA_ARGS__)
-#define PRINT
+#define PRINT(...)
using namespace Tizen;
using namespace Tizen::Base;
}
}
+
// Set texture info
__texSize = pSurfaceImpl->GetPhysicalSize();
__textureId = ((TextureInfo*)pSurfaceImpl->GetNativeHandle())->textureId;
+
// Calc texture coordinates
if (__useStencil)
{
//#define PRINT(...) fprintf(stderr, __VA_ARGS__)
#define PRINT(...)
-#if 0
-static bool __checkCondition(bool condition)
-{
- bool bCond = condition;
- if(bCond == false)
- {
- return bCond;
- }
- return bCond;
-}
-#endif
+//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__)
glUniform1i(pProgramImpl->__uniformLocation[UNIFORM_SAMPLER2D_TEXTURE], 0);
- if (__pRenderQueue[i].__isTexUpdated)
+
+ if ( __pRenderQueue[i].__isTexUpdated)
{
__pGlContext->UpdateTexture(__pRenderQueue[i].__pSurfaceInfo);
}
CHECK_GL_CONTEXT(pGlContext);
- PRINT(">> CommandHandlerCreateTexture() \n");
+ PRINT(">> _GlRenderManager::CommandHandlerCreateTexture() \n");
pGlContext->MakeCurrent();
#else
CHECK_GL_CONTEXT();
- PRINT(">> CommandHandlerCreateTexture() \n");
+ PRINT(">> _GlRenderManager::CommandHandlerCreateTexture() \n");
return __pGlContext->CreateTexture(pTextureInfo);
#endif
pGlContext->MakeCurrent();
- PRINT(">> CommandHandlerDeleteTexture() texture id %u \n", pTextureInfo->textureId);
+ PRINT(">> _GlRenderManager::CommandHandlerDeleteTexture() texture id %u \n", pTextureInfo->textureId);
pGlContext->DeleteTexture(pTextureInfo);
#else
CHECK_GL_CONTEXT();
- PRINT(">> CommandHandlerDeleteTexture() texture id %u \n", pTextureInfo->textureId);
+ PRINT(">> _GlRenderManager::CommandHandlerDeleteTexture() texture id %u \n", pTextureInfo->textureId);
__pGlContext->DeleteTexture(pTextureInfo);
#endif
#ifdef ECORE_X_NATIVE
_EcoreXLooper* pLooper = static_cast<_EcoreXLooper*>(_Looper::GetInstance());
_GlContext::CreateInstance(reinterpret_cast<Handle>(pLooper->GetXDisplay()) );
+
#endif
pThis->__pGlContext = _GlContext::GetInstance();
#endif
+ if(_VisualElementSurfaceManager::GetInstance() == null)
+ {
+#ifdef __SHARED_CONTEXT__
+ _VisualElementSurfaceManager::CreateInstance(*pThis->__pGlContext);
+#else
+ _VisualElementSurfaceManager::Initialize();
+#endif
+ }
+
pThis->__pAnimationManager = _AnimationManager::GetInstance();
pThis->__pGlContext = null;
#endif
+ _VisualElementSurfaceManager::ReleaseInstance();
+
_GlesInterfaceTerminate();
{
#include "FUiAnim_GlVisualElementSurfaceImpl.h"
#include "FUiAnim_VisualElementSurfaceManager.h"
+//#define PRINT(...) fprintf(stderr, __VA_ARGS__)
+#define PRINT(...)
+
using namespace Tizen::Base;
using namespace Tizen::Graphics;
__textureInfo.stride = 0;
__textureInfo.bitsPerPixel = 0;
+
if (_VisualElementSurfaceManager::GetInstance()->CreateSurface(this) != E_SUCCESS)
{
SysAssertf(false, "Cannot initialize GL texture for surface");
//};
_VisualElementCanvas::_VisualElementCanvas(void)
+ : __pSurface(null)
{
}
_VisualElementCanvas::~_VisualElementCanvas(void)
{
+ if(__pSurface)
+ {
+ _VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*__pSurface);
+ pSurfaceImpl->Invalidate(true);
+
+ delete __pSurface;
+ __pSurface = null;
+ }
}
// TODO:
{
ClearLastResult();
+ if(__pSurface)
+ {
+ return E_OBJ_ALREADY_EXIST;
+ }
+
+ __pSurface = new (std::nothrow) VisualElementSurface(surface);
+ SysTryReturnResult(NID_UI, __pSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+
Tizen::Graphics::_CanvasImpl* pCanvasImpl = Tizen::Graphics::_CanvasImpl::GetInstance(*this);
SysTryReturnResult(NID_UI, pCanvasImpl, E_OUT_OF_MEMORY, "Memory allocation failed.");
- SysTryReturnResult(NID_UI, _VisualElementSurfaceImpl::GetInstance(surface), E_SYSTEM, "A system error has been occurred. Invalid surface.");
+ SysTryReturnResult(NID_UI, _VisualElementSurfaceImpl::GetInstance(*__pSurface), E_SYSTEM, "A system error has been occurred. Invalid surface.");
- Handle window = _VisualElementSurfaceImpl::GetInstance(surface)->GetNativeHandle();
+ Handle window = _VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle();
#ifdef ENABLE_VE_EFL
Tizen::Graphics::_Canvas* pNativeCanvas = pCanvasImpl->_pNativeCanvas;
result
_VisualElementCanvas::Construct(const VisualElementSurface& surface, const Tizen::Graphics::FloatRectangle& rectangle, bool useEfl)
{
+ if(__pSurface)
+ {
+ return E_OBJ_ALREADY_EXIST;
+ }
+
+ __pSurface = new (std::nothrow) VisualElementSurface(surface);
+ SysTryReturnResult(NID_UI, __pSurface, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
Tizen::Graphics::_CanvasImpl* pCanvasImpl = Tizen::Graphics::_CanvasImpl::GetInstance(*this);
SysTryReturnResult(NID_UI, pCanvasImpl, E_OUT_OF_MEMORY, "Memory allocation failed.");
- SysTryReturnResult(NID_UI, _VisualElementSurfaceImpl::GetInstance(surface), E_SYSTEM, "A system error has been occurred. Invalid surface.");
+ SysTryReturnResult(NID_UI, _VisualElementSurfaceImpl::GetInstance(*__pSurface), E_SYSTEM, "A system error has been occurred. Invalid surface.");
- Handle window = _VisualElementSurfaceImpl::GetInstance(surface)->GetNativeHandle();
+ Handle window = _VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle();
#ifdef ENABLE_VE_EFL
Tizen::Graphics::_Canvas* pNativeCanvas = pCanvasImpl->_pNativeCanvas;
{
pPropertyAnimation->SetEndValue(newValue);
}
- pPropertyAnimation->SetStartValue(Variant());
+ //pPropertyAnimation->SetStartValue(Variant()); //default is empty
+
}
// if (isCustomProperty)
// pRenderTarget->SetFlushNeeded();
// pRenderTarget->GetSharedData().pNativeNode->SetFlushNeeded();
- _VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pSurface);
- pSurfaceImpl->Invalidate(true);
+
+
+// _VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pSurface);
+// pSurfaceImpl->Invalidate(true);
+
// pRenderTarget->GetRootPublic()->SetNeedsSurfaceUpdate(true);
#ifdef VE_USE_GL_MULTI_CONTEXT
#include "FUiAnim_GlContext.h"
#endif
+#ifdef ECORE_X_NATIVE
+#include "FUiAnim_EcoreXLooper.h"
+#endif
+
//#define PRINT(...) fprintf(stderr, __VA_ARGS__)
#define PRINT(...)
-#if 0
-static bool __checkCondition(bool condition)
-{
- bool bCond = condition;
- if(bCond == false)
- {
- return bCond;
- }
- return bCond;
-}
-#endif
+
+//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__)
_VisualElementSurfaceManager* _VisualElementSurfaceManager::__pInstance = null;
void
-_VisualElementSurfaceManager::Initialize(void)
+_VisualElementSurfaceManager::CreateInstance(void)
{
if (!__pInstance)
{
- static _VisualElementSurfaceManager instance;
- __pInstance = &instance;
+ __pInstance = new _VisualElementSurfaceManager;
}
}
#ifdef __SHARED_CONTEXT__
void
-_VisualElementSurfaceManager::Initialize(Handle nativeDisplay, Handle window,_GlContext& context)
+_VisualElementSurfaceManager::CreateInstance(_GlContext& context)
{
if (!__pInstance)
{
- static _VisualElementSurfaceManager instance;
- __pInstance = &instance;
- __pInstance->__nativeDisplay = nativeDisplay;
- __pInstance->__window = window;
+ __pInstance = new _VisualElementSurfaceManager;
+#ifdef ECORE_X_NATIVE
+ _EcoreXLooper* pLooper = static_cast<_EcoreXLooper*>(_Looper::GetInstance());
+ Handle display = reinterpret_cast<Handle>(pLooper->GetXDisplay());
+ __pInstance->__nativeDisplay = display;
+#endif
__pInstance->InitializeManager(&context);
-
}
}
#endif
+void
+_VisualElementSurfaceManager::ReleaseInstance(void)
+{
+ if (!__pInstance)
+ {
+ __pInstance = null;
+ }
+}
_VisualElementSurfaceManager::_VisualElementSurfaceManager(void)
#ifdef __SHARED_CONTEXT__
_VisualElementSurfaceManager::~_VisualElementSurfaceManager(void)
{
#ifdef __SHARED_CONTEXT__
- delete __pGlContext;
+
+ _AutoMutex commandTransactionLock(__commandTransaction);
+ _AutoMutex commandLock(__commandLock);
+
+ __commandId = COMMAND_EXIT;
+ __commandRequest.SendSignal();
+
+ __commandReply.WaitForSignal(&__commandLock);
+
+ pthread_join(__threadInfo, NULL);
+
+
#endif
}
break;
case COMMAND_EXIT:
PRINT("COMMAND_EXIT\n");
+ pThis->CommandHandlerFinalizeManager();
goto exit_renderer;
}
return null;
}
+
bool
_VisualElementSurfaceManager::InitializeManager(_GlContext* pContext)
{
bool
_VisualElementSurfaceManager::CommandHandlerInitializeManager(_GlContext* pContext)
{
- __pInstance->__pGlContext = _GlContext::CreateN(__nativeDisplay, __window, pContext);
+ __pGlContext = _GlContext::CreateN(*pContext);
+ return true;
+}
+
+bool
+_VisualElementSurfaceManager::CommandHandlerFinalizeManager(void)
+{
+ delete __pGlContext;
+ __pGlContext = null;
return true;
}
+
bool
_VisualElementSurfaceManager::CommandHandlerInitializeGLLayer(_GlLayer* pGlLayer)
{
};
#endif //__SHARED_CONTEXT__
- static void Initialize(void);
+ static void CreateInstance(void);
#ifdef __SHARED_CONTEXT__
- static void Initialize(Handle nativeDisplay, Handle window,_GlContext& context);
+ static void CreateInstance(_GlContext& context);
#endif
+ static void ReleaseInstance(void);
+
static _VisualElementSurfaceManager* GetInstance(void)
{
return __pInstance;
private:
bool IsSelfThread(void){ return pthread_equal(__threadInfo, pthread_self()); }
bool CommandHandlerInitializeManager(_GlContext* pContext);
+ bool CommandHandlerFinalizeManager(void);
bool CommandHandlerInitializeGLLayer(_GlLayer* pGlLayer);
bool CommandHandlerFinalizeGLLayer(_GlLayer* pGlLayer);
Eina_Bool
OnIdleEntered(void* pData)
{
+ PRINT("OnIdlerEnter() \n");
if(_DisplayManager::GetInstance()->HasUpdates())
{
PRINT("RAWEVENT_DRAW() \n");
_EcoreXLooper* pLooper = static_cast<_EcoreXLooper*>(_Looper::GetInstance());
_RawEvent rawEvent;
bool event = true;
+ int loop = 0;
do
{
+ PRINT("OnIdlerEnter() - Loop(%d)\n", loop);
pLooper->MonitorEvents();
event = pLooper->PeekRawEvent(rawEvent, true);
if (event)
{
pLooper->DispatchRawEvent(rawEvent);
}
+ loop++;
} while (event == true);
+ PRINT("OnIdlerEnter() - Exit\n");
+
return EINA_TRUE;
}
* This file contains implementation _Egl class.
*/
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
#include <FBaseResult.h>
#include <FBaseSysLog.h>
#include "FUiAnim_GlVisualElementSurfaceImpl.h"
#include "FUiAnim_VisualElementSurfaceManager.h"
#include "FUiAnim_Egl.h"
-
+#include "FUiAnim_Debug.h"
#if !defined(VE_SIMULATOR) && !defined(BUILD_UI_CORE)
#include <X11/Xlib.h>
// depends on target
#define NATIVE_PIXMAP_PADDING_VALUE 2 // Redwood old target
//#define NATIVE_PIXMAP_PADDING_VALUE 32 // Redwood 8974
+#define SCREEN_SIZE (720*1280)
_Egl::_Egl(Handle nativeDisplay, Handle window, _Egl* pSharedContext)
: _GlContext(nativeDisplay, window)
, __dummySurface(EGL_NO_SURFACE)
, __nativeDummyPixmap(0)
#endif
+#ifdef USE_EGL_IMAGE
+ , __funcEglCreateImageKHR(null)
+ , __funcGlEglImageTargetTexture2DOES(null)
+ , __funcEglDestroyImageKhr(null)
+ , __cachePixmapSize(0)
+#endif
{
SysAssertf(nativeDisplay, "Invalid display");
CheckBGRASupport();
InitGL();
-
+#ifdef USE_EGL_IMAGE
__nativePixmaps.Construct();
-
+ __deletedPixmaps.Construct(500);
+#endif
PRINT(">> _Egl:_Egl() \n");
}
_Egl::~_Egl(void)
{
+#ifdef USE_EGL_IMAGE
+ CleanCacheIfNeeded(true);
+#endif
TerminateGL();
#ifndef BUILD_UI_CORE
_PixmapInfo* pPixmapInfo = null;
__nativePixmaps.GetValue(pTextureInfo->textureId, pPixmapInfo);
+ __nativePixmaps.Remove(pTextureInfo->textureId);
+
+ if (pPixmapInfo)
+ {
+ AddToCache(*pPixmapInfo);
+ }
+#endif
+}
+#ifdef USE_EGL_IMAGE
+bool
+_Egl::AddToCache(_PixmapInfo& pixmapInfo)
+{
+ if(pixmapInfo.__width * pixmapInfo.__height > (SCREEN_SIZE/2))
+ {
+ DeletePixmapTexture(&pixmapInfo);
+ return false;
+ }
+
+ if(__deletedPixmaps.Add(&pixmapInfo) != E_SUCCESS)
+ {
+ DeletePixmapTexture(&pixmapInfo);
+ return false;
+ }
+ __cachePixmapSize += pixmapInfo.__width * pixmapInfo.__height;
+ // if too big it should be deleted directly.
+ return true;
+}
+
+bool
+_Egl::PickPixmapFromCache(unsigned int textureId, TextureInfo &textureInfo)
+{
+ _PixmapInfo* pPixmapInfo = null;
+ int count = __deletedPixmaps.GetCount();
+ for (int i = count-1 ; i >= 0; i--) //search form end
+ {
+ if (__deletedPixmaps.GetAt(i, pPixmapInfo) == E_SUCCESS)
+ {
+ // WARNING: is condition right?
+ if ( pPixmapInfo != null
+ && pPixmapInfo->__width == textureInfo.width
+ && pPixmapInfo->__height == textureInfo.height
+ && pPixmapInfo->__bitsPerPixel == textureInfo.bitsPerPixel)
+ {
+ __deletedPixmaps.RemoveAt(i);
+ __nativePixmaps.Add(textureId, pPixmapInfo);
+ textureInfo.pPixels = pPixmapInfo->__pPixels;
+ textureInfo.stride = pPixmapInfo->__stride;
+ pPixmapInfo->__reuseCount++;
+
+ __funcGlEglImageTargetTexture2DOES(GL_TEXTURE_2D, pPixmapInfo->__eglImage);
+ PRINT("_Egl::CreateDynamicTexture found pixmap in the cache(%d) , return \n",i);
+ return true;
+ }
+
+ }
+ }
+ return false;
+}
+
+void
+_Egl::CleanCacheIfNeeded(bool fullClean)
+{
+ _PixmapInfo* pPixmapInfo = null;
+ int count = __deletedPixmaps.GetCount();
+ if(fullClean ==true )
+ {
+ for (int i = 0 ; i < count; i++)
+ {
+ if (__deletedPixmaps.GetAt(i, pPixmapInfo) == E_SUCCESS)
+ {
+ if(pPixmapInfo != null)
+ {
+ DeletePixmapTexture(pPixmapInfo);
+ }
+
+ }
+ }
+ __deletedPixmaps.RemoveAll();
+ }
+ else
+ {
+ if(__cachePixmapSize >= SCREEN_SIZE*4)
+ {
+ for (int i = count ; i >=0 ; i--)
+ {
+ if (__deletedPixmaps.GetAt(i, pPixmapInfo) == E_SUCCESS)
+ {
+ if(pPixmapInfo != null)
+ {
+ if(pPixmapInfo->__reuseCount > 10)
+ {
+ pPixmapInfo->__reuseCount -=2;
+ continue;
+ }
+
+ DeletePixmapTexture(pPixmapInfo);
+ }
+ __deletedPixmaps.RemoveAt(i);
+
+ }
+ }
+ }
+ }
+}
+
+void
+_Egl::DeletePixmapTexture(_PixmapInfo* pPixmapInfo)
+{
if (pPixmapInfo)
{
//TODO: member variable
- PFNEGLDESTROYIMAGEKHRPROC funcEglDestroyImageKhr = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
- SysTryReturnVoidResult(NID_GRP, funcEglDestroyImageKhr != null, E_SYSTEM, "Destroy ImageKHR failed.");
+
+ if (!__funcEglDestroyImageKhr )
+ {
+ __funcEglDestroyImageKhr = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
+ }
+
+ SysTryReturnVoidResult(NID_GRP, __funcEglDestroyImageKhr != null, E_SYSTEM, "Destroy ImageKHR failed.");
PRINT("_Egl::DeleteTexture: pPixmapInfo = %p, eglImage = %p\n", pPixmapInfo, pPixmapInfo->__eglImage);
- funcEglDestroyImageKhr(__display, pPixmapInfo->__eglImage);
+ __funcEglDestroyImageKhr(__display, pPixmapInfo->__eglImage);
#ifdef VE_USE_NATIVE_BUFFER
native_buffer_destroy((native_buffer_t*)pPixmapInfo->__pNativeBuffer);
XFreePixmap((Display*)__nativeDisplay, pPixmapInfo->__nativePixmap);
#endif
-
- __nativePixmaps.Remove(pTextureInfo->textureId);
-
delete pPixmapInfo;
}
-#endif
+
}
+#endif
bool
_Egl::CreateDynamicTexture(unsigned int textureId, TextureInfo* pTextureInfo)
{
#ifdef USE_EGL_IMAGE
_PixmapInfo* pPixmapInfo;
+ if (!__funcEglCreateImageKHR)
+ {
+ __funcEglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
+ }
+ if (!__funcGlEglImageTargetTexture2DOES)
+ {
+ __funcGlEglImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
+ }
- PFNEGLCREATEIMAGEKHRPROC funcEglCreateImageKHR =
- (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
- PFNGLEGLIMAGETARGETTEXTURE2DOESPROC funcGlEglImageTargetTexture2DOES =
- (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
- SysAssertf((funcEglCreateImageKHR != null && funcGlEglImageTargetTexture2DOES != null), "eglImageKHR is not supported.")
-
+ SysAssertf((__funcEglCreateImageKHR != null && __funcGlEglImageTargetTexture2DOES != null), "eglImageKHR is not supported.");
// SysTryReturn(NID_UI_ANIM, (funcEglCreateImageKHR != null && funcGlEglImageTargetTexture2dOes != null),
// E_UNSUPPORTED_OPERATION, "eglCreateImageKHR");
+ if(PickPixmapFromCache(textureId, *pTextureInfo) == true)
+ {
+ return true;
+ }
+ CleanCacheIfNeeded();
+
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, 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, 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);
+ __funcGlEglImageTargetTexture2DOES(GL_TEXTURE_2D, pPixmapInfo->__eglImage);
// Set surface info
#ifdef VE_USE_NATIVE_BUFFER
#else
pTextureInfo->stride = (pTextureInfo->width + NATIVE_PIXMAP_PADDING_VALUE - 1) / NATIVE_PIXMAP_PADDING_VALUE * NATIVE_PIXMAP_PADDING_VALUE * pTextureInfo->bitsPerPixel / 8;
#endif
+ pPixmapInfo->__stride = pTextureInfo->stride;
__nativePixmaps.Add(textureId, pPixmapInfo);
return false;
#endif
}
-
+#ifdef USE_EGL_IMAGE
_Egl::_PixmapInfo*
_Egl::CreateNativePixmap(TextureInfo *pTextureInfo)
{
-#ifdef USE_EGL_IMAGE
+
_PixmapInfo* pPixmapInfo = null;
pPixmapInfo = new (std::nothrow) _PixmapInfo();
SysTryReturn(NID_UI_ANIM, pPixmapInfo, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ pPixmapInfo->__width = pTextureInfo->width;
+ pPixmapInfo->__height = pTextureInfo->height;
+ pPixmapInfo->__bitsPerPixel = pTextureInfo->bitsPerPixel;
+
#ifdef VE_USE_NATIVE_BUFFER
pPixmapInfo->__pProvider = (void*)native_buffer_provider_create(NATIVE_BUFFER_PROVIDER_CORE);
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)
{
PRINT("Error 9!\n");
goto CATCH_05;
}
+ pPixmapInfo->__pPixels = pTextureInfo->pPixels;
PRINT("_Egl::CreateNativePixmap: pPixels = 0x%p\n", pTextureInfo->pPixels);
SysLog(NID_UI_ANIM, "CreateNativePixmap failed!!");
#endif
-#endif
return null;
}
-
+#endif
}}} // Tizen::Ui::Animations
#include <EGL/egl.h>
#include <EGL/eglext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#include <FBaseDataType.h>
#include <FBaseColHashMapT.h>
{
//#define VE_USE_NATIVE_BUFFER
-
+#define USE_EGL_IMAGE
struct TextureInfo;
class _Egl
virtual void SwapBuffers(void) const;
private:
+#ifdef USE_EGL_IMAGE
class _PixmapInfo
{
public:
, __pTbmBufferObject(null)
, __drmFd(0)
#endif
+ , __width(0)
+ , __height(0)
+ , __stride(0)
+ , __bitsPerPixel(0)
+ , __pPixels(null)
, __eglImage(null)
{
}
void* __pTbmBufferObject; // tbm_bo
int __drmFd;
#endif
+ int __width;
+ int __height;
+ int __stride;
+ int __bitsPerPixel;
+ long __reuseCount;
+ unsigned long* __pPixels;
EGLImageKHR __eglImage;
};
-
+#endif
bool GetDisplay(Handle nativeDisplay);
bool CreateContext(EGLContext sharedContext);
EGLConfig GetConfig(bool useAlpha, bool useStencil, bool useDepth) const;
virtual bool CreateDynamicTexture(unsigned int textureId, TextureInfo* pTextureInfo);
virtual void DeleteDynamicTexture(TextureInfo *pTextureInfo);
+#ifdef USE_EGL_IMAGE
_PixmapInfo* CreateNativePixmap(TextureInfo *pTextureInfo);
-
+#endif
+private:
+#ifdef USE_EGL_IMAGE
+ void DeletePixmapTexture(_PixmapInfo* pPixmapInfo);
+ bool AddToCache(_PixmapInfo& pixmapInfo);
+ bool PickPixmapFromCache(unsigned int textureId, TextureInfo &textureInfo);
+ void CleanCacheIfNeeded(bool fullClean = false);
+#endif
private:
EGLDisplay __display;
EGLContext __context;
EGLSurface __dummySurface;
Handle __nativeDummyPixmap; // for dummy
#endif
+#ifdef USE_EGL_IMAGE
+ PFNEGLCREATEIMAGEKHRPROC __funcEglCreateImageKHR;
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC __funcGlEglImageTargetTexture2DOES ;
+ PFNEGLDESTROYIMAGEKHRPROC __funcEglDestroyImageKhr;
Tizen::Base::Collection::HashMapT<int, _PixmapInfo*> __nativePixmaps;
-
+ Tizen::Base::Collection::ArrayListT<_PixmapInfo*> __deletedPixmaps;
+ unsigned long __cachePixmapSize;
+#endif
friend class _GlRenderManager;
};
#endif
_GlContext*
-_GlContext::CreateN(Handle nativeDisplay, Handle window, _GlContext* pSharedContext)
+_GlContext::CreateN(Handle nativeDisplay, Handle window)
{
SysAssertf(nativeDisplay, "Invalid display");
_GlContext* pGlContext = null;
#ifndef BUILD_UI_CORE
- pGlContext = new (std::nothrow) _Egl(nativeDisplay, window, dynamic_cast<_Egl*>(pSharedContext));
+ pGlContext = new (std::nothrow) _Egl(nativeDisplay, window,null);
#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();
+ return pGlContext;
+}
+
+_GlContext*
+_GlContext::CreateN(_GlContext& sharedContext)
+{
+ _GlContext* pGlContext = null;
+
+#ifndef BUILD_UI_CORE
+ pGlContext = new (std::nothrow) _Egl(sharedContext.__nativeDisplay, sharedContext.__window, dynamic_cast<_Egl*>(&sharedContext));
+#elif _WIN32
+ pGlContext = new (std::nothrow) _Wgl(sharedContext.__nativeDisplay, sharedContext.__window);// to do implementation
+#elif LINUX
+ pGlContext = new (std::nothrow) _Xgl(sharedContext.__nativeDisplay, sharedContext.__window);// to do implementation
+//#elif
+// pGlContext = new (std::nothrow) _Agl(nativeDisplay, window);
#endif
- }
return pGlContext;
}
_GlContext::_GlContext(Handle nativeDisplay, Handle window)
: __nativeDisplay(nativeDisplay)
+ , __window(window)
, __supportBGRA8888(false)
, __useBlend(false)
, __useStencil(false)
{
SysTryReturnResult(NID_UI_ANIM, !__pInstance, E_OBJ_ALREADY_EXIST, "The GL context already created.");
- __pInstance = _GlContext::CreateN(nativeDisplay, null, null);
+ __pInstance = _GlContext::CreateN(nativeDisplay, null);
if (!__pInstance)
{
return E_OUT_OF_MEMORY;
void
_GlContext::UpdateTexture(TextureInfo* pTextureInfo)
{
-#ifndef USE_EGL_IMAGE
+
// BindTexture(pTextureInfo->textureId);
-// if (pTextureInfo->type == TEXTURE_EGL_NORMAL && pTextureInfo->updated)
+// if (pTextureInfo->type == TEXTURE_NORMAL && pTextureInfo->updated)
if (pTextureInfo->type == TEXTURE_NORMAL)
{
LoadTexture(pTextureInfo, false);
pTextureInfo->updated = false;
}
-#endif
}
void
using namespace Tizen::Graphics;
using namespace Tizen::Ui;
-#define PRINT(...) fprintf(stderr,__VA_ARGS__)
-//#define PRINT printf
+//#define PRINT(...) fprintf(stderr,__VA_ARGS__)
+#define PRINT(...)
namespace Tizen { namespace Ui { namespace Animations {
private:
_VisualElementCanvas(const _VisualElementCanvas& rhs);
_VisualElementCanvas& operator =(const _VisualElementCanvas& rhs);
+private:
+ VisualElementSurface* __pSurface;
}; // _VisualElementCanvas