Import EGL/GLES translator
This commit is contained in:
parent
7644d86e40
commit
085e3c56a3
91 changed files with 17910 additions and 8 deletions
72
external/android-emugl/host/libs/Translator/include/GLcommon/FramebufferData.h
vendored
Normal file
72
external/android-emugl/host/libs/Translator/include/GLcommon/FramebufferData.h
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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 _FRAMEBUFFER_DATA_H
|
||||
#define _FRAMEBUFFER_DATA_H
|
||||
|
||||
#include "objectNameManager.h"
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
|
||||
class RenderbufferData : public ObjectData
|
||||
{
|
||||
public:
|
||||
RenderbufferData();
|
||||
~RenderbufferData();
|
||||
|
||||
unsigned int sourceEGLImage;
|
||||
void (*eglImageDetach)(unsigned int imageId);
|
||||
GLuint attachedFB;
|
||||
GLenum attachedPoint;
|
||||
GLuint eglImageGlobalTexName;
|
||||
|
||||
};
|
||||
|
||||
const int MAX_ATTACH_POINTS = 3;
|
||||
|
||||
class FramebufferData : public ObjectData
|
||||
{
|
||||
public:
|
||||
explicit FramebufferData(GLuint name);
|
||||
~FramebufferData();
|
||||
|
||||
void setAttachment(GLenum attachment,
|
||||
GLenum target,
|
||||
GLuint name,
|
||||
ObjectDataPtr obj,
|
||||
bool takeOwnership = false);
|
||||
|
||||
GLuint getAttachment(GLenum attachment,
|
||||
GLenum *outTarget,
|
||||
ObjectDataPtr *outObj);
|
||||
|
||||
void validate(class GLEScontext* ctx);
|
||||
|
||||
private:
|
||||
inline int attachmentPointIndex(GLenum attachment);
|
||||
void detachObject(int idx);
|
||||
|
||||
private:
|
||||
GLuint m_fbName;
|
||||
struct attachPoint {
|
||||
GLenum target; // OGL if owned, GLES otherwise
|
||||
GLuint name; // OGL if owned, GLES otherwise
|
||||
ObjectDataPtr obj;
|
||||
bool owned;
|
||||
} m_attachPoints[MAX_ATTACH_POINTS+1];
|
||||
bool m_dirty;
|
||||
};
|
||||
|
||||
#endif
|
||||
50
external/android-emugl/host/libs/Translator/include/GLcommon/GLDispatch.h
vendored
Normal file
50
external/android-emugl/host/libs/Translator/include/GLcommon/GLDispatch.h
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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 GL_DISPATCHH
|
||||
#define GL_DISPATCHH
|
||||
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
#include "OpenGLESDispatch/gldefs.h"
|
||||
#include "OpenGLESDispatch/gles_functions.h"
|
||||
#include "GLutils.h"
|
||||
|
||||
#include "emugl/common/mutex.h"
|
||||
|
||||
#define GLAPIENTRY GL_APIENTRY
|
||||
typedef void(*FUNCPTR)();
|
||||
|
||||
class GlLibrary;
|
||||
|
||||
#define GLES_DECLARE_METHOD(return_type, function_name, signature, args) \
|
||||
static GL_APICALL return_type (GL_APIENTRY *function_name) signature;
|
||||
|
||||
class GLDispatch {
|
||||
public:
|
||||
// Constructor.
|
||||
GLDispatch();
|
||||
|
||||
void dispatchFuncs(GLESVersion version, GlLibrary* glLib);
|
||||
|
||||
LIST_GLES_FUNCTIONS(GLES_DECLARE_METHOD, GLES_DECLARE_METHOD)
|
||||
|
||||
private:
|
||||
bool m_isLoaded;
|
||||
static emugl::Mutex s_lock;
|
||||
};
|
||||
|
||||
#endif // GL_DISPATCH_H
|
||||
47
external/android-emugl/host/libs/Translator/include/GLcommon/GLESbuffer.h
vendored
Normal file
47
external/android-emugl/host/libs/Translator/include/GLcommon/GLESbuffer.h
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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 GLES_BUFFER_H
|
||||
#define GLES_BUFFER_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <GLcommon/objectNameManager.h>
|
||||
#include <GLcommon/RangeManip.h>
|
||||
|
||||
class GLESbuffer: public ObjectData {
|
||||
public:
|
||||
GLESbuffer():ObjectData(BUFFER_DATA),m_size(0),m_usage(GL_STATIC_DRAW),m_data(NULL),m_wasBound(false){}
|
||||
GLuint getSize(){return m_size;};
|
||||
GLuint getUsage(){return m_usage;};
|
||||
GLvoid* getData(){ return m_data;}
|
||||
bool setBuffer(GLuint size,GLuint usage,const GLvoid* data);
|
||||
bool setSubBuffer(GLint offset,GLuint size,const GLvoid* data);
|
||||
void getConversions(const RangeList& rIn,RangeList& rOut);
|
||||
bool fullyConverted(){return m_conversionManager.size() == 0;};
|
||||
void setBinded(){m_wasBound = true;};
|
||||
bool wasBinded(){return m_wasBound;};
|
||||
~GLESbuffer();
|
||||
|
||||
private:
|
||||
GLuint m_size;
|
||||
GLuint m_usage;
|
||||
unsigned char* m_data;
|
||||
RangeList m_conversionManager;
|
||||
bool m_wasBound;
|
||||
};
|
||||
|
||||
typedef emugl::SmartPtr<GLESbuffer> GLESbufferPtr;
|
||||
#endif
|
||||
222
external/android-emugl/host/libs/Translator/include/GLcommon/GLEScontext.h
vendored
Normal file
222
external/android-emugl/host/libs/Translator/include/GLcommon/GLEScontext.h
vendored
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
* Copyright 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 GLES_CONTEXT_H
|
||||
#define GLES_CONTEXT_H
|
||||
|
||||
#include "GLDispatch.h"
|
||||
#include "GLESpointer.h"
|
||||
#include "objectNameManager.h"
|
||||
#include "emugl/common/mutex.h"
|
||||
#include <string>
|
||||
|
||||
typedef std::map<GLenum,GLESpointer*> ArraysMap;
|
||||
|
||||
enum TextureTarget {
|
||||
TEXTURE_2D,
|
||||
TEXTURE_CUBE_MAP,
|
||||
NUM_TEXTURE_TARGETS
|
||||
};
|
||||
|
||||
typedef struct _textureTargetState {
|
||||
GLuint texture;
|
||||
GLboolean enabled;
|
||||
} textureTargetState;
|
||||
|
||||
typedef textureTargetState textureUnitState[NUM_TEXTURE_TARGETS];
|
||||
|
||||
class Version{
|
||||
public:
|
||||
Version();
|
||||
Version(int major,int minor,int release);
|
||||
Version(const char* versionString);
|
||||
Version(const Version& ver);
|
||||
bool operator<(const Version& ver) const;
|
||||
Version& operator=(const Version& ver);
|
||||
private:
|
||||
int m_major;
|
||||
int m_minor;
|
||||
int m_release;
|
||||
};
|
||||
|
||||
struct GLSupport {
|
||||
GLSupport():maxLights(0),maxVertexAttribs(0),maxClipPlane(0),maxTexUnits(0), \
|
||||
maxTexImageUnits(0),maxTexSize(0) , maxCombinedTexImageUnits(0), \
|
||||
GL_EXT_TEXTURE_FORMAT_BGRA8888(false), GL_EXT_FRAMEBUFFER_OBJECT(false), \
|
||||
GL_ARB_VERTEX_BLEND(false), GL_ARB_MATRIX_PALETTE(false), \
|
||||
GL_EXT_PACKED_DEPTH_STENCIL(false) , GL_OES_READ_FORMAT(false), \
|
||||
GL_ARB_HALF_FLOAT_PIXEL(false), GL_NV_HALF_FLOAT(false), \
|
||||
GL_ARB_HALF_FLOAT_VERTEX(false),GL_SGIS_GENERATE_MIPMAP(false),
|
||||
GL_ARB_ES2_COMPATIBILITY(false),GL_OES_STANDARD_DERIVATIVES(false),
|
||||
GL_OES_TEXTURE_NPOT(false), GL_OES_RGB8_RGBA8(false) {} ;
|
||||
int maxLights;
|
||||
int maxVertexAttribs;
|
||||
int maxClipPlane;
|
||||
int maxTexUnits;
|
||||
int maxTexImageUnits;
|
||||
int maxTexSize;
|
||||
int maxCombinedTexImageUnits;
|
||||
Version glslVersion;
|
||||
bool GL_EXT_TEXTURE_FORMAT_BGRA8888;
|
||||
bool GL_EXT_FRAMEBUFFER_OBJECT;
|
||||
bool GL_ARB_VERTEX_BLEND;
|
||||
bool GL_ARB_MATRIX_PALETTE;
|
||||
bool GL_EXT_PACKED_DEPTH_STENCIL;
|
||||
bool GL_OES_READ_FORMAT;
|
||||
bool GL_ARB_HALF_FLOAT_PIXEL;
|
||||
bool GL_NV_HALF_FLOAT;
|
||||
bool GL_ARB_HALF_FLOAT_VERTEX;
|
||||
bool GL_SGIS_GENERATE_MIPMAP;
|
||||
bool GL_ARB_ES2_COMPATIBILITY;
|
||||
bool GL_OES_STANDARD_DERIVATIVES;
|
||||
bool GL_OES_TEXTURE_NPOT;
|
||||
bool GL_OES_RGB8_RGBA8;
|
||||
|
||||
};
|
||||
|
||||
struct ArrayData{
|
||||
ArrayData():data(NULL),
|
||||
type(0),
|
||||
stride(0),
|
||||
allocated(false){};
|
||||
|
||||
void* data;
|
||||
GLenum type;
|
||||
unsigned int stride;
|
||||
bool allocated;
|
||||
};
|
||||
|
||||
class GLESConversionArrays
|
||||
{
|
||||
public:
|
||||
GLESConversionArrays():m_current(0){};
|
||||
void setArr(void* data,unsigned int stride,GLenum type);
|
||||
void allocArr(unsigned int size,GLenum type);
|
||||
ArrayData& operator[](int i);
|
||||
void* getCurrentData();
|
||||
ArrayData& getCurrentArray();
|
||||
unsigned int getCurrentIndex();
|
||||
void operator++();
|
||||
|
||||
~GLESConversionArrays();
|
||||
private:
|
||||
std::map<GLenum,ArrayData> m_arrays;
|
||||
unsigned int m_current;
|
||||
};
|
||||
|
||||
class GLEScontext{
|
||||
public:
|
||||
virtual void init(GlLibrary* glLib);
|
||||
GLEScontext();
|
||||
GLenum getGLerror();
|
||||
void setGLerror(GLenum err);
|
||||
void setShareGroup(ShareGroupPtr grp){m_shareGroup = grp;};
|
||||
ShareGroupPtr shareGroup() const { return m_shareGroup; }
|
||||
virtual void setActiveTexture(GLenum tex);
|
||||
unsigned int getBindedTexture(GLenum target);
|
||||
unsigned int getBindedTexture(GLenum unit,GLenum target);
|
||||
void setBindedTexture(GLenum target,unsigned int tex);
|
||||
bool isTextureUnitEnabled(GLenum unit);
|
||||
void setTextureEnabled(GLenum target, GLenum enable);
|
||||
ObjectLocalName getDefaultTextureName(GLenum target);
|
||||
bool isInitialized() { return m_initialized; };
|
||||
void setUnpackAlignment(GLint param){ m_unpackAlignment = param; };
|
||||
GLint getUnpackAlignment(){ return m_unpackAlignment; };
|
||||
|
||||
bool isArrEnabled(GLenum);
|
||||
void enableArr(GLenum arr,bool enable);
|
||||
const GLvoid* setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize = false);
|
||||
virtual const GLESpointer* getPointer(GLenum arrType);
|
||||
virtual void setupArraysPointers(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct) = 0;
|
||||
void bindBuffer(GLenum target,GLuint buffer);
|
||||
void unbindBuffer(GLuint buffer);
|
||||
bool isBuffer(GLuint buffer);
|
||||
bool isBindedBuffer(GLenum target);
|
||||
GLvoid* getBindedBuffer(GLenum target);
|
||||
void getBufferSize(GLenum target,GLint* param);
|
||||
void getBufferUsage(GLenum target,GLint* param);
|
||||
bool setBufferData(GLenum target,GLsizeiptr size,const GLvoid* data,GLenum usage);
|
||||
bool setBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const GLvoid* data);
|
||||
const char * getExtensionString();
|
||||
const char * getVendorString() const;
|
||||
const char * getRendererString() const;
|
||||
const char * getVersionString() const;
|
||||
void getGlobalLock();
|
||||
void releaseGlobalLock();
|
||||
virtual GLSupport* getCaps(){return &s_glSupport;};
|
||||
virtual ~GLEScontext();
|
||||
virtual int getMaxTexUnits() = 0;
|
||||
virtual void drawValidate(void);
|
||||
|
||||
void setRenderbufferBinding(GLuint rb) { m_renderbuffer = rb; }
|
||||
GLuint getRenderbufferBinding() const { return m_renderbuffer; }
|
||||
void setFramebufferBinding(GLuint fb) { m_framebuffer = fb; }
|
||||
GLuint getFramebufferBinding() const { return m_framebuffer; }
|
||||
|
||||
static GLDispatch& dispatcher(){return s_glDispatch;};
|
||||
|
||||
static int getMaxLights(){return s_glSupport.maxLights;}
|
||||
static int getMaxClipPlanes(){return s_glSupport.maxClipPlane;}
|
||||
static int getMaxTexSize(){return s_glSupport.maxTexSize;}
|
||||
static Version glslVersion(){return s_glSupport.glslVersion;}
|
||||
static bool isAutoMipmapSupported(){return s_glSupport.GL_SGIS_GENERATE_MIPMAP;}
|
||||
static TextureTarget GLTextureTargetToLocal(GLenum target);
|
||||
static unsigned int findMaxIndex(GLsizei count,GLenum type,const GLvoid* indices);
|
||||
|
||||
virtual bool glGetIntegerv(GLenum pname, GLint *params);
|
||||
virtual bool glGetBooleanv(GLenum pname, GLboolean *params);
|
||||
virtual bool glGetFloatv(GLenum pname, GLfloat *params);
|
||||
virtual bool glGetFixedv(GLenum pname, GLfixed *params);
|
||||
|
||||
protected:
|
||||
static void buildStrings(const char* baseVendor, const char* baseRenderer, const char* baseVersion, const char* version);
|
||||
virtual bool needConvert(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id) = 0;
|
||||
void convertDirect(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p);
|
||||
void convertDirectVBO(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p);
|
||||
void convertIndirect(GLESConversionArrays& fArrs,GLsizei count,GLenum type,const GLvoid* indices,GLenum array_id,GLESpointer* p);
|
||||
void convertIndirectVBO(GLESConversionArrays& fArrs,GLsizei count,GLenum indices_type,const GLvoid* indices,GLenum array_id,GLESpointer* p);
|
||||
void initCapsLocked(const GLubyte * extensionString);
|
||||
virtual void initExtensionString() =0;
|
||||
|
||||
static emugl::Mutex s_lock;
|
||||
static GLDispatch s_glDispatch;
|
||||
bool m_initialized;
|
||||
unsigned int m_activeTexture;
|
||||
GLint m_unpackAlignment;
|
||||
ArraysMap m_map;
|
||||
static std::string* s_glExtensions;
|
||||
static GLSupport s_glSupport;
|
||||
|
||||
private:
|
||||
|
||||
virtual void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride, GLboolean normalized, int pointsIndex = -1) = 0 ;
|
||||
GLuint getBuffer(GLenum target);
|
||||
|
||||
ShareGroupPtr m_shareGroup;
|
||||
GLenum m_glError;
|
||||
textureUnitState* m_texState;
|
||||
unsigned int m_arrayBuffer;
|
||||
unsigned int m_elementBuffer;
|
||||
GLuint m_renderbuffer;
|
||||
GLuint m_framebuffer;
|
||||
|
||||
static std::string s_glVendor;
|
||||
static std::string s_glRenderer;
|
||||
static std::string s_glVersion;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
48
external/android-emugl/host/libs/Translator/include/GLcommon/GLESmacros.h
vendored
Normal file
48
external/android-emugl/host/libs/Translator/include/GLcommon/GLESmacros.h
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef GLES_MACROS_H
|
||||
#define GLES_MACROS_H
|
||||
|
||||
#define GET_CTX() \
|
||||
if(!s_eglIface) return; \
|
||||
GLEScontext *ctx = s_eglIface->getGLESContext(); \
|
||||
if(!ctx) return;
|
||||
|
||||
#define GET_CTX_CM() \
|
||||
if(!s_eglIface) return; \
|
||||
GLEScmContext *ctx = static_cast<GLEScmContext *>(s_eglIface->getGLESContext()); \
|
||||
if(!ctx) return;
|
||||
|
||||
#define GET_CTX_V2() \
|
||||
if(!s_eglIface) return; \
|
||||
GLESv2Context *ctx = static_cast<GLESv2Context *>(s_eglIface->getGLESContext()); \
|
||||
if(!ctx) return;
|
||||
|
||||
#define GET_CTX_RET(failure_ret) \
|
||||
if(!s_eglIface) return failure_ret; \
|
||||
GLEScontext *ctx = s_eglIface->getGLESContext(); \
|
||||
if(!ctx) return failure_ret;
|
||||
|
||||
#define GET_CTX_CM_RET(failure_ret) \
|
||||
if(!s_eglIface) return failure_ret; \
|
||||
GLEScmContext *ctx = static_cast<GLEScmContext *>(s_eglIface->getGLESContext()); \
|
||||
if(!ctx) return failure_ret;
|
||||
|
||||
#define GET_CTX_V2_RET(failure_ret) \
|
||||
if(!s_eglIface) return failure_ret; \
|
||||
GLESv2Context *ctx = static_cast<GLESv2Context *>(s_eglIface->getGLESContext()); \
|
||||
if(!ctx) return failure_ret;
|
||||
|
||||
|
||||
#define SET_ERROR_IF(condition,err) if((condition)) { \
|
||||
fprintf(stderr, "%s:%s:%d error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
|
||||
ctx->setGLerror(err); \
|
||||
return; \
|
||||
}
|
||||
|
||||
|
||||
#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) { \
|
||||
fprintf(stderr, "%s:%s:%d error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
|
||||
ctx->setGLerror(err); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#endif
|
||||
58
external/android-emugl/host/libs/Translator/include/GLcommon/GLESpointer.h
vendored
Normal file
58
external/android-emugl/host/libs/Translator/include/GLcommon/GLESpointer.h
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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 GLES_POINTER_H
|
||||
#define GLES_POINTER_H
|
||||
|
||||
#include <GLES/gl.h>
|
||||
#include "GLESbuffer.h"
|
||||
|
||||
class GLESpointer
|
||||
{
|
||||
|
||||
public:
|
||||
GLESpointer();
|
||||
GLenum getType() const;
|
||||
GLint getSize() const;
|
||||
GLsizei getStride() const;
|
||||
const GLvoid* getArrayData() const;
|
||||
GLvoid* getBufferData() const;
|
||||
GLuint getBufferName() const;
|
||||
GLboolean getNormalized() const { return m_normalize ? GL_TRUE : GL_FALSE; }
|
||||
const GLvoid* getData() const;
|
||||
unsigned int getBufferOffset() const;
|
||||
void redirectPointerData();
|
||||
void getBufferConversions(const RangeList& rl,RangeList& rlOut);
|
||||
bool bufferNeedConversion(){ return !m_buffer->fullyConverted();}
|
||||
void setArray (GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize = false);
|
||||
void setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,GLuint bufferName,int offset,bool normalize = false);
|
||||
bool isEnable() const;
|
||||
bool isNormalize() const;
|
||||
bool isVBO() const;
|
||||
void enable(bool b);
|
||||
|
||||
private:
|
||||
GLint m_size;
|
||||
GLenum m_type;
|
||||
GLsizei m_stride;
|
||||
bool m_enabled;
|
||||
bool m_normalize;
|
||||
const GLvoid* m_data;
|
||||
GLESbuffer* m_buffer;
|
||||
GLuint m_bufferName;
|
||||
unsigned int m_buffOffset;
|
||||
bool m_isVBO;
|
||||
};
|
||||
#endif
|
||||
44
external/android-emugl/host/libs/Translator/include/GLcommon/GLESvalidate.h
vendored
Normal file
44
external/android-emugl/host/libs/Translator/include/GLcommon/GLESvalidate.h
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* 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 GLES_VALIDATE_H
|
||||
#define GLES_VALIDATE_H
|
||||
|
||||
#include <GLES/gl.h>
|
||||
#include "GLEScontext.h"
|
||||
struct GLESvalidate
|
||||
{
|
||||
static bool textureEnum(GLenum e,unsigned int maxTex);
|
||||
static bool pixelType(GLEScontext * ctx,GLenum type);
|
||||
static bool pixelOp(GLenum format,GLenum type);
|
||||
static bool pixelFrmt(GLEScontext* ctx , GLenum format);
|
||||
static bool bufferTarget(GLenum target);
|
||||
static bool bufferUsage(GLenum usage);
|
||||
static bool bufferParam(GLenum param);
|
||||
static bool drawMode(GLenum mode);
|
||||
static bool drawType(GLenum mode);
|
||||
static bool textureTarget(GLenum target);
|
||||
static bool textureTargetLimited(GLenum target);
|
||||
static bool textureTargetEx(GLenum target);
|
||||
static bool texImgDim(GLsizei width,GLsizei height,int maxTexSize);
|
||||
static bool blendEquationMode(GLenum mode);
|
||||
static bool framebufferTarget(GLenum target);
|
||||
static bool framebufferAttachment(GLenum attachment);
|
||||
static bool framebufferAttachmentParams(GLenum pname);
|
||||
static bool renderbufferTarget(GLenum target);
|
||||
static bool renderbufferParams(GLenum pname);
|
||||
};
|
||||
|
||||
#endif
|
||||
36
external/android-emugl/host/libs/Translator/include/GLcommon/GLLibrary.h
vendored
Normal file
36
external/android-emugl/host/libs/Translator/include/GLcommon/GLLibrary.h
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2015 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 GLCOMMON_GL_LIBRARY_H
|
||||
#define GLCOMMON_GL_LIBRARY_H
|
||||
|
||||
// An interface class used to model the desktop GL library to use at runtime.
|
||||
// Use GlLibrary::getHostInstance() to retrieve the instance corresponding
|
||||
// to the host's default system GL library.
|
||||
class GlLibrary {
|
||||
public:
|
||||
// Generic pointer-to-function type.
|
||||
typedef void (*GlFunctionPointer)(void);
|
||||
|
||||
// Empty constructor.
|
||||
GlLibrary() {}
|
||||
|
||||
// Empty destructor.
|
||||
virtual ~GlLibrary() {}
|
||||
|
||||
// Find the function named |name| in the library and return its address.
|
||||
virtual GlFunctionPointer findSymbol(const char* name) = 0;
|
||||
};
|
||||
|
||||
#endif // GLCOMMON_GL_LIBRARY_H
|
||||
31
external/android-emugl/host/libs/Translator/include/GLcommon/GLconversion_macros.h
vendored
Normal file
31
external/android-emugl/host/libs/Translator/include/GLcommon/GLconversion_macros.h
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 _GL_FIXED_OPS_H
|
||||
#define _GL_FIXED_OPS_H
|
||||
|
||||
#define X2F(x) (((float)(x))/65536.0f)
|
||||
#define X2D(x) (((double)(x))/65536.0)
|
||||
#define X2I(x) ((x) /65536)
|
||||
#define B2S(x) ((short)x)
|
||||
|
||||
|
||||
#define F2X(d) ((d) > 32767.65535 ? 32767 * 65536 + 65535 : \
|
||||
(d) < -32768.65535 ? -32768 * 65536 + 65535 : \
|
||||
((GLfixed) ((d) * 65536)))
|
||||
|
||||
#define I2X(d) ((d)*65536)
|
||||
|
||||
#endif
|
||||
54
external/android-emugl/host/libs/Translator/include/GLcommon/GLutils.h
vendored
Normal file
54
external/android-emugl/host/libs/Translator/include/GLcommon/GLutils.h
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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 GL_UTILS_H
|
||||
#define GL_UTILS_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum {
|
||||
GLES_1_1 = 1,
|
||||
GLES_2_0 = 2,
|
||||
MAX_GLES_VERSION //Must be last
|
||||
} GLESVersion;
|
||||
|
||||
bool isPowerOf2(int num);
|
||||
|
||||
// <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) {
|
||||
#if 1
|
||||
// Ignore the assert below to avoid crashing when running older
|
||||
// system images, which might have buggy encoder libraries. Print
|
||||
// an error message though.
|
||||
if ((uintptr_t)(ptr) != (unsigned int)(uintptr_t)(ptr)) {
|
||||
fprintf(stderr, "EmuGL:WARNING: bad generic pointer %p\n", ptr);
|
||||
}
|
||||
#else
|
||||
// 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));
|
||||
#endif
|
||||
return (unsigned int)(uintptr_t)(ptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
25
external/android-emugl/host/libs/Translator/include/GLcommon/PaletteTexture.h
vendored
Normal file
25
external/android-emugl/host/libs/Translator/include/GLcommon/PaletteTexture.h
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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 __PALETTE_TEXTURE_H__
|
||||
#define __PALETTE_TEXTURE_H__
|
||||
|
||||
#include <GLES/gl.h>
|
||||
|
||||
#define MAX_SUPPORTED_PALETTE 10
|
||||
|
||||
unsigned char* uncompressTexture(GLenum internalformat,GLenum& formatOut,GLsizei width,GLsizei height,GLsizei imageSize, const GLvoid* data,GLint level);
|
||||
|
||||
#endif
|
||||
69
external/android-emugl/host/libs/Translator/include/GLcommon/RangeManip.h
vendored
Normal file
69
external/android-emugl/host/libs/Translator/include/GLcommon/RangeManip.h
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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 RANGE_H
|
||||
#define RANGE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
class Range {
|
||||
|
||||
public:
|
||||
Range():m_start(0),m_end(0),m_size(0){};
|
||||
Range(int start,int size):m_start(start),m_end(start+size),m_size(size){};
|
||||
Range(const Range& r):m_start(r.m_start),m_end(r.m_end),m_size(r.m_size){};
|
||||
void setRange(int start,int size){m_start = start; m_end = start+size; m_size = size;};
|
||||
inline int getStart() const{return m_start;};
|
||||
inline int getEnd() const{return m_end;};
|
||||
inline int getSize() const{return m_size;};
|
||||
Range& operator=(const Range& r) {
|
||||
m_start = r.m_start;
|
||||
m_end = r.m_end;
|
||||
m_size = r.m_size;
|
||||
return *this;
|
||||
}
|
||||
bool operator ==(const Range& r) const {
|
||||
return m_start == r.m_start && m_size == r.m_size && m_end == r.m_end;
|
||||
}
|
||||
bool operator !=(const Range& r) const {return !((*this) == r);};
|
||||
bool rangeIntersection(const Range& r,Range& rOut) const ;
|
||||
bool rangeUnion(const Range& r,Range& rOut) const ;
|
||||
|
||||
private:
|
||||
int m_start;
|
||||
int m_end;
|
||||
int m_size;
|
||||
};
|
||||
|
||||
class RangeList {
|
||||
public:
|
||||
void addRange(const Range& r);
|
||||
void addRanges(const RangeList& rl);
|
||||
void delRange(const Range& r,RangeList& deleted);
|
||||
void delRanges(const RangeList& rl,RangeList& deleted);
|
||||
bool empty() const;
|
||||
void merge();
|
||||
int size() const;
|
||||
void clear();
|
||||
Range& operator[](unsigned int i){return list[i];};
|
||||
private:
|
||||
void erase(unsigned int i);
|
||||
std::vector<Range> list;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
31
external/android-emugl/host/libs/Translator/include/GLcommon/TextureUtils.h
vendored
Normal file
31
external/android-emugl/host/libs/Translator/include/GLcommon/TextureUtils.h
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 _TEXTURE_UTILS_H
|
||||
#define _TEXTURE_UTILS_H
|
||||
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include "GLEScontext.h"
|
||||
#include "PaletteTexture.h"
|
||||
#include "etc1.h"
|
||||
|
||||
int getCompressedFormats(int* formats);
|
||||
void doCompressedTexImage2D(GLEScontext * ctx, GLenum target, GLint level,
|
||||
GLenum internalformat, GLsizei width,
|
||||
GLsizei height, GLint border,
|
||||
GLsizei imageSize, const GLvoid* data, void * funcPtr);
|
||||
|
||||
#endif
|
||||
120
external/android-emugl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
vendored
Normal file
120
external/android-emugl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* 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 TRANSLATOR_IFACES_H
|
||||
#define TRANSLATOR_IFACES_H
|
||||
|
||||
#include "GLcommon/objectNameManager.h"
|
||||
|
||||
#include <GLES/gl.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* This is a generic function pointer type, whose name indicates it must
|
||||
* be cast to the proper type *and calling convention* before use.
|
||||
*/
|
||||
typedef void (*__translatorMustCastToProperFunctionPointerType)(void);
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
__translatorMustCastToProperFunctionPointerType address;
|
||||
}ExtentionDescriptor;
|
||||
|
||||
class TextureData : public ObjectData
|
||||
{
|
||||
public:
|
||||
~TextureData() {
|
||||
if (sourceEGLImage && eglImageDetach) (*eglImageDetach)(sourceEGLImage);
|
||||
}
|
||||
TextureData(): ObjectData(TEXTURE_DATA),
|
||||
width(0),
|
||||
height(0),
|
||||
border(0),
|
||||
internalFormat(GL_RGBA),
|
||||
sourceEGLImage(0),
|
||||
wasBound(false),
|
||||
requiresAutoMipmap(false),
|
||||
target(0),
|
||||
oldGlobal(0) {
|
||||
memset(crop_rect,0,4*sizeof(int));
|
||||
};
|
||||
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int border;
|
||||
unsigned int internalFormat;
|
||||
unsigned int sourceEGLImage;
|
||||
bool wasBound;
|
||||
bool requiresAutoMipmap;
|
||||
int crop_rect[4];
|
||||
void (*eglImageDetach)(unsigned int imageId);
|
||||
GLenum target;
|
||||
GLuint oldGlobal;
|
||||
};
|
||||
|
||||
struct EglImage
|
||||
{
|
||||
~EglImage(){};
|
||||
unsigned int imageId;
|
||||
unsigned int globalTexName;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int internalFormat;
|
||||
unsigned int border;
|
||||
};
|
||||
|
||||
typedef emugl::SmartPtr<EglImage> ImagePtr;
|
||||
typedef std::map< unsigned int, ImagePtr> ImagesHndlMap;
|
||||
|
||||
class GLEScontext;
|
||||
|
||||
typedef struct {
|
||||
void (*initGLESx)();
|
||||
GLEScontext* (*createGLESContext)();
|
||||
void (*initContext)(GLEScontext*,ShareGroupPtr);
|
||||
void (*deleteGLESContext)(GLEScontext*);
|
||||
void (*flush)();
|
||||
void (*finish)();
|
||||
void (*setShareGroup)(GLEScontext*,ShareGroupPtr);
|
||||
__translatorMustCastToProperFunctionPointerType (*getProcAddress)(const char*);
|
||||
}GLESiface;
|
||||
|
||||
class GlLibrary;
|
||||
|
||||
// A structure containing function pointers implemented by the EGL
|
||||
// translator library, and called from the GLES 1.x and 2.0 translator
|
||||
// libraries.
|
||||
struct EGLiface {
|
||||
// Get the current GLESContext instance for the current thread.
|
||||
GLEScontext* (*getGLESContext)();
|
||||
|
||||
// Create a new global EglImage object named |imageId| and return a
|
||||
// pointer to its new instance.
|
||||
EglImage* (*eglAttachEGLImage)(unsigned int imageId);
|
||||
|
||||
// Release a global EglImage instance named |imageId|.
|
||||
void (*eglDetachEGLImage)(unsigned int imageId);
|
||||
|
||||
// Return instance of GlLibrary class to use for dispatch.
|
||||
// at runtime. This is implemented in the EGL library because on Windows
|
||||
// all functions returned by wglGetProcAddress() are context-dependent!
|
||||
GlLibrary* (*eglGetGlLibrary)();
|
||||
};
|
||||
|
||||
typedef GLESiface* (*__translator_getGLESIfaceFunc)(const EGLiface*);
|
||||
|
||||
}
|
||||
#endif
|
||||
108
external/android-emugl/host/libs/Translator/include/GLcommon/etc1.h
vendored
Normal file
108
external/android-emugl/host/libs/Translator/include/GLcommon/etc1.h
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
// 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 MAX_ETC_SUPPORTED 1
|
||||
|
||||
#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
|
||||
269
external/android-emugl/host/libs/Translator/include/GLcommon/objectNameManager.h
vendored
Normal file
269
external/android-emugl/host/libs/Translator/include/GLcommon/objectNameManager.h
vendored
Normal file
|
|
@ -0,0 +1,269 @@
|
|||
/*
|
||||
* 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 _OBJECT_NAME_MANAGER_H
|
||||
#define _OBJECT_NAME_MANAGER_H
|
||||
|
||||
#include <map>
|
||||
#include "emugl/common/mutex.h"
|
||||
#include "emugl/common/smart_ptr.h"
|
||||
|
||||
enum NamedObjectType {
|
||||
VERTEXBUFFER = 0,
|
||||
TEXTURE = 1,
|
||||
RENDERBUFFER = 2,
|
||||
FRAMEBUFFER = 3,
|
||||
SHADER = 4,
|
||||
NUM_OBJECT_TYPES = 5 // Must be last
|
||||
};
|
||||
|
||||
enum ObjectDataType {
|
||||
SHADER_DATA,
|
||||
PROGRAM_DATA,
|
||||
TEXTURE_DATA,
|
||||
BUFFER_DATA,
|
||||
UNDEFINED_DATA
|
||||
};
|
||||
|
||||
class ObjectData
|
||||
{
|
||||
public:
|
||||
ObjectData() : m_dataType(UNDEFINED_DATA) {};
|
||||
ObjectData(ObjectDataType type): m_dataType(type) {};
|
||||
ObjectDataType getDataType() { return m_dataType; };
|
||||
virtual ~ObjectData() {};
|
||||
private:
|
||||
ObjectDataType m_dataType;
|
||||
};
|
||||
typedef emugl::SmartPtr<ObjectData> ObjectDataPtr;
|
||||
typedef unsigned long long ObjectLocalName;
|
||||
typedef std::map<ObjectLocalName, unsigned int> NamesMap;
|
||||
|
||||
//
|
||||
// Class NameSpace - this class manages allocations and deletions of objects
|
||||
// from a single "local" namespace (private to context group).
|
||||
// For each allocated object name, a "global" name is
|
||||
// generated as well to be used in the space where all
|
||||
// contexts are shared.
|
||||
//
|
||||
// NOTE: this class does not used by the EGL/GLES layer directly,
|
||||
// the EGL/GLES layer creates objects using the ShareGroup class
|
||||
// interface (see below).
|
||||
class GlobalNameSpace;
|
||||
class NameSpace
|
||||
{
|
||||
friend class ShareGroup;
|
||||
friend class GlobalNameSpace;
|
||||
|
||||
private:
|
||||
NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace);
|
||||
~NameSpace();
|
||||
|
||||
//
|
||||
// genName - creates new object in the namespace and returns its name.
|
||||
// if genLocal is false then the specified p_localName will be used.
|
||||
// This function also generate a global name for the object,
|
||||
// the value of the global name can be retrieved using the
|
||||
// getGlobalName function.
|
||||
//
|
||||
ObjectLocalName genName(ObjectLocalName p_localName, bool genGlobal, bool genLocal);
|
||||
|
||||
// genGlobalName() - This function creates a global name
|
||||
// with no associated local name, for the
|
||||
// translator internal use.
|
||||
unsigned int genGlobalName(void);
|
||||
|
||||
//
|
||||
// getGlobalName - returns the global name of an object or 0 if the object
|
||||
// does not exist.
|
||||
//
|
||||
unsigned int getGlobalName(ObjectLocalName p_localName);
|
||||
|
||||
//
|
||||
// getLocaalName - returns the local name of an object or 0 if the object
|
||||
// does not exist.
|
||||
//
|
||||
ObjectLocalName getLocalName(unsigned int p_globalName);
|
||||
|
||||
//
|
||||
// deleteName - deletes and object from the namespace as well as its
|
||||
// global name from the global name space.
|
||||
//
|
||||
void deleteName(ObjectLocalName p_localName);
|
||||
|
||||
//
|
||||
// isObject - returns true if the named object exist.
|
||||
//
|
||||
bool isObject(ObjectLocalName p_localName);
|
||||
|
||||
//
|
||||
// replaces an object to map to an existing global object
|
||||
//
|
||||
void replaceGlobalName(ObjectLocalName p_localName, unsigned int p_globalName);
|
||||
|
||||
private:
|
||||
ObjectLocalName m_nextName;
|
||||
NamesMap m_localToGlobalMap;
|
||||
const NamedObjectType m_type;
|
||||
GlobalNameSpace *m_globalNameSpace;
|
||||
};
|
||||
|
||||
class GlobalNameSpace
|
||||
{
|
||||
public:
|
||||
GlobalNameSpace();
|
||||
~GlobalNameSpace();
|
||||
unsigned int genName(NamedObjectType p_type);
|
||||
void deleteName(NamedObjectType p_type, unsigned int p_name);
|
||||
|
||||
private:
|
||||
emugl::Mutex m_lock;
|
||||
};
|
||||
|
||||
//
|
||||
// class ShareGroup -
|
||||
// That class manages objects of one "local" context share group, typically
|
||||
// there will be one inctance of ShareGroup for each user OpenGL context
|
||||
// unless the user context share with another user context. In that case they
|
||||
// both will share the same ShareGroup instance.
|
||||
// calls into that class gets serialized through a lock so it is thread safe.
|
||||
//
|
||||
class ShareGroup
|
||||
{
|
||||
friend class ObjectNameManager;
|
||||
friend class emugl::SmartPtr<ShareGroup>; // to allow destructing when ShareGroupPtr refcount reaches zero
|
||||
|
||||
public:
|
||||
|
||||
//
|
||||
// genName - generates new object name and returns its name value.
|
||||
// if genLocal is false, p_localName will be used as the name.
|
||||
// This function also generates a "global" name for the object
|
||||
// which can be queried using the getGlobalName function.
|
||||
//
|
||||
ObjectLocalName genName(NamedObjectType p_type, ObjectLocalName p_localName = 0, bool genLocal= false);
|
||||
|
||||
// genGlobalName() - This function creates a global name
|
||||
// with no associated local name, for the
|
||||
// translator internal use.
|
||||
unsigned int genGlobalName(NamedObjectType p_type);
|
||||
|
||||
//
|
||||
// getGlobalName - retrieves the "global" name of an object or 0 if the
|
||||
// object does not exist.
|
||||
//
|
||||
unsigned int getGlobalName(NamedObjectType p_type, ObjectLocalName p_localName);
|
||||
|
||||
//
|
||||
// getLocalName - retrieves the "local" name of an object or 0 if the
|
||||
// object does not exist.
|
||||
//
|
||||
ObjectLocalName getLocalName(NamedObjectType p_type, unsigned int p_globalName);
|
||||
|
||||
//
|
||||
// deleteName - deletes and object from the namespace as well as its
|
||||
// global name from the global name space.
|
||||
//
|
||||
void deleteName(NamedObjectType p_type, ObjectLocalName p_localName);
|
||||
|
||||
//
|
||||
// replaceGlobalName - replaces an object to map to an existing global
|
||||
// named object. (used when creating EGLImage siblings)
|
||||
//
|
||||
void replaceGlobalName(NamedObjectType p_type, ObjectLocalName p_localName, unsigned int p_globalName);
|
||||
|
||||
//
|
||||
// isObject - returns true if the named object exist.
|
||||
//
|
||||
bool isObject(NamedObjectType p_type, ObjectLocalName p_localName);
|
||||
|
||||
//
|
||||
// Assign object global data to a names object
|
||||
//
|
||||
void setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, ObjectDataPtr data);
|
||||
|
||||
//
|
||||
// Retrieve object global data
|
||||
//
|
||||
ObjectDataPtr getObjectData(NamedObjectType p_type, ObjectLocalName p_localName);
|
||||
|
||||
private:
|
||||
explicit ShareGroup(GlobalNameSpace *globalNameSpace);
|
||||
~ShareGroup();
|
||||
|
||||
private:
|
||||
emugl::Mutex m_lock;
|
||||
NameSpace *m_nameSpace[NUM_OBJECT_TYPES];
|
||||
void *m_objectsData;
|
||||
};
|
||||
|
||||
typedef emugl::SmartPtr<ShareGroup> ShareGroupPtr;
|
||||
typedef std::multimap<void *, ShareGroupPtr> ShareGroupsMap;
|
||||
|
||||
//
|
||||
// ObjectNameManager -
|
||||
// This class manages the set of all ShareGroups instances,
|
||||
// each ShareGroup instance can be accessed through one or more 'groupName'
|
||||
// values. the type of 'groupName' is void *, the intent is that the EGL
|
||||
// layer will use the user context handle as the name for its ShareGroup
|
||||
// object. Multiple names can be attached to a ShareGroup object to support
|
||||
// user context sharing.
|
||||
//
|
||||
class ObjectNameManager
|
||||
{
|
||||
public:
|
||||
explicit ObjectNameManager(GlobalNameSpace *globalNameSpace);
|
||||
~ObjectNameManager();
|
||||
|
||||
//
|
||||
// createShareGroup - create a new ShareGroup object and attach it with
|
||||
// the "name" specified by p_groupName.
|
||||
//
|
||||
ShareGroupPtr createShareGroup(void *p_groupName);
|
||||
|
||||
//
|
||||
// attachShareGroup - find the ShareGroup object attached to the name
|
||||
// specified in p_existingGroupName and attach p_groupName to the same
|
||||
// ShareGroup instance.
|
||||
//
|
||||
ShareGroupPtr attachShareGroup(void *p_groupName, void *p_existingGroupName);
|
||||
|
||||
//
|
||||
// getShareGroup - retreive a ShareGroup object based on its "name"
|
||||
//
|
||||
ShareGroupPtr getShareGroup(void *p_groupName);
|
||||
|
||||
//
|
||||
// deleteShareGroup - deletes the attachment of the p_groupName to its
|
||||
// attached ShareGroup. When the last name of ShareGroup is
|
||||
// deleted the ShareGroup object is destroyed.
|
||||
//
|
||||
void deleteShareGroup(void *p_groupName);
|
||||
|
||||
//
|
||||
// getGlobalContext() - this function returns a name of an existing
|
||||
// ShareGroup. The intent is that the EGL layer will
|
||||
// use that function to get the GL context which each
|
||||
// new context needs to share with.
|
||||
//
|
||||
void *getGlobalContext();
|
||||
|
||||
private:
|
||||
ShareGroupsMap m_groups;
|
||||
emugl::Mutex m_lock;
|
||||
GlobalNameSpace *m_globalNameSpace;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue