emulator: opengl: Fix Mac build

This fixes several issues when building the host libraris on Darwin.
Note that there is still not proper implementation of backend functions.

Change-Id: I3ba4120df6545a8c2aa62fdfcaadaf5ff4972456
This commit is contained in:
David Turner
2011-05-02 13:51:50 +02:00
parent 27c128d701
commit 2d3b98f87b
8 changed files with 56 additions and 11 deletions

View File

@@ -10,7 +10,7 @@ OS_SRCS:=
ifeq ($(HOST_OS),linux) ifeq ($(HOST_OS),linux)
OS_SRCS = EglX11Api.cpp OS_SRCS = EglX11Api.cpp
LOCAL_LDLIBS := -lX11 -lGL -ldl LOCAL_LDLIBS := -lX11 -lGL -ldl -lpthread
endif endif
ifeq ($(HOST_OS),darwin) ifeq ($(HOST_OS),darwin)

View File

@@ -34,14 +34,15 @@
#define MINOR 1 #define MINOR 1
#define MAJOR 4 #define MAJOR 4
//declerations //declarations
EglImage *attachEGLImage(unsigned int imageId); EglImage *attachEGLImage(unsigned int imageId);
void detachEGLImage(unsigned int imageId); void detachEGLImage(unsigned int imageId);
#define tls_thread EglThreadInfo::get()
EglGlobalInfo* g_eglInfo = EglGlobalInfo::getInstance(); EglGlobalInfo* g_eglInfo = EglGlobalInfo::getInstance();
__thread EglThreadInfo* tls_thread = NULL;
static EGLiface s_eglIface = { static EGLiface s_eglIface = {
getThreadInfo : getThreadInfo, // implemented in ThreadInfo.cpp getThreadInfo : getThreadInfo, // implemented in ThreadInfo.cpp
eglAttachEGLImage:attachEGLImage, eglAttachEGLImage:attachEGLImage,
@@ -71,10 +72,7 @@ static EglExtentionDescriptor s_extentions[] = {
/****************************************************************************************************************************************/ /****************************************************************************************************************************************/
//macros for accessing global egl info & tls objects //macros for accessing global egl info & tls objects
#define CURRENT_THREAD() \ #define CURRENT_THREAD() do {} while (0);
if(!tls_thread) { \
tls_thread = new EglThreadInfo(); \
}
#define RETURN_ERROR(ret,err) \ #define RETURN_ERROR(ret,err) \
CURRENT_THREAD() \ CURRENT_THREAD() \

View File

@@ -20,7 +20,7 @@
//TODO: implementation for mac for all funcs //TODO: implementation for mac for all funcs
namespace EglOS { namespace EglOS {
EGLNativeDisplayType getDefaultDisplay() {return NULL} EGLNativeDisplayType getDefaultDisplay() {return NULL;}
bool releaseDisplay(EGLNativeDisplayType dpy) { bool releaseDisplay(EGLNativeDisplayType dpy) {
return false; return false;
@@ -53,6 +53,10 @@ EGLNativePbufferType createPbuffer(EGLNativeDisplayType dpy,EglConfig* cfg,EglPb
return NULL; return NULL;
} }
bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb) {
return true;
}
EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) { EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) {
return NULL; return NULL;
} }

View File

@@ -17,7 +17,11 @@
#define EGL_OS_API_H #define EGL_OS_API_H
#include <EGL/egl.h> #include <EGL/egl.h>
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h> #include <GL/gl.h>
#endif
#include "EglConfig.h" #include "EglConfig.h"
#include "EglDisplay.h" #include "EglDisplay.h"
#include "EglPbufferSurface.h" #include "EglPbufferSurface.h"

View File

@@ -17,3 +17,26 @@
#include "EglOsApi.h" #include "EglOsApi.h"
EglThreadInfo::EglThreadInfo():m_err(EGL_SUCCESS),m_api(EGL_OPENGL_ES_API) {} EglThreadInfo::EglThreadInfo():m_err(EGL_SUCCESS),m_api(EGL_OPENGL_ES_API) {}
#include <cutils/threads.h>
static thread_store_t s_tls = THREAD_STORE_INITIALIZER;
static void tlsDestruct(void *ptr)
{
if (ptr) {
EglThreadInfo *ti = (EglThreadInfo *)ptr;
delete ti;
}
}
EglThreadInfo* EglThreadInfo::get(void)
{
EglThreadInfo *ti = (EglThreadInfo *)thread_store_get(&s_tls);
if (!ti) {
ti = new EglThreadInfo();
thread_store_set(&s_tls, ti, tlsDestruct);
}
return ti;
}

View File

@@ -32,6 +32,8 @@ public:
void setApi(EGLenum api){m_api = api;} void setApi(EGLenum api){m_api = api;}
EGLenum getApi(){return m_api;} EGLenum getApi(){return m_api;}
static EglThreadInfo* get(void) __attribute__((const));
private: private:
EglDisplay* m_currentDisplay; EglDisplay* m_currentDisplay;
EGLint m_err; EGLint m_err;

View File

@@ -16,7 +16,6 @@
#include <GLcommon/ThreadInfo.h> #include <GLcommon/ThreadInfo.h>
__thread ThreadInfo* thread = NULL;
void ThreadInfo::updateInfo(void* eglCtx,void* dpy,void* glesCtx,ShareGroupPtr share,ObjectNameManager* manager) { void ThreadInfo::updateInfo(void* eglCtx,void* dpy,void* glesCtx,ShareGroupPtr share,ObjectNameManager* manager) {
eglContext = eglCtx; eglContext = eglCtx;
@@ -27,6 +26,9 @@ void ThreadInfo::updateInfo(void* eglCtx,void* dpy,void* glesCtx,ShareGroupPtr s
} }
#ifdef __linux__ #ifdef __linux__
__thread ThreadInfo* thread = NULL;
ThreadInfo* getThreadInfo(){ ThreadInfo* getThreadInfo(){
if(!thread) { if(!thread) {
thread = new ThreadInfo(); thread = new ThreadInfo();
@@ -35,6 +37,7 @@ ThreadInfo* getThreadInfo(){
} }
#else #else
#include <cutils/threads.h> #include <cutils/threads.h>
static thread_store_t s_tls = THREAD_STORE_INITIALIZER; static thread_store_t s_tls = THREAD_STORE_INITIALIZER;
@@ -46,13 +49,14 @@ static void tlsDestruct(void *ptr)
} }
} }
RenderThreadInfo *getRenderThreadInfo() ThreadInfo *getThreadInfo()
{ {
ThreadInfo *ti = (ThreadInfo *)thread_store_get(&s_tls); ThreadInfo *ti = (ThreadInfo *)thread_store_get(&s_tls);
if (!ti) { if (!ti) {
ti = new RenderThreadInfo(); ti = new ThreadInfo();
thread_store_set(&s_tls, ti, tlsDestruct); thread_store_set(&s_tls, ti, tlsDestruct);
} }
return ti; return ti;
} }
#endif #endif

View File

@@ -73,6 +73,16 @@ typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType; typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType; typedef HWND EGLNativeWindowType;
#elif defined(__APPLE__)
typedef int EGLNativePixelFormatType;
typedef struct _EGLNativeContextType* EGLNativeContextType;
typedef struct _EGLNativePbufferType* EGLNativePbufferType;
typedef struct _EGLNativeDisplayType* EGLNativeDisplayType;
typedef int EGLNativePixmapType;
typedef int EGLNativeWindowType;
#elif defined(__unix__) #elif defined(__unix__)
/* X11 (tentative) */ /* X11 (tentative) */