opengles emulator: fixed EGLContext and EGLSurface ref-counting.
Handle EGL context and surfaces destrouction using ref counting
pointer (SmartPtr) rather then maintaining a "markForDeletion" flag.
This has required to re-arrange the ThreadInfo structure to be local
to EGL rather then in the GLcommon area so that we will be able to
place a ref-counted pointer to the current context in the TLS.
That fixes the crash during exit of covgl conformance test.
Change-Id: I6f0a2e49c6f21eb75b654cab4346c764715c449b
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp
index 1223168..c2ea4a7 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp
@@ -14,21 +14,26 @@
* limitations under the License.
*/
#include "EglContext.h"
+#include "EglDisplay.h"
+#include "EglGlobalInfo.h"
+#include "EglOsApi.h"
unsigned int EglContext::s_nextContextHndl = 0;
+extern EglGlobalInfo* g_eglInfo; // defined in EglImp.cpp
+
bool EglContext::usingSurface(SurfacePtr surface) {
return surface.Ptr() == m_read.Ptr() || surface.Ptr() == m_draw.Ptr();
}
-EglContext::EglContext(EGLNativeContextType context,ContextPtr shared_context,
+EglContext::EglContext(EglDisplay *dpy, EGLNativeContextType context,ContextPtr shared_context,
EglConfig* config,GLEScontext* glesCtx,GLESVersion ver,ObjectNameManager* mngr):
+m_dpy(dpy),
m_native(context),
m_config(config),
m_glesContext(glesCtx),
m_read(NULL),
m_draw(NULL),
-m_destroy(false),
m_version(ver),
m_mngr(mngr)
{
@@ -40,6 +45,17 @@
EglContext::~EglContext()
{
+
+ //
+ // remove the context in the underlying OS layer
+ //
+ EglOS::destroyContext(m_dpy->nativeType(),m_native);
+
+ //
+ // call the client-api to remove the GLES context
+ //
+ g_eglInfo->getIface(version())->deleteGLESContext(m_glesContext);
+
if (m_mngr)
{
m_mngr->deleteShareGroup(m_native);
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h
index 1f54631..e4917c6 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.h
@@ -32,15 +32,15 @@
class EglContext;
typedef SmartPtr<EglContext> ContextPtr;
+class EglDisplay;
+
class EglContext {
public:
- EglContext(EGLNativeContextType context,ContextPtr shared_context,EglConfig* config,GLEScontext* glesCtx,GLESVersion ver,ObjectNameManager* mngr);
+ EglContext(EglDisplay *dpy, EGLNativeContextType context,ContextPtr shared_context,EglConfig* config,GLEScontext* glesCtx,GLESVersion ver,ObjectNameManager* mngr);
bool usingSurface(SurfacePtr surface);
EGLNativeContextType nativeType(){return m_native;};
- void markForDestruction(){m_destroy = true;}
- bool destroy(){ return m_destroy;}
bool getAttrib(EGLint attrib,EGLint* value);
SurfacePtr read(){ return m_read;};
SurfacePtr draw(){ return m_draw;};
@@ -57,13 +57,13 @@
private:
static unsigned int s_nextContextHndl;
+ EglDisplay *m_dpy;
EGLNativeContextType m_native;
EglConfig* m_config;
GLEScontext* m_glesContext;
ShareGroupPtr m_shareGroup;
SurfacePtr m_read;
SurfacePtr m_draw;
- bool m_destroy;
GLESVersion m_version;
ObjectNameManager *m_mngr;
unsigned int m_hndl;
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
index 8b64b94..fd9779f 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
@@ -22,7 +22,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
-#include <GLcommon/ThreadInfo.h>
+#include "ThreadInfo.h"
#include <GLcommon/TranslatorIfaces.h>
#include <OpenglOsUtils/osDynLibrary.h>
@@ -44,13 +44,14 @@
EglImage *attachEGLImage(unsigned int imageId);
void detachEGLImage(unsigned int imageId);
+GLEScontext* getGLESContext();
#define tls_thread EglThreadInfo::get()
EglGlobalInfo* g_eglInfo = EglGlobalInfo::getInstance();
static EGLiface s_eglIface = {
- getThreadInfo : getThreadInfo, // implemented in ThreadInfo.cpp
+ getGLESContext : getGLESContext,
eglAttachEGLImage:attachEGLImage,
eglDetachEGLImage:detachEGLImage
};
@@ -125,6 +126,12 @@
VALIDATE_CONTEXT_RETURN(EGLContext,EGL_FALSE)
+GLEScontext* getGLESContext()
+{
+ ThreadInfo* thread = getThreadInfo();
+ return thread->glesContext;
+}
+
EGLAPI EGLint EGLAPIENTRY eglGetError(void) {
CURRENT_THREAD();
EGLint err = tls_thread->getError();
@@ -479,7 +486,7 @@
if(!EglOS::checkWindowPixelFormatMatch(dpy->nativeType(),win,cfg,&width,&height)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
- SurfacePtr wSurface(new EglWindowSurface(win,cfg,width,height));
+ SurfacePtr wSurface(new EglWindowSurface(dpy, win,cfg,width,height));
if(!wSurface.Ptr()) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
@@ -495,7 +502,7 @@
}
- SurfacePtr pbSurface(new EglPbufferSurface(cfg));
+ SurfacePtr pbSurface(new EglPbufferSurface(dpy,cfg));
if(!pbSurface.Ptr()) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
@@ -549,7 +556,7 @@
if(!EglOS::checkPixmapPixelFormatMatch(dpy->nativeType(),pixmap,cfg,&width,&height)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
- SurfacePtr pixSurface(new EglPixmapSurface(pixmap,cfg));
+ SurfacePtr pixSurface(new EglPixmapSurface(dpy, pixmap,cfg));
if(!pixSurface.Ptr()) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
@@ -557,18 +564,6 @@
return dpy->addSurface(pixSurface);
}
-static bool destroySurfaceIfNotCurrent(EglDisplay* dpy,SurfacePtr surface) {
-
- ThreadInfo* thread = getThreadInfo();
- EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
- if((!currCtx) || (currCtx && !currCtx->usingSurface(surface))){
- if(surface->type() == EglSurface::PBUFFER) {
- EglOS::releasePbuffer(dpy->nativeType(),surface->native());
- }
- return true;
- }
- return false;
-}
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay display, EGLSurface surface) {
VALIDATE_DISPLAY(display);
SurfacePtr srfc = dpy->getSurface(surface);
@@ -576,10 +571,7 @@
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
- srfc->markForDestruction(); //mark surface for destruction
- if(destroySurfaceIfNotCurrent(dpy,srfc)) { //removes surface from the list if not current
- dpy->removeSurface(surface);
- }
+ dpy->removeSurface(surface);
return EGL_TRUE;
}
@@ -650,7 +642,7 @@
EGLNativeContextType nativeContext = EglOS::createContext(dpy->nativeType(),cfg,globalSharedContext);
if(nativeContext) {
- ContextPtr ctx(new EglContext(nativeContext,sharedCtxPtr,cfg,glesCtx,version,dpy->getManager(version)));
+ ContextPtr ctx(new EglContext(dpy, nativeContext,sharedCtxPtr,cfg,glesCtx,version,dpy->getManager(version)));
return dpy->addContext(ctx);
} else {
iface->deleteGLESContext(glesCtx);
@@ -659,25 +651,11 @@
return EGL_NO_CONTEXT;
}
-static bool destroyContextIfNotCurrent(EglDisplay* dpy,ContextPtr ctx ) {
- ThreadInfo* thread = getThreadInfo();
- EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
- if(ctx.Ptr() != currCtx ){
- EglOS::destroyContext(dpy->nativeType(),ctx->nativeType());
- return true;
- }
- return false;
-}
-
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay display, EGLContext context) {
VALIDATE_DISPLAY(display);
VALIDATE_CONTEXT(context);
- ctx->markForDestruction(); //mark for destruction
- if(destroyContextIfNotCurrent(dpy,ctx)){ //removes the context from the list if it is not current
- g_eglInfo->getIface(ctx->version())->deleteGLESContext(ctx->getGlesContext());
- dpy->removeContext(context);
- }
+ dpy->removeContext(context);
return EGL_TRUE;
}
@@ -692,15 +670,15 @@
}
ThreadInfo* thread = getThreadInfo();
- EglContext* prevCtx = static_cast<EglContext*>(thread->eglContext);
+ ContextPtr prevCtx = thread->eglContext;
if(releaseContext) { //releasing current context
- if(prevCtx) {
+ if(prevCtx.Ptr()) {
g_eglInfo->getIface(prevCtx->version())->flush();
if(!EglOS::makeCurrent(dpy->nativeType(),NULL,NULL,NULL)) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ACCESS);
}
- thread->updateInfo(NULL,dpy,NULL,ShareGroupPtr(NULL),dpy->getManager(prevCtx->version()));
+ thread->updateInfo(ContextPtr(NULL),dpy,NULL,ShareGroupPtr(NULL),dpy->getManager(prevCtx->version()));
}
} else { //assining new context
VALIDATE_CONTEXT(context);
@@ -709,10 +687,10 @@
EglSurface* newDrawPtr = newDrawSrfc.Ptr();
EglSurface* newReadPtr = newReadSrfc.Ptr();
- EglContext* newCtx = ctx.Ptr();
+ ContextPtr newCtx = ctx;
- if (newCtx && prevCtx) {
- if (newCtx == prevCtx) {
+ if (newCtx.Ptr() && prevCtx.Ptr()) {
+ if (newCtx.Ptr() == prevCtx.Ptr()) {
if (newDrawPtr == prevCtx->draw().Ptr() &&
newReadPtr == prevCtx->read().Ptr()) {
// nothing to do
@@ -749,7 +727,7 @@
if(newDrawPtr->type() == EglSurface::PIXMAP && !EglOS::validNativePixmap(nativeDisplay,nativeDraw)) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_PIXMAP);
}
- if(prevCtx) {
+ if(prevCtx.Ptr()) {
g_eglInfo->getIface(prevCtx->version())->flush();
}
if(!EglOS::makeCurrent(dpy->nativeType(),newReadPtr,newDrawPtr,newCtx->nativeType())) {
@@ -763,33 +741,11 @@
g_eglInfo->getIface(newCtx->version())->initContext(newCtx->getGlesContext(),newCtx->getShareGroup());
}
- SurfacePtr prevRead;
- SurfacePtr prevDraw;
- //removing terminated surfaces & context
- if(prevCtx && releaseContext) {
- prevRead = prevCtx->read();
- if(prevRead->destroy()){
- if(destroySurfaceIfNotCurrent(dpy,prevRead)) { //removes surface from the list if not current
- dpy->removeSurface(prevRead);
- }
- }
- prevDraw = prevCtx->draw();
- if(prevDraw->destroy()){
- if(destroySurfaceIfNotCurrent(dpy,prevDraw)) { //removes surface from the list if not current
- dpy->removeSurface(prevDraw);
- }
- }
-
- if(prevCtx->destroy()) {
- ContextPtr prevCtxPtr = ContextPtr(prevCtx);
- if(destroyContextIfNotCurrent(dpy,prevCtxPtr)){ //removes the context from the list if it is not current
- g_eglInfo->getIface(prevCtx->version())->deleteGLESContext(prevCtx->getGlesContext());
- dpy->removeContext(prevCtxPtr);
- }
- }
-
+ // release previous context surface binding
+ if(prevCtx.Ptr() && releaseContext) {
prevCtx->setSurfaces(SurfacePtr(NULL),SurfacePtr(NULL));
}
+
return EGL_TRUE;
}
@@ -808,7 +764,7 @@
VALIDATE_DISPLAY(display);
VALIDATE_SURFACE(surface,Srfc);
ThreadInfo* thread = getThreadInfo();
- EglContext* currentCtx = static_cast<EglContext*>(thread->eglContext);
+ ContextPtr currentCtx = thread->eglContext;
//if surface not window return
@@ -816,7 +772,7 @@
RETURN_ERROR(EGL_TRUE,EGL_SUCCESS);
}
- if(!currentCtx || !currentCtx->usingSurface(Srfc) || !EglOS::validNativeWin(dpy->nativeType(),Srfc.Ptr()->native())) {
+ if(!currentCtx.Ptr() || !currentCtx->usingSurface(Srfc) || !EglOS::validNativeWin(dpy->nativeType(),Srfc.Ptr()->native())) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
@@ -827,8 +783,8 @@
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay display, EGLint interval) {
VALIDATE_DISPLAY(display);
ThreadInfo* thread = getThreadInfo();
- EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
- if(currCtx) {
+ ContextPtr currCtx = thread->eglContext;
+ if(currCtx.Ptr()) {
if(!currCtx->read().Ptr() || !currCtx->draw().Ptr() || currCtx->draw()->type()!=EglSurface::WINDOW) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_CURRENT_SURFACE);
}
@@ -843,8 +799,8 @@
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void) {
ThreadInfo* thread = getThreadInfo();
EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
- EglContext* ctx = static_cast<EglContext*>(thread->eglContext);
- if(dpy && ctx){
+ ContextPtr ctx = thread->eglContext;
+ if(dpy && ctx.Ptr()){
// This double check is required because a context might still be current after it is destroyed - in which case
// its handle should be invalid, that is EGL_NO_CONTEXT should be returned even though the context is current
EGLContext c = (EGLContext)ctx->getHndl();
@@ -861,9 +817,9 @@
ThreadInfo* thread = getThreadInfo();
EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
- EglContext* ctx = static_cast<EglContext*>(thread->eglContext);
+ ContextPtr ctx = thread->eglContext;
- if(dpy && ctx) {
+ if(dpy && ctx.Ptr()) {
SurfacePtr surface = readdraw == EGL_READ ? ctx->read() : ctx->draw();
if(surface.Ptr())
{
@@ -884,7 +840,7 @@
EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) {
ThreadInfo* thread = getThreadInfo();
- return (thread->eglContext) ? thread->eglDisplay : EGL_NO_DISPLAY;
+ return (thread->eglContext.Ptr()) ? thread->eglDisplay : EGL_NO_DISPLAY;
}
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void) {
@@ -898,9 +854,9 @@
RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER);
}
ThreadInfo* thread = getThreadInfo();
- EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
+ ContextPtr currCtx = thread->eglContext;
EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
- if(currCtx) {
+ if(currCtx.Ptr()) {
SurfacePtr read = currCtx->read();
SurfacePtr draw = currCtx->draw();
@@ -946,8 +902,8 @@
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void) {
ThreadInfo* thread = getThreadInfo();
- EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
- if(currCtx) {
+ ContextPtr currCtx = thread->eglContext;
+ if(currCtx.Ptr()) {
if(!currCtx->read().Ptr() || !currCtx->draw().Ptr()) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_CURRENT_SURFACE);
}
@@ -1026,8 +982,8 @@
{
ThreadInfo* thread = getThreadInfo();
EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
- EglContext* ctx = static_cast<EglContext*>(thread->eglContext);
- if (ctx) {
+ ContextPtr ctx = thread->eglContext;
+ if (ctx.Ptr()) {
ImagePtr img = dpy->getImage(reinterpret_cast<EGLImageKHR>(imageId));
if(img.Ptr()) {
ctx->attachImage(imageId,img);
@@ -1041,8 +997,8 @@
{
ThreadInfo* thread = getThreadInfo();
EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
- EglContext* ctx = static_cast<EglContext*>(thread->eglContext);
- if (ctx) {
+ ContextPtr ctx = thread->eglContext;
+ if (ctx.Ptr()) {
ctx->detachImage(imageId);
}
}
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.h
index 184cc47..9740170 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.h
@@ -18,9 +18,12 @@
#include "EglSurface.h"
+class EglDisplay;
+
class EglPbufferSurface:public EglSurface {
public:
- EglPbufferSurface(EglConfig* config):EglSurface(PBUFFER,config,0,0),
+ EglPbufferSurface(EglDisplay *dpy, EglConfig* config):
+ EglSurface(dpy,PBUFFER,config,0,0),
m_texFormat(EGL_NO_TEXTURE),
m_texTarget(EGL_NO_TEXTURE),
m_texMipmap(EGL_FALSE),
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.cpp
index 245e23f..2087594 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.cpp
@@ -23,7 +23,12 @@
}
-EglPixmapSurface::EglPixmapSurface(EGLNativePixmapType pix,EglConfig* config):EglSurface(PIXMAP,config,0,0),m_pixmap(pix) {
+EglPixmapSurface::EglPixmapSurface(EglDisplay *dpy,
+ EGLNativePixmapType pix,
+ EglConfig* config) :
+ EglSurface(dpy, PIXMAP,config,0,0),
+ m_pixmap(pix)
+{
s_associatedPixmaps.insert(pix);
m_native = EglOS::createPixmapSurface(pix);
}
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.h
index eb42fab..f027eab 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.h
@@ -20,9 +20,11 @@
#include <EGL/egl.h>
#include "EglSurface.h"
+class EglDisplay;
+
class EglPixmapSurface: public EglSurface {
public:
- EglPixmapSurface(EGLNativePixmapType pix,EglConfig* config);
+ EglPixmapSurface(EglDisplay *dpy, EGLNativePixmapType pix,EglConfig* config);
~EglPixmapSurface();
bool getAttrib(EGLint attrib,EGLint* val);
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.cpp
index 27455d3..7f658b6 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.cpp
@@ -19,6 +19,11 @@
unsigned int EglSurface::s_nextSurfaceHndl = 0;
EglSurface::~EglSurface(){
+
+ if(m_type == EglSurface::PBUFFER) {
+ EglOS::releasePbuffer(m_dpy->nativeType(),m_native);
+ }
+
if(m_native) EglOS::destroySurface(m_native);
}
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
index 3fc4840..d65f480 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
@@ -23,9 +23,10 @@
#include "EglConfig.h"
class EglSurface;
-
typedef SmartPtr<EglSurface> SurfacePtr;
+class EglDisplay;
+
class EglSurface {
public:
typedef enum {
@@ -38,8 +39,6 @@
virtual bool setAttrib(EGLint attrib,EGLint val);
virtual bool getAttrib(EGLint attrib,EGLint* val) = 0;
void setDim(int width,int height){ m_width = width; m_height = height;};
- void markForDestruction(){m_destroy = true;};
- bool destroy(){return m_destroy;};
EglConfig* getConfig(){return m_config;};
unsigned int getHndl(){return m_hndl;};
virtual ~EglSurface();
@@ -47,19 +46,29 @@
private:
static unsigned int s_nextSurfaceHndl;
ESurfaceType m_type;
- bool m_destroy;
unsigned int m_hndl;
protected:
- EglSurface(ESurfaceType type,EglConfig* config,EGLint width,EGLint height):m_type(type),
- m_destroy(false),
- m_config(config),
- m_width(width),
- m_height(height),
- m_native(NULL){ m_hndl = ++s_nextSurfaceHndl;};
+ EglSurface(EglDisplay *dpy,
+ ESurfaceType type,
+ EglConfig* config,
+ EGLint width,
+ EGLint height) :
+ m_type(type),
+ m_config(config),
+ m_width(width),
+ m_height(height),
+ m_native(NULL),
+ m_dpy(dpy)
+ {
+ m_hndl = ++s_nextSurfaceHndl;
+ }
+
+protected:
EglConfig* m_config;
EGLint m_width;
EGLint m_height;
EGLNativeSurfaceType m_native;
+ EglDisplay *m_dpy;
};
#endif
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.cpp
index f32cb18..7bff896 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.cpp
@@ -23,7 +23,13 @@
}
-EglWindowSurface::EglWindowSurface(EGLNativeWindowType win,EglConfig* config,unsigned int width,unsigned int height):EglSurface(WINDOW,config,width,height),m_win(win){
+EglWindowSurface::EglWindowSurface(EglDisplay *dpy,
+ EGLNativeWindowType win,
+ EglConfig* config,
+ unsigned int width,unsigned int height) :
+ EglSurface(dpy, WINDOW,config,width,height),
+ m_win(win)
+{
s_associatedWins.insert(win);
m_native = EglOS::createWindowSurface(win);
}
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.h
index 17249e0..460a293 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.h
@@ -21,9 +21,11 @@
#include "EglSurface.h"
#include "EglConfig.h"
+class EglDisplay;
+
class EglWindowSurface: public EglSurface {
public:
- EglWindowSurface(EGLNativeWindowType win,EglConfig* config,unsigned width,unsigned int height);
+ EglWindowSurface(EglDisplay *dpy, EGLNativeWindowType win,EglConfig* config,unsigned width,unsigned int height);
~EglWindowSurface();
bool getAttrib(EGLint attrib,EGLint* val);
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
index 8acf8a1..d1d018f 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-#include <GLcommon/ThreadInfo.h>
+#include "ThreadInfo.h"
-void ThreadInfo::updateInfo(EglContext* eglCtx,
+void ThreadInfo::updateInfo(ContextPtr eglCtx,
EglDisplay* dpy,
GLEScontext* glesCtx,
ShareGroupPtr share,
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/ThreadInfo.h b/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.h
similarity index 84%
rename from tools/emulator/opengl/host/libs/Translator/include/GLcommon/ThreadInfo.h
rename to tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.h
index 69b8ac4..9ee55bf 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/ThreadInfo.h
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.h
@@ -16,22 +16,21 @@
#ifndef THREAD_INFO_H
#define THREAD_INFO_H
-#include "objectNameManager.h"
+#include "EglContext.h"
-class EglContext;
class EglDisplay;
class GLEScontext;
struct ThreadInfo {
- ThreadInfo():eglContext(NULL),glesContext(NULL),objManager(NULL){}
+ ThreadInfo():glesContext(NULL),objManager(NULL){}
- void updateInfo(EglContext* eglctx,
+ void updateInfo(ContextPtr eglctx,
EglDisplay* dpy,
GLEScontext* glesCtx,
ShareGroupPtr share,
ObjectNameManager* manager);
- EglContext* eglContext;
+ ContextPtr eglContext;
EglDisplay* eglDisplay;
GLEScontext* glesContext;
ShareGroupPtr shareGroup;
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
index 677f251..6c63762 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -30,7 +30,6 @@
#include <GLcommon/GLDispatch.h>
#include <GLcommon/GLconversion_macros.h>
#include <GLcommon/TranslatorIfaces.h>
-#include <GLcommon/ThreadInfo.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <cmath>
@@ -178,16 +177,16 @@
static TextureData* getTextureData(ObjectLocalName tex){
GET_CTX_RET(NULL);
- if(!thrd->shareGroup->isObject(TEXTURE,tex))
+ if(!ctx->shareGroup()->isObject(TEXTURE,tex))
{
return NULL;
}
TextureData *texData = NULL;
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(TEXTURE,tex);
if(!objData.Ptr()){
texData = new TextureData();
- thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
+ ctx->shareGroup()->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
} else {
texData = (TextureData*)objData.Ptr();
}
@@ -203,8 +202,8 @@
GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer) {
GET_CTX_RET(GL_FALSE)
- if(buffer && thrd->shareGroup.Ptr()) {
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer);
+ if(buffer && ctx->shareGroup().Ptr()) {
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(VERTEXBUFFER,buffer);
return objData.Ptr() ? ((GLESbuffer*)objData.Ptr())->wasBinded():GL_FALSE;
}
return GL_FALSE;
@@ -292,13 +291,13 @@
SET_ERROR_IF(!GLEScmValidate::bufferTarget(target),GL_INVALID_ENUM);
//if buffer wasn't generated before,generate one
- if(buffer && thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(VERTEXBUFFER,buffer)){
- thrd->shareGroup->genName(VERTEXBUFFER,buffer);
- thrd->shareGroup->setObjectData(VERTEXBUFFER,buffer,ObjectDataPtr(new GLESbuffer()));
+ if(buffer && ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(VERTEXBUFFER,buffer)){
+ ctx->shareGroup()->genName(VERTEXBUFFER,buffer);
+ ctx->shareGroup()->setObjectData(VERTEXBUFFER,buffer,ObjectDataPtr(new GLESbuffer()));
}
ctx->bindBuffer(target,buffer);
if (buffer) {
- GLESbuffer* vbo = (GLESbuffer*)thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer).Ptr();
+ GLESbuffer* vbo = (GLESbuffer*)ctx->shareGroup()->getObjectData(VERTEXBUFFER,buffer).Ptr();
vbo->setBinded();
}
}
@@ -312,12 +311,12 @@
ObjectLocalName localTexName = TextureLocalName(target,texture);
GLuint globalTextureName = localTexName;
- if(thrd->shareGroup.Ptr()){
- globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName);
+ if(ctx->shareGroup().Ptr()){
+ globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,localTexName);
//if texture wasn't generated before,generate one
if(!globalTextureName){
- thrd->shareGroup->genName(TEXTURE,localTexName);
- globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName);
+ ctx->shareGroup()->genName(TEXTURE,localTexName);
+ globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,localTexName);
}
TextureData* texData = getTextureData(localTexName);
@@ -478,9 +477,9 @@
GL_API void GL_APIENTRY glDeleteBuffers( GLsizei n, const GLuint *buffers) {
GET_CTX()
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i < n; i++){
- thrd->shareGroup->deleteName(VERTEXBUFFER,buffers[i]);
+ ctx->shareGroup()->deleteName(VERTEXBUFFER,buffers[i]);
ctx->unbindBuffer(buffers[i]);
}
}
@@ -489,12 +488,12 @@
GL_API void GL_APIENTRY glDeleteTextures( GLsizei n, const GLuint *textures) {
GET_CTX()
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i < n; i++){
if(textures[i] != 0)
{
- thrd->shareGroup->deleteName(TEXTURE,textures[i]);
- const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]);
+ ctx->shareGroup()->deleteName(TEXTURE,textures[i]);
+ const GLuint globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,textures[i]);
ctx->dispatcher().glDeleteTextures(1,&globalTextureName);
if(ctx->getBindedTexture(GL_TEXTURE_2D) == textures[i])
@@ -666,20 +665,20 @@
GL_API void GL_APIENTRY glGenBuffers( GLsizei n, GLuint *buffers) {
GET_CTX()
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i<n ;i++) {
- buffers[i] = thrd->shareGroup->genName(VERTEXBUFFER, 0, true);
+ buffers[i] = ctx->shareGroup()->genName(VERTEXBUFFER, 0, true);
//generating vbo object related to this buffer name
- thrd->shareGroup->setObjectData(VERTEXBUFFER,buffers[i],ObjectDataPtr(new GLESbuffer()));
+ ctx->shareGroup()->setObjectData(VERTEXBUFFER,buffers[i],ObjectDataPtr(new GLESbuffer()));
}
}
}
GL_API void GL_APIENTRY glGenTextures( GLsizei n, GLuint *textures) {
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i<n ;i++) {
- textures[i] = thrd->shareGroup->genName(TEXTURE, 0, true);
+ textures[i] = ctx->shareGroup()->genName(TEXTURE, 0, true);
}
}
}
@@ -870,15 +869,15 @@
ctx->dispatcher().glGetIntegerv(GL_TEXTURE_GEN_S,¶ms[0]);
break;
case GL_FRAMEBUFFER_BINDING_OES:
- if (thrd->shareGroup.Ptr()) {
+ if (ctx->shareGroup().Ptr()) {
ctx->dispatcher().glGetIntegerv(pname,&i);
- *params = thrd->shareGroup->getLocalName(FRAMEBUFFER,i);
+ *params = ctx->shareGroup()->getLocalName(FRAMEBUFFER,i);
}
break;
case GL_RENDERBUFFER_BINDING_OES:
- if (thrd->shareGroup.Ptr()) {
+ if (ctx->shareGroup().Ptr()) {
ctx->dispatcher().glGetIntegerv(pname,&i);
- *params = thrd->shareGroup->getLocalName(RENDERBUFFER,i);
+ *params = ctx->shareGroup()->getLocalName(RENDERBUFFER,i);
}
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
@@ -1445,7 +1444,7 @@
ctx->dispatcher().glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);
- if (thrd->shareGroup.Ptr()){
+ if (ctx->shareGroup().Ptr()){
TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
if(texData) {
@@ -1574,7 +1573,7 @@
ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
- if (thrd->shareGroup.Ptr()){
+ if (ctx->shareGroup().Ptr()){
TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
if(texData && texData->requiresAutoMipmap)
@@ -1615,15 +1614,15 @@
// Create the texture object in the underlying EGL implementation,
// flag to the OpenGL layer to skip the image creation and map the
// current binded texture object to the existing global object.
- if (thrd->shareGroup.Ptr()) {
+ if (ctx->shareGroup().Ptr()) {
ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target));
- unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex);
+ unsigned int oldGlobal = ctx->shareGroup()->getGlobalName(TEXTURE, tex);
// Delete old texture object
if (oldGlobal) {
ctx->dispatcher().glDeleteTextures(1, &oldGlobal);
}
// replace mapping and bind the new global object
- thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName);
+ ctx->shareGroup()->replaceGlobalName(TEXTURE, tex,img->globalTexName);
ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName);
TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
@@ -1666,8 +1665,8 @@
GL_API GLboolean GL_APIENTRY glIsRenderbufferOES(GLuint renderbuffer) {
GET_CTX_RET(GL_FALSE)
RET_AND_SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION,GL_FALSE);
- if(renderbuffer && thrd->shareGroup.Ptr()){
- return thrd->shareGroup->isObject(RENDERBUFFER,renderbuffer) ? GL_TRUE :GL_FALSE;
+ if(renderbuffer && ctx->shareGroup().Ptr()){
+ return ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer) ? GL_TRUE :GL_FALSE;
}
return ctx->dispatcher().glIsRenderbufferEXT(renderbuffer);
}
@@ -1678,11 +1677,11 @@
SET_ERROR_IF(!GLEScmValidate::renderbufferTarget(target),GL_INVALID_ENUM);
//if buffer wasn't generated before,generate one
- if(renderbuffer && thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(RENDERBUFFER,renderbuffer)){
- thrd->shareGroup->genName(RENDERBUFFER,renderbuffer);
+ if(renderbuffer && ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer)){
+ ctx->shareGroup()->genName(RENDERBUFFER,renderbuffer);
}
- int globalBufferName = (renderbuffer != 0) ? thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer) : 0;
+ int globalBufferName = (renderbuffer != 0) ? ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer) : 0;
ctx->dispatcher().glBindRenderbufferEXT(target,globalBufferName);
}
@@ -1690,7 +1689,7 @@
GET_CTX()
SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
for (int i=0;i<n;++i) {
- GLuint globalBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffers[i]);
+ GLuint globalBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffers[i]);
ctx->dispatcher().glDeleteRenderbuffersEXT(1,&globalBufferName);
}
}
@@ -1699,9 +1698,9 @@
GET_CTX()
SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i<n ;i++) {
- renderbuffers[i] = thrd->shareGroup->genName(RENDERBUFFER, 0, true);
+ renderbuffers[i] = ctx->shareGroup()->genName(RENDERBUFFER, 0, true);
}
}
}
@@ -1725,8 +1724,8 @@
GL_API GLboolean GLAPIENTRY glIsFramebufferOES(GLuint framebuffer) {
GET_CTX_RET(GL_FALSE)
RET_AND_SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION,GL_FALSE);
- if (framebuffer && thrd->shareGroup.Ptr()) {
- return thrd->shareGroup->isObject(FRAMEBUFFER,framebuffer) ? GL_TRUE : GL_FALSE;
+ if (framebuffer && ctx->shareGroup().Ptr()) {
+ return ctx->shareGroup()->isObject(FRAMEBUFFER,framebuffer) ? GL_TRUE : GL_FALSE;
}
return ctx->dispatcher().glIsFramebufferEXT(framebuffer);
}
@@ -1735,10 +1734,10 @@
GET_CTX()
SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) ,GL_INVALID_ENUM);
- if (framebuffer && thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(FRAMEBUFFER,framebuffer)) {
- thrd->shareGroup->genName(FRAMEBUFFER,framebuffer);
+ if (framebuffer && ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(FRAMEBUFFER,framebuffer)) {
+ ctx->shareGroup()->genName(FRAMEBUFFER,framebuffer);
}
- int globalBufferName = (framebuffer!=0) ? thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffer) : 0;
+ int globalBufferName = (framebuffer!=0) ? ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffer) : 0;
ctx->dispatcher().glBindFramebufferEXT(target,globalBufferName);
}
@@ -1746,7 +1745,7 @@
GET_CTX()
SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
for (int i=0;i<n;++i) {
- GLuint globalBufferName = thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffers[i]);
+ GLuint globalBufferName = ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffers[i]);
ctx->dispatcher().glDeleteFramebuffersEXT(1,&globalBufferName);
}
}
@@ -1755,9 +1754,9 @@
GET_CTX()
SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if (thrd->shareGroup.Ptr()) {
+ if (ctx->shareGroup().Ptr()) {
for (int i=0;i<n;i++) {
- framebuffers[i] = thrd->shareGroup->genName(FRAMEBUFFER, 0, true);
+ framebuffers[i] = ctx->shareGroup()->genName(FRAMEBUFFER, 0, true);
}
}
}
@@ -1774,10 +1773,10 @@
SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) || !GLEScmValidate::framebufferAttachment(attachment) ||
!GLEScmValidate::textureTargetEx(textarget),GL_INVALID_ENUM);
- if (thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(TEXTURE,texture)) {
- thrd->shareGroup->genName(TEXTURE,texture);
+ if (ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(TEXTURE,texture)) {
+ ctx->shareGroup()->genName(TEXTURE,texture);
}
- GLuint globalTexName = thrd->shareGroup->getGlobalName(TEXTURE,texture);
+ GLuint globalTexName = ctx->shareGroup()->getGlobalName(TEXTURE,texture);
ctx->dispatcher().glFramebufferTexture2DEXT(target,attachment,textarget,globalTexName,level);
}
@@ -1786,10 +1785,10 @@
SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION);
SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) || !GLEScmValidate::framebufferAttachment(attachment) ||
!GLEScmValidate::renderbufferTarget(renderbuffertarget), GL_INVALID_ENUM);
- if (thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(RENDERBUFFER,renderbuffer)) {
- thrd->shareGroup->genName(RENDERBUFFER,renderbuffer);
+ if (ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer)) {
+ ctx->shareGroup()->genName(RENDERBUFFER,renderbuffer);
}
- GLuint globalBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer);
+ GLuint globalBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer);
ctx->dispatcher().glFramebufferRenderbufferEXT(target,attachment,renderbuffertarget,globalBufferName);
}
@@ -2012,7 +2011,7 @@
unsigned int texname = ctx->getBindedTexture(GL_TEXTURE0+i,GL_TEXTURE_2D);
ObjectLocalName tex = TextureLocalName(GL_TEXTURE_2D,texname);
ctx->dispatcher().glClientActiveTexture(GL_TEXTURE0+i);
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(TEXTURE,tex);
if (objData.Ptr()) {
texData = (TextureData*)objData.Ptr();
//calculate texels
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 5329556..fd918f4 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -25,7 +25,6 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <GLcommon/TranslatorIfaces.h>
-#include <GLcommon/ThreadInfo.h>
#include <GLcommon/gldefs.h>
#include "GLESv2Context.h"
#include "GLESv2Validate.h"
@@ -124,10 +123,10 @@
static TextureData* getTextureData(ObjectLocalName tex) {
GET_CTX_RET(NULL);
TextureData *texData = NULL;
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(TEXTURE,tex);
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(TEXTURE,tex);
if(!objData.Ptr()){
texData = new TextureData();
- thrd->shareGroup->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
+ ctx->shareGroup()->setObjectData(TEXTURE, tex, ObjectDataPtr(texData));
} else {
texData = (TextureData*)objData.Ptr();
}
@@ -149,14 +148,14 @@
GL_APICALL void GL_APIENTRY glAttachShader(GLuint program, GLuint shader){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader);
SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE);
- ObjectDataPtr programData = thrd->shareGroup->getObjectData(SHADER,program);
- ObjectDataPtr shaderData = thrd->shareGroup->getObjectData(SHADER,shader);
+ ObjectDataPtr programData = ctx->shareGroup()->getObjectData(SHADER,program);
+ ObjectDataPtr shaderData = ctx->shareGroup()->getObjectData(SHADER,shader);
SET_ERROR_IF(!shaderData.Ptr() || !programData.Ptr() ,GL_INVALID_OPERATION);
SET_ERROR_IF(!(shaderData.Ptr()->getDataType() ==SHADER_DATA) ||
!(programData.Ptr()->getDataType()==PROGRAM_DATA) ,GL_INVALID_OPERATION);
@@ -171,8 +170,8 @@
GL_APICALL void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
ctx->dispatcher().glBindAttribLocation(globalProgramName,index,name);
}
@@ -182,13 +181,13 @@
GET_CTX();
SET_ERROR_IF(!GLESv2Validate::bufferTarget(target),GL_INVALID_ENUM);
//if buffer wasn't generated before,generate one
- if(buffer && thrd->shareGroup.Ptr() && !thrd->shareGroup->isObject(VERTEXBUFFER,buffer)){
- thrd->shareGroup->genName(VERTEXBUFFER,buffer);
- thrd->shareGroup->setObjectData(VERTEXBUFFER,buffer,ObjectDataPtr(new GLESbuffer()));
+ if(buffer && ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(VERTEXBUFFER,buffer)){
+ ctx->shareGroup()->genName(VERTEXBUFFER,buffer);
+ ctx->shareGroup()->setObjectData(VERTEXBUFFER,buffer,ObjectDataPtr(new GLESbuffer()));
}
ctx->bindBuffer(target,buffer);
if (buffer) {
- GLESbuffer* vbo = (GLESbuffer*)thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer).Ptr();
+ GLESbuffer* vbo = (GLESbuffer*)ctx->shareGroup()->getObjectData(VERTEXBUFFER,buffer).Ptr();
vbo->setBinded();
}
}
@@ -198,12 +197,12 @@
SET_ERROR_IF(!GLESv2Validate::framebufferTarget(target),GL_INVALID_ENUM);
GLuint globalFrameBufferName = framebuffer;
- if(framebuffer && thrd->shareGroup.Ptr()){
- globalFrameBufferName = thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffer);
+ if(framebuffer && ctx->shareGroup().Ptr()){
+ globalFrameBufferName = ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffer);
//if framebuffer wasn't generated before,generate one
if(!globalFrameBufferName){
- thrd->shareGroup->genName(FRAMEBUFFER,framebuffer);
- globalFrameBufferName = thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffer);
+ ctx->shareGroup()->genName(FRAMEBUFFER,framebuffer);
+ globalFrameBufferName = ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffer);
}
}
ctx->dispatcher().glBindFramebufferEXT(target,globalFrameBufferName);
@@ -214,12 +213,12 @@
SET_ERROR_IF(!GLESv2Validate::renderbufferTarget(target),GL_INVALID_ENUM);
GLuint globalRenderBufferName = renderbuffer;
- if(renderbuffer && thrd->shareGroup.Ptr()){
- globalRenderBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer);
+ if(renderbuffer && ctx->shareGroup().Ptr()){
+ globalRenderBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer);
//if renderbuffer wasn't generated before,generate one
if(!globalRenderBufferName){
- thrd->shareGroup->genName(RENDERBUFFER,renderbuffer);
- globalRenderBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer);
+ ctx->shareGroup()->genName(RENDERBUFFER,renderbuffer);
+ globalRenderBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer);
}
}
ctx->dispatcher().glBindRenderbufferEXT(target,globalRenderBufferName);
@@ -233,12 +232,12 @@
ObjectLocalName localTexName = TextureLocalName(target,texture);
GLuint globalTextureName = localTexName;
- if(thrd->shareGroup.Ptr()){
- globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName);
+ if(ctx->shareGroup().Ptr()){
+ globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,localTexName);
//if texture wasn't generated before,generate one
if(!globalTextureName){
- thrd->shareGroup->genName(TEXTURE,localTexName);
- globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,localTexName);
+ ctx->shareGroup()->genName(TEXTURE,localTexName);
+ globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,localTexName);
}
TextureData* texData = getTextureData(localTexName);
@@ -327,8 +326,8 @@
GL_APICALL void GL_APIENTRY glCompileShader(GLuint shader){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader);
SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE);
ctx->dispatcher().glCompileShader(globalShaderName);
}
@@ -366,11 +365,11 @@
GL_APICALL GLuint GL_APIENTRY glCreateProgram(void){
GET_CTX_RET(0);
const GLuint globalProgramName = ctx->dispatcher().glCreateProgram();
- if(thrd->shareGroup.Ptr() && globalProgramName) {
+ if(ctx->shareGroup().Ptr() && globalProgramName) {
ProgramData* programInfo = new ProgramData();
- const GLuint localProgramName = thrd->shareGroup->genName(SHADER, 0, true);
- thrd->shareGroup->replaceGlobalName(SHADER,localProgramName,globalProgramName);
- thrd->shareGroup->setObjectData(SHADER,localProgramName,ObjectDataPtr(programInfo));
+ const GLuint localProgramName = ctx->shareGroup()->genName(SHADER, 0, true);
+ ctx->shareGroup()->replaceGlobalName(SHADER,localProgramName,globalProgramName);
+ ctx->shareGroup()->setObjectData(SHADER,localProgramName,ObjectDataPtr(programInfo));
return localProgramName;
}
if(globalProgramName){
@@ -382,11 +381,11 @@
GL_APICALL GLuint GL_APIENTRY glCreateShader(GLenum type){
GET_CTX_V2_RET(0);
const GLuint globalShaderName = ctx->dispatcher().glCreateShader(type);
- if(thrd->shareGroup.Ptr() && globalShaderName) {
- const GLuint localShaderName = thrd->shareGroup->genName(SHADER, 0, true);
+ if(ctx->shareGroup().Ptr() && globalShaderName) {
+ const GLuint localShaderName = ctx->shareGroup()->genName(SHADER, 0, true);
ShaderParser* sp = new ShaderParser(type);
- thrd->shareGroup->replaceGlobalName(SHADER,localShaderName,globalShaderName);
- thrd->shareGroup->setObjectData(SHADER,localShaderName,ObjectDataPtr(sp));
+ ctx->shareGroup()->replaceGlobalName(SHADER,localShaderName,globalShaderName);
+ ctx->shareGroup()->setObjectData(SHADER,localShaderName,ObjectDataPtr(sp));
return localShaderName;
}
if(globalShaderName){
@@ -403,9 +402,9 @@
GL_APICALL void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers){
GET_CTX();
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i < n; i++){
- thrd->shareGroup->deleteName(VERTEXBUFFER,buffers[i]);
+ ctx->shareGroup()->deleteName(VERTEXBUFFER,buffers[i]);
}
}
}
@@ -413,10 +412,10 @@
GL_APICALL void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers){
GET_CTX();
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i < n; i++){
- const GLuint globalFrameBufferName = thrd->shareGroup->getGlobalName(FRAMEBUFFER,framebuffers[i]);
- thrd->shareGroup->deleteName(FRAMEBUFFER,framebuffers[i]);
+ const GLuint globalFrameBufferName = ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffers[i]);
+ ctx->shareGroup()->deleteName(FRAMEBUFFER,framebuffers[i]);
ctx->dispatcher().glDeleteFramebuffersEXT(1,&globalFrameBufferName);
}
}
@@ -425,10 +424,10 @@
GL_APICALL void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers){
GET_CTX();
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i < n; i++){
- const GLuint globalRenderBufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffers[i]);
- thrd->shareGroup->deleteName(RENDERBUFFER,renderbuffers[i]);
+ const GLuint globalRenderBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffers[i]);
+ ctx->shareGroup()->deleteName(RENDERBUFFER,renderbuffers[i]);
ctx->dispatcher().glDeleteRenderbuffersEXT(1,&globalRenderBufferName);
}
}
@@ -437,11 +436,11 @@
GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures){
GET_CTX();
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i < n; i++){
if (textures[i]!=0) {
- const GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,textures[i]);
- thrd->shareGroup->deleteName(TEXTURE,textures[i]);
+ const GLuint globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,textures[i]);
+ ctx->shareGroup()->deleteName(TEXTURE,textures[i]);
ctx->dispatcher().glDeleteTextures(1,&globalTextureName);
if (ctx->getBindedTexture(GL_TEXTURE_2D) == textures[i])
@@ -455,20 +454,20 @@
GL_APICALL void GL_APIENTRY glDeleteProgram(GLuint program){
GET_CTX();
- if(program && thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(program && ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(!globalProgramName, GL_INVALID_VALUE);
- thrd->shareGroup->deleteName(SHADER,program);
+ ctx->shareGroup()->deleteName(SHADER,program);
ctx->dispatcher().glDeleteProgram(globalProgramName);
}
}
GL_APICALL void GL_APIENTRY glDeleteShader(GLuint shader){
GET_CTX();
- if(shader && thrd->shareGroup.Ptr()) {
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+ if(shader && ctx->shareGroup().Ptr()) {
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader);
SET_ERROR_IF(!globalShaderName, GL_INVALID_VALUE);
- thrd->shareGroup->deleteName(SHADER,shader);
+ ctx->shareGroup()->deleteName(SHADER,shader);
ctx->dispatcher().glDeleteShader(globalShaderName);
}
@@ -489,13 +488,13 @@
GL_APICALL void GL_APIENTRY glDetachShader(GLuint program, GLuint shader){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader);
SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE);
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(SHADER,program);
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program);
SET_ERROR_IF(!objData.Ptr(),GL_INVALID_OPERATION);
SET_ERROR_IF(!(objData.Ptr()->getDataType()==PROGRAM_DATA) ,GL_INVALID_OPERATION);
@@ -599,8 +598,8 @@
GLESv2Validate::renderbufferTarget(renderbuffertarget) &&
GLESv2Validate::framebufferAttachment(attachment)),GL_INVALID_ENUM);
- if(thrd->shareGroup.Ptr()) {
- GLuint globalRenderbufferName = thrd->shareGroup->getGlobalName(RENDERBUFFER,renderbuffer);
+ if(ctx->shareGroup().Ptr()) {
+ GLuint globalRenderbufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer);
ctx->dispatcher().glFramebufferRenderbufferEXT(target,attachment,renderbuffertarget,globalRenderbufferName);
}
@@ -613,9 +612,9 @@
GLESv2Validate::framebufferAttachment(attachment)),GL_INVALID_ENUM);
SET_ERROR_IF(level != 0, GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
ObjectLocalName texname = TextureLocalName(textarget,texture);
- GLuint globalTextureName = thrd->shareGroup->getGlobalName(TEXTURE,texname);
+ GLuint globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,texname);
ctx->dispatcher().glFramebufferTexture2DEXT(target,attachment,textarget,globalTextureName,level);
}
}
@@ -629,11 +628,11 @@
GL_APICALL void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers){
GET_CTX();
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i<n ;i++) {
- buffers[i] = thrd->shareGroup->genName(VERTEXBUFFER, 0, true);
+ buffers[i] = ctx->shareGroup()->genName(VERTEXBUFFER, 0, true);
//generating vbo object related to this buffer name
- thrd->shareGroup->setObjectData(VERTEXBUFFER,buffers[i],ObjectDataPtr(new GLESbuffer()));
+ ctx->shareGroup()->setObjectData(VERTEXBUFFER,buffers[i],ObjectDataPtr(new GLESbuffer()));
}
}
}
@@ -647,9 +646,9 @@
GL_APICALL void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers){
GET_CTX();
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i<n ;i++) {
- framebuffers[i] = thrd->shareGroup->genName(FRAMEBUFFER, 0 ,true);
+ framebuffers[i] = ctx->shareGroup()->genName(FRAMEBUFFER, 0 ,true);
}
}
}
@@ -657,9 +656,9 @@
GL_APICALL void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers){
GET_CTX();
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i<n ;i++) {
- renderbuffers[i] = thrd->shareGroup->genName(RENDERBUFFER, 0, true);
+ renderbuffers[i] = ctx->shareGroup()->genName(RENDERBUFFER, 0, true);
}
}
}
@@ -667,17 +666,17 @@
GL_APICALL void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures){
GET_CTX();
SET_ERROR_IF(n<0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()) {
+ if(ctx->shareGroup().Ptr()) {
for(int i=0; i<n ;i++) {
- textures[i] = thrd->shareGroup->genName(TEXTURE, 0, true);
+ textures[i] = ctx->shareGroup()->genName(TEXTURE, 0, true);
}
}
}
GL_APICALL void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
ctx->dispatcher().glGetActiveAttrib(globalProgramName,index,bufsize,length,size,type,name);
}
@@ -685,8 +684,8 @@
GL_APICALL void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
ctx->dispatcher().glGetActiveUniform(globalProgramName,index,bufsize,length,size,type,name);
}
@@ -694,20 +693,20 @@
GL_APICALL void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
ctx->dispatcher().glGetAttachedShaders(globalProgramName,maxcount,count,shaders);
for(int i=0 ; i < *count ;i++){
- shaders[i] = thrd->shareGroup->getLocalName(SHADER,shaders[i]);
+ shaders[i] = ctx->shareGroup()->getLocalName(SHADER,shaders[i]);
}
}
}
GL_APICALL int GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name){
GET_CTX_RET(-1);
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
RET_AND_SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE,-1);
return ctx->dispatcher().glGetAttribLocation(globalProgramName,name);
}
@@ -835,21 +834,21 @@
switch (pname) {
case GL_CURRENT_PROGRAM:
- if (thrd->shareGroup.Ptr()) {
+ if (ctx->shareGroup().Ptr()) {
ctx->dispatcher().glGetIntegerv(pname,&i);
- *params = thrd->shareGroup->getLocalName(SHADER,i);
+ *params = ctx->shareGroup()->getLocalName(SHADER,i);
}
break;
case GL_FRAMEBUFFER_BINDING:
- if (thrd->shareGroup.Ptr()) {
+ if (ctx->shareGroup().Ptr()) {
ctx->dispatcher().glGetIntegerv(pname,&i);
- *params = thrd->shareGroup->getLocalName(FRAMEBUFFER,i);
+ *params = ctx->shareGroup()->getLocalName(FRAMEBUFFER,i);
}
break;
case GL_RENDERBUFFER_BINDING:
- if (thrd->shareGroup.Ptr()) {
+ if (ctx->shareGroup().Ptr()) {
ctx->dispatcher().glGetIntegerv(pname,&i);
- *params = thrd->shareGroup->getLocalName(RENDERBUFFER,i);
+ *params = ctx->shareGroup()->getLocalName(RENDERBUFFER,i);
}
break;
@@ -922,13 +921,13 @@
GL_APICALL void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
switch(pname) {
case GL_LINK_STATUS:
{
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(SHADER,program);
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program);
SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION);
SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION);
ProgramData* programData = (ProgramData*)objData.Ptr();
@@ -938,7 +937,7 @@
//validate status should not return GL_TRUE if link failed
case GL_VALIDATE_STATUS:
{
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(SHADER,program);
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program);
SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION);
SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION);
ProgramData* programData = (ProgramData*)objData.Ptr();
@@ -956,8 +955,8 @@
GL_APICALL void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
ctx->dispatcher().glGetProgramInfoLog(globalProgramName,bufsize,length,infolog);
}
@@ -965,8 +964,8 @@
GL_APICALL void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader);
SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE);
ctx->dispatcher().glGetShaderiv(globalShaderName,pname,params);
}
@@ -974,8 +973,8 @@
GL_APICALL void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader);
SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE);
ctx->dispatcher().glGetShaderInfoLog(globalShaderName,bufsize,length,infolog);
}
@@ -1012,10 +1011,10 @@
GL_APICALL void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader);
SET_ERROR_IF(globalShaderName == 0,GL_INVALID_VALUE);
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(SHADER,shader);
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,shader);
SET_ERROR_IF(!objData.Ptr(),GL_INVALID_OPERATION);
SET_ERROR_IF(objData.Ptr()->getDataType()!=SHADER_DATA,GL_INVALID_OPERATION);
const char* src = ((ShaderParser*)objData.Ptr())->getOriginalSrc();
@@ -1067,8 +1066,8 @@
GL_APICALL void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
ctx->dispatcher().glGetUniformfv(globalProgramName,location,params);
}
@@ -1076,8 +1075,8 @@
GL_APICALL void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
ctx->dispatcher().glGetUniformiv(globalProgramName,location,params);
}
@@ -1085,8 +1084,8 @@
GL_APICALL int GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name){
GET_CTX_RET(-1);
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
RET_AND_SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE,-1);
return ctx->dispatcher().glGetUniformLocation(globalProgramName,name);
}
@@ -1190,8 +1189,8 @@
GL_APICALL GLboolean GL_APIENTRY glIsBuffer(GLuint buffer){
GET_CTX_RET(GL_FALSE)
- if(buffer && thrd->shareGroup.Ptr()) {
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(VERTEXBUFFER,buffer);
+ if(buffer && ctx->shareGroup().Ptr()) {
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(VERTEXBUFFER,buffer);
return objData.Ptr() ? ((GLESbuffer*)objData.Ptr())->wasBinded():GL_FALSE;
}
return GL_FALSE;
@@ -1199,16 +1198,16 @@
GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer){
GET_CTX_RET(GL_FALSE)
- if(framebuffer && thrd->shareGroup.Ptr()){
- return thrd->shareGroup->isObject(FRAMEBUFFER,framebuffer) ? GL_TRUE :GL_FALSE;
+ if(framebuffer && ctx->shareGroup().Ptr()){
+ return ctx->shareGroup()->isObject(FRAMEBUFFER,framebuffer) ? GL_TRUE :GL_FALSE;
}
return GL_FALSE;
}
GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer){
GET_CTX_RET(GL_FALSE)
- if(renderbuffer && thrd->shareGroup.Ptr()){
- return thrd->shareGroup->isObject(RENDERBUFFER,renderbuffer) ? GL_TRUE :GL_FALSE;
+ if(renderbuffer && ctx->shareGroup().Ptr()){
+ return ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer) ? GL_TRUE :GL_FALSE;
}
return GL_FALSE;
}
@@ -1223,9 +1222,9 @@
GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program){
GET_CTX_RET(GL_FALSE)
- if(program && thrd->shareGroup.Ptr() &&
- thrd->shareGroup->isObject(SHADER,program)) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(program && ctx->shareGroup().Ptr() &&
+ ctx->shareGroup()->isObject(SHADER,program)) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
return ctx->dispatcher().glIsProgram(globalProgramName);
}
return GL_FALSE;
@@ -1233,9 +1232,9 @@
GL_APICALL GLboolean GL_APIENTRY glIsShader(GLuint shader){
GET_CTX_RET(GL_FALSE)
- if(shader && thrd->shareGroup.Ptr() &&
- thrd->shareGroup->isObject(SHADER,shader)) {
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+ if(shader && ctx->shareGroup().Ptr() &&
+ ctx->shareGroup()->isObject(SHADER,shader)) {
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader);
return ctx->dispatcher().glIsShader(globalShaderName);
}
return GL_FALSE;
@@ -1249,11 +1248,11 @@
GL_APICALL void GL_APIENTRY glLinkProgram(GLuint program){
GET_CTX();
GLint linkStatus = GL_FALSE;
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(SHADER,program);
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program);
SET_ERROR_IF(!objData.Ptr(), GL_INVALID_OPERATION);
SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA, GL_INVALID_OPERATION);
ProgramData* programData = (ProgramData*)objData.Ptr();
@@ -1263,8 +1262,8 @@
/* validating that the fragment & vertex shaders were compiled successfuly*/
GLint fCompileStatus = GL_FALSE;
GLint vCompileStatus = GL_FALSE;
- GLuint fragmentShaderGlobal = thrd->shareGroup->getGlobalName(SHADER,fragmentShader);
- GLuint vertexShaderGlobal = thrd->shareGroup->getGlobalName(SHADER,vertexShader);
+ GLuint fragmentShaderGlobal = ctx->shareGroup()->getGlobalName(SHADER,fragmentShader);
+ GLuint vertexShaderGlobal = ctx->shareGroup()->getGlobalName(SHADER,vertexShader);
ctx->dispatcher().glGetShaderiv(fragmentShaderGlobal,GL_COMPILE_STATUS,&fCompileStatus);
ctx->dispatcher().glGetShaderiv(vertexShaderGlobal,GL_COMPILE_STATUS,&vCompileStatus);
@@ -1339,9 +1338,9 @@
SET_ERROR_IF( (ctx->dispatcher().glShaderBinary == NULL), GL_INVALID_OPERATION);
- if(thrd->shareGroup.Ptr()){
+ if(ctx->shareGroup().Ptr()){
for(int i=0; i < n ; i++){
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shaders[i]);
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shaders[i]);
SET_ERROR_IF(globalShaderName == 0,GL_INVALID_VALUE);
ctx->dispatcher().glShaderBinary(1,&globalShaderName,binaryformat,binary,length);
}
@@ -1351,10 +1350,10 @@
GL_APICALL void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length){
GET_CTX_V2();
SET_ERROR_IF(count < 0,GL_INVALID_VALUE);
- if(thrd->shareGroup.Ptr()){
- const GLuint globalShaderName = thrd->shareGroup->getGlobalName(SHADER,shader);
+ if(ctx->shareGroup().Ptr()){
+ const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader);
SET_ERROR_IF(globalShaderName == 0,GL_INVALID_VALUE);
- ObjectDataPtr objData = thrd->shareGroup->getObjectData(SHADER,shader);
+ ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,shader);
SET_ERROR_IF(!objData.Ptr(),GL_INVALID_OPERATION);
SET_ERROR_IF(objData.Ptr()->getDataType()!=SHADER_DATA,GL_INVALID_OPERATION);
ShaderParser* sp = (ShaderParser*)objData.Ptr();
@@ -1401,7 +1400,7 @@
SET_ERROR_IF(!(GLESv2Validate::pixelOp(format,type) && internalformat == ((GLint)format)),GL_INVALID_OPERATION);
SET_ERROR_IF(border != 0,GL_INVALID_VALUE);
- if (thrd->shareGroup.Ptr()){
+ if (ctx->shareGroup().Ptr()){
TextureData *texData = getTextureTargetData(target);
if(texData) {
texData->width = width;
@@ -1544,8 +1543,8 @@
GL_APICALL void GL_APIENTRY glUseProgram(GLuint program){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(program!=0 && globalProgramName==0,GL_INVALID_VALUE);
ctx->dispatcher().glUseProgram(globalProgramName);
}
@@ -1553,8 +1552,8 @@
GL_APICALL void GL_APIENTRY glValidateProgram(GLuint program){
GET_CTX();
- if(thrd->shareGroup.Ptr()) {
- const GLuint globalProgramName = thrd->shareGroup->getGlobalName(SHADER,program);
+ if(ctx->shareGroup().Ptr()) {
+ const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program);
SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
ctx->dispatcher().glValidateProgram(globalProgramName);
}
@@ -1621,15 +1620,15 @@
// Create the texture object in the underlying EGL implementation,
// flag to the OpenGL layer to skip the image creation and map the
// current binded texture object to the existing global object.
- if (thrd->shareGroup.Ptr()) {
+ if (ctx->shareGroup().Ptr()) {
ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target));
- unsigned int oldGlobal = thrd->shareGroup->getGlobalName(TEXTURE, tex);
+ unsigned int oldGlobal = ctx->shareGroup()->getGlobalName(TEXTURE, tex);
// Delete old texture object
if (oldGlobal) {
ctx->dispatcher().glDeleteTextures(1, &oldGlobal);
}
// replace mapping and bind the new global object
- thrd->shareGroup->replaceGlobalName(TEXTURE, tex,img->globalTexName);
+ ctx->shareGroup()->replaceGlobalName(TEXTURE, tex,img->globalTexName);
ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName);
TextureData *texData = getTextureTargetData(target);
SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION);
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
index 035f521..9e99284 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
@@ -103,6 +103,7 @@
GLenum getGLerror();
void setGLerror(GLenum err);
void setShareGroup(ShareGroupPtr grp){m_shareGroup = grp;};
+ ShareGroupPtr shareGroup() const { return m_shareGroup; }
virtual void setActiveTexture(GLenum tex);
unsigned int getBindedTexture(GLenum target);
unsigned int getBindedTexture(GLenum unit,GLenum target);
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h
index 1485f75..95ffadb 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h
@@ -1,49 +1,33 @@
#ifndef GLES_MACROS_H
#define GLES_MACROS_H
-#define GET_THREAD() \
- ThreadInfo* thrd = NULL; \
- if(s_eglIface) { \
- thrd = s_eglIface->getThreadInfo(); \
- } else { \
- fprintf(stderr,"Context wasn't initialized yet \n"); \
- }
+#define GET_CTX() \
+ if(!s_eglIface) return; \
+ GLEScontext *ctx = s_eglIface->getGLESContext(); \
-
-#define GET_CTX() \
- GET_THREAD(); \
- if(!thrd) return; \
- GLEScontext *ctx = static_cast<GLEScontext*>(thrd->glesContext); \
+#define GET_CTX_CM() \
+ if(!s_eglIface) return; \
+ GLEScmContext *ctx = static_cast<GLEScmContext *>(s_eglIface->getGLESContext()); \
if(!ctx) return;
-#define GET_CTX_CM() \
- GET_THREAD(); \
- if(!thrd) return; \
- GLEScmContext *ctx = static_cast<GLEScmContext*>(thrd->glesContext); \
+#define GET_CTX_V2() \
+ if(!s_eglIface) return; \
+ GLESv2Context *ctx = static_cast<GLESv2Context *>(s_eglIface->getGLESContext()); \
if(!ctx) return;
-#define GET_CTX_V2() \
- GET_THREAD(); \
- if(!thrd) return; \
- GLESv2Context *ctx = static_cast<GLESv2Context*>(thrd->glesContext); \
- if(!ctx) return;
-
-#define GET_CTX_RET(failure_ret) \
- GET_THREAD(); \
- if(!thrd) return failure_ret; \
- GLEScontext *ctx = static_cast<GLEScontext*>(thrd->glesContext); \
+#define GET_CTX_RET(failure_ret) \
+ if(!s_eglIface) return failure_ret; \
+ GLEScontext *ctx = s_eglIface->getGLESContext(); \
if(!ctx) return failure_ret;
-#define GET_CTX_CM_RET(failure_ret) \
- GET_THREAD(); \
- if(!thrd) return failure_ret; \
- GLEScmContext *ctx = static_cast<GLEScmContext*>(thrd->glesContext); \
+#define GET_CTX_CM_RET(failure_ret) \
+ if(!s_eglIface) return failure_ret; \
+ GLEScmContext *ctx = static_cast<GLEScmContext *>(s_eglIface->getGLESContext()); \
if(!ctx) return failure_ret;
-#define GET_CTX_V2_RET(failure_ret) \
- GET_THREAD(); \
- if(!thrd) return failure_ret; \
- GLESv2Context *ctx = static_cast<GLESv2Context*>(thrd->glesContext); \
+#define GET_CTX_V2_RET(failure_ret) \
+ if(!s_eglIface) return failure_ret; \
+ GLESv2Context *ctx = static_cast<GLESv2Context *>(s_eglIface->getGLESContext()); \
if(!ctx) return failure_ret;
diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
index 19f69e5..ec44f6d 100644
--- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
+++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
@@ -15,9 +15,9 @@
*/
#ifndef TRANSLATOR_IFACES_H
#define TRANSLATOR_IFACES_H
-#include <GLcommon/ThreadInfo.h>
#include <GLES/gl.h>
#include <string.h>
+#include "objectNameManager.h"
extern "C" {
@@ -89,7 +89,7 @@
typedef struct {
- ThreadInfo* (*getThreadInfo)();
+ GLEScontext* (*getGLESContext)();
EglImage* (*eglAttachEGLImage)(unsigned int imageId);
void (*eglDetachEGLImage)(unsigned int imageId);
}EGLiface;