aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/opengl/host
diff options
context:
space:
mode:
Diffstat (limited to 'emulator/opengl/host')
-rw-r--r--emulator/opengl/host/libs/GLESv1_dec/Android.mk18
-rw-r--r--emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp20
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/Android.mk18
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp7
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/Android.mk13
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglContext.h4
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp51
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglDisplay.h7
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp10
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h11
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglImp.cpp54
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglSurface.h7
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp31
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp24
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp17
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp58
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/Android.mk13
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp2
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h6
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp2
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h1
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp26
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/Android.mk12
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp5
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h1
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp19
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp1
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp4
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/Android.mk28
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp41
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp12
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp174
-rw-r--r--emulator/opengl/host/libs/Translator/include/ETC1/etc1.h106
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h6
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h2
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h4
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h41
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h163
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h4
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h16
-rw-r--r--emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h282
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/Android.mk28
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp28
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h4
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp1
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp38
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h7
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/RenderContext.h4
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp14
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp2
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp19
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp5
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/WindowSurface.h4
-rw-r--r--emulator/opengl/host/libs/renderControl_dec/Android.mk16
-rw-r--r--emulator/opengl/host/libs/renderControl_dec/renderControl.in1
-rw-r--r--emulator/opengl/host/renderer/main.cpp2
-rw-r--r--emulator/opengl/host/tools/emugen/Android.mk36
-rw-r--r--emulator/opengl/host/tools/emugen/ApiGen.cpp40
-rw-r--r--emulator/opengl/host/tools/emugen/ApiGen.h2
-rw-r--r--emulator/opengl/host/tools/emugen/getopt.c76
-rw-r--r--emulator/opengl/host/tools/emugen/getopt.h18
-rw-r--r--emulator/opengl/host/tools/emugen/main.cpp1
62 files changed, 1029 insertions, 638 deletions
diff --git a/emulator/opengl/host/libs/GLESv1_dec/Android.mk b/emulator/opengl/host/libs/GLESv1_dec/Android.mk
index a6d8670..7ab3f0a 100644
--- a/emulator/opengl/host/libs/GLESv1_dec/Android.mk
+++ b/emulator/opengl/host/libs/GLESv1_dec/Android.mk
@@ -18,20 +18,24 @@ $(call emugl-gen-decoder,$(LOCAL_PATH),gl)
LOCAL_SRC_FILES := GLDecoder.cpp
$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS))
+$(call emugl-export,LDLIBS,-lstdc++)
$(call emugl-end-module)
### host library, 64-bit ####################################
-$(call emugl-begin-host-static-library,lib64GLESv1_dec)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64GLESv1_dec)
-$(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ $(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-$(call emugl-gen-decoder,$(LOCAL_PATH),gl)
+ $(call emugl-gen-decoder,$(LOCAL_PATH),gl)
-LOCAL_SRC_FILES := GLDecoder.cpp
+ LOCAL_SRC_FILES := GLDecoder.cpp
-$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS) -m64)
+ $(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS) -m64)
+ $(call emugl-export,LDLIBS,-lstdc++)
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp b/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp
index 5399445..3c5bd70 100644
--- a/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp
+++ b/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp
@@ -21,6 +21,10 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
+static inline void* SafePointerFromUInt(GLuint value) {
+ return (void*)(uintptr_t)value;
+}
+
GLDecoder::GLDecoder()
{
m_contextData = NULL;
@@ -88,43 +92,43 @@ int GLDecoder::s_glFinishRoundTrip(void *self)
void GLDecoder::s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glVertexPointer(size, type, stride, (void *)offset);
+ ctx->glVertexPointer(size, type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glColorPointer(size, type, stride, (void *)offset);
+ ctx->glColorPointer(size, type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glTexCoordPointer(size, type, stride, (void *) offset);
+ ctx->glTexCoordPointer(size, type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glNormalPointer(type, stride, (void *)offset);
+ ctx->glNormalPointer(type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glPointSizePointerOES(type, stride, (void *)offset);
+ ctx->glPointSizePointerOES(type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glWeightPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glWeightPointerOES(size, type, stride, (void*)offset);
+ ctx->glWeightPointerOES(size, type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glMatrixIndexPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glMatrixIndexPointerOES(size, type, stride, (void*)offset);
+ ctx->glMatrixIndexPointerOES(size, type, stride, SafePointerFromUInt(offset));
}
@@ -204,7 +208,7 @@ void GLDecoder::s_glMatrixIndexPointerData(void * self, GLint size, GLenum type,
void GLDecoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glDrawElements(mode, count, type, (void *)offset);
+ ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset));
}
void GLDecoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen)
diff --git a/emulator/opengl/host/libs/GLESv2_dec/Android.mk b/emulator/opengl/host/libs/GLESv2_dec/Android.mk
index 7a034ec..bc04c25 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/Android.mk
+++ b/emulator/opengl/host/libs/GLESv2_dec/Android.mk
@@ -22,15 +22,17 @@ LOCAL_SRC_FILES := GL2Decoder.cpp
$(call emugl-end-module)
### host library, 64-bit ####################################
-$(call emugl-begin-host-static-library,lib64GLESv2_dec)
-$(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
-$(call emugl-gen-decoder,$(LOCAL_PATH),gl2)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64GLESv2_dec)
+ $(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
+ $(call emugl-gen-decoder,$(LOCAL_PATH),gl2)
-# For gl2_types.h !
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ # For gl2_types.h !
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS) -m64)
+ $(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS) -m64)
-LOCAL_SRC_FILES := GL2Decoder.cpp
+ LOCAL_SRC_FILES := GL2Decoder.cpp
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp b/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
index a777c50..ccf2f06 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
+++ b/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
@@ -19,6 +19,9 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
+static inline void* SafePointerFromUInt(GLuint value) {
+ return (void*)(uintptr_t)value;
+}
GL2Decoder::GL2Decoder()
{
@@ -115,7 +118,7 @@ void GL2Decoder::s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint si
GLboolean normalized, GLsizei stride, GLuint data)
{
GL2Decoder *ctx = (GL2Decoder *) self;
- ctx->glVertexAttribPointer(indx, size, type, normalized, stride, (GLvoid *)data);
+ ctx->glVertexAttribPointer(indx, size, type, normalized, stride, SafePointerFromUInt(data));
}
@@ -129,7 +132,7 @@ void GL2Decoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GL
void GL2Decoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset)
{
GL2Decoder *ctx = (GL2Decoder *)self;
- ctx->glDrawElements(mode, count, type, (void *)offset);
+ ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset));
}
void GL2Decoder::s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len)
diff --git a/emulator/opengl/host/libs/Translator/EGL/Android.mk b/emulator/opengl/host/libs/Translator/EGL/Android.mk
index f1a6d3a..5d1c9b2 100644
--- a/emulator/opengl/host/libs/Translator/EGL/Android.mk
+++ b/emulator/opengl/host/libs/Translator/EGL/Android.mk
@@ -47,11 +47,12 @@ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
$(call emugl-end-module)
### EGL host implementation, 64-bit ########################
-$(call emugl-begin-host-shared-library,lib64EGL_translator)
-$(call emugl-import,lib64GLcommon)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-shared-library,lib64EGL_translator)
+ $(call emugl-import,lib64GLcommon)
-LOCAL_LDLIBS += $(host_common_LDLIBS) -m64
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-
-$(call emugl-end-module)
+ LOCAL_LDLIBS += $(host_common_LDLIBS) -m64
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ $(call emugl-end-module)
+endif
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglContext.h b/emulator/opengl/host/libs/Translator/EGL/EglContext.h
index e4917c6..d8eb05e 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglContext.h
+++ b/emulator/opengl/host/libs/Translator/EGL/EglContext.h
@@ -19,10 +19,10 @@
#include <map>
#include <EGL/egl.h>
#include <GLcommon/GLutils.h>
-#include <GLcommon/SmartPtr.h>
#include <GLcommon/TranslatorIfaces.h>
#include <GLcommon/objectNameManager.h>
+#include "emugl/common/smart_ptr.h"
#include "EglConfig.h"
#include "EglSurface.h"
@@ -30,7 +30,7 @@
class EglContext;
-typedef SmartPtr<EglContext> ContextPtr;
+typedef emugl::SmartPtr<EglContext> ContextPtr;
class EglDisplay;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
index 99f9d8b..24b9a0d 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
@@ -16,7 +16,6 @@
#include "EglDisplay.h"
#include "EglOsApi.h"
#include <GLcommon/GLutils.h>
-#include <utils/threads.h>
EglDisplay::EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault) :
m_dpy(dpy),
@@ -31,7 +30,7 @@ EglDisplay::EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault) :
};
EglDisplay::~EglDisplay() {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
//
// Destroy the global context if one was created.
@@ -59,7 +58,7 @@ EglDisplay::~EglDisplay() {
EGLNativeInternalDisplayType EglDisplay::nativeType(){return m_dpy;}
void EglDisplay::initialize(int renderableType) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_initialized = true;
initConfigurations(renderableType);
m_configInitialized = true;
@@ -68,7 +67,7 @@ void EglDisplay::initialize(int renderableType) {
bool EglDisplay::isInitialize() { return m_initialized;}
void EglDisplay::terminate(){
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_contexts.clear();
m_surfaces.clear();
m_initialized = false;
@@ -128,7 +127,7 @@ void EglDisplay::initConfigurations(int renderableType) {
}
EglConfig* EglDisplay::getConfig(EGLConfig conf) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() ;it++) {
if(static_cast<EGLConfig>(*it) == conf) {
@@ -140,9 +139,9 @@ EglConfig* EglDisplay::getConfig(EGLConfig conf) {
}
SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* surface is "key" in map<unsigned int, SurfacePtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)surface);
+ unsigned int hndl = SafeUIntFromPointer(surface);
SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
return it != m_surfaces.end() ?
(*it).second :
@@ -150,9 +149,9 @@ SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
}
ContextPtr EglDisplay::getContext(EGLContext ctx) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* ctx is "key" in map<unsigned int, ContextPtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)ctx);
+ unsigned int hndl = SafeUIntFromPointer(ctx);
ContextsHndlMap::iterator it = m_contexts.find(hndl);
return it != m_contexts.end() ?
(*it).second :
@@ -160,9 +159,9 @@ ContextPtr EglDisplay::getContext(EGLContext ctx) {
}
bool EglDisplay::removeSurface(EGLSurface s) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* s is "key" in map<unsigned int, SurfacePtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)s);
+ unsigned int hndl = SafeUIntFromPointer(s);
SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
if(it != m_surfaces.end()) {
m_surfaces.erase(it);
@@ -172,7 +171,7 @@ bool EglDisplay::removeSurface(EGLSurface s) {
}
bool EglDisplay::removeSurface(SurfacePtr s) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
SurfacesHndlMap::iterator it;
for(it = m_surfaces.begin(); it!= m_surfaces.end();it++)
@@ -189,9 +188,9 @@ bool EglDisplay::removeSurface(SurfacePtr s) {
}
bool EglDisplay::removeContext(EGLContext ctx) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* ctx is "key" in map<unsigned int, ContextPtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)ctx);
+ unsigned int hndl = SafeUIntFromPointer(ctx);
ContextsHndlMap::iterator it = m_contexts.find(hndl);
if(it != m_contexts.end()) {
m_contexts.erase(it);
@@ -201,7 +200,7 @@ bool EglDisplay::removeContext(EGLContext ctx) {
}
bool EglDisplay::removeContext(ContextPtr ctx) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ContextsHndlMap::iterator it;
for(it = m_contexts.begin(); it != m_contexts.end();it++) {
@@ -217,7 +216,7 @@ bool EglDisplay::removeContext(ContextPtr ctx) {
}
EglConfig* EglDisplay::getConfig(EGLint id) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() ;it++) {
if((*it)->id() == id) {
@@ -229,7 +228,7 @@ EglConfig* EglDisplay::getConfig(EGLint id) {
}
int EglDisplay::getConfigs(EGLConfig* configs,int config_size) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
int i = 0;
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && i < config_size ;i++,it++) {
configs[i] = static_cast<EGLConfig>(*it);
@@ -238,7 +237,7 @@ int EglDisplay::getConfigs(EGLConfig* configs,int config_size) {
}
int EglDisplay::chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
return doChooseConfigs(dummy, configs, config_size);
}
@@ -258,7 +257,7 @@ int EglDisplay::doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int co
}
EGLSurface EglDisplay::addSurface(SurfacePtr s ) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
unsigned int hndl = s.Ptr()->getHndl();
EGLSurface ret =reinterpret_cast<EGLSurface> (hndl);
@@ -271,7 +270,7 @@ EGLSurface EglDisplay::addSurface(SurfacePtr s ) {
}
EGLContext EglDisplay::addContext(ContextPtr ctx ) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
unsigned int hndl = ctx.Ptr()->getHndl();
EGLContext ret = reinterpret_cast<EGLContext> (hndl);
@@ -285,7 +284,7 @@ EGLContext EglDisplay::addContext(ContextPtr ctx ) {
EGLImageKHR EglDisplay::addImageKHR(ImagePtr img) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
do { ++m_nextEglImageId; } while(m_nextEglImageId == 0);
img->imageId = m_nextEglImageId;
m_eglImages[m_nextEglImageId] = img;
@@ -293,17 +292,17 @@ EGLImageKHR EglDisplay::addImageKHR(ImagePtr img) {
}
ImagePtr EglDisplay::getImage(EGLImageKHR img) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* img is "key" in map<unsigned int, ImagePtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)img);
+ unsigned int hndl = SafeUIntFromPointer(img);
ImagesHndlMap::iterator i( m_eglImages.find(hndl) );
return (i != m_eglImages.end()) ? (*i).second :ImagePtr(NULL);
}
bool EglDisplay:: destroyImageKHR(EGLImageKHR img) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* img is "key" in map<unsigned int, ImagePtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)img);
+ unsigned int hndl = SafeUIntFromPointer(img);
ImagesHndlMap::iterator i( m_eglImages.find(hndl) );
if (i != m_eglImages.end())
{
@@ -314,7 +313,7 @@ bool EglDisplay:: destroyImageKHR(EGLImageKHR img) {
}
EGLNativeContextType EglDisplay::getGlobalSharedContext(){
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
#ifndef _WIN32
// find an existing OpenGL context to share with, if exist
EGLNativeContextType ret =
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h
index 587e92a..47a2598 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h
+++ b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h
@@ -20,8 +20,8 @@
#include <map>
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <utils/threads.h>
-#include <GLcommon/SmartPtr.h>
+#include "emugl/common/mutex.h"
+#include "emugl/common/smart_ptr.h"
#include "EglConfig.h"
#include "EglContext.h"
@@ -30,6 +30,7 @@
+
typedef std::list<EglConfig*> ConfigsList;
typedef std::map< unsigned int, ContextPtr> ContextsHndlMap;
typedef std::map< unsigned int, SurfacePtr> SurfacesHndlMap;
@@ -81,7 +82,7 @@ private:
SurfacesHndlMap m_surfaces;
GlobalNameSpace m_globalNameSpace;
ObjectNameManager *m_manager[MAX_GLES_VERSION];
- android::Mutex m_lock;
+ emugl::Mutex m_lock;
ImagesHndlMap m_eglImages;
unsigned int m_nextEglImageId;
EGLNativeContextType m_globalSharedContext;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp
index 8e5b462..95b696e 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp
@@ -51,7 +51,7 @@ void EglGlobalInfo::delInstance() {
EglDisplay* EglGlobalInfo::addDisplay(EGLNativeDisplayType dpy,EGLNativeInternalDisplayType idpy) {
//search if it is not already exists
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(DisplaysMap::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if((*it).second == dpy) return (*it).first;
}
@@ -68,7 +68,7 @@ EglDisplay* EglGlobalInfo::addDisplay(EGLNativeDisplayType dpy,EGLNativeInternal
}
bool EglGlobalInfo::removeDisplay(EGLDisplay dpy) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(DisplaysMap::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if(static_cast<EGLDisplay>((*it).first) == dpy) {
delete (*it).first;
@@ -80,7 +80,7 @@ bool EglGlobalInfo::removeDisplay(EGLDisplay dpy) {
}
EglDisplay* EglGlobalInfo::getDisplay(EGLNativeDisplayType dpy) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(DisplaysMap::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if((*it).second == dpy) return (*it).first;
}
@@ -88,7 +88,7 @@ EglDisplay* EglGlobalInfo::getDisplay(EGLNativeDisplayType dpy) {
}
EglDisplay* EglGlobalInfo::getDisplay(EGLDisplay dpy) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
DisplaysMap::iterator it = m_displays.find(static_cast<EglDisplay*>(dpy));
return (it != m_displays.end() ? (*it).first : NULL);
}
@@ -99,7 +99,7 @@ EGLNativeInternalDisplayType EglGlobalInfo::generateInternalDisplay(EGLNativeDis
void EglGlobalInfo::initClientExtFuncTable(GLESVersion ver)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
if (!m_gles_extFuncs_inited[ver]) {
ClientAPIExts::initClientFuncs(m_gles_ifaces[ver], (int)ver - 1);
m_gles_extFuncs_inited[ver] = true;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h
index ec07ffe..f56b79e 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h
+++ b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h
@@ -16,14 +16,15 @@
#ifndef EGL_GLOBAL_INFO
#define EGL_GLOBAL_INFO
-#include <list>
-#include <EGL/egl.h>
-#include <utils/threads.h>
-#include <GLcommon/TranslatorIfaces.h>
#include "EglDisplay.h"
#include "EglConfig.h"
#include "EglContext.h"
+#include <GLcommon/TranslatorIfaces.h>
+#include "emugl/common/mutex.h"
+#include <list>
+#include <EGL/egl.h>
+
typedef std::map<EglDisplay*,EGLNativeDisplayType>DisplaysMap;
@@ -58,7 +59,7 @@ private:
EGLNativeInternalDisplayType m_default;
GLESiface* m_gles_ifaces[MAX_GLES_VERSION];
bool m_gles_extFuncs_inited[MAX_GLES_VERSION];
- android::Mutex m_lock;
+ emugl::Mutex m_lock;
};
#endif
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
index d03c9db..06dcf67 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
@@ -50,11 +50,11 @@ GLEScontext* getGLESContext();
#define tls_thread EglThreadInfo::get()
EglGlobalInfo* g_eglInfo = NULL;
-android::Mutex s_eglLock;
+emugl::Mutex s_eglLock;
void initGlobalInfo()
{
- android::Mutex::Autolock mutex(s_eglLock);
+ emugl::Mutex::AutoLock mutex(s_eglLock);
if (!g_eglInfo) {
g_eglInfo = EglGlobalInfo::getInstance();
}
@@ -72,8 +72,8 @@ static EGLiface s_eglIface = {
#define EGL_EXTENTIONS 2
//decleration
-EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
-EGLBoolean eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image);
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image);
// extentions descriptors
static ExtentionDescriptor s_eglExtentions[] = {
@@ -273,28 +273,31 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
}
//selection defaults
+ // NOTE: Some variables below are commented out to reduce compiler warnings.
+ // TODO(digit): Look if these variables are really needed or not, and if so
+ // fix the code to do it properly.
EGLint surface_type = EGL_WINDOW_BIT;
EGLint renderable_type = EGL_OPENGL_ES_BIT;
- EGLBoolean bind_to_tex_rgb = EGL_DONT_CARE;
- EGLBoolean bind_to_tex_rgba = EGL_DONT_CARE;
+ //EGLBoolean bind_to_tex_rgb = EGL_DONT_CARE;
+ //EGLBoolean bind_to_tex_rgba = EGL_DONT_CARE;
EGLenum caveat = EGL_DONT_CARE;
EGLint config_id = EGL_DONT_CARE;
EGLBoolean native_renderable = EGL_DONT_CARE;
EGLint native_visual_type = EGL_DONT_CARE;
- EGLint max_swap_interval = EGL_DONT_CARE;
- EGLint min_swap_interval = EGL_DONT_CARE;
+ //EGLint max_swap_interval = EGL_DONT_CARE;
+ //EGLint min_swap_interval = EGL_DONT_CARE;
EGLint trans_red_val = EGL_DONT_CARE;
EGLint trans_green_val = EGL_DONT_CARE;
EGLint trans_blue_val = EGL_DONT_CARE;
EGLenum transparent_type = EGL_NONE;
- EGLint buffer_size = 0;
+ //EGLint buffer_size = 0;
EGLint red_size = 0;
EGLint green_size = 0;
EGLint blue_size = 0;
EGLint alpha_size = 0;
EGLint depth_size = 0;
EGLint frame_buffer_level = 0;
- EGLint sample_buffers_num = 0;
+ //EGLint sample_buffers_num = 0;
EGLint samples_per_pixel = 0;
EGLint stencil_size = 0;
@@ -318,7 +321,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
- buffer_size = attrib_list[i+1];
+ //buffer_size = attrib_list[i+1];
break;
case EGL_RED_SIZE:
if(attrib_list[i+1] < 0) {
@@ -345,10 +348,10 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
alpha_size = attrib_list[i+1];
break;
case EGL_BIND_TO_TEXTURE_RGB:
- bind_to_tex_rgb = attrib_list[i+1];
+ //bind_to_tex_rgb = attrib_list[i+1];
break;
case EGL_BIND_TO_TEXTURE_RGBA:
- bind_to_tex_rgba = attrib_list[i+1];
+ //bind_to_tex_rgba = attrib_list[i+1];
break;
case EGL_CONFIG_CAVEAT:
if(attrib_list[i+1] != EGL_NONE && attrib_list[i+1] != EGL_SLOW_CONFIG && attrib_list[i+1] != EGL_NON_CONFORMANT_CONFIG) {
@@ -373,13 +376,13 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
- max_swap_interval = attrib_list[i+1];
+ //max_swap_interval = attrib_list[i+1];
break;
case EGL_MIN_SWAP_INTERVAL:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
- min_swap_interval = attrib_list[i+1];
+ //min_swap_interval = attrib_list[i+1];
break;
case EGL_NATIVE_RENDERABLE:
native_renderable = attrib_list[i+1];
@@ -394,7 +397,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
case EGL_SAMPLE_BUFFERS:
- sample_buffers_num = attrib_list[i+1];
+ //sample_buffers_num = attrib_list[i+1];
break;
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
@@ -635,13 +638,11 @@ EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay display, EGLConfig con
}
ContextPtr sharedCtxPtr;
- EGLNativeContextType nativeShared = NULL;
if(share_context != EGL_NO_CONTEXT) {
sharedCtxPtr = dpy->getContext(share_context);
if(!sharedCtxPtr.Ptr()) {
RETURN_ERROR(EGL_NO_CONTEXT,EGL_BAD_CONTEXT);
}
- nativeShared = sharedCtxPtr->nativeType();
}
EGLNativeContextType globalSharedContext = dpy->getGlobalSharedContext();
@@ -815,7 +816,7 @@ EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void) {
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();
+ EGLContext c = (EGLContext)SafePointerFromUInt(ctx->getHndl());
if(dpy->getContext(c).Ptr())
{
return c;
@@ -839,7 +840,7 @@ EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) {
// current after it is destroyed - in which case its handle should
// be invalid, that is EGL_NO_SURFACE should be returned even
// though the surface is current.
- EGLSurface s = (EGLSurface)surface->getHndl();
+ EGLSurface s = (EGLSurface)SafePointerFromUInt(surface->getHndl());
surface = dpy->getSurface(s);
if(surface.Ptr())
{
@@ -858,7 +859,9 @@ EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) {
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void) {
EGLenum api = eglQueryAPI();
eglBindAPI(EGL_OPENGL_ES_API);
- return eglWaitClient();
+ EGLBoolean ret = eglWaitClient();
+ eglBindAPI(api);
+ return ret;
}
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) {
@@ -1012,7 +1015,6 @@ EglImage *attachEGLImage(unsigned int imageId)
void detachEGLImage(unsigned int imageId)
{
ThreadInfo* thread = getThreadInfo();
- EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
ContextPtr ctx = thread->eglContext;
if (ctx.Ptr()) {
ctx->detachImage(imageId);
@@ -1020,7 +1022,7 @@ void detachEGLImage(unsigned int imageId)
}
-EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
{
VALIDATE_DISPLAY(display);
VALIDATE_CONTEXT(context);
@@ -1033,13 +1035,13 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum ta
ThreadInfo* thread = getThreadInfo();
ShareGroupPtr sg = thread->shareGroup;
if (sg.Ptr() != NULL) {
- unsigned int globalTexName = sg->getGlobalName(TEXTURE, (uintptr_t)buffer);
+ unsigned int globalTexName = sg->getGlobalName(TEXTURE, SafeUIntFromPointer(buffer));
if (!globalTexName) return EGL_NO_IMAGE_KHR;
ImagePtr img( new EglImage() );
if (img.Ptr() != NULL) {
- ObjectDataPtr objData = sg->getObjectData(TEXTURE, (uintptr_t)buffer);
+ ObjectDataPtr objData = sg->getObjectData(TEXTURE, SafeUIntFromPointer(buffer));
if (!objData.Ptr()) return EGL_NO_IMAGE_KHR;
TextureData *texData = (TextureData *)objData.Ptr();
@@ -1057,7 +1059,7 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum ta
}
-EGLBoolean eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image)
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image)
{
VALIDATE_DISPLAY(display);
return dpy->destroyImageKHR(image) ? EGL_TRUE:EGL_FALSE;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglSurface.h b/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
index d65f480..ba28ae8 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
+++ b/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
@@ -16,14 +16,15 @@
#ifndef EGL_SURFACE_H
#define EGL_SURFACE_H
+#include <map>
+
#include <EGL/egl.h>
#include <EGL/eglinternalplatform.h>
-#include <map>
-#include <GLcommon/SmartPtr.h>
+#include "emugl/common/smart_ptr.h"
#include "EglConfig.h"
class EglSurface;
-typedef SmartPtr<EglSurface> SurfacePtr;
+typedef emugl::SmartPtr<EglSurface> SurfacePtr;
class EglDisplay;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp
index 1b403f2..6481774 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp
@@ -16,26 +16,33 @@
#include "EglThreadInfo.h"
#include "EglOsApi.h"
-EglThreadInfo::EglThreadInfo():m_err(EGL_SUCCESS),m_api(EGL_OPENGL_ES_API) {}
+#include "emugl/common/lazy_instance.h"
+#include "emugl/common/thread_store.h"
-#include <cutils/threads.h>
+namespace {
-static thread_store_t s_tls = THREAD_STORE_INITIALIZER;
-
-static void tlsDestruct(void *ptr)
-{
- if (ptr) {
- EglThreadInfo *ti = (EglThreadInfo *)ptr;
- delete ti;
+class EglThreadInfoStore : public emugl::ThreadStore {
+public:
+ EglThreadInfoStore() : emugl::ThreadStore(&destructor) {}
+private:
+ static void destructor(void* value) {
+ delete static_cast<EglThreadInfo*>(value);
}
-}
+};
+
+} // namespace
+
+EglThreadInfo::EglThreadInfo() :
+ m_err(EGL_SUCCESS), m_api(EGL_OPENGL_ES_API) {}
+
+static emugl::LazyInstance<EglThreadInfoStore> s_tls = LAZY_INSTANCE_INIT;
EglThreadInfo* EglThreadInfo::get(void)
{
- EglThreadInfo *ti = (EglThreadInfo *)thread_store_get(&s_tls);
+ EglThreadInfo *ti = static_cast<EglThreadInfo*>(s_tls->get());
if (!ti) {
ti = new EglThreadInfo();
- thread_store_set(&s_tls, ti, tlsDestruct);
+ s_tls->set(ti);
}
return ti;
}
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp b/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
index 460c0b6..5b48fcb 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
@@ -20,8 +20,7 @@
#include <stdio.h>
#define IS_TRUE(a) \
- if(a != true) return false;
-
+ if(a != true) return NULL;
struct DisplayInfo{
DisplayInfo():dc(NULL),hwnd(NULL),isPixelFormatSet(false){};
@@ -48,9 +47,7 @@ static TlsData *getTLS() {
class WinDisplay{
public:
- typedef enum {
- DEFAULT_DISPLAY = 0
- };
+ enum { DEFAULT_DISPLAY = 0 };
WinDisplay(){};
DisplayInfo& getInfo(int configurationIndex){ return getTLS()->m_map[configurationIndex];}
HDC getDC(int configId){return getTLS()->m_map[configId].dc;}
@@ -193,7 +190,8 @@ HWND createDummyWindow(){
wcx.lpszClassName = "DummyWin"; // name of window class
wcx.hIconSm = (HICON) NULL; // small class icon
- ATOM winClass = RegisterClassEx(&wcx);
+ RegisterClassEx(&wcx);
+
HWND hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,
"DummyWin",
"Dummy",
@@ -340,7 +338,7 @@ EglConfig* pixelFormatToConfig(EGLNativeInternalDisplayType display,int renderab
EGLint transparentType,samples;
EGLint tRed,tGreen,tBlue;
EGLint pMaxWidth,pMaxHeight,pMaxPixels;
- EGLint configId,level;
+ EGLint level;
EGLint window,bitmap,pbuffer,transparent;
HDC dpy = getDummyDC(display,WinDisplay::DEFAULT_DISPLAY);
@@ -416,10 +414,10 @@ void queryConfigs(EGLNativeInternalDisplayType display,int renderableType,Config
initPixelFormat(dpy);
//quering num of formats
- int nFormats = DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ int maxFormat = DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
//inserting rest of formats
- for(iPixelFormat;iPixelFormat < nFormats; iPixelFormat++) {
+ for(;iPixelFormat <= maxFormat; iPixelFormat++) {
DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
EglConfig* pConfig = pixelFormatToConfig(display,renderableType,&pfd,iPixelFormat);
if(pConfig) listOut.push_back(pConfig);
@@ -497,7 +495,7 @@ EGLNativeSurfaceType createPbufferSurface(EGLNativeInternalDisplayType display,E
if(!s_wglExtProcs->wglCreatePbufferARB) return NULL;
EGLNativePbufferType pb = s_wglExtProcs->wglCreatePbufferARB(dpy,cfg->nativeId(),width,height,pbAttribs);
if(!pb) {
- DWORD err = GetLastError();
+ GetLastError();
return NULL;
}
return new SrfcInfo(pb);
@@ -507,7 +505,7 @@ bool releasePbuffer(EGLNativeInternalDisplayType display,EGLNativeSurfaceType pb
if (!pb) return false;
if(!s_wglExtProcs->wglReleasePbufferDCARB || !s_wglExtProcs->wglDestroyPbufferARB) return false;
if(!s_wglExtProcs->wglReleasePbufferDCARB(pb->getPbuffer(),pb->getDC()) || !s_wglExtProcs->wglDestroyPbufferARB(pb->getPbuffer())){
- DWORD err = GetLastError();
+ GetLastError();
return false;
}
return true;
@@ -539,7 +537,7 @@ EGLNativeContextType createContext(EGLNativeInternalDisplayType display,EglConfi
bool destroyContext(EGLNativeInternalDisplayType dpy,EGLNativeContextType ctx) {
if(!wglDeleteContext(ctx)) {
- DWORD err = GetLastError();
+ GetLastError();
return false;
}
return true;
@@ -566,7 +564,7 @@ bool makeCurrent(EGLNativeInternalDisplayType display,EglSurface* read,EglSurfac
void swapBuffers(EGLNativeInternalDisplayType display,EGLNativeSurfaceType srfc){
if(srfc && !SwapBuffers(srfc->getDC())) {
- DWORD err = GetLastError();
+ GetLastError();
}
}
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp b/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
index 129f244..41cf8c4 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
@@ -14,10 +14,11 @@
* limitations under the License.
*/
#include "EglOsApi.h"
+#include "emugl/common/mutex.h"
+
#include <string.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
-#include <utils/threads.h>
class ErrorHandler{
@@ -29,7 +30,7 @@ int getLastError(){ return s_lastErrorCode;};
private:
static int s_lastErrorCode;
int (*m_oldErrorHandler) (Display *, XErrorEvent *);
-static android::Mutex s_lock;
+static emugl::Mutex s_lock;
static int errorHandlerProc(EGLNativeDisplayType dpy,XErrorEvent* event);
};
@@ -50,17 +51,17 @@ private:
};
int ErrorHandler::s_lastErrorCode = 0;
-android::Mutex ErrorHandler::s_lock;
+emugl::Mutex ErrorHandler::s_lock;
ErrorHandler::ErrorHandler(EGLNativeDisplayType dpy){
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
XSync(dpy,False);
s_lastErrorCode = 0;
m_oldErrorHandler = XSetErrorHandler(errorHandlerProc);
}
ErrorHandler::~ErrorHandler(){
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
XSetErrorHandler(m_oldErrorHandler);
s_lastErrorCode = 0;
}
@@ -71,7 +72,7 @@ int ErrorHandler::errorHandlerProc(EGLNativeDisplayType dpy,XErrorEvent* event){
}
#define IS_SUCCESS(a) \
- if(a != Success) return false;
+ if(a != Success) return 0;
namespace EglOS {
@@ -193,7 +194,7 @@ bool validNativePixmap(EGLNativeDisplayType dpy,EGLNativeSurfaceType pix) {
int tmp;
unsigned int utmp;
ErrorHandler handler(dpy);
- if(!XGetGeometry(dpy,pix ? pix->srfc() : NULL,&root,&tmp,&tmp,&utmp,&utmp,&utmp,&utmp)) return false;
+ if(!XGetGeometry(dpy,pix ? pix->srfc() : 0,&root,&tmp,&tmp,&utmp,&utmp,&utmp,&utmp)) return false;
return handler.getLastError() == 0;
}
@@ -260,7 +261,7 @@ bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLN
bool retval = false;
if (!ctx && !read && !draw) {
// unbind
- retval = glXMakeContextCurrent(dpy, NULL, NULL, NULL);
+ retval = glXMakeContextCurrent(dpy, 0, 0, NULL);
}
else if (ctx && read && draw) {
retval = glXMakeContextCurrent(dpy,draw->native()->srfc(),read->native()->srfc(),ctx);
diff --git a/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
index 4f5d75f..1571b3a 100644
--- a/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
@@ -14,16 +14,47 @@
* limitations under the License.
*/
-#include <stdio.h>
#include "ThreadInfo.h"
-//#define TRACE_THREADINFO
-#ifdef TRACE_THREADINFO
+#include "emugl/common/lazy_instance.h"
+#include "emugl/common/thread_store.h"
+
+#include <stdio.h>
+
+// Set TRACE_THREADINFO to 1 to debug creation/destruction of ThreadInfo
+// instances.
+#define TRACE_THREADINFO 0
+
+#if TRACE_THREADINFO
#define LOG_THREADINFO(x...) fprintf(stderr, x)
#else
#define LOG_THREADINFO(x...)
#endif
+namespace {
+
+class ThreadInfoStore : public ::emugl::ThreadStore {
+public:
+ ThreadInfoStore() : ::emugl::ThreadStore(&destructor) {}
+
+ size_t getInstanceCount() const { return mNumInstances; }
+
+private:
+ static void destructor(void* value) {
+ LOG_THREADINFO("%s: EFL %p (%d instances)\n", __FUNCTION__,
+ value, mNumInstances);
+ delete static_cast<ThreadInfo*>(value);
+ mNumInstances--;
+ }
+
+ static size_t mNumInstances;
+};
+
+size_t ThreadInfoStore::mNumInstances = 0;
+
+} // namespace
+
+
void ThreadInfo::updateInfo(ContextPtr eglCtx,
EglDisplay* dpy,
GLEScontext* glesCtx,
@@ -37,27 +68,16 @@ void ThreadInfo::updateInfo(ContextPtr eglCtx,
objManager = manager;
}
-#include <cutils/threads.h>
-static thread_store_t s_tls = THREAD_STORE_INITIALIZER;
-static int active_instance = 0;
-static void tlsDestruct(void *ptr)
-{
- active_instance--;
- LOG_THREADINFO("tlsDestruct EGL %lx %d\n", (long)ptr, active_instance);
- if (ptr) {
- ThreadInfo *ti = (ThreadInfo *)ptr;
- delete ti;
- }
-}
+static ::emugl::LazyInstance<ThreadInfoStore> s_tls = LAZY_INSTANCE_INIT;
ThreadInfo *getThreadInfo()
{
- ThreadInfo *ti = (ThreadInfo *)thread_store_get(&s_tls);
+ ThreadInfo *ti = static_cast<ThreadInfo*>(s_tls->get());
if (!ti) {
ti = new ThreadInfo();
- thread_store_set(&s_tls, ti, tlsDestruct);
- active_instance++;
- LOG_THREADINFO("getThreadInfo EGL %lx %d\n", (long)ti, active_instance);
+ s_tls->set(ti);
+ LOG_THREADINFO("%s: EGL %p (%d instances)\n", __FUNCTION__,
+ ti, (int)ThreadInfoStore::getInstanceCount());
}
return ti;
}
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk b/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk
index 9aa74a7..c5e7e6d 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk
@@ -18,11 +18,14 @@ $(call emugl-end-module)
### GLES_CM host implementation, 64-bit ########################
-$(call emugl-begin-host-shared-library,lib64GLES_CM_translator)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-shared-library,lib64GLES_CM_translator)
-$(call emugl-import,lib64GLcommon)
+ $(call emugl-import,lib64GLcommon)
-LOCAL_LDLIBS += -m64
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ LOCAL_CFLAGS += -fPIC
+ LOCAL_LDLIBS += -m64
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp
index af5c0d8..66adefb 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp
@@ -51,7 +51,7 @@ GLDispatch::GLDispatch():m_isLoaded(false){};
void GLDispatch::dispatchFuncs() {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
if(m_isLoaded)
return;
LOAD_GL_FUNC(glActiveTexture);
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h
index 9dc320f..ae8c9f8 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h
@@ -17,7 +17,7 @@
#define GLDISPATCHH
#include <GLES/gl.h>
-#include <utils/threads.h>
+#include "emugl/common/mutex.h"
#define GLAPIENTRY GL_APIENTRY
@@ -151,8 +151,8 @@ public:
void (GLAPIENTRY *glVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void (GLAPIENTRY *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
private:
- bool m_isLoaded;
- android::Mutex m_lock;
+ bool m_isLoaded;
+ emugl::Mutex m_lock;
};
#endif
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
index ecf51bb..6476c02 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
@@ -23,7 +23,7 @@
#include <GLES/glext.h>
void GLEScmContext::init() {
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
if(!m_initialized) {
s_glDispatch.dispatchFuncs(GLES_1_1);
GLEScontext::init();
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
index 1785877..fbb7023 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
@@ -23,7 +23,6 @@
#include <map>
#include <vector>
#include <string>
-#include <utils/threads.h>
typedef std::map<GLfloat,std::vector<int> > PointSizeIndices;
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
index 3ae271f..dd74750 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -582,7 +582,7 @@ GL_API void GL_APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type
GLESConversionArrays tmpArrs;
if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo
const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER));
- indices = buf+reinterpret_cast<uintptr_t>(elementsIndices);
+ indices = buf + SafeUIntFromPointer(elementsIndices);
}
ctx->setupArraysPointers(tmpArrs,0,count,type,indices,false);
@@ -699,8 +699,6 @@ GL_API void GL_APIENTRY glGetBooleanv( GLenum pname, GLboolean *params) {
return;
}
- GLint i;
-
switch(pname)
{
case GL_FRAMEBUFFER_BINDING_OES:
@@ -745,7 +743,6 @@ GL_API void GL_APIENTRY glGetBufferParameteriv( GLenum target, GLenum pname, GL
GET_CTX()
SET_ERROR_IF(!(GLEScmValidate::bufferTarget(target) && GLEScmValidate::bufferParam(pname)),GL_INVALID_ENUM);
SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
- bool ret = true;
switch(pname) {
case GL_BUFFER_SIZE:
ctx->getBufferSize(target,params);
@@ -787,7 +784,6 @@ GL_API void GL_APIENTRY glGetFixedv( GLenum pname, GLfixed *params) {
size_t nParams = glParamSize(pname);
GLfloat fParams[16];
- GLint i;
switch(pname)
{
@@ -994,9 +990,9 @@ GL_API void GL_APIENTRY glGetPointerv( GLenum pname, void **params) {
if(p) {
if(p->isVBO())
{
- *params = (void*)(p->getBufferOffset());
+ *params = SafePointerFromUInt(p->getBufferOffset());
}else{
- *params = const_cast<void *>( p->getArrayData());
+ *params = const_cast<void *>(p->getArrayData());
}
} else {
ctx->setGLerror(GL_INVALID_ENUM);
@@ -1652,7 +1648,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
{
GET_CTX();
SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM);
- unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
+ unsigned int imagehndl = SafeUIntFromPointer(image);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
if (img) {
// Create the texture object in the underlying EGL implementation,
@@ -1688,7 +1684,7 @@ GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GL
{
GET_CTX();
SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
- unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
+ unsigned int imagehndl = SafeUIntFromPointer(image);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
SET_ERROR_IF(!img,GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
@@ -2231,13 +2227,15 @@ void glDrawTexOES (T x, T y, T z, T width, T height) {
int numClipPlanes;
- GLint viewport[4];
+ GLint viewport[4] = {};
z = (z>1 ? 1 : (z<0 ? 0 : z));
- T vertices[4*3] = {x , y, z,
- x , y+height, z,
- x+width, y+height, z,
- x+width, y, z};
+ T vertices[4*3] = {
+ x , y, z,
+ x , static_cast<T>(y+height), z,
+ static_cast<T>(x+width), static_cast<T>(y+height), z,
+ static_cast<T>(x+width), y, z
+ };
GLfloat texels[ctx->getMaxTexUnits()][4*2];
memset((void*)texels, 0, ctx->getMaxTexUnits()*4*2*sizeof(GLfloat));
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk b/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk
index f4845f7..438334a 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk
@@ -18,10 +18,12 @@ $(call emugl-end-module)
### GLES_V2 host implementation, 64-bit ##############################
-$(call emugl-begin-host-shared-library,lib64GLES_V2_translator)
-$(call emugl-import, lib64GLcommon)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-shared-library,lib64GLES_V2_translator)
+ $(call emugl-import, lib64GLcommon)
-LOCAL_LDLIBS += -m64
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ LOCAL_LDLIBS += -m64
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
index 1457cec..f8f674b 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
@@ -15,11 +15,10 @@
*/
#include "GLESv2Context.h"
-
-
+#include <string.h>
void GLESv2Context::init() {
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
if(!m_initialized) {
s_glDispatch.dispatchFuncs(GLES_2_0);
GLEScontext::init();
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
index 75af864..7e71177 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
@@ -20,7 +20,6 @@
#include <GLcommon/GLDispatch.h>
#include <GLcommon/GLEScontext.h>
#include <GLcommon/objectNameManager.h>
-#include <utils/threads.h>
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 7ae9427..fe64f6f 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -593,7 +593,7 @@ GL_APICALL void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum t
const GLvoid* indices = elementsIndices;
if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo
const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER));
- indices = buf+reinterpret_cast<uintptr_t>(elementsIndices);
+ indices = buf + SafeUIntFromPointer(elementsIndices);
}
GLESConversionArrays tmpArrs;
@@ -867,7 +867,6 @@ GL_APICALL void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname,
GET_CTX();
SET_ERROR_IF(!(GLESv2Validate::bufferTarget(target) && GLESv2Validate::bufferParam(pname)),GL_INVALID_ENUM);
SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
- bool ret = true;
switch(pname) {
case GL_BUFFER_SIZE:
ctx->getBufferSize(target,params);
@@ -941,11 +940,19 @@ GL_APICALL void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params){
}
GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params){
+ int destroyCtx = 0;
GET_CTX();
+ if (!ctx) {
+ ctx = createGLESContext();
+ if (ctx)
+ destroyCtx = 1;
+ }
if (ctx->glGetIntegerv(pname,params))
{
- return;
+ if (destroyCtx)
+ deleteGLESContext(ctx);
+ return;
}
bool es2 = ctx->getCaps()->GL_ARB_ES2_COMPATIBILITY;
@@ -1031,6 +1038,8 @@ GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params){
default:
ctx->dispatcher().glGetIntegerv(pname,params);
}
+ if (destroyCtx)
+ deleteGLESContext(ctx);
}
GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params){
@@ -2006,7 +2015,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma
{
GET_CTX();
SET_ERROR_IF(!GLESv2Validate::textureTargetLimited(target),GL_INVALID_ENUM);
- unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
+ unsigned int imagehndl = SafeUIntFromPointer(image);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
if (img) {
// Create the texture object in the underlying EGL implementation,
@@ -2042,7 +2051,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target
{
GET_CTX();
SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
- unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
+ unsigned int imagehndl = SafeUIntFromPointer(image);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
SET_ERROR_IF(!img,GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
index 53d1314..3f00428 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "GLESv2Validate.h"
+#include <string.h>
bool GLESv2Validate::blendEquationMode(GLenum mode){
return mode == GL_FUNC_ADD ||
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
index a80326d..940538a 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
@@ -15,6 +15,7 @@
*/
#include "ShaderParser.h"
+#include <stdlib.h>
#include <string.h>
ShaderParser::ShaderParser():ObjectData(SHADER_DATA),
@@ -223,8 +224,7 @@ void ShaderParser::parseOmitPrecision(){
SEMICOLON
} statementState = PRECISION;
const char *precision = NULL;
- const char *delimiter = NULL;
-
+
enum {
PARSE_NONE,
PARSE_IN_C_COMMENT,
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk b/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
index 1236566..b215329 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
+++ b/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
@@ -41,21 +41,23 @@ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
$(call emugl-export,LDLIBS,$(host_common_LDLIBS))
$(call emugl-export,LDFLAGS,$(host_common_LDFLAGS))
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared)
-$(call emugl-export,STATIC_LIBRARIES, libcutils libutils liblog)
+$(call emugl-export,STATIC_LIBRARIES, libemugl_common)
$(call emugl-end-module)
### EGL host implementation, 64-bit ################
-
-$(call emugl-begin-host-static-library,lib64GLcommon)
-
-$(call emugl-import,lib64OpenglOsUtils)
-translator_path := $(LOCAL_PATH)/..
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-$(call emugl-export,LDLIBS,$(host_common_LDLIBS))
-$(call emugl-export,LDFLAGS,$(host_common_LDFLAGS))
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared)
-$(call emugl-export,STATIC_LIBRARIES, lib64cutils lib64utils lib64log)
-
-$(call emugl-end-module)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64GLcommon)
+
+ $(call emugl-import,lib64OpenglOsUtils)
+ translator_path := $(LOCAL_PATH)/..
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ LOCAL_CFLAGS += -fPIC
+ $(call emugl-export,LDLIBS,$(host_common_LDLIBS))
+ $(call emugl-export,LDFLAGS,$(host_common_LDFLAGS))
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared)
+ $(call emugl-export,STATIC_LIBRARIES, lib64emugl_common)
+
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
index abed760..7b217fd 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
@@ -45,29 +45,30 @@ static GL_FUNC_PTR getGLFuncAddress(const char *funcName) {
return ret;
}
-#define LOAD_GL_FUNC(name) { void * funcAddrs = NULL; \
- if(name == NULL){ \
- funcAddrs = (void *)getGLFuncAddress(#name); \
- if(funcAddrs){ \
- *(void**)(&name) = funcAddrs; \
- } else { \
- fprintf(stderr,"could not load func %s\n",#name); \
- *(void**)(&name) = (void *)dummy_##name; \
- } \
- } \
- }
+#define LOAD_GL_FUNC(name) do { \
+ if (!name) { \
+ void* funcAddress = (void *)getGLFuncAddress(#name); \
+ if (funcAddress) { \
+ name = (__typeof__(name))(funcAddress); \
+ } else { \
+ fprintf(stderr, "Could not load func %s\n", #name); \
+ name = (__typeof__(name))(dummy_##name); \
+ } \
+ } \
+ } while (0)
-#define LOAD_GLEXT_FUNC(name) { void * funcAddrs = NULL; \
- if(name == NULL){ \
- funcAddrs = (void *)getGLFuncAddress(#name); \
- if(funcAddrs) \
- *(void**)(&name) = funcAddrs; \
- } \
- }
+#define LOAD_GLEXT_FUNC(name) do { \
+ if (!name) { \
+ void* funcAddress = (void *)getGLFuncAddress(#name); \
+ if (funcAddress) { \
+ name = (__typeof__(name))(funcAddress); \
+ } \
+ } \
+ } while (0)
/* initializing static GLDispatch members*/
-android::Mutex GLDispatch::s_lock;
+emugl::Mutex GLDispatch::s_lock;
void (GLAPIENTRY *GLDispatch::glActiveTexture)(GLenum) = NULL;
void (GLAPIENTRY *GLDispatch::glBindBuffer)(GLenum,GLuint) = NULL;
void (GLAPIENTRY *GLDispatch::glBindTexture)(GLenum, GLuint) = NULL;
@@ -298,7 +299,7 @@ GLDispatch::GLDispatch():m_isLoaded(false){};
void GLDispatch::dispatchFuncs(GLESVersion version){
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
if(m_isLoaded)
return;
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
index 387eb2d..ba3edbe 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
@@ -23,6 +23,7 @@
#include <GLcommon/TextureUtils.h>
#include <GLcommon/FramebufferData.h>
#include <strings.h>
+#include <string.h>
//decleration
static void convertFixedDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize);
@@ -84,7 +85,7 @@ void GLESConversionArrays::operator++(){
}
GLDispatch GLEScontext::s_glDispatch;
-android::Mutex GLEScontext::s_lock;
+emugl::Mutex GLEScontext::s_lock;
std::string* GLEScontext::s_glExtensions= NULL;
std::string GLEScontext::s_glVendor;
std::string GLEScontext::s_glRenderer;
@@ -191,7 +192,7 @@ GLEScontext::~GLEScontext() {
const GLvoid* GLEScontext::setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) {
GLuint bufferName = m_arrayBuffer;
if(bufferName) {
- unsigned int offset = ToTargetCompatibleHandle((uintptr_t)data);
+ unsigned int offset = SafeUIntFromPointer(data);
GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr());
m_map[arrType]->setBuffer(size,type,stride,vbo,bufferName,offset,normalize);
return static_cast<const unsigned char*>(vbo->getData()) + offset;
@@ -329,10 +330,8 @@ void GLEScontext::convertDirectVBO(GLESConversionArrays& cArrs,GLint first,GLsiz
RangeList ranges;
RangeList conversions;
GLushort* indices = NULL;
- GLenum type = p->getType();
int attribSize = p->getSize();
int stride = p->getStride()?p->getStride():sizeof(GLfixed)*attribSize;
- unsigned int size = p->getStride()?p->getStride()*count:attribSize*count*sizeof(GLfixed);
char* data = (char*)p->getBufferData() + (first*stride);
if(p->bufferNeedConversion()) {
@@ -388,7 +387,6 @@ void GLEScontext::convertIndirectVBO(GLESConversionArrays& cArrs,GLsizei count,G
RangeList ranges;
RangeList conversions;
GLushort* conversionIndices = NULL;
- GLenum type = p->getType();
int attribSize = p->getSize();
int stride = p->getStride()?p->getStride():sizeof(GLfixed)*attribSize;
char* data = static_cast<char*>(p->getBufferData());
@@ -679,6 +677,10 @@ bool GLEScontext::glGetIntegerv(GLenum pname, GLint *params)
case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
*params = GL_RGBA;
break;
+
+ case GL_MAX_TEXTURE_SIZE:
+ *params = getMaxTexSize();
+ break;
default:
return false;
}
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp b/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp
index cfea855..3612211 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp
@@ -18,12 +18,11 @@
#include <GLcommon/GLEScontext.h>
-NameSpace::NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace) :
+NameSpace::NameSpace(NamedObjectType p_type,
+ GlobalNameSpace *globalNameSpace) :
m_nextName(0),
m_type(p_type),
- m_globalNameSpace(globalNameSpace)
-{
-}
+ m_globalNameSpace(globalNameSpace) {}
NameSpace::~NameSpace()
{
@@ -35,14 +34,16 @@ NameSpace::~NameSpace()
}
ObjectLocalName
-NameSpace::genName(ObjectLocalName p_localName, bool genGlobal, bool genLocal)
+NameSpace::genName(ObjectLocalName p_localName,
+ bool genGlobal, bool genLocal)
{
-
ObjectLocalName localName = p_localName;
if (genLocal) {
do {
localName = ++m_nextName;
- } while( localName == 0 || m_localToGlobalMap.find(localName) != m_localToGlobalMap.end() );
+ } while(localName == 0 ||
+ m_localToGlobalMap.find(localName) !=
+ m_localToGlobalMap.end() );
}
if (genGlobal) {
@@ -114,15 +115,9 @@ NameSpace::replaceGlobalName(ObjectLocalName p_localName, unsigned int p_globalN
}
-GlobalNameSpace::GlobalNameSpace()
-{
- mutex_init(&m_lock);
-}
+GlobalNameSpace::GlobalNameSpace() : m_lock() {}
-GlobalNameSpace::~GlobalNameSpace()
-{
- mutex_destroy(&m_lock);
-}
+GlobalNameSpace::~GlobalNameSpace() {}
unsigned int
GlobalNameSpace::genName(NamedObjectType p_type)
@@ -130,7 +125,7 @@ GlobalNameSpace::genName(NamedObjectType p_type)
if ( p_type >= NUM_OBJECT_TYPES ) return 0;
unsigned int name = 0;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
switch (p_type) {
case VERTEXBUFFER:
GLEScontext::dispatcher().glGenBuffers(1,&name);
@@ -148,7 +143,6 @@ GlobalNameSpace::genName(NamedObjectType p_type)
default:
name = 0;
}
- mutex_unlock(&m_lock);
return name;
}
@@ -160,11 +154,8 @@ GlobalNameSpace::deleteName(NamedObjectType p_type, unsigned int p_name)
typedef std::pair<NamedObjectType, ObjectLocalName> ObjectIDPair;
typedef std::map<ObjectIDPair, ObjectDataPtr> ObjectDataMap;
-ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace)
-{
- mutex_init(&m_lock);
-
- for (int i=0; i<NUM_OBJECT_TYPES; i++) {
+ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace) : m_lock() {
+ for (int i=0; i < NUM_OBJECT_TYPES; i++) {
m_nameSpace[i] = new NameSpace((NamedObjectType)i, globalNameSpace);
}
@@ -173,27 +164,24 @@ ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace)
ShareGroup::~ShareGroup()
{
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
for (int t = 0; t < NUM_OBJECT_TYPES; t++) {
delete m_nameSpace[t];
}
- ObjectDataMap *map = (ObjectDataMap *)m_objectsData;
- if (map) delete map;
-
- mutex_unlock(&m_lock);
- mutex_destroy(&m_lock);
+ delete (ObjectDataMap *)m_objectsData;
}
ObjectLocalName
-ShareGroup::genName(NamedObjectType p_type, ObjectLocalName p_localName, bool genLocal)
+ShareGroup::genName(NamedObjectType p_type,
+ ObjectLocalName p_localName,
+ bool genLocal)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- ObjectLocalName localName = m_nameSpace[p_type]->genName(p_localName,true,genLocal);
- mutex_unlock(&m_lock);
-
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ObjectLocalName localName =
+ m_nameSpace[p_type]->genName(p_localName, true, genLocal);
return localName;
}
@@ -202,35 +190,28 @@ ShareGroup::genGlobalName(NamedObjectType p_type)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- unsigned int name = m_nameSpace[p_type]->genGlobalName();
- mutex_unlock(&m_lock);
-
- return name;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return m_nameSpace[p_type]->genGlobalName();
}
unsigned int
-ShareGroup::getGlobalName(NamedObjectType p_type, ObjectLocalName p_localName)
+ShareGroup::getGlobalName(NamedObjectType p_type,
+ ObjectLocalName p_localName)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- unsigned int globalName = m_nameSpace[p_type]->getGlobalName(p_localName);
- mutex_unlock(&m_lock);
-
- return globalName;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return m_nameSpace[p_type]->getGlobalName(p_localName);
}
ObjectLocalName
-ShareGroup::getLocalName(NamedObjectType p_type, unsigned int p_globalName)
+ShareGroup::getLocalName(NamedObjectType p_type,
+ unsigned int p_globalName)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- ObjectLocalName localName = m_nameSpace[p_type]->getLocalName(p_globalName);
- mutex_unlock(&m_lock);
-
- return localName;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return m_nameSpace[p_type]->getLocalName(p_globalName);
}
void
@@ -238,13 +219,12 @@ ShareGroup::deleteName(NamedObjectType p_type, ObjectLocalName p_localName)
{
if (p_type >= NUM_OBJECT_TYPES) return;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
m_nameSpace[p_type]->deleteName(p_localName);
ObjectDataMap *map = (ObjectDataMap *)m_objectsData;
if (map) {
map->erase( ObjectIDPair(p_type, p_localName) );
}
- mutex_unlock(&m_lock);
}
bool
@@ -252,29 +232,29 @@ ShareGroup::isObject(NamedObjectType p_type, ObjectLocalName p_localName)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- bool exist = m_nameSpace[p_type]->isObject(p_localName);
- mutex_unlock(&m_lock);
-
- return exist;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return m_nameSpace[p_type]->isObject(p_localName);
}
void
-ShareGroup::replaceGlobalName(NamedObjectType p_type, ObjectLocalName p_localName, unsigned int p_globalName)
+ShareGroup::replaceGlobalName(NamedObjectType p_type,
+ ObjectLocalName p_localName,
+ unsigned int p_globalName)
{
if (p_type >= NUM_OBJECT_TYPES) return;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
m_nameSpace[p_type]->replaceGlobalName(p_localName, p_globalName);
- mutex_unlock(&m_lock);
}
void
-ShareGroup::setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, ObjectDataPtr data)
+ShareGroup::setObjectData(NamedObjectType p_type,
+ ObjectLocalName p_localName,
+ ObjectDataPtr data)
{
if (p_type >= NUM_OBJECT_TYPES) return;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ObjectDataMap *map = (ObjectDataMap *)m_objectsData;
if (!map) {
@@ -284,45 +264,36 @@ ShareGroup::setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, O
ObjectIDPair id( p_type, p_localName );
map->insert( std::pair<ObjectIDPair, ObjectDataPtr>(id, data) );
-
- mutex_unlock(&m_lock);
}
ObjectDataPtr
-ShareGroup::getObjectData(NamedObjectType p_type, ObjectLocalName p_localName)
+ShareGroup::getObjectData(NamedObjectType p_type,
+ ObjectLocalName p_localName)
{
ObjectDataPtr ret;
if (p_type >= NUM_OBJECT_TYPES) return ret;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ObjectDataMap *map = (ObjectDataMap *)m_objectsData;
if (map) {
- ObjectDataMap::iterator i = map->find( ObjectIDPair(p_type, p_localName) );
+ ObjectDataMap::iterator i =
+ map->find( ObjectIDPair(p_type, p_localName) );
if (i != map->end()) ret = (*i).second;
}
-
- mutex_unlock(&m_lock);
-
return ret;
}
ObjectNameManager::ObjectNameManager(GlobalNameSpace *globalNameSpace) :
- m_globalNameSpace(globalNameSpace)
-{
- mutex_init(&m_lock);
-}
+ m_lock(), m_globalNameSpace(globalNameSpace) {}
-ObjectNameManager::~ObjectNameManager()
-{
- mutex_destroy(&m_lock);
-}
+ObjectNameManager::~ObjectNameManager() {}
ShareGroupPtr
ObjectNameManager::createShareGroup(void *p_groupName)
{
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ShareGroupPtr shareGroupReturn;
@@ -334,19 +305,19 @@ ObjectNameManager::createShareGroup(void *p_groupName)
//
// Group does not exist, create new group
//
- shareGroupReturn = ShareGroupPtr( new ShareGroup(m_globalNameSpace) );
- m_groups.insert( std::pair<void *, ShareGroupPtr>(p_groupName, shareGroupReturn) );
+ shareGroupReturn = ShareGroupPtr(new ShareGroup(m_globalNameSpace));
+ m_groups.insert(
+ std::pair<void*, ShareGroupPtr>(
+ p_groupName, shareGroupReturn));
}
- mutex_unlock(&m_lock);
-
return shareGroupReturn;
}
ShareGroupPtr
ObjectNameManager::getShareGroup(void *p_groupName)
{
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ShareGroupPtr shareGroupReturn(NULL);
@@ -354,58 +325,45 @@ ObjectNameManager::getShareGroup(void *p_groupName)
if (s != m_groups.end()) {
shareGroupReturn = (*s).second;
}
- mutex_unlock(&m_lock);
return shareGroupReturn;
}
ShareGroupPtr
-ObjectNameManager::attachShareGroup(void *p_groupName, void *p_existingGroupName)
+ObjectNameManager::attachShareGroup(void *p_groupName,
+ void *p_existingGroupName)
{
- mutex_lock(&m_lock);
-
- ShareGroupPtr shareGroupReturn;
+ emugl::Mutex::AutoLock _lock(m_lock);
ShareGroupsMap::iterator s( m_groups.find(p_existingGroupName) );
if (s == m_groups.end()) {
// ShareGroup did not found !!!
- mutex_unlock(&m_lock);
return ShareGroupPtr(NULL);
}
- shareGroupReturn = (*s).second;
-
- if (m_groups.find(p_groupName) == m_groups.end())
- {
- m_groups.insert( std::pair<void *, ShareGroupPtr>(p_groupName, shareGroupReturn) );
+ ShareGroupPtr shareGroupReturn((*s).second);
+ if (m_groups.find(p_groupName) == m_groups.end()) {
+ m_groups.insert(
+ std::pair<void*, ShareGroupPtr>(
+ p_groupName, shareGroupReturn));
}
-
- mutex_unlock(&m_lock);
-
return shareGroupReturn;
}
void
ObjectNameManager::deleteShareGroup(void *p_groupName)
{
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ShareGroupsMap::iterator s( m_groups.find(p_groupName) );
if (s != m_groups.end()) {
m_groups.erase(s);
}
-
- mutex_unlock(&m_lock);
}
void *ObjectNameManager::getGlobalContext()
{
- void *ret = NULL;
-
- mutex_lock(&m_lock);
- if (m_groups.size() > 0) ret = (*m_groups.begin()).first;
- mutex_unlock(&m_lock);
-
- return ret;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return (m_groups.size() > 0) ? (*m_groups.begin()).first : NULL;
}
diff --git a/emulator/opengl/host/libs/Translator/include/ETC1/etc1.h b/emulator/opengl/host/libs/Translator/include/ETC1/etc1.h
new file mode 100644
index 0000000..0d38905
--- /dev/null
+++ b/emulator/opengl/host/libs/Translator/include/ETC1/etc1.h
@@ -0,0 +1,106 @@
+// Copyright 2009 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __etc1_h__
+#define __etc1_h__
+
+#define ETC1_ENCODED_BLOCK_SIZE 8
+#define ETC1_DECODED_BLOCK_SIZE 48
+
+#ifndef ETC1_RGB8_OES
+#define ETC1_RGB8_OES 0x8D64
+#endif
+
+typedef unsigned char etc1_byte;
+typedef int etc1_bool;
+typedef unsigned int etc1_uint32;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Encode a block of pixels.
+//
+// pIn is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
+// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
+// value of pixel (x, y).
+//
+// validPixelMask is a 16-bit mask where bit (1 << (x + y * 4)) indicates whether
+// the corresponding (x,y) pixel is valid. Invalid pixel color values are ignored when compressing.
+//
+// pOut is an ETC1 compressed version of the data.
+
+void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 validPixelMask, etc1_byte* pOut);
+
+// Decode a block of pixels.
+//
+// pIn is an ETC1 compressed version of the data.
+//
+// pOut is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
+// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
+// value of pixel (x, y).
+
+void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut);
+
+// Return the size of the encoded image data (does not include size of PKM header).
+
+etc1_uint32 etc1_get_encoded_data_size(etc1_uint32 width, etc1_uint32 height);
+
+// Encode an entire image.
+// pIn - pointer to the image data. Formatted such that
+// pixel (x,y) is at pIn + pixelSize * x + stride * y;
+// pOut - pointer to encoded data. Must be large enough to store entire encoded image.
+// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
+// returns non-zero if there is an error.
+
+int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height,
+ etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut);
+
+// Decode an entire image.
+// pIn - pointer to encoded data.
+// pOut - pointer to the image data. Will be written such that
+// pixel (x,y) is at pIn + pixelSize * x + stride * y. Must be
+// large enough to store entire image.
+// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
+// returns non-zero if there is an error.
+
+int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut,
+ etc1_uint32 width, etc1_uint32 height,
+ etc1_uint32 pixelSize, etc1_uint32 stride);
+
+// Size of a PKM header, in bytes.
+
+#define ETC_PKM_HEADER_SIZE 16
+
+// Format a PKM header
+
+void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height);
+
+// Check if a PKM header is correctly formatted.
+
+etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader);
+
+// Read the image width from a PKM header
+
+etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader);
+
+// Read the image height from a PKM header
+
+etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
index de7d563..18a989c 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
@@ -18,7 +18,7 @@
#include <GLES/gl.h>
#include <GLES2/gl2.h>
-#include <utils/threads.h>
+#include "emugl/common/mutex.h"
#include "gldefs.h"
#include "GLutils.h"
@@ -260,8 +260,8 @@ public:
static void (GL_APIENTRY *glShaderSource)(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
private:
- bool m_isLoaded;
- static android::Mutex s_lock;
+ bool m_isLoaded;
+ static emugl::Mutex s_lock;
};
#endif
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h
index 3353ec1..38429d1 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h
@@ -43,5 +43,5 @@ private:
bool m_wasBound;
};
-typedef SmartPtr<GLESbuffer> GLESbufferPtr;
+typedef emugl::SmartPtr<GLESbuffer> GLESbufferPtr;
#endif
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
index 20509fc..5aed0ad 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
@@ -20,7 +20,7 @@
#include "GLDispatch.h"
#include "GLESpointer.h"
#include "objectNameManager.h"
-#include <utils/threads.h>
+#include "emugl/common/mutex.h"
#include <string>
typedef std::map<GLenum,GLESpointer*> ArraysMap;
@@ -187,7 +187,7 @@ protected:
void initCapsLocked(const GLubyte * extensionString);
virtual void initExtensionString() =0;
- static android::Mutex s_lock;
+ static emugl::Mutex s_lock;
static GLDispatch s_glDispatch;
bool m_initialized;
unsigned int m_activeTexture;
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
index 2aed646..974b9be 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
@@ -16,36 +16,37 @@
#ifndef GL_UTILS_H
#define GL_UTILS_H
-#include <inttypes.h>
#include <assert.h>
+#include <inttypes.h>
-typedef enum{
- GLES_1_1 = 1,
- GLES_2_0 = 2,
- MAX_GLES_VERSION //Must be last
- }GLESVersion;
+typedef enum {
+ GLES_1_1 = 1,
+ GLES_2_0 = 2,
+ MAX_GLES_VERSION //Must be last
+} GLESVersion;
template <class T>
void swap(T& x,T& y) {
T temp;
- temp=x;
- x=y;
- y=temp;
+ temp = x;
+ x = y;
+ y = temp;
}
bool isPowerOf2(int num);
-inline
-unsigned int ToTargetCompatibleHandle(uintptr_t hostHandle)
-{
- // The host and target handles can have different sizes (e.g. 32-bit
- // target handle for ARM, and 64-bit host handle on x86_64).
- // This function checks that the input host handle value can be
- // converted into a target handle one without losing any bits.
- //
- unsigned int targetHandle = (unsigned int)hostHandle;
- assert(sizeof(targetHandle) == sizeof(hostHandle) || targetHandle == hostHandle);
- return targetHandle;
+// <EGL/egl.h> defines many types as 'void*' while they're really
+// implemented as unsigned integers. These convenience template functions
+// help casting between them safely without generating compiler warnings.
+inline void* SafePointerFromUInt(unsigned int handle) {
+ return (void*)(uintptr_t)(handle);
+}
+
+inline unsigned int SafeUIntFromPointer(const void* ptr) {
+ // Assertion error if the pointer contains a value that does not fit
+ // in an unsigned integer!
+ assert((uintptr_t)(ptr) == (unsigned int)(uintptr_t)(ptr));
+ return (unsigned int)(uintptr_t)(ptr);
}
#endif
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h b/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h
deleted file mode 100644
index 8ac93fb..0000000
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
-* Copyright (C) 2011 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __SMART_PTR_H
-#define __SMART_PTR_H
-
-#include <cutils/threads.h>
-#include <cutils/atomic.h>
-
-template <class T, bool threadSafe = false>
-class SmartPtr
-{
-public:
- explicit SmartPtr(T* ptr = (T*)NULL) {
- if (threadSafe) {
- m_lock = new mutex_t;
- mutex_init(m_lock);
- }
- else m_lock = NULL;
-
- m_ptr = ptr;
- if (ptr)
- m_pRefCount = new int32_t(1);
- else
- m_pRefCount = NULL;
- }
-
- SmartPtr<T,threadSafe>(const SmartPtr<T,false>& rhs) {
- if (threadSafe) {
- m_lock = new mutex_t;
- mutex_init(m_lock);
- }
- else m_lock = NULL;
-
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- }
-
- SmartPtr<T,threadSafe>(SmartPtr<T,true>& rhs) {
- if (threadSafe) {
- m_lock = new mutex_t;
- mutex_init(m_lock);
- }
- else m_lock = NULL;
-
- if (rhs.m_lock) mutex_lock(rhs.m_lock);
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- if (rhs.m_lock) mutex_unlock(rhs.m_lock);
- }
-
- ~SmartPtr() {
- if (m_lock) mutex_lock(m_lock);
- release();
- if (m_lock)
- {
- mutex_unlock(m_lock);
- mutex_destroy(m_lock);
- delete m_lock;
- }
- }
-
- T* Ptr() const {
- return m_ptr;
- }
-
- const T* constPtr() const
- {
- return m_ptr;
- }
-
- T* operator->() const {
- return m_ptr;
- }
-
- T& operator*() const {
- return *m_ptr;
- }
-
- // This gives STL lists something to compare.
- bool operator <(const SmartPtr<T>& t1) const {
- return m_ptr < t1.m_ptr;
- }
-
- SmartPtr<T,threadSafe>& operator=(const SmartPtr<T,false>& rhs)
- {
- if (m_ptr == rhs.m_ptr)
- return *this;
-
- if (m_lock) mutex_lock(m_lock);
- release();
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- if (m_lock) mutex_unlock(m_lock);
-
- return *this;
- }
-
- SmartPtr<T,threadSafe>& operator=(SmartPtr<T,true>& rhs)
- {
- if (m_ptr == rhs.m_ptr)
- return *this;
-
- if (m_lock) mutex_lock(m_lock);
- release();
- if (rhs.m_lock) mutex_lock(rhs.m_lock);
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- if (rhs.m_lock) mutex_unlock(rhs.m_lock);
- if (m_lock) mutex_unlock(m_lock);
-
- return *this;
- }
-
-private:
- int32_t *m_pRefCount;
- mutex_t *m_lock;
- T* m_ptr;
-
- // Increment the reference count on this pointer by 1.
- int use() {
- if (!m_pRefCount) return 0;
- return android_atomic_inc(m_pRefCount) + 1;
- }
-
- // Decrement the reference count on the pointer by 1.
- // If the reference count goes to (or below) 0, the pointer is deleted.
- int release() {
- if (!m_pRefCount) return 0;
-
- int iVal = android_atomic_dec(m_pRefCount);
- if (iVal > 1)
- return iVal - 1;
-
- delete m_pRefCount;
- m_pRefCount = NULL;
-
- if (m_ptr) {
- delete m_ptr;
- m_ptr = NULL;
- }
- return 0;
- }
-
-};
-
-#endif // of __SMART_PTR_H
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h b/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
index 3c5e15a..e0d1bfb 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
@@ -74,8 +74,8 @@ struct EglImage
unsigned int border;
};
-typedef SmartPtr<EglImage> ImagePtr;
-typedef std::map< unsigned int, ImagePtr> ImagesHndlMap;
+typedef emugl::SmartPtr<EglImage> ImagePtr;
+typedef std::map< unsigned int, ImagePtr> ImagesHndlMap;
class GLEScontext;
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h b/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h
index 605fd29..4d4d038 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h
@@ -16,9 +16,9 @@
#ifndef _OBJECT_NAME_MANAGER_H
#define _OBJECT_NAME_MANAGER_H
-#include <cutils/threads.h>
#include <map>
-#include "SmartPtr.h"
+#include "emugl/common/mutex.h"
+#include "emugl/common/smart_ptr.h"
enum NamedObjectType {
VERTEXBUFFER = 0,
@@ -47,7 +47,7 @@ public:
private:
ObjectDataType m_dataType;
};
-typedef SmartPtr<ObjectData> ObjectDataPtr;
+typedef emugl::SmartPtr<ObjectData> ObjectDataPtr;
typedef unsigned long long ObjectLocalName;
typedef std::map<ObjectLocalName, unsigned int> NamesMap;
@@ -129,7 +129,7 @@ public:
void deleteName(NamedObjectType p_type, unsigned int p_name);
private:
- mutex_t m_lock;
+ emugl::Mutex m_lock;
};
//
@@ -143,7 +143,7 @@ private:
class ShareGroup
{
friend class ObjectNameManager;
- friend class SmartPtr<ShareGroup>; // to allow destructing when ShareGroupPtr refcount reaches zero
+ friend class emugl::SmartPtr<ShareGroup>; // to allow destructing when ShareGroupPtr refcount reaches zero
public:
@@ -204,12 +204,12 @@ private:
~ShareGroup();
private:
- mutex_t m_lock;
+ emugl::Mutex m_lock;
NameSpace *m_nameSpace[NUM_OBJECT_TYPES];
void *m_objectsData;
};
-typedef SmartPtr<ShareGroup> ShareGroupPtr;
+typedef emugl::SmartPtr<ShareGroup> ShareGroupPtr;
typedef std::multimap<void *, ShareGroupPtr> ShareGroupsMap;
//
@@ -262,7 +262,7 @@ public:
private:
ShareGroupsMap m_groups;
- mutex_t m_lock;
+ emugl::Mutex m_lock;
GlobalNameSpace *m_globalNameSpace;
};
diff --git a/emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h b/emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h
new file mode 100644
index 0000000..c9e6f17
--- /dev/null
+++ b/emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h
@@ -0,0 +1,282 @@
+#ifndef __khrplatform_h_
+#define __khrplatform_h_
+
+/*
+** Copyright (c) 2008-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Khronos platform-specific types and definitions.
+ *
+ * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $
+ *
+ * Adopters may modify this file to suit their platform. Adopters are
+ * encouraged to submit platform specific modifications to the Khronos
+ * group so that they can be included in future versions of this file.
+ * Please submit changes by sending them to the public Khronos Bugzilla
+ * (http://khronos.org/bugzilla) by filing a bug against product
+ * "Khronos (general)" component "Registry".
+ *
+ * A predefined template which fills in some of the bug fields can be
+ * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
+ * must create a Bugzilla login first.
+ *
+ *
+ * See the Implementer's Guidelines for information about where this file
+ * should be located on your system and for more details of its use:
+ * http://www.khronos.org/registry/implementers_guide.pdf
+ *
+ * This file should be included as
+ * #include <KHR/khrplatform.h>
+ * by Khronos client API header files that use its types and defines.
+ *
+ * The types in khrplatform.h should only be used to define API-specific types.
+ *
+ * Types defined in khrplatform.h:
+ * khronos_int8_t signed 8 bit
+ * khronos_uint8_t unsigned 8 bit
+ * khronos_int16_t signed 16 bit
+ * khronos_uint16_t unsigned 16 bit
+ * khronos_int32_t signed 32 bit
+ * khronos_uint32_t unsigned 32 bit
+ * khronos_int64_t signed 64 bit
+ * khronos_uint64_t unsigned 64 bit
+ * khronos_intptr_t signed same number of bits as a pointer
+ * khronos_uintptr_t unsigned same number of bits as a pointer
+ * khronos_ssize_t signed size
+ * khronos_usize_t unsigned size
+ * khronos_float_t signed 32 bit floating point
+ * khronos_time_ns_t unsigned 64 bit time in nanoseconds
+ * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
+ * nanoseconds
+ * khronos_stime_nanoseconds_t signed time interval in nanoseconds
+ * khronos_boolean_enum_t enumerated boolean type. This should
+ * only be used as a base type when a client API's boolean type is
+ * an enum. Client APIs which use an integer or other type for
+ * booleans cannot use this as the base type for their boolean.
+ *
+ * Tokens defined in khrplatform.h:
+ *
+ * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
+ *
+ * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
+ * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
+ *
+ * Calling convention macros defined in this file:
+ * KHRONOS_APICALL
+ * KHRONOS_APIENTRY
+ * KHRONOS_APIATTRIBUTES
+ *
+ * These may be used in function prototypes as:
+ *
+ * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
+ * int arg1,
+ * int arg2) KHRONOS_APIATTRIBUTES;
+ */
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APICALL
+ *-------------------------------------------------------------------------
+ * This precedes the return type of the function in the function prototype.
+ */
+#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
+# define KHRONOS_APICALL __declspec(dllimport)
+#elif defined (__SYMBIAN32__)
+# define KHRONOS_APICALL IMPORT_C
+#else
+# define KHRONOS_APICALL
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIENTRY
+ *-------------------------------------------------------------------------
+ * This follows the return type of the function and precedes the function
+ * name in the function prototype.
+ */
+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
+ /* Win32 but not WinCE */
+# define KHRONOS_APIENTRY __stdcall
+#else
+# define KHRONOS_APIENTRY
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIATTRIBUTES
+ *-------------------------------------------------------------------------
+ * This follows the closing parenthesis of the function prototype arguments.
+ */
+#if defined (__ARMCC_2__)
+#define KHRONOS_APIATTRIBUTES __softfp
+#else
+#define KHRONOS_APIATTRIBUTES
+#endif
+
+/*-------------------------------------------------------------------------
+ * basic type definitions
+ *-----------------------------------------------------------------------*/
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
+
+
+/*
+ * Using <stdint.h>
+ */
+#include <stdint.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__VMS ) || defined(__sgi)
+
+/*
+ * Using <inttypes.h>
+ */
+#include <inttypes.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
+
+/*
+ * Win32
+ */
+typedef __int32 khronos_int32_t;
+typedef unsigned __int32 khronos_uint32_t;
+typedef __int64 khronos_int64_t;
+typedef unsigned __int64 khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__sun__) || defined(__digital__)
+
+/*
+ * Sun or Digital
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#if defined(__arch64__) || defined(_LP64)
+typedef long int khronos_int64_t;
+typedef unsigned long int khronos_uint64_t;
+#else
+typedef long long int khronos_int64_t;
+typedef unsigned long long int khronos_uint64_t;
+#endif /* __arch64__ */
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif 0
+
+/*
+ * Hypothetical platform with no float or int64 support
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#define KHRONOS_SUPPORT_INT64 0
+#define KHRONOS_SUPPORT_FLOAT 0
+
+#else
+
+/*
+ * Generic fallback
+ */
+#include <stdint.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#endif
+
+
+/*
+ * Types that are (so far) the same on all platforms
+ */
+typedef signed char khronos_int8_t;
+typedef unsigned char khronos_uint8_t;
+typedef signed short int khronos_int16_t;
+typedef unsigned short int khronos_uint16_t;
+
+/*
+ * Types that differ between LLP64 and LP64 architectures - in LLP64,
+ * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
+ * to be the only LLP64 architecture in current use.
+ */
+#ifdef _WIN64
+typedef signed long long int khronos_intptr_t;
+typedef unsigned long long int khronos_uintptr_t;
+typedef signed long long int khronos_ssize_t;
+typedef unsigned long long int khronos_usize_t;
+#else
+typedef signed long int khronos_intptr_t;
+typedef unsigned long int khronos_uintptr_t;
+typedef signed long int khronos_ssize_t;
+typedef unsigned long int khronos_usize_t;
+#endif
+
+#if KHRONOS_SUPPORT_FLOAT
+/*
+ * Float type
+ */
+typedef float khronos_float_t;
+#endif
+
+#if KHRONOS_SUPPORT_INT64
+/* Time types
+ *
+ * These types can be used to represent a time interval in nanoseconds or
+ * an absolute Unadjusted System Time. Unadjusted System Time is the number
+ * of nanoseconds since some arbitrary system event (e.g. since the last
+ * time the system booted). The Unadjusted System Time is an unsigned
+ * 64 bit value that wraps back to 0 every 584 years. Time intervals
+ * may be either signed or unsigned.
+ */
+typedef khronos_uint64_t khronos_utime_nanoseconds_t;
+typedef khronos_int64_t khronos_stime_nanoseconds_t;
+#endif
+
+/*
+ * Dummy value used to pad enum types to 32 bits.
+ */
+#ifndef KHRONOS_MAX_ENUM
+#define KHRONOS_MAX_ENUM 0x7FFFFFFF
+#endif
+
+/*
+ * Enumerated boolean type
+ *
+ * Values other than zero should be considered to be true. Therefore
+ * comparisons should not be made against KHRONOS_TRUE.
+ */
+typedef enum {
+ KHRONOS_FALSE = 0,
+ KHRONOS_TRUE = 1,
+ KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
+} khronos_boolean_enum_t;
+
+#endif /* __khrplatform_h_ */
diff --git a/emulator/opengl/host/libs/libOpenglRender/Android.mk b/emulator/opengl/host/libs/libOpenglRender/Android.mk
index 1d923b4..787ae83 100644
--- a/emulator/opengl/host/libs/libOpenglRender/Android.mk
+++ b/emulator/opengl/host/libs/libOpenglRender/Android.mk
@@ -54,7 +54,7 @@ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
# use Translator's egl/gles headers
LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include
-LOCAL_STATIC_LIBRARIES += libutils liblog
+LOCAL_STATIC_LIBRARIES += libemugl_common
$(call emugl-export,CFLAGS,$(host_common_CFLAGS))
@@ -62,22 +62,24 @@ $(call emugl-end-module)
### host libOpenglRender, 64-bit #########################################
-$(call emugl-begin-host-shared-library,lib64OpenglRender)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-shared-library,lib64OpenglRender)
-$(call emugl-import,lib64GLESv1_dec lib64GLESv2_dec lib64_renderControl_dec lib64OpenglCodecCommon lib64OpenglOsUtils)
+ $(call emugl-import,lib64GLESv1_dec lib64GLESv2_dec lib64_renderControl_dec lib64OpenglCodecCommon lib64OpenglOsUtils)
-#LOCAL_LDFLAGS += -m64 # adding -m64 here doesn't work, because it somehow appear BEFORE -m32 in command-line.
-LOCAL_LDLIBS += $(host_common_LDLIBS) -m64 # Put -m64 it in LOCAL_LDLIBS instead.
+ #LOCAL_LDFLAGS += -m64 # adding -m64 here doesn't work, because it somehow appear BEFORE -m32 in command-line.
+ LOCAL_LDLIBS += $(host_common_LDLIBS) -m64 # Put -m64 it in LOCAL_LDLIBS instead.
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include)
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ $(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include)
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-# use Translator's egl/gles headers
-LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include
+ # use Translator's egl/gles headers
+ LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include
-LOCAL_STATIC_LIBRARIES += lib64utils lib64log
+ LOCAL_STATIC_LIBRARIES += lib64emugl_common
-$(call emugl-export,CFLAGS,$(host_common_CFLAGS) -m64)
+ $(call emugl-export,CFLAGS,$(host_common_CFLAGS) -m64)
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
index 46c5acf..e612294 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
@@ -18,6 +18,7 @@
#include "EGLDispatch.h"
#include "GLDispatch.h"
#include "ThreadInfo.h"
+#include "GLcommon/GLutils.h"
#ifdef WITH_GLES2
#include "GL2Dispatch.h"
#endif
@@ -92,17 +93,19 @@ ColorBuffer *ColorBuffer::create(int p_width, int p_height,
cb->m_internalFormat = texInternalFormat;
if (fb->getCaps().has_eglimage_texture_2d) {
- cb->m_eglImage = s_egl.eglCreateImageKHR(fb->getDisplay(),
- s_egl.eglGetCurrentContext(),
- EGL_GL_TEXTURE_2D_KHR,
- (EGLClientBuffer)cb->m_tex,
- NULL);
-
- cb->m_blitEGLImage = s_egl.eglCreateImageKHR(fb->getDisplay(),
- s_egl.eglGetCurrentContext(),
- EGL_GL_TEXTURE_2D_KHR,
- (EGLClientBuffer)cb->m_blitTex,
- NULL);
+ cb->m_eglImage = s_egl.eglCreateImageKHR(
+ fb->getDisplay(),
+ s_egl.eglGetCurrentContext(),
+ EGL_GL_TEXTURE_2D_KHR,
+ (EGLClientBuffer)SafePointerFromUInt(cb->m_tex),
+ NULL);
+
+ cb->m_blitEGLImage = s_egl.eglCreateImageKHR(
+ fb->getDisplay(),
+ s_egl.eglGetCurrentContext(),
+ EGL_GL_TEXTURE_2D_KHR,
+ (EGLClientBuffer)SafePointerFromUInt(cb->m_blitTex),
+ NULL);
}
fb->unbind_locked();
@@ -201,7 +204,7 @@ bool ColorBuffer::blitFromCurrentReadBuffer()
// save current viewport and match it to the current
// colorbuffer size
//
- GLint vport[4];
+ GLint vport[4] = {};
s_gl.glGetIntegerv(GL_VIEWPORT, vport);
s_gl.glViewport(0, 0, m_width, m_height);
@@ -295,6 +298,7 @@ bool ColorBuffer::bind_fbo()
GL_TEXTURE_2D, m_tex, 0);
GLenum status = s_gl.glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
if (status != GL_FRAMEBUFFER_COMPLETE_OES) {
+ ERR("ColorBuffer::bind_fbo: FBO not complete: %#x\n", status);
s_gl.glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
s_gl.glDeleteFramebuffersOES(1, &m_fbo);
m_fbo = 0;
diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h
index 883162b..9a919c3 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h
+++ b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h
@@ -19,7 +19,7 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES/gl.h>
-#include <SmartPtr.h>
+#include "emugl/common/smart_ptr.h"
class ColorBuffer
{
@@ -55,6 +55,6 @@ private:
GLenum m_internalFormat;
};
-typedef SmartPtr<ColorBuffer> ColorBufferPtr;
+typedef emugl::SmartPtr<ColorBuffer> ColorBufferPtr;
#endif
diff --git a/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp b/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp
index ca7351e..08c71e8 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp
@@ -67,7 +67,6 @@ InitConfigStatus FBConfig::initConfigList(FrameBuffer *fb)
return ret;
}
- const FrameBufferCaps &caps = fb->getCaps();
EGLDisplay dpy = fb->getDisplay();
if (dpy == EGL_NO_DISPLAY) {
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
index cfadf12..e7a7960 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
@@ -393,7 +393,7 @@ FrameBuffer::~FrameBuffer()
void FrameBuffer::setPostCallback(OnPostFn onPost, void* onPostContext)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_onPost = onPost;
m_onPostContext = onPostContext;
if (m_onPost && !m_fbImage) {
@@ -490,7 +490,7 @@ HandleType FrameBuffer::genHandle()
HandleType FrameBuffer::createColorBuffer(int p_width, int p_height,
GLenum p_internalFormat)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
HandleType ret = 0;
ColorBufferPtr cb( ColorBuffer::create(p_width, p_height, p_internalFormat) );
@@ -505,7 +505,7 @@ HandleType FrameBuffer::createColorBuffer(int p_width, int p_height,
HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share,
bool p_isGL2)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
HandleType ret = 0;
RenderContextPtr share(NULL);
@@ -527,7 +527,7 @@ HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share,
HandleType FrameBuffer::createWindowSurface(int p_config, int p_width, int p_height)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
HandleType ret = 0;
WindowSurfacePtr win( WindowSurface::create(p_config, p_width, p_height) );
@@ -541,32 +541,35 @@ HandleType FrameBuffer::createWindowSurface(int p_config, int p_width, int p_hei
void FrameBuffer::DestroyRenderContext(HandleType p_context)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_contexts.erase(p_context);
}
void FrameBuffer::DestroyWindowSurface(HandleType p_surface)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_windows.erase(p_surface);
}
-void FrameBuffer::openColorBuffer(HandleType p_colorbuffer)
+int FrameBuffer::openColorBuffer(HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) {
// bad colorbuffer handle
- return;
+ ERR("FB: openColorBuffer cb handle %#x not found\n", p_colorbuffer);
+ return -1;
}
(*c).second.refcount++;
+ return 0;
}
void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) {
+ ERR("FB: closeColorBuffer cb handle %#x not found\n", p_colorbuffer);
// bad colorbuffer handle
return;
}
@@ -577,10 +580,11 @@ void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer)
bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
WindowSurfaceMap::iterator w( m_windows.find(p_surface) );
if (w == m_windows.end()) {
+ ERR("FB::flushWindowSurfaceColorBuffer: window handle %#x not found\n", p_surface);
// bad surface handle
return false;
}
@@ -591,16 +595,18 @@ bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface)
bool FrameBuffer::setWindowSurfaceColorBuffer(HandleType p_surface,
HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
WindowSurfaceMap::iterator w( m_windows.find(p_surface) );
if (w == m_windows.end()) {
// bad surface handle
+ ERR("%s: bad window surface handle %#x\n", __FUNCTION__, p_surface);
return false;
}
ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) );
if (c == m_colorbuffers.end()) {
+ ERR("%s: bad color buffer handle %#x\n", __FUNCTION__, p_colorbuffer);
// bad colorbuffer handle
return false;
}
@@ -614,7 +620,7 @@ bool FrameBuffer::updateColorBuffer(HandleType p_colorbuffer,
int x, int y, int width, int height,
GLenum format, GLenum type, void *pixels)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) );
if (c == m_colorbuffers.end()) {
@@ -629,7 +635,7 @@ bool FrameBuffer::updateColorBuffer(HandleType p_colorbuffer,
bool FrameBuffer::bindColorBufferToTexture(HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) );
if (c == m_colorbuffers.end()) {
@@ -642,7 +648,7 @@ bool FrameBuffer::bindColorBufferToTexture(HandleType p_colorbuffer)
bool FrameBuffer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) );
if (c == m_colorbuffers.end()) {
@@ -657,7 +663,7 @@ bool FrameBuffer::bindContext(HandleType p_context,
HandleType p_drawSurface,
HandleType p_readSurface)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
WindowSurfacePtr draw(NULL), read(NULL);
RenderContextPtr ctx(NULL);
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
index de0b71c..f8683b2 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
+++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
@@ -20,7 +20,8 @@
#include "ColorBuffer.h"
#include "RenderContext.h"
#include "WindowSurface.h"
-#include <utils/threads.h>
+#include "emugl/common/mutex.h"
+
#include <map>
#include <EGL/egl.h>
#include <stdint.h>
@@ -72,7 +73,7 @@ public:
HandleType createColorBuffer(int p_width, int p_height, GLenum p_internalFormat);
void DestroyRenderContext(HandleType p_context);
void DestroyWindowSurface(HandleType p_surface);
- void openColorBuffer(HandleType p_colorbuffer);
+ int openColorBuffer(HandleType p_colorbuffer);
void closeColorBuffer(HandleType p_colorbuffer);
bool bindContext(HandleType p_context, HandleType p_drawSurface, HandleType p_readSurface);
@@ -111,7 +112,7 @@ private:
int m_y;
int m_width;
int m_height;
- android::Mutex m_lock;
+ emugl::Mutex m_lock;
FBNativeWindowType m_nativeWindow;
FrameBufferCaps m_caps;
EGLDisplay m_eglDisplay;
diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderContext.h b/emulator/opengl/host/libs/libOpenglRender/RenderContext.h
index 9cbb5fc..80ac43f 100644
--- a/emulator/opengl/host/libs/libOpenglRender/RenderContext.h
+++ b/emulator/opengl/host/libs/libOpenglRender/RenderContext.h
@@ -16,12 +16,12 @@
#ifndef _LIBRENDER_RENDERCONTEXT_H
#define _LIBRENDER_RENDERCONTEXT_H
-#include "SmartPtr.h"
+#include "emugl/common/smart_ptr.h"
#include <EGL/egl.h>
#include "GLDecoderContextData.h"
class RenderContext;
-typedef SmartPtr<RenderContext> RenderContextPtr;
+typedef emugl::SmartPtr<RenderContext> RenderContextPtr;
class RenderContext
{
diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp
index 6a15138..83ba9c5 100644
--- a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp
@@ -215,13 +215,20 @@ static uint32_t rcCreateColorBuffer(uint32_t width,
return fb->createColorBuffer(width, height, internalFormat);
}
-static void rcOpenColorBuffer(uint32_t colorbuffer)
+static int rcOpenColorBuffer2(uint32_t colorbuffer)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
- return;
+ return -1;
}
- fb->openColorBuffer( colorbuffer );
+ return fb->openColorBuffer( colorbuffer );
+}
+
+// Deprecated, kept for compatibility with old system images only.
+// Use rcOpenColorBuffer2 instead.
+static void rcOpenColorBuffer(uint32_t colorbuffer)
+{
+ (void) rcOpenColorBuffer2(colorbuffer);
}
static void rcCloseColorBuffer(uint32_t colorbuffer)
@@ -359,4 +366,5 @@ void initRenderControlContext(renderControl_decoder_context_t *dec)
dec->set_rcColorBufferCacheFlush(rcColorBufferCacheFlush);
dec->set_rcReadColorBuffer(rcReadColorBuffer);
dec->set_rcUpdateColorBuffer(rcUpdateColorBuffer);
+ dec->set_rcOpenColorBuffer2(rcOpenColorBuffer2);
}
diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp
index 1b2c0fe..9ae2a43 100644
--- a/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp
@@ -94,7 +94,7 @@ int RenderThread::Main()
stats_totalBytes += readBuf.validData();
long long dt = GetCurrentTimeMS() - stats_t0;
if (dt > 1000) {
- float dts = (float)dt / 1000.0f;
+ //float dts = (float)dt / 1000.0f;
//printf("Used Bandwidth %5.3f MB/s\n", ((float)stats_totalBytes / dts) / (1024.0f*1024.0f));
stats_totalBytes = 0;
stats_t0 = GetCurrentTimeMS();
diff --git a/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp b/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp
index 566ca40..5337009 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp
@@ -15,17 +15,28 @@
*/
#include "ThreadInfo.h"
-#include <cutils/threads.h>
+#include "emugl/common/lazy_instance.h"
+#include "emugl/common/thread_store.h"
-static thread_store_t s_tls = THREAD_STORE_INITIALIZER;
+namespace {
+
+class ThreadInfoStore : public ::emugl::ThreadStore {
+public:
+ ThreadInfoStore() : ::emugl::ThreadStore(NULL) {}
+};
+
+} // namespace
+
+static ::emugl::LazyInstance<ThreadInfoStore> s_tls = LAZY_INSTANCE_INIT;
RenderThreadInfo::RenderThreadInfo() {
- thread_store_set(&s_tls, this, NULL);
+ s_tls->set(this);
}
RenderThreadInfo::~RenderThreadInfo() {
+ s_tls->set(NULL);
}
RenderThreadInfo* RenderThreadInfo::get() {
- return (RenderThreadInfo*)thread_store_get(&s_tls);
+ return static_cast<RenderThreadInfo*>(s_tls->get());
}
diff --git a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp
index 9c32ff8..bdda01a 100644
--- a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp
@@ -58,9 +58,6 @@ WindowSurface *WindowSurface::create(int p_config, int p_width, int p_height)
}
win->m_fbconf = fbconf;
- FrameBuffer *fb = FrameBuffer::getFB();
- const FrameBufferCaps &caps = fb->getCaps();
-
//
// Create a pbuffer to be used as the egl surface
// for that window.
@@ -209,8 +206,6 @@ bool WindowSurface::resizePbuffer(unsigned int p_width, unsigned int p_height)
m_eglSurface = NULL;
}
- const FrameBufferCaps &caps = fb->getCaps();
-
//
// Create pbuffer surface.
//
diff --git a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h
index e9f1f7d..fe35a94 100644
--- a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h
+++ b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h
@@ -19,7 +19,7 @@
#include "ColorBuffer.h"
#include "RenderContext.h"
#include "FBConfig.h"
-#include "SmartPtr.h"
+#include "emugl/common/smart_ptr.h"
#include "FixedBuffer.h"
#include <EGL/egl.h>
#include <GLES/gl.h>
@@ -66,6 +66,6 @@ private:
const FBConfig *m_fbconf;
};
-typedef SmartPtr<WindowSurface> WindowSurfacePtr;
+typedef emugl::SmartPtr<WindowSurface> WindowSurfacePtr;
#endif
diff --git a/emulator/opengl/host/libs/renderControl_dec/Android.mk b/emulator/opengl/host/libs/renderControl_dec/Android.mk
index 1063532..4a97a93 100644
--- a/emulator/opengl/host/libs/renderControl_dec/Android.mk
+++ b/emulator/opengl/host/libs/renderControl_dec/Android.mk
@@ -10,10 +10,12 @@ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
$(call emugl-end-module)
### host library, 64-bit ####################################
-$(call emugl-begin-host-static-library,lib64_renderControl_dec)
-$(call emugl-import,lib64OpenglCodecCommon)
-$(call emugl-gen-decoder,$(LOCAL_PATH),renderControl)
-# For renderControl_types.h
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-$(call emugl-export,CFLAGS,-m64)
-$(call emugl-end-module)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64_renderControl_dec)
+ $(call emugl-import,lib64OpenglCodecCommon)
+ $(call emugl-gen-decoder,$(LOCAL_PATH),renderControl)
+ # For renderControl_types.h
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ $(call emugl-export,CFLAGS,-m64)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/renderControl_dec/renderControl.in b/emulator/opengl/host/libs/renderControl_dec/renderControl.in
index 8281fd9..55539f9 100644
--- a/emulator/opengl/host/libs/renderControl_dec/renderControl.in
+++ b/emulator/opengl/host/libs/renderControl_dec/renderControl.in
@@ -23,3 +23,4 @@ GL_ENTRY(void, rcBindRenderbuffer, uint32_t colorBuffer)
GL_ENTRY(EGLint, rcColorBufferCacheFlush, uint32_t colorbuffer, EGLint postCount,int forRead)
GL_ENTRY(void, rcReadColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
GL_ENTRY(int, rcUpdateColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
+GL_ENTRY(int, rcOpenColorBuffer2, uint32_t colorbuffer)
diff --git a/emulator/opengl/host/renderer/main.cpp b/emulator/opengl/host/renderer/main.cpp
index d2e3f72..2c3f8e2 100644
--- a/emulator/opengl/host/renderer/main.cpp
+++ b/emulator/opengl/host/renderer/main.cpp
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
int winY = 0;
int winWidth = 320;
int winHeight = 480;
- FBNativeWindowType windowId = NULL;
+ FBNativeWindowType windowId = 0;
int iWindowId = 0;
//
diff --git a/emulator/opengl/host/tools/emugen/Android.mk b/emulator/opengl/host/tools/emugen/Android.mk
index ad9ab06..e2f3939 100644
--- a/emulator/opengl/host/tools/emugen/Android.mk
+++ b/emulator/opengl/host/tools/emugen/Android.mk
@@ -1,15 +1,35 @@
-ifneq ($(HOST_OS),windows)
+# Determine if the emugen build needs to be builts from
+# sources.
+EMUGL_BUILD_EMUGEN :=
+ifeq (true,$(BUILD_STANDALONE_EMULATOR))
+ # The emulator's standalone build system can build host Linux
+ # binaries even when it targets Windows by setting
+ # LOCAL_HOST_BUILD to true, so rebuild from sources.
+ EMUGL_BUILD_EMUGEN := true
+else
+ ifneq ($(HOST_OS),windows)
+ # The platform build can only build emugen when targetting
+ # the same host sytem.
+ EMUGL_BUILD_EMUGEN := true
+ endif
+endif
LOCAL_PATH:=$(call my-dir)
+ifeq (true,$(EMUGL_BUILD_EMUGEN))
+
$(call emugl-begin-host-executable,emugen)
- LOCAL_SRC_FILES := \
- ApiGen.cpp \
- EntryPoint.cpp \
- main.cpp \
- strUtils.cpp \
- TypeFactory.cpp
+LOCAL_SRC_FILES := \
+ ApiGen.cpp \
+ EntryPoint.cpp \
+ main.cpp \
+ strUtils.cpp \
+ TypeFactory.cpp \
+
+ifeq (true,$(BUILD_STANDALONE_EMULATOR))
+LOCAL_HOST_BUILD := true
+endif
$(call emugl-end-module)
@@ -17,7 +37,7 @@ $(call emugl-end-module)
# protocol encoders/ decoders. This variable is used by other emugl modules.
EMUGL_EMUGEN := $(LOCAL_BUILT_MODULE)
-else # windows build
+else # windows platform build
# on windows use the build host emugen executable
# (that will be the linux exeutable when using mingw build)
diff --git a/emulator/opengl/host/tools/emugen/ApiGen.cpp b/emulator/opengl/host/tools/emugen/ApiGen.cpp
index 6964862..2e4c8d1 100644
--- a/emulator/opengl/host/tools/emugen/ApiGen.cpp
+++ b/emulator/opengl/host/tools/emugen/ApiGen.cpp
@@ -420,8 +420,8 @@ static void writeVarEncodingExpression(Var& var, FILE* fp)
if (!var.isVoid()) {
fprintf(fp, "\t\tmemcpy(ptr, &%s, %u); ptr += %u;\n",
varname,
- (uint) var.type()->bytes(),
- (uint) var.type()->bytes());
+ (unsigned) var.type()->bytes(),
+ (unsigned) var.type()->bytes());
}
}
}
@@ -645,7 +645,7 @@ int ApiGen::genEncoderImpl(const std::string &filename)
fprintf(fp, "\t return NULL;\n");
} else if (e->retval().type()->name() != "void") {
fprintf(fp, "\n\t%s retval;\n", e->retval().type()->name().c_str());
- fprintf(fp, "\tstream->readback(&retval, %u);\n",(uint) e->retval().type()->bytes());
+ fprintf(fp, "\tstream->readback(&retval, %u);\n",(unsigned) e->retval().type()->bytes());
fprintf(fp, "\treturn retval;\n");
}
fprintf(fp, "}\n\n");
@@ -776,12 +776,10 @@ int ApiGen::genDecoderImpl(const std::string &filename)
\tchar lastCall[256] = {0}; \n\
#endif \n\
\twhile ((len - pos >= 8) && !unknownOpcode) { \n\
-\t\tvoid *params[%u]; \n\
\t\tint opcode = *(int *)ptr; \n\
\t\tunsigned int packetLen = *(int *)(ptr + 4);\n\
\t\tif (len - pos < packetLen) return pos; \n\
-\t\tswitch(opcode) {\n",
- (uint) m_maxEntryPointsParams);
+\t\tswitch(opcode) {\n");
for (size_t f = 0; f < n; f++) {
enum Pass_t { PASS_TmpBuffAlloc = 0, PASS_MemAlloc, PASS_DebugPrint, PASS_FunctionCall, PASS_Epilog, PASS_LAST };
@@ -823,7 +821,8 @@ int ApiGen::genDecoderImpl(const std::string &filename)
}
} else if (pass == PASS_DebugPrint) {
fprintf(fp, "#ifdef DEBUG_PRINTOUT\n");
- fprintf(fp, "\t\t\tfprintf(stderr,\"%s: %s(%s)\\n\"", m_basename.c_str(), e->name().c_str(), printString.c_str());
+ fprintf(fp, "\t\t\tfprintf(stderr,\"%s(%%p): %s(%s)\\n\", stream",
+ m_basename.c_str(), e->name().c_str(), printString.c_str());
if (e->vars().size() > 0 && !e->vars()[0].isVoid()) fprintf(fp, ",");
}
@@ -845,9 +844,9 @@ int ApiGen::genDecoderImpl(const std::string &filename)
if (v->pointerDir() == Var::POINTER_IN || v->pointerDir() == Var::POINTER_INOUT) {
if (pass == PASS_MemAlloc && v->pointerDir() == Var::POINTER_INOUT) {
fprintf(fp, "\t\t\tsize_t tmpPtr%uSize = (size_t)*(unsigned int *)(ptr + %s);\n",
- (uint) j, varoffset.c_str());
+ (unsigned) j, varoffset.c_str());
fprintf(fp, "unsigned char *tmpPtr%u = (ptr + %s + 4);\n",
- (uint) j, varoffset.c_str());
+ (unsigned) j, varoffset.c_str());
}
if (pass == PASS_FunctionCall) {
if (v->nullAllowed()) {
@@ -866,30 +865,33 @@ int ApiGen::genDecoderImpl(const std::string &filename)
} else { // out pointer;
if (pass == PASS_TmpBuffAlloc) {
fprintf(fp, "\t\t\tsize_t tmpPtr%uSize = (size_t)*(unsigned int *)(ptr + %s);\n",
- (uint) j, varoffset.c_str());
+ (unsigned) j, varoffset.c_str());
if (!totalTmpBuffExist) {
- fprintf(fp, "\t\t\tsize_t totalTmpSize = tmpPtr%uSize;\n", (uint)j);
+ fprintf(fp, "\t\t\tsize_t totalTmpSize = tmpPtr%uSize;\n", (unsigned)j);
} else {
- fprintf(fp, "\t\t\ttotalTmpSize += tmpPtr%uSize;\n", (uint)j);
+ fprintf(fp, "\t\t\ttotalTmpSize += tmpPtr%uSize;\n", (unsigned)j);
}
tmpBufOffset[j] = totalTmpBuffOffset;
char tmpPtrName[16];
- sprintf(tmpPtrName," + tmpPtr%uSize", (uint)j);
+ sprintf(tmpPtrName," + tmpPtr%uSize", (unsigned)j);
totalTmpBuffOffset += std::string(tmpPtrName);
totalTmpBuffExist = true;
} else if (pass == PASS_MemAlloc) {
fprintf(fp, "\t\t\tunsigned char *tmpPtr%u = &tmpBuf[%s];\n",
- (uint)j, tmpBufOffset[j].c_str());
+ (unsigned)j, tmpBufOffset[j].c_str());
+ fprintf(fp, "\t\t\tmemset(tmpPtr%u, 0, %s);\n",
+ (unsigned)j,
+ toString(v->type()->bytes()).c_str());
} else if (pass == PASS_FunctionCall) {
if (v->nullAllowed()) {
fprintf(fp, "tmpPtr%uSize == 0 ? NULL : (%s)(tmpPtr%u)",
- (uint) j, v->type()->name().c_str(), (uint) j);
+ (unsigned) j, v->type()->name().c_str(), (unsigned) j);
} else {
- fprintf(fp, "(%s)(tmpPtr%u)", v->type()->name().c_str(), (uint) j);
+ fprintf(fp, "(%s)(tmpPtr%u)", v->type()->name().c_str(), (unsigned) j);
}
} else if (pass == PASS_DebugPrint) {
fprintf(fp, "(%s)(tmpPtr%u), *(unsigned int *)(ptr + %s)",
- v->type()->name().c_str(), (uint) j,
+ v->type()->name().c_str(), (unsigned) j,
varoffset.c_str());
}
varoffset += " + 4";
@@ -939,7 +941,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
fprintf(fp, "\t\t} //switch\n");
if (strstr(m_basename.c_str(), "gl")) {
fprintf(fp, "#ifdef CHECK_GL_ERROR\n");
- fprintf(fp, "\tint err = this->glGetError();\n");
+ fprintf(fp, "\tint err = lastCall[0] ? this->glGetError() : GL_NO_ERROR;\n");
fprintf(fp, "\tif (err) fprintf(stderr, \"%s Error: 0x%%X in %%s\\n\", err, lastCall);\n", m_basename.c_str());
fprintf(fp, "#endif\n");
}
@@ -1036,7 +1038,7 @@ int ApiGen::setGlobalAttribute(const std::string & line, size_t lc)
if (token == "base_opcode") {
std::string str = getNextToken(line, pos, &last, WHITESPACE);
if (str.size() == 0) {
- fprintf(stderr, "line %u: missing value for base_opcode\n", (uint) lc);
+ fprintf(stderr, "line %u: missing value for base_opcode\n", (unsigned) lc);
} else {
setBaseOpcode(atoi(str.c_str()));
}
diff --git a/emulator/opengl/host/tools/emugen/ApiGen.h b/emulator/opengl/host/tools/emugen/ApiGen.h
index 1627ef6..8ba18af 100644
--- a/emulator/opengl/host/tools/emugen/ApiGen.h
+++ b/emulator/opengl/host/tools/emugen/ApiGen.h
@@ -54,6 +54,8 @@ public:
case WRAPPER_SIDE:
retval = "wrapper";
break;
+ default:
+ retval = "unknown";
}
return retval;
}
diff --git a/emulator/opengl/host/tools/emugen/getopt.c b/emulator/opengl/host/tools/emugen/getopt.c
new file mode 100644
index 0000000..3523538
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/getopt.c
@@ -0,0 +1,76 @@
+#include "getopt.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#define _getprogname() nargv[0]
+
+int opterr = 1;
+int optind = 1;
+int optopt = 0;
+char* optarg;
+
+int getopt(int argc, char* const argv[], const char* ostr) {
+ static const char kEmpty[] = "";
+ static const char* place = kEmpty;
+ if (!*place) {
+ if (optind >= argc)
+ return -1;
+
+ const char* arg = argv[optind];
+ if (arg[0] != '-') {
+ // Not an option.
+ return -1;
+ }
+ if (arg[1] == '-' && !arg[2]) {
+ // '--' -> end of options.
+ return -1;
+ }
+ if (!arg[1]) {
+ // Single '-', If the program wants it, treat it as an option.
+ // Otherwise, it's the end of options.
+ if (!strchr(ostr, '-')) {
+ return -1;
+ }
+ optopt = '-';
+ place = arg + 1;
+ } else {
+ optopt = arg[1];
+ place = arg + 2;
+ }
+ };
+
+ char* oindex = strchr(ostr, optopt);
+ if (!oindex) {
+ // Unsupported option.
+ (void)fprintf(stderr, "%s: illegal option -- %c\n", argv[0]);
+ return '?';
+ }
+ if (oindex[1] != ':') {
+ // No argument needed.
+ optarg = NULL;
+ if (!*place)
+ optind++;
+ return optopt;
+ }
+
+ // This option needs an argument. Either after the option character,
+ // or the argument that follows.
+ if (*place) {
+ optarg = (char *)place;
+ } else if (argc > ++optind) {
+ optarg = (char *)argv[optind];
+ } else if (oindex[2] == ':') {
+ // Optional argument is missing.
+ place = kEmpty;
+ optarg = NULL;
+ return optopt;
+ } else {
+ // Missing argument.
+ place = kEmpty;
+ (void)fprintf(stderr, "%s: option requires an argument --%c\n",
+ argv[0], optopt);
+ return ':';
+ }
+ return optopt;
+}
diff --git a/emulator/opengl/host/tools/emugen/getopt.h b/emulator/opengl/host/tools/emugen/getopt.h
new file mode 100644
index 0000000..cc04850
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/getopt.h
@@ -0,0 +1,18 @@
+#ifndef GETOPT_H
+#define GETOPT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int optind;
+extern char* optarg;
+extern int optopt;
+
+int getopt(int argc, char* const argv[], const char* ostr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // GETOPT_H
diff --git a/emulator/opengl/host/tools/emugen/main.cpp b/emulator/opengl/host/tools/emugen/main.cpp
index 96377f2..c0c24e9 100644
--- a/emulator/opengl/host/tools/emugen/main.cpp
+++ b/emulator/opengl/host/tools/emugen/main.cpp
@@ -20,6 +20,7 @@
#include "strUtils.h"
#include "ApiGen.h"
#include "TypeFactory.h"
+#include "getopt.h"
const std::string SPEC_EXTENSION = std::string(".in");
const std::string ATTRIB_EXTENSION = std::string(".attrib");