static result CreateInstance(Handle nativeDisplay);
static result ReleaseInstance(void);
-
- Handle CreateWindowSurface(EGLNativeWindowType window);
- void DestroySurface(Handle surface);
-#endif
-
-#ifdef VE_USE_GL_MULTI_CONTEXT
- bool MakeCurrent(void);
-#else
- bool MakeCurrent(Handle surface);
#endif
+ bool MakeCurrent(Handle surface = 0);
void SwapBuffers(void) const;
+ bool IsSupportedBGRA() const { return __supportBGRA8888; }
+
+ //Texture
bool CreateTexture(TextureInfo* pTextureInfo);
void DeleteTexture(TextureInfo* pTextureInfo);
- void UploadTexture(Tizen::Graphics::GlVisualElementSurfaceInfo* pSurfaceInfo);
-
- bool IsSupportedBGRA() const { return __supportBGRA8888; }
+ void UpdateTexture(Tizen::Graphics::GlVisualElementSurfaceInfo* pSurfaceInfo); //TODO: parameter check
+ void BindTexture(unsigned int textureId);
//Shader
void UseShaderProgram(_GlShaderProgram* pShaderProgram);
_GlContext(Handle nativeDisplay, EGLNativeWindowType window);
virtual ~_GlContext(void);
+ bool GetDisplay(Handle nativeDisplay);
+ bool CreateContext(void);
+ EGLConfig GetConfig(bool useAlpha, bool useStencil, bool useDepth) const;
+
+ Handle CreateWindowSurface(EGLNativeWindowType window);
+ void DestroySurface(Handle surface);
+ Handle CreateDefaultSurface(void);
+
+ void InitGL(void);
+
+ void LoadTexture(TextureInfo& textureInfo, bool create);
+
private:
//TODO: Check structure
class _PixmapInfo
EGLImageKHR __eglImage;
};
- bool CreateContext(void);
-
-#ifdef VE_USE_GL_MULTI_CONTEXT
- Handle CreateWindowSurface(EGLNativeWindowType window);
- void DestroySurface(Handle surface);
-#else
- bool CreateDefaultSurface(void);
-#endif
-
- bool GetDisplay(Handle nativeDisplay);
- EGLConfig GetConfig(bool useAlpha, bool useStencil, bool useDepth) const;
-
- void InitGL(void);
-
- void LoadTexture(TextureInfo& textureInfo, bool create);
-
bool CreateDynamicTexture(GLuint textureId, TextureInfo* pTextureInfo);
_PixmapInfo* CreateNativePixmap(Graphics::BufferInfo& bufferInfo);
protected:
+ Handle __nativeDisplay;
+
EGLDisplay __display;
EGLContext __context;
EGLConfig __config;
+ EGLSurface __surface;
bool __supportBGRA8888;
bool __useDepthTest;
_GlShaderProgram* __pCurrentShader;
- unsigned int __currentTextureId;
+ unsigned int __textureId;
private:
#ifndef VE_USE_GL_MULTI_CONTEXT
static _GlContext* __pInstance;
#endif
- Handle __nativeDisplay;
-
-#ifdef VE_USE_GL_MULTI_CONTEXT
- EGLSurface __surface;
-#else
- EGLSurface __currentSurface;
+#ifndef VE_USE_GL_MULTI_CONTEXT
EGLSurface __dummySurface;
Handle __nativeDummyPixmap; // for dummy
#endif
, __opacity(1.0f)
, __pRootVisualElement(null)
, __pWindow(null)
- , __surface(EGL_NO_SURFACE)
+ , __surface(null)
, __reconfigureNeeded(false)
#ifdef VE_USE_GL_MULTI_CONTEXT
, __pContext(null)
#ifndef _FUI_ANIM_INTERNAL_GL_LAYER_H_
#define _FUI_ANIM_INTERNAL_GL_LAYER_H_
-#include <GLES2/gl2.h>
-#include <EGL/egl.h>
#include <FGrpRectangle.h>
#include <FGrpFloatRectangle.h>
#include "FUiAnim_NativeLayer.h"
Handle GetNativeSurface(void) const
{
- return (Handle)__surface;
+ return __surface;
}
#ifdef VE_USE_GL_MULTI_CONTEXT
float __opacity;
_RootVisualElement* __pRootVisualElement;
_NativeWindow* __pWindow;
- EGLSurface __surface;
+ Handle __surface;
bool __reconfigureNeeded;
#ifdef VE_USE_GL_MULTI_CONTEXT
if (__pRenderQueue[i].__textureId > 0)
{
- if (likely(__pGlContext->__currentTextureId != __pRenderQueue[i].__textureId))
- {
- glBindTexture(GL_TEXTURE_2D, __pRenderQueue[i].__textureId);
- __pGlContext->__currentTextureId = __pRenderQueue[i].__textureId;
- }
-
- __pGlContext->UploadTexture(__pRenderQueue[i].__pSurfaceInfo);
+ __pGlContext->BindTexture(__pRenderQueue[i].__textureId);
+ __pGlContext->UpdateTexture(__pRenderQueue[i].__pSurfaceInfo); //TODO Update안에서 bind를 해주면 안되는가?
}
if (__pGlContext->__useBlend != __pRenderQueue[i].__useBlend)
if (pMeshImpl->__pTexCoordinates)
{
- if (likely(__pGlContext->__currentTextureId != pNode->__textureId))
- {
- glBindTexture(GL_TEXTURE_2D, pNode->__textureId);
- __pGlContext->__currentTextureId = pNode->__textureId;
- }
+ __pGlContext->BindTexture(pNode->__textureId);
if (_FloatCompare(pNode->__opacity, 1.0f))
{
if (pNode->__textureId > 0)
{
- if (likely(__pGlContext->__currentTextureId != pNode->__textureId))
- {
- glBindTexture(GL_TEXTURE_2D, pNode->__textureId);
- __pGlContext->__currentTextureId = pNode->__textureId;
- }
-
_VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pNode->GetSurface());
- __pGlContext->UploadTexture((GlVisualElementSurfaceInfo*)pSurfaceImpl->GetNativeHandle());
+ __pGlContext->BindTexture(pNode->__textureId);
+ __pGlContext->UpdateTexture((GlVisualElementSurfaceInfo*)pSurfaceImpl->GetNativeHandle());
if (_FloatCompare(pNode->__opacity, 1.0f))
{
{
#ifdef VE_USE_GL_MULTI_CONTEXT
__pGlContext = (_GlContext*)pLayer->GetContext();
-
__pGlContext->MakeCurrent();
#else
__pGlContext->MakeCurrent(pLayer->GetNativeSurface());
if (!checkOnly)
{
_pRootVisualElement->SetNeedsSurfaceUpdate(false);
- _GlRenderManager::GetInstance()->UploadTexture();
+ _GlRenderManager::GetInstance()->UpdateTexture();
}
updated = true;
}
_Egl::_Egl(Handle nativeDisplay, EGLNativeWindowType window)
: _GlContext(nativeDisplay, window)
, __nativeDisplay(nativeDisplay)
-#ifdef VE_USE_GL_MULTI_CONTEXT
- , __surface(EGL_NO_SURFACE)
-#else
- , __currentSurface(EGL_NO_SURFACE)
+#ifndef VE_USE_GL_MULTI_CONTEXT
, __dummySurface(EGL_NO_SURFACE)
, __nativeDummyPixmap(0)
#endif
PRINT("_Egl:~_Egl() \n");
}
-Handle
-_Egl::CreateWindowSurface(EGLNativeWindowType window)
-{
- PRINT(">> _Egl:CreateWindowSurface() %p \n", (void*)window);
-
- EGLSurface surface = eglCreateWindowSurface(__display, __config, window, null);
- if (surface == EGL_NO_SURFACE || eglGetError() != EGL_SUCCESS)
- {
- PRINT("Failed to eglCreateWindowSurface. \n");
- SysLog(NID_UI_ANIM, "eglCreateWindowSurface() failed.");
- }
-
- return (Handle)surface;
-}
-
-void
-_Egl::DestroySurface(Handle surface)
-{
- TryReturnVoid(surface == 0, "surface is null");
-
-#ifdef VE_USE_GL_MULTI_CONTEXT
- eglMakeCurrent(__display, null, null, null);
-#else
- if (surface == (Handle)__currentSurface) // eglGetCurrentSurface(??)
- {
- PRINT(">> _Egl::DestroySurface currentSurface is destroyed. \n");
-
- MakeCurrent((Handle)__dummySurface);
- __currentSurface = __dummySurface;
- }
-#endif
-
- eglDestroySurface(__display, (EGLSurface)surface);
-}
-
-#ifndef VE_USE_GL_MULTI_CONTEXT
-bool
-_Egl::CreateDefaultSurface(void)
-{
-#ifndef BUILD_UI_CORE
- if (__dummySurface != EGL_NO_SURFACE)
- {
- return true;
- }
-
-#ifdef USE_PBUFFER
- EGLint pbufferList[] =
- {
- EGL_WIDTH, 32,
- EGL_HEIGHT, 32,
- EGL_NONE
- };
-
- // __dummySurface = eglCreatePbufferSurface(__display, __config, pbufferList);
-#endif
-
- Display* pDisplay = (Display*)__nativeDisplay;
- __nativeDummyPixmap = XCreatePixmap(pDisplay, DefaultRootWindow(pDisplay), 10, 10, DefaultDepth(pDisplay, DefaultScreen(pDisplay)));
- SysAssertf(__nativeDummyPixmap, "Failed to create default native pixmap.");
-
- __dummySurface = eglCreatePixmapSurface(__display, __config, (EGLNativePixmapType)__nativeDummyPixmap, NULL);
- if (__dummySurface == EGL_NO_SURFACE)
- {
- PRINT("_Egl:CreateDefaultSurface: %#x \n", eglGetError());
- SysLog(NID_UI_ANIM, "CreateDefaultSurface failed!");
- return false;
- }
-
- return true;
-#endif
- return false;
-}
-#endif
-
bool
_Egl::GetDisplay(Handle nativeDisplay)
{
_Egl(Handle nativeDisplay, EGLNativeWindowType window);
virtual ~_Egl(void);
-#ifndef VE_USE_GL_MULTI_CONTEXT
- Handle CreateWindowSurface(EGLNativeWindowType window);
- void DestroySurface(Handle surface);
-#endif
-
// bool CreateTexture(TextureInfo* pTextureInfo);
void DeleteTexture(TextureInfo* pTextureInfo);
#else
#ifdef LINUX
- : __nativePixmap((Pixmap)0)
+ : __nativePixmap(0)
#else
: __nativePixmap()
#endif
bool CreateContext(void);
-#ifdef VE_USE_GL_MULTI_CONTEXT
- Handle CreateWindowSurface(EGLNativeWindowType window);
- void DestroySurface(Handle surface);
-#else
- bool CreateDefaultSurface(void);
-#endif
-
bool GetDisplay(Handle nativeDisplay);
EGLConfig GetConfig(bool useAlpha, bool useStencil, bool useDepth) const;
private:
Handle __nativeDisplay;
-#ifdef VE_USE_GL_MULTI_CONTEXT
- EGLSurface __surface;
-#else
- EGLSurface __currentSurface;
+#ifndef VE_USE_GL_MULTI_CONTEXT
EGLSurface __dummySurface;
Handle __nativeDummyPixmap; // for dummy
#endif
}
_GlContext::_GlContext(Handle nativeDisplay, EGLNativeWindowType window)
- : __display(EGL_NO_DISPLAY)
+ : __nativeDisplay(nativeDisplay)
+ , __display(EGL_NO_DISPLAY)
, __context(EGL_NO_CONTEXT)
, __config(null)
+ , __surface(EGL_NO_SURFACE)
, __supportBGRA8888(false)
, __useBlend(false)
, __useStencil(false)
, __useDepthTest(false)
, __pCurrentShader(null)
- , __currentTextureId(0)
- , __nativeDisplay(nativeDisplay)
-#ifdef VE_USE_GL_MULTI_CONTEXT
- , __surface(EGL_NO_SURFACE)
-#else
- , __currentSurface(EGL_NO_SURFACE)
- , __dummySurface(EGL_NO_SURFACE) //TODO: __surface로 합치면 ??
+ , __textureId(0)
+#ifndef VE_USE_GL_MULTI_CONTEXT
+ , __dummySurface(EGL_NO_SURFACE)
, __nativeDummyPixmap(0)
#endif
{
else
{
#ifndef VE_USE_GL_MULTI_CONTEXT
- SysAssertf(CreateDefaultSurface(), "Failed to create default surface.");
+ __dummySurface = (EGLSurface)CreateDefaultSurface();
+
+ SysAssertf(__dummySurface != EGL_NO_SURFACE, "Failed to create default surface.");
SysAssertf(MakeCurrent((Handle)__dummySurface), "Failed to make current.");
#endif
}
}
#endif
-#ifdef VE_USE_GL_MULTI_CONTEXT
-bool
-_GlContext::MakeCurrent(void)
-{
- if (eglMakeCurrent(__display, __surface, __surface, __context) == EGL_FALSE)
- {
- PRINT("_GlContext::MakeCurrent: eglGetError() [%x] \n", eglGetError());
- SysLog(NID_UI_ANIM, "Can't change current context");
-
- return false;
- }
-
- return true;
-}
-#else
-bool
-_GlContext::MakeCurrent(Handle surface)
-{
- EGLSurface newSurface = (EGLSurface)surface;
-
-/* if (newSurface == EGL_NO_SURFACE)
- {
- newSurface = __dummySurface;
- }*/
-
- if (newSurface == __currentSurface)//eglGetCurrentSurface(EGL_DRAW))
- {
- return true;
- }
-
- if (eglMakeCurrent(__display, newSurface, newSurface, __context) == EGL_FALSE)
- {
- PRINT("_GlContext::MakeCurrent: eglGetError() [%x] \n", eglGetError());
- SysLog(NID_UI_ANIM, "Can't change current context");
-
- return false;
- }
-
- __currentSurface = newSurface;
-
- return true;
-}
-#endif
-
Handle
_GlContext::CreateWindowSurface(EGLNativeWindowType window)
{
#ifdef VE_USE_GL_MULTI_CONTEXT
eglMakeCurrent(__display, null, null, null);
#else
- if (surface == (Handle)__currentSurface) // eglGetCurrentSurface(??)
+ if (surface == (Handle)__surface) // eglGetCurrentSurface(??)
{
PRINT(">> _GlContext::DestroySurface currentSurface is destroyed. \n");
MakeCurrent((Handle)__dummySurface);
- __currentSurface = __dummySurface;
+ __surface = __dummySurface;
}
#endif
eglDestroySurface(__display, (EGLSurface)surface);
}
-#ifndef VE_USE_GL_MULTI_CONTEXT
-bool
+Handle
_GlContext::CreateDefaultSurface(void)
{
+ EGLSurface surface = EGL_NO_SURFACE;
+
#ifndef BUILD_UI_CORE
- if (__dummySurface != EGL_NO_SURFACE)
- {
- return true;
- }
-
#ifdef USE_PBUFFER
EGLint pbufferList[] =
{
EGL_NONE
};
- // __dummySurface = eglCreatePbufferSurface(__display, __config, pbufferList);
-#endif
-
+ surface = eglCreatePbufferSurface(__display, __config, pbufferList);
+#else
+#ifndef VE_USE_GL_MULTI_CONTEXT
Display* pDisplay = (Display*)__nativeDisplay;
__nativeDummyPixmap = XCreatePixmap(pDisplay, DefaultRootWindow(pDisplay), 10, 10, DefaultDepth(pDisplay, DefaultScreen(pDisplay)));
SysAssertf(__nativeDummyPixmap, "Failed to create default native pixmap.");
- __dummySurface = eglCreatePixmapSurface(__display, __config, (EGLNativePixmapType)__nativeDummyPixmap, NULL);
- if (__dummySurface == EGL_NO_SURFACE)
+ surface = eglCreatePixmapSurface(__display, __config, (EGLNativePixmapType)__nativeDummyPixmap, NULL);
+#endif
+#endif
+#endif
+
+ return (Handle)surface;
+}
+
+bool
+_GlContext::MakeCurrent(Handle surface)
+{
+ if (surface)
{
- PRINT("_GlContext:CreateDefaultSurface: %#x \n", eglGetError());
- SysLog(NID_UI_ANIM, "CreateDefaultSurface failed!");
+ EGLSurface newSurface = (EGLSurface)surface;
+ if (__surface == newSurface)
+ {
+ return true;
+ }
+
+ __surface = newSurface;
+ }
+
+ if (eglMakeCurrent(__display, __surface, __surface, __context) == EGL_FALSE)
+ {
+ PRINT("_GlContext::MakeCurrent: eglGetError() [%x] \n", eglGetError());
+ SysLog(NID_UI_ANIM, "Can't change current context");
+
return false;
}
return true;
-#endif
- return false;
}
-#endif
void
_GlContext::SwapBuffers(void) const
{
-#ifdef VE_USE_GL_MULTI_CONTEXT
if (!eglSwapBuffers(__display, __surface))
-#else
- if (!eglSwapBuffers(__display, __currentSurface))
-#endif
{
PRINT("_GlContext::SwapBuffers: ERROR! [0x%x]\n", eglGetError());
}
glBindTexture(GL_TEXTURE_2D, textureId);
- __currentTextureId = textureId;
+ __textureId = textureId;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (pTextureInfo->pPixels == null)
{
glDeleteTextures(1, &textureId);
- __currentTextureId = 0;
+ __textureId = 0;
return false;
}
return true;
}
+void
+_GlContext::BindTexture(unsigned int textureId)
+{
+ if (likely(__textureId != textureId))
+ {
+ glBindTexture(GL_TEXTURE_2D, textureId);
+ __textureId = textureId;
+ }
+}
+
//TODO: why?? pSurfaceInfo
void
-_GlContext::UploadTexture(GlVisualElementSurfaceInfo* pSurfaceInfo)
+_GlContext::UpdateTexture(GlVisualElementSurfaceInfo* pSurfaceInfo)
{
#ifndef USE_EGL_IMAGE
+// BindTexture(pSurfaceInfo->textureId);
+
// if (pSurfaceInfo->type == SURFACE_TYPE_DYNAMIC && pSurfaceInfo->updated)
// if (pSurfaceInfo->type == SURFACE_TYPE_DYNAMIC)
{
_Wgl::_Wgl(Handle nativeDisplay, EGLNativeWindowType window)
: _GlContext(nativeDisplay, window)
, __nativeDisplay(nativeDisplay)
-#ifdef VE_USE_GL_MULTI_CONTEXT
- , __surface(EGL_NO_SURFACE)
-#else
- , __currentSurface(EGL_NO_SURFACE)
+#ifndef VE_USE_GL_MULTI_CONTEXT
, __dummySurface(EGL_NO_SURFACE)
, __nativeDummyPixmap(0)
#endif
PRINT("_Wgl:~_Wgl() \n");
}
-Handle
-_Wgl::CreateWindowSurface(EGLNativeWindowType window)
-{
- PRINT(">> _Wgl:CreateWindowSurface() %p \n", (void*)window);
-
- EGLSurface surface = eglCreateWindowSurface(__display, __config, window, null);
- if (surface == EGL_NO_SURFACE || eglGetError() != EGL_SUCCESS)
- {
- PRINT("Failed to eglCreateWindowSurface. \n");
- SysLog(NID_UI_ANIM, "eglCreateWindowSurface() failed.");
- }
-
- return (Handle)surface;
-}
-
-void
-_Wgl::DestroySurface(Handle surface)
-{
- TryReturnVoid(surface == 0, "surface is null");
-
-#ifdef VE_USE_GL_MULTI_CONTEXT
- eglMakeCurrent(__display, null, null, null);
-#else
- if (surface == (Handle)__currentSurface) // eglGetCurrentSurface(??)
- {
- PRINT(">> _Wgl::DestroySurface currentSurface is destroyed. \n");
-
- MakeCurrent((Handle)__dummySurface);
- __currentSurface = __dummySurface;
- }
-#endif
-
- eglDestroySurface(__display, (EGLSurface)surface);
-}
-
-#ifndef VE_USE_GL_MULTI_CONTEXT
-bool
-_Wgl::CreateDefaultSurface(void)
-{
-#ifndef BUILD_UI_CORE
- if (__dummySurface != EGL_NO_SURFACE)
- {
- return true;
- }
-
-#ifdef USE_PBUFFER
- EGLint pbufferList[] =
- {
- EGL_WIDTH, 32,
- EGL_HEIGHT, 32,
- EGL_NONE
- };
-
- // __dummySurface = eglCreatePbufferSurface(__display, __config, pbufferList);
-#endif
-
- Display* pDisplay = (Display*)__nativeDisplay;
- __nativeDummyPixmap = XCreatePixmap(pDisplay, DefaultRootWindow(pDisplay), 10, 10, DefaultDepth(pDisplay, DefaultScreen(pDisplay)));
- SysAssertf(__nativeDummyPixmap, "Failed to create default native pixmap.");
-
- __dummySurface = eglCreatePixmapSurface(__display, __config, (EGLNativePixmapType)__nativeDummyPixmap, NULL);
- if (__dummySurface == EGL_NO_SURFACE)
- {
- PRINT("_Wgl:CreateDefaultSurface: %#x \n", eglGetError());
- SysLog(NID_UI_ANIM, "CreateDefaultSurface failed!");
- return false;
- }
-
- return true;
-#endif
- return false;
-}
-#endif
-
bool
_Wgl::GetDisplay(Handle nativeDisplay)
{
bool
_Wgl::CreateDynamicTexture(GLuint textureId, TextureInfo* pTextureInfo)
{
-#ifndef BUILD_UI_CORE
-#ifndef VE_SIMULATOR
+#ifdef USE_EGL_IMAGE
_PixmapInfo* pPixmapInfo;
PFNEGLCREATEIMAGEKHRPROC funcEglCreateImageKHR =
__nativePixmaps.Add(textureId, pPixmapInfo);
return true;
-#else
- return false;
-#endif
-#endif
+#endif // USE_EGL_IMAGE
+
+ return true;
}
}}} // Tizen::Ui::Animations
_Wgl(Handle nativeDisplay, EGLNativeWindowType window);
virtual ~_Wgl(void);
-#ifndef VE_USE_GL_MULTI_CONTEXT
- Handle CreateWindowSurface(EGLNativeWindowType window);
- void DestroySurface(Handle surface);
-#endif
-
// bool CreateTexture(TextureInfo* pTextureInfo);
void DeleteTexture(TextureInfo* pTextureInfo);
#else
#ifdef LINUX
- : __nativePixmap((Pixmap)0)
+ : __nativePixmap(0)
#else
: __nativePixmap()
#endif
bool CreateContext(void);
-#ifdef VE_USE_GL_MULTI_CONTEXT
- Handle CreateWindowSurface(EGLNativeWindowType window);
- void DestroySurface(Handle surface);
-#else
- bool CreateDefaultSurface(void);
-#endif
-
bool GetDisplay(Handle nativeDisplay);
EGLConfig GetConfig(bool useAlpha, bool useStencil, bool useDepth) const;
private:
Handle __nativeDisplay;
-#ifdef VE_USE_GL_MULTI_CONTEXT
- EGLSurface __surface;
-#else
- EGLSurface __currentSurface;
+#ifndef VE_USE_GL_MULTI_CONTEXT
EGLSurface __dummySurface;
Handle __nativeDummyPixmap; // for dummy
#endif