Change-Id: I41f097b5b96c4d000b1748b9e0411497d323556a
This commit is contained in:
Jean-Baptiste Queru
2012-03-22 12:57:54 -07:00
10 changed files with 76 additions and 30 deletions

View File

@@ -17,6 +17,7 @@
#include "EglOsApi.h"
#include <GLcommon/GLutils.h>
#include <utils/threads.h>
#include <assert.h>
EglDisplay::EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault) :
m_dpy(dpy),
@@ -141,8 +142,12 @@ EglConfig* EglDisplay::getConfig(EGLConfig conf) {
SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
android::Mutex::Autolock mutex(m_lock);
SurfacesHndlMap::iterator it = m_surfaces.find(reinterpret_cast<unsigned int>(surface));
/* surface is "key" in map<unsigned int, SurfacePtr>.
In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)surface;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
return it != m_surfaces.end() ?
(*it).second :
SurfacePtr(NULL);
@@ -150,8 +155,12 @@ SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
ContextPtr EglDisplay::getContext(EGLContext ctx) {
android::Mutex::Autolock mutex(m_lock);
ContextsHndlMap::iterator it = m_contexts.find(reinterpret_cast<unsigned int>(ctx));
/* ctx is "key" in map<unsigned int, ContextPtr>.
In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)ctx;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
ContextsHndlMap::iterator it = m_contexts.find(hndl);
return it != m_contexts.end() ?
(*it).second :
ContextPtr(NULL);
@@ -159,8 +168,12 @@ ContextPtr EglDisplay::getContext(EGLContext ctx) {
bool EglDisplay::removeSurface(EGLSurface s) {
android::Mutex::Autolock mutex(m_lock);
SurfacesHndlMap::iterator it = m_surfaces.find(reinterpret_cast<unsigned int>(s));
/* s is "key" in map<unsigned int, SurfacePtr>.
In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)s;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
if(it != m_surfaces.end()) {
m_surfaces.erase(it);
return true;
@@ -187,8 +200,12 @@ bool EglDisplay::removeSurface(SurfacePtr s) {
bool EglDisplay::removeContext(EGLContext ctx) {
android::Mutex::Autolock mutex(m_lock);
ContextsHndlMap::iterator it = m_contexts.find(reinterpret_cast<unsigned int>(ctx));
/* ctx is "key" in map<unsigned int, ContextPtr>.
In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)ctx;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
ContextsHndlMap::iterator it = m_contexts.find(hndl);
if(it != m_contexts.end()) {
m_contexts.erase(it);
return true;
@@ -254,7 +271,7 @@ int EglDisplay::doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int co
}
EGLSurface EglDisplay::addSurface(SurfacePtr s ) {
android::Mutex::Autolock mutex(m_lock);
android::Mutex::Autolock mutex(m_lock);
unsigned int hndl = s.Ptr()->getHndl();
EGLSurface ret =reinterpret_cast<EGLSurface> (hndl);
@@ -290,13 +307,23 @@ EGLImageKHR EglDisplay::addImageKHR(ImagePtr img) {
ImagePtr EglDisplay::getImage(EGLImageKHR img) {
android::Mutex::Autolock mutex(m_lock);
ImagesHndlMap::iterator i( m_eglImages.find((unsigned int)img) );
/* img is "key" in map<unsigned int, ImagePtr>.
In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)img;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
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);
ImagesHndlMap::iterator i( m_eglImages.find((unsigned int)img) );
/* img is "key" in map<unsigned int, ImagePtr>.
In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)img;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
ImagesHndlMap::iterator i( m_eglImages.find(hndl) );
if (i != m_eglImages.end())
{
m_eglImages.erase(i);

View File

@@ -1041,13 +1041,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, (unsigned int)buffer);
unsigned int globalTexName = sg->getGlobalName(TEXTURE, (uintptr_t)buffer);
if (!globalTexName) return EGL_NO_IMAGE_KHR;
ImagePtr img( new EglImage() );
if (img.Ptr() != NULL) {
ObjectDataPtr objData = sg->getObjectData(TEXTURE, (unsigned int)buffer);
ObjectDataPtr objData = sg->getObjectData(TEXTURE, (uintptr_t)buffer);
if (!objData.Ptr()) return EGL_NO_IMAGE_KHR;
TextureData *texData = (TextureData *)objData.Ptr();

View File

@@ -35,6 +35,7 @@
#include <GLES/glext.h>
#include <cmath>
#include <map>
#include <assert.h>
extern "C" {
@@ -585,7 +586,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<unsigned int>(elementsIndices);
indices = buf+reinterpret_cast<uintptr_t>(elementsIndices);
}
ctx->setupArraysPointers(tmpArrs,0,count,type,indices,false);
@@ -1655,7 +1656,10 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
{
GET_CTX();
SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM);
EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image);
uintptr_t imagehndlptr = (uintptr_t)image;
unsigned int imagehndl = (unsigned int)imagehndlptr;
assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
if (img) {
// Create the texture object in the underlying EGL implementation,
// flag to the OpenGL layer to skip the image creation and map the
@@ -1679,7 +1683,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
texData->height = img->height;
texData->border = img->border;
texData->internalFormat = img->internalFormat;
texData->sourceEGLImage = (unsigned int)image;
texData->sourceEGLImage = imagehndl;
texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
texData->oldGlobal = oldGlobal;
}
@@ -1690,7 +1694,10 @@ GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GL
{
GET_CTX();
SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image);
uintptr_t imagehndlptr = (uintptr_t)image;
unsigned int imagehndl = (unsigned int)imagehndlptr;
assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
SET_ERROR_IF(!img,GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
@@ -1705,7 +1712,7 @@ GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GL
//
// flag in the renderbufferData that it is an eglImage target
//
rbData->sourceEGLImage = (unsigned int)image;
rbData->sourceEGLImage = imagehndl;
rbData->eglImageDetach = s_eglIface->eglDetachEGLImage;
rbData->eglImageGlobalTexName = img->globalTexName;

View File

@@ -32,6 +32,7 @@
#include "ProgramData.h"
#include <GLcommon/TextureUtils.h>
#include <GLcommon/FramebufferData.h>
#include <assert.h>
extern "C" {
@@ -593,7 +594,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<unsigned int>(elementsIndices);
indices = buf+reinterpret_cast<uintptr_t>(elementsIndices);
}
GLESConversionArrays tmpArrs;
@@ -2008,7 +2009,10 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma
{
GET_CTX();
SET_ERROR_IF(!GLESv2Validate::textureTargetLimited(target),GL_INVALID_ENUM);
EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image);
uintptr_t imagehndlptr = (uintptr_t)image;
unsigned int imagehndl = (unsigned int)imagehndlptr;
assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
if (img) {
// Create the texture object in the underlying EGL implementation,
// flag to the OpenGL layer to skip the image creation and map the
@@ -2032,7 +2036,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma
texData->height = img->height;
texData->border = img->border;
texData->internalFormat = img->internalFormat;
texData->sourceEGLImage = (unsigned int)image;
texData->sourceEGLImage = (unsigned int)imagehndl;
texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
texData->oldGlobal = oldGlobal;
}
@@ -2043,7 +2047,10 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target
{
GET_CTX();
SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image);
uintptr_t imagehndlptr = (uintptr_t)image;
unsigned int imagehndl = (unsigned int)imagehndlptr;
assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
SET_ERROR_IF(!img,GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
@@ -2058,7 +2065,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target
//
// flag in the renderbufferData that it is an eglImage target
//
rbData->sourceEGLImage = (unsigned int)image;
rbData->sourceEGLImage = imagehndl;
rbData->eglImageDetach = s_eglIface->eglDetachEGLImage;
rbData->eglImageGlobalTexName = img->globalTexName;

View File

@@ -7,6 +7,7 @@
#include <GLcommon/TextureUtils.h>
#include <GLcommon/FramebufferData.h>
#include <strings.h>
#include <assert.h>
//decleration
static void convertFixedDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize);
@@ -173,7 +174,9 @@ 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 = reinterpret_cast<unsigned int>(data);
uintptr_t offsetptr = (uintptr_t)data;
unsigned int offset = offsetptr;
assert(sizeof(offset) == sizeof(offsetptr) || offset == offsetptr);
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;

View File

@@ -50,7 +50,7 @@ int ReadBuffer::getData()
new_buf = (unsigned char*)realloc(m_buf, new_size);
if (!new_buf) {
ERR("Failed to alloc %d bytes for ReadBuffer\n", new_size);
ERR("Failed to alloc %zu bytes for ReadBuffer\n", new_size);
return -1;
}
m_size = new_size;

View File

@@ -519,7 +519,7 @@ int ApiGen::genEncoderImpl(const std::string &filename)
npointers += writeVarEncodingSize(evars[j], fp);
}
if (npointers > 0) {
fprintf(fp, " + %u*4", npointers);
fprintf(fp, " + %zu*4", npointers);
}
fprintf(fp, ";\n");
@@ -561,7 +561,7 @@ int ApiGen::genEncoderImpl(const std::string &filename)
npointers += writeVarEncodingSize(evars[j], fp);
}
if (npointers > 0) {
fprintf(fp, "%s%u*4", plus, npointers); plus = " + ";
fprintf(fp, "%s%zu*4", plus, npointers); plus = " + ";
}
}
fprintf(fp,");\n");
@@ -760,6 +760,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
fprintf(fp, "#include \"%s_opcodes.h\"\n\n", m_basename.c_str());
fprintf(fp, "#include \"%s_dec.h\"\n\n\n", m_basename.c_str());
fprintf(fp, "#include <stdio.h>\n\n");
fprintf(fp, "typedef unsigned int tsize_t; // Target \"size_t\", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.\n\n");
// decoder switch;
fprintf(fp, "size_t %s::decode(void *buf, size_t len, IOStream *stream)\n{\n", classname.c_str());
@@ -859,7 +860,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
v->type()->name().c_str(), varoffset.c_str(),
varoffset.c_str());
}
varoffset += " + 4 + *(size_t *)(ptr +" + varoffset + ")";
varoffset += " + 4 + *(tsize_t *)(ptr +" + varoffset + ")";
} else { // out pointer;
if (pass == PASS_TmpBuffAlloc) {
fprintf(fp, "\t\t\tsize_t tmpPtr%uSize = (size_t)*(unsigned int *)(ptr + %s);\n",

View File

@@ -73,7 +73,7 @@ void *SocketStream::allocBuffer(size_t minSize)
m_buf = p;
m_bufsize = allocSize;
} else {
ERR("%s: realloc (%d) failed\n", __FUNCTION__, allocSize);
ERR("%s: realloc (%zu) failed\n", __FUNCTION__, allocSize);
free(m_buf);
m_buf = NULL;
m_bufsize = 0;

View File

@@ -20,6 +20,7 @@
#include <windows.h>
#else // !WIN32
#include <pthread.h>
#include <inttypes.h>
#endif
namespace osUtils {

View File

@@ -84,7 +84,7 @@ Thread::thread_main(void *p_arg)
pthread_mutex_lock(&self->m_lock);
self->m_isRunning = false;
self->m_exitStatus = (int)ret;
self->m_exitStatus = (int)(intptr_t)ret;
pthread_mutex_unlock(&self->m_lock);
return ret;