Merge "emulator opengl - GLESv2 implementation"
This commit is contained in:
47
tools/emulator/opengl/host/libs/GLESv2_dec/Android.mk
Normal file
47
tools/emulator/opengl/host/libs/GLESv2_dec/Android.mk
Normal file
@@ -0,0 +1,47 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
### GLESv2 Decoder ###########################################
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
emulatorOpengl := $(LOCAL_PATH)/../../..
|
||||
EMUGEN := $(BUILD_OUT_EXECUTABLES)/emugen
|
||||
|
||||
LOCAL_IS_HOST_MODULE := true
|
||||
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
|
||||
LOCAL_MODULE_TAGS := debug
|
||||
LOCAL_MODULE := libGLESv2_dec
|
||||
|
||||
intermediates := $(local-intermediates-dir)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
GL2Decoder.cpp
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(emulatorOpengl)/shared \
|
||||
$(emulatorOpengl)/shared/OpenglCodecCommon \
|
||||
$(emulatorOpengl)/host/include/libOpenglRender \
|
||||
$(emulatorOpengl)/system/GLESv2_enc
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libOpenglCodecCommon \
|
||||
libOpenglOsUtils \
|
||||
liblog
|
||||
|
||||
# XXX - uncomment for debug
|
||||
#LOCAL_CFLAGS := -DDEBUG_PRINTOUT -O0 -g
|
||||
LOCAL_LDLIBS := -ldl
|
||||
|
||||
|
||||
GEN := $(intermediates)/gl2_dec.cpp $(intermediates)/gl2_dec.h $(intermediates)/gl2_server_context.cpp
|
||||
|
||||
$(GEN) : PRIVATE_PATH := $(LOCAL_PATH)
|
||||
$(GEN) : PRIVATE_CUSTOM_TOOL := $(EMUGEN) -D $(intermediates) -i $(emulatorOpengl)/system/GLESv2_enc gl2
|
||||
$(GEN) : $(EMUGEN) \
|
||||
$(emulatorOpengl)/system/GLESv2_enc/gl2.attrib \
|
||||
$(emulatorOpengl)/system/GLESv2_enc/gl2.in \
|
||||
$(emulatorOpengl)/system/GLESv2_enc/gl2.types
|
||||
$(transform-generated-source)
|
||||
|
||||
LOCAL_GENERATED_SOURCES += $(GEN)
|
||||
include $(BUILD_HOST_SHARED_LIBRARY)
|
||||
|
||||
110
tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
Normal file
110
tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#include "GL2Decoder.h"
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
|
||||
GL2Decoder::GL2Decoder()
|
||||
{
|
||||
m_contextData = NULL;
|
||||
m_GL2library = NULL;
|
||||
}
|
||||
|
||||
GL2Decoder::~GL2Decoder()
|
||||
{
|
||||
delete m_GL2library;
|
||||
}
|
||||
|
||||
void *GL2Decoder::s_getProc(const char *name, void *userData)
|
||||
{
|
||||
GL2Decoder *ctx = (GL2Decoder *) userData;
|
||||
|
||||
if (ctx == NULL || ctx->m_GL2library == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *func = NULL;
|
||||
#ifdef USE_EGL_GETPROCADDRESS
|
||||
func = (void *) eglGetProcAddress(name);
|
||||
#endif
|
||||
if (func == NULL) {
|
||||
func = (void *) ctx->m_GL2library->findSymbol(name);
|
||||
}
|
||||
return func;
|
||||
}
|
||||
|
||||
int GL2Decoder::initGL(get_proc_func_t getProcFunc, void *getProcFuncData)
|
||||
{
|
||||
if (getProcFunc == NULL) {
|
||||
const char *libname = GLES2_LIBNAME;
|
||||
if (getenv(GLES2_LIBNAME_VAR) != NULL) {
|
||||
libname = getenv(GLES2_LIBNAME_VAR);
|
||||
}
|
||||
|
||||
m_GL2library = osUtils::dynLibrary::open(libname);
|
||||
if (m_GL2library == NULL) {
|
||||
fprintf(stderr, "Couldn't find %s \n", libname);
|
||||
return -1;
|
||||
}
|
||||
this->initDispatchByName(s_getProc, this);
|
||||
} else {
|
||||
this->initDispatchByName(getProcFunc, getProcFuncData);
|
||||
}
|
||||
|
||||
set_glGetCompressedTextureFormats(s_glGetCompressedTextureFormats);
|
||||
set_glVertexAttribPointerData(s_glVertexAttribPointerData);
|
||||
set_glVertexAttribPointerOffset(s_glVertexAttribPointerOffset);
|
||||
|
||||
set_glDrawElementsOffset(s_glDrawElementsOffset);
|
||||
set_glDrawElementsData(s_glDrawElementsData);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void GL2Decoder::s_glGetCompressedTextureFormats(void *self, int count, GLint *formats)
|
||||
{
|
||||
GL2Decoder *ctx = (GL2Decoder *) self;
|
||||
|
||||
int nFormats;
|
||||
ctx->glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nFormats);
|
||||
if (nFormats > count) {
|
||||
fprintf(stderr, "GetCompressedTextureFormats: The requested number of formats does not match the number that is reported by OpenGL\n");
|
||||
} else {
|
||||
ctx->glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
|
||||
}
|
||||
}
|
||||
|
||||
void GL2Decoder::s_glVertexAttribPointerData(void *self, GLuint indx, GLint size, GLenum type,
|
||||
GLboolean normalized, GLsizei stride, void * data, GLuint datalen)
|
||||
{
|
||||
GL2Decoder *ctx = (GL2Decoder *) self;
|
||||
if (ctx->m_contextData != NULL) {
|
||||
ctx->m_contextData->storePointerData(indx, data, datalen);
|
||||
// note - the stride of the data is always zero when it comes out of the codec.
|
||||
// See gl2.attrib for the packing function call.
|
||||
ctx->glVertexAttribPointer(indx, size, type, normalized, 0, ctx->m_contextData->pointerData(indx));
|
||||
}
|
||||
}
|
||||
|
||||
void GL2Decoder::s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint size, GLenum type,
|
||||
GLboolean normalized, GLsizei stride, GLuint data)
|
||||
{
|
||||
GL2Decoder *ctx = (GL2Decoder *) self;
|
||||
ctx->glVertexAttribPointer(indx, size, type, normalized, stride, (GLvoid *)data);
|
||||
}
|
||||
|
||||
|
||||
void GL2Decoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen)
|
||||
{
|
||||
GL2Decoder *ctx = (GL2Decoder *)self;
|
||||
ctx->glDrawElements(mode, count, type, data);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
37
tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h
Normal file
37
tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _GL2_DECODER_H_
|
||||
#define _GL2_DECODER_H_
|
||||
|
||||
#define GLES2_LIBNAME_VAR "ANDROID_GLESv2_LIB"
|
||||
#define GLES2_LIBNAME "libGLESv2.so"
|
||||
|
||||
#include "gl2_dec.h"
|
||||
#include "OpenglOsUtils/osDynLibrary.h"
|
||||
#include "GLDecoderContextData.h"
|
||||
|
||||
|
||||
class GL2Decoder : public gl2_decoder_context_t
|
||||
{
|
||||
public:
|
||||
typedef void *(*get_proc_func_t)(const char *name, void *userData);
|
||||
GL2Decoder();
|
||||
~GL2Decoder();
|
||||
int initGL(get_proc_func_t getProcFunc = NULL, void *getProcFuncData = NULL);
|
||||
void setContextData(GLDecoderContextData *contextData) { m_contextData = contextData; }
|
||||
private:
|
||||
GLDecoderContextData *m_contextData;
|
||||
osUtils::dynLibrary * m_GL2library;
|
||||
|
||||
static void *s_getProc(const char *name, void *userData);
|
||||
static void s_glGetCompressedTextureFormats(void *self, int count, GLint *formats);
|
||||
static void s_glVertexAttribPointerData(void *self, GLuint indx, GLint size, GLenum type,
|
||||
GLboolean normalized, GLsizei stride, void * data, GLuint datalen);
|
||||
static void s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint size, GLenum type,
|
||||
GLboolean normalized, GLsizei stride, GLuint offset);
|
||||
|
||||
static void s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset);
|
||||
static void s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen);
|
||||
|
||||
|
||||
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user