diff options
Diffstat (limited to 'emulator/opengl/system/renderControl_enc')
6 files changed, 248 insertions, 0 deletions
diff --git a/emulator/opengl/system/renderControl_enc/Android.mk b/emulator/opengl/system/renderControl_enc/Android.mk new file mode 100644 index 0000000..96f15a2 --- /dev/null +++ b/emulator/opengl/system/renderControl_enc/Android.mk @@ -0,0 +1,7 @@ +LOCAL_PATH := $(call my-dir) + +$(call emugl-begin-shared-library,lib_renderControl_enc) +$(call emugl-gen-encoder,$(LOCAL_PATH),renderControl) +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) +$(call emugl-import,libOpenglCodecCommon) +$(call emugl-end-module) diff --git a/emulator/opengl/system/renderControl_enc/README b/emulator/opengl/system/renderControl_enc/README new file mode 100644 index 0000000..2ee1a57 --- /dev/null +++ b/emulator/opengl/system/renderControl_enc/README @@ -0,0 +1,136 @@ +The renderControl.in file in this directory defines an API which is decoded +on the android guest into a stream and get decoded and executed on the host. +It is used in order to query the host renderer as well as send the host renderer +control commands. + +The following describes each of the entries defined by this renderControl API. + + +GLint rcGetRendererVersion(); + This function queries the host renderer version number. + +EGLint rcGetEGLVersion(EGLint* major, EGLint* minor); + This function queries the host renderer for the EGL version + it supports. returns EGL_FALSE on failure. + +EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize); + This function queries the host for EGL string (.i.e EGL_EXTENSIONS). + if buffer is NULL or the bufferSize is not big enough the return value + is the negative number of bytes required to store the string value + otherwise the string value is copied to buffer and its size is + returned. + +EGLint rcGetNumConfigs(uint32_t* numAttribs); + queries the host for the number of supported EGL configs. + The function returns the number of supported configs and returns in + numAttribs the number of attributes available for each config. + +EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer); + This function queries the host for the all set of supported configs + with their attribute values. + bufSize is the size of buffer, the size should be at least equal to + (numConfigs + 1) * numAttribs * sizeof(GLuint) + where numConfigs and numAttribs are the values returned in + rcGetNumConfigs. if bufSize is not big enough then the negative number + of required bytes is returned otherwise the function returns the number + of configs and buffer is filled as follows: The first 'numAttribs' + integer values are filled with the EGL enumerant describing a config + attribute, next for each config there are 'numAttribs' integer values + holding the attribute values for that config, the values are specified + in the same order as the attribute vector. + +EGLint rcChooseConfig(EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size) + This function triggers an eglChooseConfig on the host, to get a list of + configs matching the given attribs values. + attribs - a list of attribute names followed by the desired values, terminated by EGL_NONE + attribs_size - the size of the list + configs - the returned matching configuration names (same names as familiar to the client in rcGetConfigs) + configs_size - the size of the configs buffers + returns - the actual number of matching configurations (<= configs_size) + +EGLint rcGetFBParam(EGLint param); + queries the host for framebuffer parameter, see renderControl_types.h + for possible values of 'param'. + +uint32_t rcCreateContext(uint32_t config, uint32_t share, uint32_t glVersion); + This function creates a rendering context on the host and returns its + handle. config is the config index for the context, share is either zero + or a handle to a sharing context. glVersion is either 1 or 2 for GLES1 + or GLES2 context respectively. + + +void rcDestroyContext(uint32_t context); + This function destroys a rendering context on the host. + context is a handle returned in rcCreateContext. + +uint32_t rcCreateWindowSurface(uint32_t config, uint32_t width, uint32_t height); + This function creates a 'window' surface on the host which can be then + bind for rendering through rcMakeCurrent. + The function returns a handle to the created window surface. + +void rcDestroyWindowSurface(uint32_t windowSurface); + This function destoys a window surface. + +uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFormat); + This function creates a colorBuffer object on the host which can be then + be specified as a render target for a window surface through + rcSetWindowColorBuffer or to be displayed on the framebuffer window + through rcFBPost. + The function returns a handle to the colorBuffer object, with an initial + reference count of 1. + +void rcOpenColorBuffer(uint32_t colorbuffer); + Adds an additional reference to the colorbuffer, typically from a + different Android process than the one which created it. + +void rcCloseColorBuffer(uint32_t colorbuffer); + Removes a reference to the colorbuffer. When the reference count drops + to zero the colorbuffer is automatically destroyed. + +void rcFlushWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer); + This flushes the current window color buffer + +void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer); + This set the target color buffer for a windowSurface, when set the + previous target colorBuffer gets updated before switching to the new + colorBuffer. + +EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf, uint32_t readSurf); + Binds a windowSurface(s) and current rendering context for the + calling thread. + +void rcFBPost(uint32_t colorBuffer); + This function causes the content of the colorBuffer object to be + displayed on the host framebuffer window. The function returns + immediatly, the buffer will be displayed at the next swap interval. + +void rcFBSetSwapInterval(EGLint interval); + Sets the swap interval for the host framebuffer window. + +void rcBindTexture(uint32_t colorBuffer); + This function instruct the host to bind the content of the specified + colorBuffer to the current binded texture object of the calling thread. + This function should be used to implement eglBindTexImage. + +EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead); + This function returns only after all rendering requests for the specified + colorBuffer rendering target has been processed and after all 'postCount' + posts for the buffer requested previously through rcFBPost has been + processed. + if 'forRead' is not-zero, the function returns positive value in case + there was rendering done to the buffer since the last CacheFlush request + with non-zero 'forRead' value, otherwise the function returns zero or + negative value on failure. + +void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y, + GLint width, GLint height, GLenum format, + GLenum type, void* pixels); + This function queries the host for the pixel content of a colorBuffer's + subregion. It act the same as OpenGL glReadPixels however pixels + are always packed with alignment of 1. + +void rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, + GLint width, GLint height, GLenum format, + GLenum type, void* pixels); + Updates the content of a subregion of a colorBuffer object. + pixels are always unpacked with alignment of 1. diff --git a/emulator/opengl/system/renderControl_enc/renderControl.attrib b/emulator/opengl/system/renderControl_enc/renderControl.attrib new file mode 100644 index 0000000..8b9972f --- /dev/null +++ b/emulator/opengl/system/renderControl_enc/renderControl.attrib @@ -0,0 +1,41 @@ +GLOBAL + base_opcode 10000 + encoder_headers <stdint.h> <EGL/egl.h> "glUtils.h" + +rcGetEGLVersion + dir major out + len major sizeof(EGLint) + dir minor out + len minor sizeof(EGLint) + +rcQueryEGLString + dir buffer out + len buffer bufferSize + +rcGetGLString + dir buffer out + len buffer bufferSize + +rcGetNumConfigs + dir numAttribs out + len numAttribs sizeof(uint32_t) + +rcGetConfigs + dir buffer out + len buffer bufSize + +rcChooseConfig + dir attribs in + len attribs attribs_size + dir configs out + var_flag configs nullAllowed + len configs configs_size*sizeof(uint32_t) + +rcReadColorBuffer + dir pixels out + len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height) + +rcUpdateColorBuffer + dir pixels in + len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height) + var_flag pixels isLarge diff --git a/emulator/opengl/system/renderControl_enc/renderControl.in b/emulator/opengl/system/renderControl_enc/renderControl.in new file mode 100644 index 0000000..8281fd9 --- /dev/null +++ b/emulator/opengl/system/renderControl_enc/renderControl.in @@ -0,0 +1,25 @@ +GL_ENRTY(GLint, rcGetRendererVersion) +GL_ENTRY(EGLint, rcGetEGLVersion, EGLint *major, EGLint *minor) +GL_ENTRY(EGLint, rcQueryEGLString, EGLenum name, void *buffer, EGLint bufferSize) +GL_ENTRY(EGLint, rcGetGLString, EGLenum name, void *buffer, EGLint bufferSize) +GL_ENTRY(EGLint, rcGetNumConfigs, uint32_t *numAttribs) +GL_ENTRY(EGLint, rcGetConfigs, uint32_t bufSize, GLuint *buffer) +GL_ENTRY(EGLint, rcChooseConfig, EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size) +GL_ENTRY(EGLint, rcGetFBParam, EGLint param) +GL_ENTRY(uint32_t, rcCreateContext, uint32_t config, uint32_t share, uint32_t glVersion) +GL_ENTRY(void, rcDestroyContext, uint32_t context) +GL_ENTRY(uint32_t, rcCreateWindowSurface, uint32_t config, uint32_t width, uint32_t height) +GL_ENTRY(void, rcDestroyWindowSurface, uint32_t windowSurface) +GL_ENTRY(uint32_t, rcCreateColorBuffer, uint32_t width, uint32_t height, GLenum internalFormat) +GL_ENTRY(void, rcOpenColorBuffer, uint32_t colorbuffer) +GL_ENTRY(void, rcCloseColorBuffer, uint32_t colorbuffer) +GL_ENTRY(void, rcSetWindowColorBuffer, uint32_t windowSurface, uint32_t colorBuffer) +GL_ENTRY(int, rcFlushWindowColorBuffer, uint32_t windowSurface) +GL_ENTRY(EGLint, rcMakeCurrent, uint32_t context, uint32_t drawSurf, uint32_t readSurf) +GL_ENTRY(void, rcFBPost, uint32_t colorBuffer) +GL_ENTRY(void, rcFBSetSwapInterval, EGLint interval) +GL_ENTRY(void, rcBindTexture, uint32_t colorBuffer) +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) diff --git a/emulator/opengl/system/renderControl_enc/renderControl.types b/emulator/opengl/system/renderControl_enc/renderControl.types new file mode 100644 index 0000000..a7d96ab --- /dev/null +++ b/emulator/opengl/system/renderControl_enc/renderControl.types @@ -0,0 +1,11 @@ +uint32_t 32 0x%08x false +EGLint 32 0x%08x false +GLint 32 0x%08x false +GLuint 32 0x%08x false +GLenum 32 0x%08x false +EGLenum 32 0x%08x false +uint32_t* 32 0x%08x true +EGLint* 32 0x%08x true +GLint* 32 0x%08x true +GLuint* 32 0x%08x true +void* 32 0x%08x true diff --git a/emulator/opengl/system/renderControl_enc/renderControl_types.h b/emulator/opengl/system/renderControl_enc/renderControl_types.h new file mode 100644 index 0000000..da215bb --- /dev/null +++ b/emulator/opengl/system/renderControl_enc/renderControl_types.h @@ -0,0 +1,28 @@ +/* +* 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 <stdint.h> +#include <EGL/egl.h> +#include "glUtils.h" + +// values for 'param' argument of rcGetFBParam +#define FB_WIDTH 1 +#define FB_HEIGHT 2 +#define FB_XDPI 3 +#define FB_YDPI 4 +#define FB_FPS 5 +#define FB_MIN_SWAP_INTERVAL 6 +#define FB_MAX_SWAP_INTERVAL 7 |