diff options
author | Jesse Hall <jessehall@google.com> | 2012-04-16 12:49:39 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2012-04-16 15:54:18 -0700 |
commit | ce6c3389061fb9fcdefc94fab2044a8e11600b52 (patch) | |
tree | fedd1a11cbd21ec14bf00be83b8712054f8c5506 /emulator/opengl/host/libs/GLESv2_dec | |
parent | ad0111a77b0f0908cc945dc6e8e8949b75cb8886 (diff) | |
download | sdk-ce6c3389061fb9fcdefc94fab2044a8e11600b52.zip sdk-ce6c3389061fb9fcdefc94fab2044a8e11600b52.tar.gz sdk-ce6c3389061fb9fcdefc94fab2044a8e11600b52.tar.bz2 |
Move emulator GLES from development.git to sdk.git
The emulator GLES support has two interfaces: a host shared library
interface used by QEMU, and a protocol between the platform and the
host. The host library interface is not versioned; QEMU and the GLES
renderer must match. The protocol on the other hand must be backwards
compatible: a new GLES renderer must support an older platform image.
Thus for branching purposes it makes more sense to put the GLES
renderer in sdk.git, which is branched along with qemu.git for SDK
releases. Platform images will be built against the protocol version
in the platform branch of sdk.git.
Change-Id: I2c3bce627ecfd0a4b3e688d1839fe10755a21e58
Diffstat (limited to 'emulator/opengl/host/libs/GLESv2_dec')
-rw-r--r-- | emulator/opengl/host/libs/GLESv2_dec/Android.mk | 38 | ||||
-rw-r--r-- | emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp | 139 | ||||
-rw-r--r-- | emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h | 52 |
3 files changed, 229 insertions, 0 deletions
diff --git a/emulator/opengl/host/libs/GLESv2_dec/Android.mk b/emulator/opengl/host/libs/GLESv2_dec/Android.mk new file mode 100644 index 0000000..f9a83ae --- /dev/null +++ b/emulator/opengl/host/libs/GLESv2_dec/Android.mk @@ -0,0 +1,38 @@ +LOCAL_PATH := $(call my-dir) + +host_common_debug_CFLAGS := + +#For gl debbuging +#host_common_debug_CFLAGS += -DCHECK_GL_ERROR +#host_common_debug_CFLAGS += -DDEBUG_PRINTOUT + + +### host library ########################################## +$(call emugl-begin-host-static-library,libGLESv2_dec) +$(call emugl-import, libOpenglCodecCommon libOpenglOsUtils) +$(call emugl-gen-decoder,$(EMUGL_PATH)/system/GLESv2_enc,gl2) + +# For gl2_types.h ! +$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/system/GLESv2_enc) +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) + +$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS)) + +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,$(EMUGL_PATH)/system/GLESv2_enc,gl2) + +# For gl2_types.h ! +$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/system/GLESv2_enc) +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) + +$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS) -m64) + +LOCAL_SRC_FILES := GL2Decoder.cpp + +$(call emugl-end-module) diff --git a/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp b/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp new file mode 100644 index 0000000..a777c50 --- /dev/null +++ b/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp @@ -0,0 +1,139 @@ +/* +* 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. +*/ + +#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, "%s: Couldn't find %s \n", __FUNCTION__, 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); + set_glShaderString(s_glShaderString); + set_glFinishRoundTrip(s_glFinishRoundTrip); + return 0; + +} + +int GL2Decoder::s_glFinishRoundTrip(void *self) +{ + GL2Decoder *ctx = (GL2Decoder *)self; + ctx->glFinish(); + 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, "%s: GetCompressedTextureFormats: The requested number of formats does not match the number that is reported by OpenGL\n", __FUNCTION__); + } 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); +} + +void GL2Decoder::s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len) +{ + GL2Decoder *ctx = (GL2Decoder *)self; + ctx->glShaderSource(shader, 1, &string, NULL); +} diff --git a/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h b/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h new file mode 100644 index 0000000..dcf2c07 --- /dev/null +++ b/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h @@ -0,0 +1,52 @@ +/* +* 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 _GL2_DECODER_H_ +#define _GL2_DECODER_H_ + +#define GLES2_LIBNAME_VAR "ANDROID_GLESv2_LIB" +#define GLES2_LIBNAME "libGLESv2.so" + +#include "gl2_dec.h" +#include "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 gl2_APIENTRY s_glGetCompressedTextureFormats(void *self, int count, GLint *formats); + static void gl2_APIENTRY s_glVertexAttribPointerData(void *self, GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, void * data, GLuint datalen); + static void gl2_APIENTRY s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, GLuint offset); + + static void gl2_APIENTRY s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset); + static void gl2_APIENTRY s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen); + static void gl2_APIENTRY s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len); + static int gl2_APIENTRY s_glFinishRoundTrip(void *self); +}; +#endif |