diff options
author | David 'Digit' Turner <digit@google.com> | 2014-12-07 14:24:43 +0100 |
---|---|---|
committer | David 'Digit' Turner <digit@google.com> | 2014-12-08 09:27:26 +0100 |
commit | e8d37d5d88fa24a66ea8467e9b87a665b5e56992 (patch) | |
tree | 57345b9ec703cd08608f90ab7a63d3affc8da0af /emulator | |
parent | 6e909dbb16b137b08545df345c3fcffd262ffc7f (diff) | |
download | sdk-e8d37d5d88fa24a66ea8467e9b87a665b5e56992.zip sdk-e8d37d5d88fa24a66ea8467e9b87a665b5e56992.tar.gz sdk-e8d37d5d88fa24a66ea8467e9b87a665b5e56992.tar.bz2 |
emulator/opengl: Remove obsolete directory.
All sources were moved to external/qemu/distrib/android-emugl
to make it easier to modify both the emulator and host libraries
at the same time. See:
https://android-review.googlesource.com/#/c/118203/
As such, the sources in this directory are now ignored and can be
safely removed.
Change-Id: I5d143c971f995e2599e5e1d6174030d6803e8080
Diffstat (limited to 'emulator')
260 files changed, 2 insertions, 43724 deletions
diff --git a/emulator/opengl/Android.mk b/emulator/opengl/Android.mk deleted file mode 100644 index 42d12ca..0000000 --- a/emulator/opengl/Android.mk +++ /dev/null @@ -1,84 +0,0 @@ -# This is the top-level build file for the Android HW OpenGL ES emulation -# in Android. -# -# You must define BUILD_EMULATOR_HOST_OPENGL to 'true' in your environment to -# build the following files. -# -ifeq (true,$(BUILD_EMULATOR_HOST_OPENGL)) - -# Top-level for all modules -EMUGL_PATH := $(call my-dir) - -# Directory containing common headers used by several modules -# This is always set to a module's LOCAL_C_INCLUDES -# See the definition of emugl-begin-module in common.mk -# -EMUGL_COMMON_INCLUDES := \ - $(EMUGL_PATH)/host/include/libOpenglRender \ - $(EMUGL_PATH)/shared - -ifeq ($(BUILD_STANDALONE_EMULATOR),true) -EMUGL_COMMON_INCLUDES := $(EMUGL_PATH)/host/libs/Translator/include -endif - -# common cflags used by several modules -# This is always set to a module's LOCAL_CFLAGS -# See the definition of emugl-begin-module in common.mk -# -EMUGL_COMMON_CFLAGS := -DWITH_GLES2 - -# Define EMUGL_BUILD_DEBUG=1 in your environment to build a -# debug version of the EmuGL host binaries. -ifneq (,$(strip $(EMUGL_BUILD_DEBUG))) -EMUGL_COMMON_CFLAGS += -O0 -g -DEMUGL_DEBUG=1 -endif - -# Uncomment the following line if you want to enable debug traces -# in the GLES emulation libraries. -# EMUGL_COMMON_CFLAGS += -DEMUGL_DEBUG=1 - -# Include common definitions used by all the modules included later -# in this build file. This contains the definition of all useful -# emugl-xxxx functions. -# -include $(EMUGL_PATH)/common.mk - -# IMPORTANT: ORDER IS CRUCIAL HERE -# -# For the import/export feature to work properly, you must include -# modules below in correct order. That is, if module B depends on -# module A, then it must be included after module A below. -# -# This ensures that anything exported by module A will be correctly -# be imported by module B when it is declared. -# -# Note that the build system will complain if you try to import a -# module that hasn't been declared yet anyway. -# - -# Required by our units test. -include $(EMUGL_PATH)/googletest.mk - -# First, build the emugen host source-generation tool -# -# It will be used by other modules to generate wire protocol encode/decoder -# source files (see all emugl-gen-decoder/encoder in common.mk) -# -include $(EMUGL_PATH)/host/tools/emugen/Android.mk - -include $(EMUGL_PATH)/shared/emugl/common/Android.mk -include $(EMUGL_PATH)/shared/OpenglCodecCommon/Android.mk - -# Host static libraries -include $(EMUGL_PATH)/host/libs/GLESv1_dec/Android.mk -include $(EMUGL_PATH)/host/libs/GLESv2_dec/Android.mk -include $(EMUGL_PATH)/host/libs/renderControl_dec/Android.mk -include $(EMUGL_PATH)/host/libs/Translator/GLcommon/Android.mk -include $(EMUGL_PATH)/host/libs/Translator/GLES_CM/Android.mk -include $(EMUGL_PATH)/host/libs/Translator/GLES_V2/Android.mk -include $(EMUGL_PATH)/host/libs/Translator/EGL/Android.mk - -# Host shared libraries -include $(EMUGL_PATH)/host/libs/libOpenglRender/Android.mk - -endif # BUILD_EMULATOR_HOST_OPENGL == true diff --git a/emulator/opengl/DESIGN b/emulator/opengl/DESIGN deleted file mode 100644 index 70a5d27..0000000 --- a/emulator/opengl/DESIGN +++ /dev/null @@ -1,614 +0,0 @@ -Android Hardware OpenGLES emulation design overview -=================================================== - -Introduction: -------------- - -Hardware GLES emulation in the Android platform is implemented with a mix -of components, which are: - - - Several host "translator" libraries. They implement the EGL, GLES 1.1 and - GLES 2.0 ABIs defined by Khronos, and translate the corresponding function - calls into calls to the appropriate desktop APIs, i.e.: - - - Xgl (Linux), AGL (OS X) or WGL (Windows) for EGL - - desktop GL 2.0 for GLES 1.1 and GLES 2.0 - - _________ __________ __________ - | | | | | | HOST - |TRANSLATOR |TRANSLATOR| |TRANSLATOR| HOST - | EGL | | GLES 1.1 | | GLES 2.0 | TRANSLATOR - |_________| |__________| |__________| LIBRARIES - | | | - - - - | - - - - - - - - - | - - - - - - - - - | - - - - - - | | | - ____v____ ____v_____ _____v____ HOST - | | | | | | SYSTEM - | Xgl | | GL 2.0 | | GL 2.0 | LIBRARIES - |_________| |__________| |__________| - - - - - Several system libraries inside the emulated guest system that implement - the same EGL / GLES 1.1 and GLES 2.0 ABIs. - - They collect the sequence of EGL/GLES function calls and translate then - into a custom wire protocol stream that is sent to the emulator program - through a high-speed communication channel called a "QEMU Pipe". - - For now, all you need to know is that the pipe is implemented with a - custom kernel driver, and provides for _very_ fast bandwidth. All read() - and writes() from/to the pipes are essentially instantaneous from the - guest's point of view. - - - _________ __________ __________ - | | | | | | - |EMULATION| |EMULATION | |EMULATION | GUEST - | EGL | | GLES 1.1 | | GLES 2.0 | SYSTEM - |_________| |__________| |__________| LIBRARIES - | | | - - - - | - - - - - - - - - | - - - - - - - - - | - - - - - - | | | - ____v____________________v____________________v____ GUEST - | | KERNEL - | QEMU PIPE | - |___________________________________________________| - | - - - - - - - - - - - - - - -|- - - - - - - - - - - - - - - - - | - v - EMULATOR - - - Specific code inside the emulator program that is capable of transmitting - the wire protocol stream to a special rendering library or process (called - the "renderer" here), which understands the format. - - | - | PROTOCOL BYTE STREAM - _____v_____ - | | - | EMULATOR | - |___________| - | - | UNMODIFIED PROTOCOL BYTE STREAM - _____v_____ - | | - | RENDERER | - |___________| - - - - The renderer decodes the EGL/GLES commands from the wire - protocol stream, and dispatches them to the translator libraries - appropriately. - - | - | PROTOCOL BYTE STREAM - _____v_____ - | | - | RENDERER | - |___________| - | | | - +-----------------+ | +-----------------+ - | | | - ____v____ ___v______ ____v_____ - | | | | | | HOST - |TRANSLATOR |TRANSLATOR| |TRANSLATOR| HOST - | EGL | | GLES 1.1 | | GLES 2.0 | TRANSLATOR - |_________| |__________| |__________| LIBRARIES - - - - - In reality, the protocol stream flows in both directions, even though most - of the commands result in data going from the guest to the host. A complete - picture of the emulation would thus be: - - - - - - _________ __________ __________ - | | | | | | - |EMULATION| |EMULATION | |EMULATION | GUEST - | EGL | | GLES 1.1 | | GLES 2.0 | SYSTEM - |_________| |__________| |__________| LIBRARIES - ^ ^ ^ - | | | - - - - | - - - - - - - - - | - - - - - - - - - | - - - - - - | | | - ____v____________________v____________________v____ GUEST - | | KERNEL - | QEMU PIPE | - |___________________________________________________| - ^ - | - - - - - - - - - - - - - - -|- - - - - - - - - - - - - - - - - | - | PROTOCOL BYTE STREAM - _____v_____ - | | - | EMULATOR | - |___________| - ^ - | UNMODIFIED PROTOCOL BYTE STREAM - _____v_____ - | | - | RENDERER | - |___________| - ^ ^ ^ - | | | - +-----------------+ | +-----------------+ - | | | - ____v____ ___v______ ____v_____ - | | | | | | - |TRANSLATOR |TRANSLATOR| |TRANSLATOR| HOST - | EGL | | GLES 1.1 | | GLES 2.0 | TRANSLATOR - |_________| |__________| |__________| LIBRARIES - ^ ^ ^ - | | | - - - - | - - - - - - - - - | - - - - - - - - - | - - - - - - | | | - ____v____ ____v_____ _____v____ HOST - | | | | | | SYSTEM - | Xgl | | GL 2.0 | | GL 2.0 | LIBRARIES - |_________| |__________| |__________| - - (NOTE: 'Xgl' is for Linux only, replace 'AGL' on OS X, and 'WGL' on Windows). - - -Note that, in the above graphics, only the host system libraries at the bottom -are _not_ provided by Android. - - -Design Requirements: --------------------- - -The above design comes from several important requirements that were decided -early in the project: - -1 - The ability to run the renderer in a separate process from the emulator - itself is important. - - For various practical reasons, we plan to completely separate the core QEMU - emulation from the UI window by using two distinct processes. As such, the - renderer will be implemented as a library inside the UI program, but will - need to receive protocol bytes from the QEMU process. - - The communication channel will be either a fast Unix socket or a Win32 - named pipe between these two. A shared memory segment with appropriate - synchronization primitives might also be used if performance becomes - an issue. - - This explains why the emulator doesn't alter or even try to parse the - protocol byte stream. It only acts as a dumb proxy between the guest - system and the renderer. This also avoids adding lots of GLES-specific - code inside the QEMU code base which is terribly complex. - -2 - The ability to use vendor-specific desktop EGL/GLES libraries is - important. - - GPU vendors like NVidia, AMD or ARM all provide host versions of the - EGL/GLES libraries that emulate their respectivie embedded graphics - chipset. - - The renderer library can be configured to use these instead of the - translator libraries provided with this project. This can be useful to - more accurately emulate the behaviour of specific devices. - - Moreover, these vendor libraries typically expose vendor-specific - extensions that are not provided by the translator libraries. We cannot - expose them without modifying our code, but it's important to be able - to do so without too much pain. - - -Code organization: ------------------- - -All source code for the components above is spread over multiple directories -in the Android source trees: - - - The emulator sources are under $ANDROID/external/qemu, which we'll - call $QEMU in the rest of this document. - - - The guest libraries are under - $ANDROID/development/tools/emulator/opengl, which we'll call $EMUGL_GUEST - - - The host renderer and translator libraries are under - $ANDROID/sdk/emulator/opengl, which we'll call $EMUGL_HOST - - - The QEMU Pipe kernel driver is under $KERNEL/drivers/misc/qemupipe - -Where $ANDROID is the top of the open-source Android source tree, and -$KERNEL is the top of the qemu-specific kernel source tree (using one -of the android-goldfish-xxxx branches here). - -The emulator sources related to this projects are: - - $QEMU/hw/goldfish_pipe.c -> implement QEMU pipe virtual hardware - $QEMU/hw/opengles.c -> implement GLES initialization - $QEMU/hw/hw-pipe-net.c -> implements the communication channel - between the QEMU Pipe and the renderer library - -The other sources are: - - $EMUGL_GUEST/system -> system libraries - $EMUGL_GUEST/shared -> guest copy of shared libraries - $EMUGL_GUEST/tests -> various test programs - $EMUGL_HOST/host -> host libraries (translator + renderer) - $EMUGL_HOST/shared -> host copy of shared libraries - $EMUGL_HOST/tests -> various test programs - -The reason the shared libraries aren't actually shared is historical: at one -point both guest and host code lived in the same place. That turned out to be -impractical with the way the Android SDK is branched, and didn't support the -requirement that a single emulator binary be able to run several generations -of Android. - - -Translator libraries: ---------------------- - -There are three translator host libraries provided by this project: - - libEGL_translator -> EGL 1.2 translation - libGLES_CM_translator -> GLES 1.1 translation - libGLES_V2_translator -> GLES 2.0 translation - -The full name of the library will depend on the host system. -For simplicity, only the library name suffix will change (i.e. the -'lib' prefix is not dropped on Windows), i.e.: - - libEGL_translator.so -> for Linux - libEGL_translator.dylib -> for OS X - libEGL_translator.dll -> for Windows - -The source code for these libraries is located under the following -path in the Android source tree: - - $EMUGL_HOST/host/libs/Translator/EGL - $EMUGL_HOST/host/libs/Translator/GLES_CM - $EMUGL_HOST/host/libs/Translator/GLES_V2 - -The translator libraries also use a common routines defined under: - - $EMUGL_HOST/host/libs/Translator/GLcommon - - -Wire Protocol Overiew: ----------------------- - -The "wire protocol" is implemented as follows: - - - EGL/GLES function calls are described through several "specification" - files, which describes the types, function signatures and various - attributes for each one of them. - - - These files are read by a tool called "emugen" which generates C - source files and headers based on the specification. These correspond - to both encoding, decoding and "wrappers" (more on this later). - - - System "encoder" static libraries are built using some of these generated - files. They contain code that can serialize EGL/GLES calls into simple - byte messages and send it through a generic "IOStream" object. - - - Host "decoder" static libraries are also built using some of these - generated files. Their code retrieves byte messages from an "IOStream" - object, and translates them into function callbacks. - -IOStream abstraction: -- - - - - - - - - - - - -The "IOStream" is a very simple abstract class used to send byte messages -both in the guest and host. It is defined through a shared header under -$EMUGL/host/include/libOpenglRender/IOStream.h - -Note that despite the path, this header is included by *both* host and guest -source code. The main idea around IOStream's design is that to send a message, -one does the following: - - 1/ call stream->allocBuffer(size), which returns the address of a - memory buffer of at least 'size' bytes. - - 2/ write the content of the serialized command (usually a header + some - payload) directly into the buffer - - 3/ call stream->commitBuffer() to send it. - -Alternatively, one can also pack several commands into a single buffer with -stream->alloc() and stream->flush(), as in: - - 1/ buf1 = stream->alloc(size1) - 2/ write first command bytes into buf1 - 3/ buf2 = stream->alloc(size2) - 4/ write second command bytes into buf2 - 5/ stream->flush() - -Finally, there are also explict read/write methods like stream->readFully() -or stream->writeFully() which can be used when you don't want an intermediate -buffer. This is used in certain cases by the implementation, e.g. to avoid -an intermediate memory copy when sending texture data from the guest to the -host. - -The host IOStream implementations are under $EMUGL/shared/OpenglCodecCommon/, -see in particular: - - $EMUGL_HOST/shared/OpenglCodecCommon/TcpStream.cpp - -> using local TCP sockets - $EMUGL_HOST/shared/OpenglCodecCommon/UnixStream.cpp - -> using Unix sockets - $EMUGL_HOST/shared/OpenglCodecCommon/Win32PipeStream.cpp - -> using Win32 named pipes - -The guest IOStream implementation uses the TcpStream.cpp above, as well as -an alternative QEMU-specific source: - - $EMUGL_GUEST/system/OpenglSystemCommon/QemuPipeStream.cpp - -> uses QEMU pipe from the guest - -The QEMU Pipe implementation is _significantly_ faster (about 20x) due to -several reasons: - - - all succesful read() and write() operations through it are instantaneous - from the guest's point of view. - - - all buffer/memory copies are performed directly by the emulator, and thus - much faster than performing the same thing inside the kernel with emulated - ARM instructions. - - - it doesn't need to go through a kernel TCP/IP stack that will wrap the - data into TCP/IP/MAC packets, send them to an emulated ethernet device, - which is itself connected to an internal firewall implementation that - will unwrap the packets, re-assemble them, then send them through BSD - sockets to the host kernel. - -However, would it be necessary, you could write a guest IOStream implementation -that uses a different transport. If you do, please look at -$EMUGL_GUEST/system/OpenglCodecCommon/HostConnection.cpp which contains the -code used to connect the guest to the host, on a per-thread basis. - - -Source code auto-generation: -- - - - - - - - - - - - - - - -The 'emugen' tool is located under $EMUGL_HOST/host/tools/emugen. There is a -README file that explains how it works. - -You can also look at the following specifications files: - -For GLES 1.1: - $EMUGL_HOST/host/GLESv1_dec/gl.types - $EMUGL_HOST/host/GLESv1_dec/gl.in - $EMUGL_HOST/host/GLESv1_dec/gl.attrib - -For GLES 2.0: - $EMUGL_HOST/host/GLESv2_dec/gl2.types - $EMUGL_HOST/host/GLESv2_dec/gl2.in - $EMUGL_HOST/host/GLESv2_dec/gl2.attrib - -For EGL: - $EMUGL_HOST/host/renderControl_dec/renderControl.types - $EMUGL_HOST/host/renderControl_dec/renderControl.in - $EMUGL_HOST/host/renderControl_dec/renderControl.attrib - -Note that the EGL specification files are under a directory named -"renderControl_dec" and have filenames that begin with "renderControl" - -This is mainly for historic reasons now, but is also related to the fact that -this part of the wire protocol contains support functions/calls/specifications -that are not part of the EGL specification itself, but add a few features -required to make everything works. For example, they have calls related to -the "gralloc" system library module used to manage graphics surfaces at a -lower level than EGL. - -Generally speaking, guest encoder sources are located under directories -named $EMUGL_GUEST/system/<name>_enc/, while the corresponding host decoder -sources will be under $EMUGL_HOST/host/libs/<name>_dec/ - -However, all these sources use the same spec files located under the -decoding directories. - -The encoder files are built from emugen and spec files located in $EMUGL_HOST -and copied to the encoder directories in $EMUGL_GUEST by the gen-encoder.sh -script. They are checked in, so that a given version of Android supports a -specific version of the protocol, even if newer versions of the renderer (and -future Android versions) support a newer protocol version. This step needs to -be done manually when the protocol changes; these changes also need to be -accompanied by changes in the renderer to handle the old version of the -protocol. - - -System libraries: ------------------ - -Meta EGL/GLES system libraries, and egl.cfg: -- - - - - - - - - - - - - - - - - - - - - - - -It is important to understand that the emulation-specific EGL/GLES libraries -are not directly linked by applications at runtime. Instead, the system -provides a set of "meta" EGL/GLES libraries that will load the appropriate -hardware-specific libraries on first use. - -More specifically, the system libEGL.so contains a "loader" which will try -to load: - - - hardware-specific EGL/GLES libraries - - the software-based rendering libraries (called "libagl") - -The system libEGL.so is also capable of merging the EGL configs of both the -hardware and software libraries transparently to the application. The system -libGLESv1_CM.so and libGLESv2.so, work with it to ensure that the thread's -current context will be linked to either the hardware or software libraries -depending on the config selected. - -For the record, the loader's source code in under -frameworks/base/opengl/libs/EGL/Loader.cpp. It depends on a file named -/system/lib/egl/egl.cfg which must contain two lines that look like: - - 0 1 <name> - 0 0 android - -The first number in each line is a display number, and must be 0 since the -system's EGL/GLES libraries don't support anything else. - -The second number must be 1 to indicate hardware libraries, and 0 to indicate -a software one. The line corresponding to the hardware library, if any, must -always appear before the one for the software library. - -The third field is a name corresponding to a shared library suffix. It really -means that the corresponding libraries will be named libEGL_<name>.so, -libGLESv1_CM_<name>.so and libGLESv2_<name>.so. Moreover these libraries must -be placed under /system/lib/egl/ - -The name "android" is reserved for the system software renderer. - -The egl.cfg that comes with this project uses the name "emulation" for the -hardware libraries. This means that it provides an egl.cfg file that contains -the following lines: - - 0 1 emulation - 0 0 android - -See $EMUGL_GUEST/system/egl/egl.cfg and more generally the following build -files: - - $EMUGL_GUEST/system/egl/Android.mk - $EMUGL_GUEST/system/GLESv1/Android.mk - $EMUGL_GUEST/system/GLESv2/Android.mk - -to see how the libraries are named and placed under /system/lib/egl/ by the -build system. - - -Emulation libraries: -- - - - - - - - - - - - -The emulator-specific libraries are under the following: - - $EMUGL_GUEST/system/egl/ - $EMUGL_GUEST/system/GLESv1/ - $EMUGL_GUEST/system/GLESv2/ - -The code for GLESv1 and GLESv2 is pretty small, since it mostly link against -the static encoding libraries. - -The code for EGL is a bit more complex, because it needs to deal with -extensions dynamically. I.e. if an extension is not available on the host -it shouldn't be exposed by the library at runtime. So the EGL code queries -the host for the list of available extensions in order to return them to -clients. Similarly, it must query the list of valid EGLConfigs for the -current host system. - - -"gralloc" module implementation: -- - - - - - - - - - - - - - - - - - -In addition to EGL/GLES libraries, the Android system requires a -hardware-specific library to manage graphics surfaces at a level lower than -EGL. This library must be what is called in Android land as a "HAL module". - -A "HAL module" must provide interfaces defined by Android's HAL -(Hardware Abstraction Library). These interface definitions can be found -under $ANDROID/hardware/libhardware/include/ - -Of all possible HAL modules, the "gralloc" one is used by the system's -SurfaceFlinger to allocate framebuffers and other graphics memory regions, -as well as eventually lock/unlock/swap them when needed. - -The code under $EMUGL/system/gralloc/ implements the module required by the -GLES emulation project. It's not very long, but there are a few things to -notice here: - -- first, it will probe the guest system to determine if the emulator that - is running the virtual device really supports GPU emulation. In certain - circumstances this may not be possible. - - If this is the case, then the module will redirect all calls to the - "default" gralloc module that is normally used by the system when - software-only rendering is enabled. - - The probing happens in the function "fallback_init" which gets called - when the module is first opened. This initializes the 'sFallback' variable - to a pointer to the default gralloc module when required. - -- second, this module is used by SurfaceFlinger to display "software surfaces", - i.e. those that are backed by system memory pixel buffers, and written to - directly through the Skia graphics library (i.e. the non-accelerated ones). - - the default module simply copies the pixel data from the surface to the - virtual framebuffer i/o memory, but this project's gralloc module sends it - to the renderer through the QEMU Pipe instead. - - It turns out that this results in _faster_ rendering/frame-rates overall, - because memory copies inside the guest are slow, while QEMU pipe transfers - are done directly in the emulator. - - -Host Renderer: --------------- - -The host renderer library is located under -$EMUGL_HOST/host/libs/libOpenglRender, and it provides an interface described -by the headers under $EMUGL_HOST/host/include/libOpenglRender/render_api.h -(e.g. for use by the emulator). - -In a nutshell, the rendering library is responsible for the following: - - - Providing a virtual off-screen video surface where everything will get - rendered at runtime. Its dimensions are fixed by the call to - initOpenglRender() that must happen just after the library is - initialized. - - - Provide a way to display the virtual video surface on a host application's - UI. This is done by calling createOpenGLSubWindow() which takes as argument - the window ID or handle of a parent window, some display dimensions and - a rotation angle. This allows the surface to be scaled/rotated when it is - displayed, even if the dimensions of the video surface do not change. - - - Provide a way to listen to incoming EGL/GLES commands from the guest. - This is done by providing a so-called "port number" to initOpenglRender(). - - By default, the port number corresponds to a local TCP port number that the - renderer will bind to and listen. Every new connection to this port will - correspond to the creation of a new guest host connection, each such - connection corresponding to a distinct thread in the guest system. - - For performance reasons, it is possible to listen to either Unix sockets - (on Linux and OS X), or to a Win32 named pipe (on Windows). To do so, one - had to call setStreamType() between library initialization - (i.e. initLibrary()) and construction (i.e. initOpenglRender()). - - Note that in these modes, the port number is still used to differentiate - between several emulator instances. These details are normally handled by - the emulator code so you shouldn't care too much. - -Note that an earlier version of the interface allowed a client of the renderer -library to provide its own IOStream implementation. However, this wasn't very -convenient for a number of reasons. This maybe something that could be done -again if it makes sense, but for now the performance numbers are pretty good. - - -Host emulator: --------------- - -The code under $QEMU/android/opengles.c is in charge of dynamically loading -the rendering library and initializing / constructing it properly. - -QEMU pipe connections to the 'opengles' service are piped through the code -in $QEMU/android/hw-pipe-net.c. Look for the openglesPipe_init() function, -which is in charge of creating a connection to the renderer library -(either through a TCP socket, or a Unix pipe depending on configuration. -support for Win32 named pipes hasn't been implemented yet in the emulator) -whenever a guest process opens the "opengles" service through /dev/qemu_pipe. - -There is also some support code for the display of the GLES framebuffer -(through the renderer library's subwindow) under $QEMU/skin/window. - -Note that at the moment, scaling and rotation are supported. However, -brightness emulation (which used to modify the pixel values from the -hardware framebuffer before displaying them) doesn't work. - -Another issue is that it is not possible to display anything on top of the -GL subwindow at the moment. E.g. this will obscure the emulated trackball -image (that is normally toggled with Ctrl-T during emulation, or enabled -by pressing the Delete key). - diff --git a/emulator/opengl/README b/emulator/opengl/README index f806b41..11b10aa 100644 --- a/emulator/opengl/README +++ b/emulator/opengl/README @@ -1,96 +1,3 @@ -This directory contains the host-side modules related to hardware OpenGL ES -emulation. The guest-side modules are in -$ANDROID_BUILD_TOP/development/tools/emulator/opengl. - -I. Overview of components: -========================== - -The 'emugen' tool is used to generate several source files related to the -EGL/GLES command stream used between the guest and the host during emulation. - - host/tools/emugen -> emugen program - -Note that emugen is capable of generating, from a single set of specification -files, three types of auto-generated sources: - - - sources to encode commands into a byte stream. - - sources to decode the byte stream into commands. - - sources to wrap normal procedural EGL/GLES calls into context-aware ones. - -Modules under the system/ directory corresponds to code that runs on the -guest, and implement the marshalling of EGL/GLES commands into a stream of -bytes sent to the host through a fast pipe mechanism. - - system/GLESv1_enc -> encoder for GLES 1.1 commands - system/GLESv2_enc -> encoder for GLES 2.0 commands - system/renderControl_enc -> encoder for rendering control commands - system/egl -> emulator-specific guest EGL library - system/GLESv1 -> emulator-specific guest GLES 1.1 library - system/gralloc -> emulator-specific gralloc module - system/OpenglSystemCommon -> library of common routines - -Modules under the host/ directory corresponds to code that runs on the -host, and implement the decoding of the command stream, translation of -EGL/GLES commands into desktop GL 2.0 ones, and rendering to an off-screen -buffer. - - host/libs/GLESv1_dec -> decoder for GLES 1.1 commands - host/libs/GLESv2_dec -> decoder for GLES 2.0 commands - host/libs/renderControl_dec -> decoder for rendering control commands - - host/libs/Translator/EGL -> translator for EGL commands - host/libs/Translator/GLES_CM -> translator for GLES 1.1 commands - host/libs/Translator/GLES_V2 -> translator for GLES 2.0 commands - host/libs/Translator/GLcommon -> library of common translation routines - - host/libs/libOpenglRender -> rendering library (uses all host libs above) - can be used by the 'renderer' program below, - or directly linked into the emulator UI program. - - host/renderer/ -> stand-alone renderer program executable. - this can run in head-less mode and receive requests from - several emulators at the same time. It is the receiving - end of all command streams. - -Modules under the test/ directory correspond to test programs that are useful -to debug the various modules described above: - - tests/EGL_host_wrapper -> a small library used to dynamically load the - desktop libEGL.so or a replacement named by the - ANDROID_EGL_LIB environment variable. This lib - provides all EGL entry points. - - tests/emulator_test_renderer -> a small program to run the rendering library - in a single SDL window on the host desktop. - - tests/gles_android_wrapper -> guest EGL / GLES libraries that are run on - the device to run some tests. Replace the - system/egl and system/GLESv1 modules for now. - - tests/translator_tests/GLES_CM -> desktop GLESv1 translation unit test - tests/translator_tests/GLES_V2 -> desktop GLESv2 translation unit test - tests/translator_tests/MacCommon -> used by translation tests on Mac only. - - tests/ut_rendercontrol_enc -> guest library used by tests/ut_renderer - tests/ut_rendercontrol_dec -> host library used by tests/ut_renderer - tests/ut_renderer -> unit-test for render control and rendering library. - - -II. Build system considerations: --------------------------------- - -The dependencies on the more than 20 components described in the previous -section are pretty sophisticated, involving lots of auto-generated code and -non-trivial placement for guest/device libraries. - -To simplify the development and maintenance of these modules, a set of -helper GNU Make function is defined in common.mk, and included from the -Android.mk in this directory. - -These functions all begin with the "emugl-" prefix, and can be used to -declare modules, what information they export to other modules, or import -from them, and also what kind of auto-generated sources they depend on. - -Look at the comments inside common.mk and the Android.mk of the modules -to better understand what's happening. +The sources in this directory have been moved to: + external/qemu/distrib/android-emugl diff --git a/emulator/opengl/common.mk b/emulator/opengl/common.mk deleted file mode 100644 index 255b9e3..0000000 --- a/emulator/opengl/common.mk +++ /dev/null @@ -1,258 +0,0 @@ -# This top-level build file is included by all modules that implement -# the hardware OpenGL ES emulation for Android. -# -# We use it to ensure that all sub-Makefiles are included in the right -# order for various variable definitions and usage to happen in the correct -# order. -# - -# The following macros are used to start a new GLES emulation module. -# -# This will define LOCAL_MODULE as $1, plus a few other variables -# needed by the build system (e.g. LOCAL_MODULE_TAGS, LOCAL_MODULE_CLASS...) -# -# NOTE: You still need to define LOCAL_PATH before this -# -# Usage example: -# -# $(call emugl-begin-static-library,<name>) -# LOCAL_SRC_FILES := .... -# LOCAL_C_INCLUDES += .... -# $(call emugl-end-module) -# -emugl-begin-host-static-library = $(call emugl-begin-module,$1,HOST_STATIC_LIBRARY,HOST) -emugl-begin-host-shared-library = $(call emugl-begin-module,$1,HOST_SHARED_LIBRARY,HOST) -emugl-begin-host-executable = $(call emugl-begin-module,$1,HOST_EXECUTABLE,HOST) - -emugl-begin-host64-static-library = $(call emugl-begin-module64,$1,HOST_STATIC_LIBRARY,HOST) -emugl-begin-host64-shared-library = $(call emugl-begin-module64,$1,HOST_SHARED_LIBRARY,HOST) -emugl-begin-host64-executable = $(call emugl-begin-module64,$1,HOST_EXECUTABLE,HOST) - -# Internal list of all declared modules (used for sanity checking) -_emugl_modules := -_emugl_HOST_modules := - -ifeq ($(BUILD_STANDALONE_EMULATOR),true) -EMUGL_LOCAL_EXTRAS = $(end-emulator-module-ev) -else # BUILD_STANDALONE_EMULATOR != true -EMUGL_LOCAL_EXTRAS = -endif # BUILD_STANDALONE_EMULATOR != true - -# do not use directly, see functions above instead -emugl-begin-module = \ - $(eval include $(CLEAR_VARS)) \ - $(eval LOCAL_MODULE := $1) \ - $(eval LOCAL_MODULE_TAGS := $(if $3,,debug)) \ - $(eval LOCAL_MODULE_CLASS := $(patsubst HOST_%,%,$(patsubst %EXECUTABLE,%EXECUTABLES,$(patsubst %LIBRARY,%LIBRARIES,$2)))) \ - $(eval LOCAL_IS_HOST_MODULE := $(if $3,true,))\ - $(eval LOCAL_C_INCLUDES += $(EMUGL_COMMON_INCLUDES)) \ - $(eval LOCAL_CFLAGS += $(EMUGL_COMMON_CFLAGS)) \ - $(eval LOCAL_LDLIBS += -lstdc++) \ - $(eval LOCAL_PRELINK_MODULE := false)\ - $(eval _EMUGL_INCLUDE_TYPE := $(BUILD_$2)) \ - $(eval LOCAL_MODULE_BITS := 32) \ - $(call _emugl-init-module,$1,$2,$3) - -emugl-begin-module64 = \ - $(call emugl-begin-module,$1,$2,$3) \ - $(eval LOCAL_MODULE_BITS := 64) \ - -# Used to end a module definition, see function definitions above -emugl-end-module = \ - $(eval $(EMUGL_LOCAL_EXTRAS)) \ - $(eval include $(_EMUGL_INCLUDE_TYPE))\ - $(eval _EMUGL_INCLUDE_TYPE :=) \ - $(eval _emugl_$(_emugl_HOST)modules += $(_emugl_MODULE))\ - $(if $(EMUGL_DEBUG),$(call emugl-dump-module)) - -# Managing module exports and imports. -# -# A module can 'import' another module, by calling emugl-import. This will -# make the current LOCAL_MODULE inherit various definitions exported from -# the imported module. -# -# Module exports are defined by calling emugl-export. Here is an example: -# -# $(call emugl-begin-static-library,foo) -# LOCAL_SRC_FILES := foo.c -# $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) -# $(call emugl-export,SHARED_LIBRARIES,libcutils) -# $(call emugl-end-module) -# -# $(call emugl-begin-shared-library,bar) -# LOCAL_SRC_FILES := bar.cpp -# $(call emugl-import,foo) -# $(call emugl-end-module) -# -# Here, we define a static library named 'foo' which exports an include -# path and a shared library requirement, and a shared library 'bar' which -# imports it. -# -# What this means is that: -# -# - 'bar' will automatically inherit foo's LOCAL_PATH in its LOCAL_C_INCLUDES -# - 'bar' will automatically inherit libcutils in its own LOCAL_SHARED_LIBRARIES -# -# Note that order of declaration matters. If 'foo' is defined after 'bar' in -# the example above, nothing will work correctly because dependencies are -# computed at import time. -# -# -# IMPORTANT: Imports are transitive, i.e. when module A imports B, -# it automatically imports anything imported by B too. - -# This is the list of recognized export types we support for now. -EMUGL_EXPORT_TYPES := \ - CFLAGS \ - CXXFLAGS \ - LDLIBS \ - LDFLAGS \ - C_INCLUDES \ - SHARED_LIBRARIES \ - STATIC_LIBRARIES \ - ADDITIONAL_DEPENDENCIES - -# Initialize a module in our database -# $1: Module name -# $2: Module type -# $3: "HOST" for a host module, empty for a target one. -_emugl-init-module = \ - $(eval _emugl_HOST := $(if $3,HOST_,))\ - $(eval _emugl_MODULE := $(_emugl_HOST)$1)\ - $(if $(filter $(_emugl_$(_emugl_HOST)modules),$(_emugl_MODULE)),\ - $(error There is already a $(if $3,host,) module named $1!)\ - )\ - $(eval _mod = $(_emugl_MODULE)) \ - $(eval _emugl.$(_mod).type := $(patsubst HOST_%,%,$2))\ - $(eval _emugl.$(_mod).imports :=) \ - $(eval _emugl,$(_mod).moved :=) \ - $(foreach _type,$(EMUGL_EXPORT_TYPES),\ - $(eval _emugl.$(_mod).export.$(_type) :=)\ - ) - -# Called to indicate that a module exports a given local variable for its -# users. This also adds this to LOCAL_$1 -# $1: Local variable type (e.g. CFLAGS, LDLIBS, etc...) -# $2: Value(s) to append to the export -emugl-export = \ - $(eval _emugl.$(_emugl_MODULE).export.$1 += $2)\ - $(eval LOCAL_$1 := $(LOCAL_$1) $2) - -emugl-export-outer = \ - $(eval _emugl.$(_emugl_MODULE).export.$1 += $2) - -# Called to indicate that a module imports the exports of another module -# $1: list of modules to import -# -emugl-import = \ - $(foreach _imod,$1,\ - $(call _emugl-module-import,$(_emugl_HOST)$(_imod))\ - ) - -_emugl-module-import = \ - $(eval _mod := $(_emugl_MODULE))\ - $(if $(filter-out $(_emugl_$(_emugl_HOST)modules),$1),\ - $(info Unknown imported emugles module: $1)\ - $(if $(_emugl_HOST),\ - $(eval _names := $(patsubst HOST_%,%,$(_emugl_HOST_modules))),\ - $(eval _names := $(_emugl_modules))\ - )\ - $(info Please one of the following names: $(_names))\ - $(error Aborting)\ - )\ - $(if $(filter-out $(_emugl.$(_mod).imports),$1),\ - $(eval _emugl.$(_mod).imports += $1)\ - $(foreach _sub,$(_emugl.$1.imports),\ - $(call _emugl-module-import,$(_sub))\ - )\ - $(foreach _type,$(EMUGL_EXPORT_TYPES),\ - $(eval LOCAL_$(_type) := $(LOCAL_$(_type)) $(_emugl.$1.export.$(_type)))\ - )\ - $(if $(filter EXECUTABLE SHARED_LIBRARY,$(_emugl.$(_emugl_MODULE).type)),\ - $(if $(filter STATIC_LIBRARY,$(_emugl.$1.type)),\ - $(eval LOCAL_STATIC_LIBRARIES := $(1:HOST_%=%) $(LOCAL_STATIC_LIBRARIES))\ - )\ - $(if $(filter SHARED_LIBRARY,$(_emugl.$1.type)),\ - $(if $(_emugl.$1.moved),,\ - $(eval LOCAL_SHARED_LIBRARIES := $(1:HOST_%=%) $(LOCAL_SHARED_LIBRARIES))\ - )\ - )\ - )\ - ) - -_emugl-dump-list = \ - $(foreach _list_item,$(strip $1),$(info . $(_list_item))) - -emugl-dump-module = \ - $(info MODULE=$(_emugl_MODULE))\ - $(info . HOST=$(_emugl_HOST))\ - $(info . TYPE=$(_emugl.$(_emugl_MODULE).type))\ - $(info . IMPORTS=$(_emugl.$(_emugl_MODULE).imports))\ - $(foreach _type,$(EMUGL_EXPORT_TYPES),\ - $(if $(filter C_INCLUDES ADDITIONAL_DEPENDENCIES,$(_type)),\ - $(info . EXPORT.$(_type) :=)\ - $(call _emugl-dump-list,$(_emugl.$(_emugl_MODULE).export.$(_type)))\ - $(info . LOCAL_$(_type) :=)\ - $(call _emugl-dump-list,$(LOCAL_$(_type)))\ - ,\ - $(info . EXPORT.$(_type) := $(strip $(_emugl.$(_emugl_MODULE).export.$(_type))))\ - $(info . LOCAL_$(_type) := $(strip $(LOCAL_$(_type))))\ - )\ - )\ - $(info . LOCAL_SRC_FILES := $(LOCAL_SRC_FILES))\ - -# This function can be called to generate the decoder source files. -# LOCAL_MODULE and LOCAL_MODULE_CLASS must be defined or the build will abort. -# Source files will be stored in the local intermediates directory that will -# be automatically added to your LOCAL_C_INCLUDES. -# -# Usage: -# $(call emugl-gen-decoder,<input-dir>,<basename>) -# -emugl-gen-decoder = \ - $(eval _emugl_out := $(call local-intermediates-dir))\ - $(call emugl-gen-decoder-generic,$(_emugl_out),$1,$2)\ - $(call emugl-export,C_INCLUDES,$(_emugl_out)) - -# DO NOT CALL DIRECTLY, USE emugl-gen-decoder instead. -# -# The following function can be called to generate wire protocol decoder -# source files, Usage is: -# -# $(call emugl-gen-decoder-generic,<dst-dir>,<src-dir>,<basename>) -# -# <dst-dir> is the destination directory where the generated sources are stored -# <src-dir> is the source directory where to find <basename>.attrib, etc.. -# <basename> is the emugen basename (see host/tools/emugen/README) -# -emugl-gen-decoder-generic = $(eval $(emugl-gen-decoder-generic-ev)) - -define emugl-gen-decoder-generic-ev -_emugl_dec := $$1/$$3 -_emugl_src := $$2/$$3 -GEN := $$(_emugl_dec)_dec.cpp \ - $$(_emugl_dec)_dec.h \ - $$(_emugl_dec)_opcodes.h \ - $$(_emugl_dec)_server_context.h \ - $$(_emugl_dec)_server_context.cpp - -$$(GEN): PRIVATE_PATH := $$(LOCAL_PATH) -$$(GEN): PRIVATE_CUSTOM_TOOL := $$(EMUGL_EMUGEN) -D $$1 -i $$2 $$3 -$$(GEN): $$(EMUGL_EMUGEN) $$(_emugl_src).attrib $$(_emugl_src).in $$(_emugl_src).types - $$(transform-generated-source) - -$$(call emugl-export,ADDITIONAL_DEPENDENCIES,$$(GEN)) -LOCAL_GENERATED_SOURCES += $$(GEN) -LOCAL_C_INCLUDES += $$1 -endef - -# Call this function when your shared library must be placed in a non-standard -# library path (i.e. not under /system/lib -# $1: library sub-path,relative to /system/lib -# For example: $(call emugl-set-shared-library-subpath,egl) -emugl-set-shared-library-subpath = \ - $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/$1)\ - $(eval LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/$1)\ - $(eval _emugl.$(LOCAL_MODULE).moved := true)\ - $(call emugl-export-outer,ADDITIONAL_DEPENDENCIES,$(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)$(TARGET_SHLIB_SUFFIX)) - diff --git a/emulator/opengl/gen-encoder.sh b/emulator/opengl/gen-encoder.sh deleted file mode 100755 index c55a170..0000000 --- a/emulator/opengl/gen-encoder.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Generate the Android-side encoder source files. -# Requirements: -# (a) The ANDROID_BUILD_TOP and ANDROID_HOST_OUT environment variables must be -# defined appropriately. The Android "lunch" bash function will do this. -# (b) The emugen binary must already be built. Any normal build that includes -# the emulator will do this. - -if [ -z "$ANDROID_BUILD_TOP" ]; then - echo error: ANDROID_BUILD_TOP not set - exit 1 -fi -cd "$ANDROID_BUILD_TOP" >/dev/null -SRCDIR="sdk/emulator/opengl/host/libs" -DSTDIR="device/generic/goldfish/opengl/system" -EMUGEN="external/qemu/objs/emugen" -if [ ! -d "$SRCDIR" -o ! -d "$DSTDIR" ]; then - echo error: can\'t find source and/or destination directory - exit 1 -fi -if [ ! -x "$EMUGEN" ]; then - echo error: emugen not available, did you forget to build? - exit 1 -fi - -function gen() { - local src="$SRCDIR/$1_dec" - local dst="$DSTDIR/$1_enc" - local name="$2" - echo "${EMUGEN}" -E "$dst" -i "$src" "$name" "$src/$name".{attrib,in,types} -} - -$(gen GLESv1 gl) -$(gen GLESv2 gl2) -$(gen renderControl renderControl) diff --git a/emulator/opengl/googletest.mk b/emulator/opengl/googletest.mk deleted file mode 100644 index 7cc511d..0000000 --- a/emulator/opengl/googletest.mk +++ /dev/null @@ -1,50 +0,0 @@ -# This contains common definitions used to define a host module -# to link GoogleTest with the EmuGL test programs. -# -# This is used instead of including external/gtest/Android.mk to -# be able to build both the 32-bit and 64-bit binaries while -# building a 32-bit only SDK (sdk-eng, sdk_x86-eng, sdk_mips-eng). - - -ifeq (true,$(BUILD_STANDALONE_EMULATOR)) -LOCAL_PATH := $(EMULATOR_GTEST_SOURCES_DIR) -else -LOCAL_PATH := $(EMUGL_PATH)/../../../external/gtest -endif - -common_SRC_FILES := \ - src/gtest-all.cc \ - src/gtest_main.cc - -common_CFLAGS := -O0 - -ifneq (windows,$(HOST_OS)) - common_LDLIBS += -lpthread -endif - -$(call emugl-begin-host-static-library,libemugl_gtest) -LOCAL_SRC_FILES := $(common_SRC_FILES) -LOCAL_CFLAGS += $(common_CFLAGS) -LOCAL_CPP_EXTENSION := .cc -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include) -$(call emugl-export,LDLIBS,$(common_LDLIBS)) -$(call emugl-end-module) - -$(call emugl-begin-host64-static-library,lib64emugl_gtest) -LOCAL_SRC_FILES := $(common_SRC_FILES) -LOCAL_CFLAGS += $(common_CFLAGS) -LOCAL_C_INCLUDES += $(LOCAL_PATH)/include -LOCAL_CPP_EXTENSION := .cc -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include) -$(call emugl-export,LDLIBS,$(common_LDLIBS)) -$(call emugl-end-module) - -$(call emugl-begin-host-static-library,libemugl_gtest_host) -LOCAL_SRC_FILES := $(common_SRC_FILES) -LOCAL_CFLAGS += $(common_CFLAGS) -LOCAL_C_INCLUDES += $(LOCAL_PATH)/include -LOCAL_CPP_EXTENSION := .cc -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include) -$(call emugl-export,LDLIBS,$(common_LDLIBS) -lpthread) -LOCAL_HOST_BUILD := true -$(call emugl-end-module) diff --git a/emulator/opengl/host/include/libOpenglRender/IOStream.h b/emulator/opengl/host/include/libOpenglRender/IOStream.h deleted file mode 100644 index 445ec17..0000000 --- a/emulator/opengl/host/include/libOpenglRender/IOStream.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -* 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 __IO_STREAM_H__ -#define __IO_STREAM_H__ - -#include <stdlib.h> -#include <stdio.h> - -#include "ErrorLog.h" - -class IOStream { -public: - - IOStream(size_t bufSize) { - m_buf = NULL; - m_bufsize = bufSize; - m_free = 0; - } - - virtual void *allocBuffer(size_t minSize) = 0; - virtual int commitBuffer(size_t size) = 0; - virtual const unsigned char *readFully( void *buf, size_t len) = 0; - virtual const unsigned char *read( void *buf, size_t *inout_len) = 0; - virtual int writeFully(const void* buf, size_t len) = 0; - - virtual ~IOStream() { - - // NOTE: m_buf is 'owned' by the child class thus we expect it to be released by it - } - - unsigned char *alloc(size_t len) { - - if (m_buf && len > m_free) { - if (flush() < 0) { - ERR("Failed to flush in alloc\n"); - return NULL; // we failed to flush so something is wrong - } - } - - if (!m_buf || len > m_bufsize) { - int allocLen = m_bufsize < len ? len : m_bufsize; - m_buf = (unsigned char *)allocBuffer(allocLen); - if (!m_buf) { - ERR("Alloc (%u bytes) failed\n", allocLen); - return NULL; - } - m_bufsize = m_free = allocLen; - } - - unsigned char *ptr; - - ptr = m_buf + (m_bufsize - m_free); - m_free -= len; - - return ptr; - } - - int flush() { - - if (!m_buf || m_free == m_bufsize) return 0; - - int stat = commitBuffer(m_bufsize - m_free); - m_buf = NULL; - m_free = 0; - return stat; - } - - const unsigned char *readback(void *buf, size_t len) { - flush(); - return readFully(buf, len); - } - - -private: - unsigned char *m_buf; - size_t m_bufsize; - size_t m_free; -}; - -// -// When a client opens a connection to the renderer, it should -// send unsigned int value indicating the "clientFlags". -// The following are the bitmask of the clientFlags. -// currently only one bit is used which flags the server -// it should exit. -// -#define IOSTREAM_CLIENT_EXIT_SERVER 1 - -#endif diff --git a/emulator/opengl/host/include/libOpenglRender/render_api.h b/emulator/opengl/host/include/libOpenglRender/render_api.h deleted file mode 100644 index 990903e..0000000 --- a/emulator/opengl/host/include/libOpenglRender/render_api.h +++ /dev/null @@ -1,160 +0,0 @@ -/* -* 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 _OPENGL_RENDERER_RENDER_API_H -#define _OPENGL_RENDERER_RENDER_API_H - -/* This header and its declarations must be usable from C code. - * - * If RENDER_API_NO_PROTOTYPES is #defined before including this header, only - * the interface function pointer types will be declared, not the prototypes. - * This allows the client to use those names for its function pointer variables. - * - * All interfaces which can fail return an int, with zero indicating failure - * and anything else indicating success. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdlib.h> -#include "render_api_platform_types.h" - -#if defined(RENDER_API_NO_PROTOTYPES) -#define DECL(ret, name, args) \ - typedef ret (* name##Fn) args -#else -#define DECL(ret, name, args) \ - typedef ret (* name##Fn) args ; \ - ret name args -#endif - -/* initLibrary - initialize the library and tries to load the corresponding - * GLES translator libraries. This function must be called before anything - * else to ensure that everything works. If it returns an error, then - * you cannot use the library at all (this can happen under certain - * environments where the desktop GL libraries are not available) - */ -DECL(int, initLibrary, (void)); - -/* list of constants to be passed to setStreamMode */ -#define STREAM_MODE_DEFAULT 0 -#define STREAM_MODE_TCP 1 -#define STREAM_MODE_UNIX 2 -#define STREAM_MODE_PIPE 3 - -/* Change the stream mode. This must be called before initOpenGLRenderer */ -DECL(int, setStreamMode, (int mode)); - -/* initOpenGLRenderer - initialize the OpenGL renderer process. - * - * width and height are the framebuffer dimensions that will be reported to the - * guest display driver. - * - * addr is a buffer of addrLen bytes that will receive the address that clients - * should connect to. The interpretation depends on the transport: - * - TCP: The buffer contains the port number as a string. The server is - * listening only on the loopback address. - * - Win32 and UNIX named pipes: The buffer contains the full path clients - * should connect to. - * - * This function is *NOT* thread safe and should be called first - * to initialize the renderer after initLibrary(). - */ -DECL(int, initOpenGLRenderer, (int width, int height, char* addr, size_t addrLen)); - -/* getHardwareStrings - describe the GPU hardware and driver. - * The underlying GL's vendor/renderer/version strings are returned to the - * caller. The pointers become invalid after a call to stopOpenGLRenderer(). - */ -DECL(void, getHardwareStrings, (const char** vendor, const char** renderer, - const char** version)); - -/* A per-frame callback can be registered with setPostCallback(); to remove it - * pass NULL for both parameters. While a callback is registered, the renderer - * will call it just before each new frame is displayed, providing a copy of - * the framebuffer contents. - * - * The callback will be called from one of the renderer's threads, so will - * probably need synchronization on any data structures it modifies. The - * pixels buffer may be overwritten as soon as the callback returns; if it - * needs the pixels afterwards it must copy them. - * - * The pixels buffer is intentionally not const: the callback may modify the - * data without copying to another buffer if it wants, e.g. in-place RGBA to - * RGB conversion, or in-place y-inversion. - * - * Parameters are: - * context The pointer optionally provided when the callback was - * registered. The client can use this to pass whatever - * information it wants to the callback. - * width, height Dimensions of the image, in pixels. Rows are tightly - * packed; there is no inter-row padding. - * ydir Indicates row order: 1 means top-to-bottom order, -1 means - * bottom-to-top order. - * format, type Format and type GL enums, as used in glTexImage2D() or - * glReadPixels(), describing the pixel format. - * pixels The framebuffer image. - * - * In the first implementation, ydir is always -1 (bottom to top), format and - * type are always GL_RGBA and GL_UNSIGNED_BYTE, and the width and height will - * always be the same as the ones passed to initOpenGLRenderer(). - */ -typedef void (*OnPostFn)(void* context, int width, int height, int ydir, - int format, int type, unsigned char* pixels); -DECL(void, setPostCallback, (OnPostFn onPost, void* onPostContext)); - -/* createOpenGLSubwindow - - * Create a native subwindow which is a child of 'window' - * to be used for framebuffer display. - * Framebuffer will not get displayed if a subwindow is not - * created. - * x,y,width,height are the dimensions of the rendering subwindow. - * zRot is the rotation to apply on the framebuffer display image. - */ -DECL(int, createOpenGLSubwindow, (FBNativeWindowType window, - int x, int y, int width, int height, float zRot)); - -/* destroyOpenGLSubwindow - - * destroys the created native subwindow. Once destroyed, - * Framebuffer content will not be visible until a new - * subwindow will be created. - */ -DECL(int, destroyOpenGLSubwindow, (void)); - -/* setOpenGLDisplayRotation - - * set the framebuffer display image rotation in units - * of degrees around the z axis - */ -DECL(void, setOpenGLDisplayRotation, (float zRot)); - -/* repaintOpenGLDisplay - - * causes the OpenGL subwindow to get repainted with the - * latest framebuffer content. - */ -DECL(void, repaintOpenGLDisplay, (void)); - -/* stopOpenGLRenderer - stops the OpenGL renderer process. - * This functions is *NOT* thread safe and should be called - * only if previous initOpenGLRenderer has returned true. - */ -DECL(int, stopOpenGLRenderer, (void)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/emulator/opengl/host/include/libOpenglRender/render_api_platform_types.h b/emulator/opengl/host/include/libOpenglRender/render_api_platform_types.h deleted file mode 100644 index 38324e1..0000000 --- a/emulator/opengl/host/include/libOpenglRender/render_api_platform_types.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -* 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 _RENDER_API_PLATFORM_TYPES_H -#define _RENDER_API_PLATFORM_TYPES_H - -#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ -#include <windows.h> - -typedef HDC FBNativeDisplayType; -typedef HWND FBNativeWindowType; - -#elif defined(__linux__) - -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -typedef Window FBNativeWindowType; - -#elif defined(__APPLE__) - -typedef void* FBNativeWindowType; - -#else -#warning "Unsupported platform" -#endif - -#endif // of _RENDER_API_PLATFORM_TYPES_H diff --git a/emulator/opengl/host/libs/GLESv1_dec/Android.mk b/emulator/opengl/host/libs/GLESv1_dec/Android.mk deleted file mode 100644 index c9db93e..0000000 --- a/emulator/opengl/host/libs/GLESv1_dec/Android.mk +++ /dev/null @@ -1,39 +0,0 @@ -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,libGLESv1_dec) - -$(call emugl-import, libOpenglCodecCommon) -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) - -$(call emugl-gen-decoder,$(LOCAL_PATH),gl) - -LOCAL_SRC_FILES := GLDecoder.cpp - -$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS)) -$(call emugl-export,LDLIBS,-lstdc++) - -$(call emugl-end-module) - - -### host library, 64-bit #################################### -$(call emugl-begin-host64-static-library,lib64GLESv1_dec) - -$(call emugl-import, lib64OpenglCodecCommon) -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) - -$(call emugl-gen-decoder,$(LOCAL_PATH),gl) - -LOCAL_SRC_FILES := GLDecoder.cpp - -$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS)) -$(call emugl-export,LDLIBS,-lstdc++) - -$(call emugl-end-module) diff --git a/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp b/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp deleted file mode 100644 index 725b815..0000000 --- a/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* -* 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. -*/ -#include "GLDecoder.h" -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <EGL/egl.h> -#include <GLES/gl.h> -#include <GLES/glext.h> - -static inline void* SafePointerFromUInt(GLuint value) { - return (void*)(uintptr_t)value; -} - -GLDecoder::GLDecoder() -{ - m_contextData = NULL; - m_glesDso = NULL; -} - -GLDecoder::~GLDecoder() -{ - if (m_glesDso != NULL) { - delete m_glesDso; - } -} - - -int GLDecoder::initGL(get_proc_func_t getProcFunc, void *getProcFuncData) -{ - if (getProcFunc == NULL) { - const char *libname = GLES_LIBNAME; - if (getenv(GLES_LIBNAME_VAR) != NULL) { - libname = getenv(GLES_LIBNAME_VAR); - } - - m_glesDso = emugl::SharedLibrary::open(libname); - if (m_glesDso == NULL) { - fprintf(stderr, "Couldn't find %s \n", GLES_LIBNAME); - return -1; - } - - this->initDispatchByName(s_getProc, this); - } else { - this->initDispatchByName(getProcFunc, getProcFuncData); - } - - glGetCompressedTextureFormats = s_glGetCompressedTextureFormats; - glVertexPointerOffset = s_glVertexPointerOffset; - glColorPointerOffset = s_glColorPointerOffset; - glNormalPointerOffset = s_glNormalPointerOffset; - glTexCoordPointerOffset = s_glTexCoordPointerOffset; - glPointSizePointerOffset = s_glPointSizePointerOffset; - glWeightPointerOffset = s_glWeightPointerOffset; - glMatrixIndexPointerOffset = s_glMatrixIndexPointerOffset; - - glVertexPointerData = s_glVertexPointerData; - glColorPointerData = s_glColorPointerData; - glNormalPointerData = s_glNormalPointerData; - glTexCoordPointerData = s_glTexCoordPointerData; - glPointSizePointerData = s_glPointSizePointerData; - glWeightPointerData = s_glWeightPointerData; - glMatrixIndexPointerData = s_glMatrixIndexPointerData; - - glDrawElementsOffset = s_glDrawElementsOffset; - glDrawElementsData = s_glDrawElementsData; - glFinishRoundTrip = s_glFinishRoundTrip; - - return 0; -} - -int GLDecoder::s_glFinishRoundTrip(void *self) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glFinish(); - return 0; -} - -void GLDecoder::s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glVertexPointer(size, type, stride, SafePointerFromUInt(offset)); -} - -void GLDecoder::s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glColorPointer(size, type, stride, SafePointerFromUInt(offset)); -} - -void GLDecoder::s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glTexCoordPointer(size, type, stride, SafePointerFromUInt(offset)); -} - -void GLDecoder::s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glNormalPointer(type, stride, SafePointerFromUInt(offset)); -} - -void GLDecoder::s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glPointSizePointerOES(type, stride, SafePointerFromUInt(offset)); -} - -void GLDecoder::s_glWeightPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glWeightPointerOES(size, type, stride, SafePointerFromUInt(offset)); -} - -void GLDecoder::s_glMatrixIndexPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glMatrixIndexPointerOES(size, type, stride, SafePointerFromUInt(offset)); -} - - - -#define STORE_POINTER_DATA_OR_ABORT(location) \ - if (ctx->m_contextData != NULL) { \ - ctx->m_contextData->storePointerData((location), data, datalen); \ - } else { \ - return; \ - } - -void GLDecoder::s_glVertexPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) -{ - GLDecoder *ctx = (GLDecoder *)self; - - STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::VERTEX_LOCATION); - - ctx->glVertexPointer(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::VERTEX_LOCATION)); -} - -void GLDecoder::s_glColorPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) -{ - GLDecoder *ctx = (GLDecoder *)self; - - STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::COLOR_LOCATION); - - ctx->glColorPointer(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::COLOR_LOCATION)); -} - -void GLDecoder::s_glTexCoordPointerData(void *self, GLint unit, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) -{ - GLDecoder *ctx = (GLDecoder *)self; - STORE_POINTER_DATA_OR_ABORT((GLDecoderContextData::PointerDataLocation) - (GLDecoderContextData::TEXCOORD0_LOCATION + unit)); - - ctx->glTexCoordPointer(size, type, 0, - ctx->m_contextData->pointerData((GLDecoderContextData::PointerDataLocation) - (GLDecoderContextData::TEXCOORD0_LOCATION + unit))); -} - -void GLDecoder::s_glNormalPointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen) -{ - GLDecoder *ctx = (GLDecoder *)self; - - STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::NORMAL_LOCATION); - - ctx->glNormalPointer(type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::NORMAL_LOCATION)); -} - -void GLDecoder::s_glPointSizePointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen) -{ - GLDecoder *ctx = (GLDecoder *)self; - - STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::POINTSIZE_LOCATION); - - ctx->glPointSizePointerOES(type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::POINTSIZE_LOCATION)); -} - -void GLDecoder::s_glWeightPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -{ - GLDecoder *ctx = (GLDecoder *)self; - - STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::WEIGHT_LOCATION); - - ctx->glWeightPointerOES(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::WEIGHT_LOCATION)); -} - -void GLDecoder::s_glMatrixIndexPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -{ - GLDecoder *ctx = (GLDecoder *)self; - - STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::MATRIXINDEX_LOCATION); - - ctx->glMatrixIndexPointerOES(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::MATRIXINDEX_LOCATION)); -} - -void GLDecoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset)); -} - -void GLDecoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen) -{ - GLDecoder *ctx = (GLDecoder *)self; - ctx->glDrawElements(mode, count, type, data); -} - -void GLDecoder::s_glGetCompressedTextureFormats(void *self, GLint count, GLint *data) -{ - GLDecoder *ctx = (GLDecoder *) self; - ctx->glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, data); -} - -void *GLDecoder::s_getProc(const char *name, void *userData) -{ - GLDecoder *ctx = (GLDecoder *)userData; - - if (ctx == NULL || ctx->m_glesDso == NULL) { - return NULL; - } - - void *func = NULL; -#ifdef USE_EGL_GETPROCADDRESS - func = (void *) eglGetProcAddress(name); -#endif - if (func == NULL) { - func = (void *)(ctx->m_glesDso->findSymbol(name)); - } - return func; -} diff --git a/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.h b/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.h deleted file mode 100644 index 0d26090..0000000 --- a/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -* 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_DECODER_H_ -#define _GL_DECODER_H_ - -#include "gl_dec.h" -#include "FixedBuffer.h" -#include "GLDecoderContextData.h" -#include "emugl/common/shared_library.h" - -#define GLES_LIBNAME_VAR "ANDROID_GLESv1_LIB" -#define GLES_LIBNAME "libGLES_CM.so" - -class GLDecoder : public gl_decoder_context_t -{ -public: - typedef void *(*get_proc_func_t)(const char *name, void *userData); - - GLDecoder(); - ~GLDecoder(); - int initGL(get_proc_func_t getProcFunc = NULL, void *getProcFuncData = NULL); - void setContextData(GLDecoderContextData *contextData) { m_contextData = contextData; } - -private: - static void gl_APIENTRY s_glGetCompressedTextureFormats(void * self, GLint cont, GLint *data); - static void gl_APIENTRY s_glVertexPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen); - static void gl_APIENTRY s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset); - - static void gl_APIENTRY s_glColorPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen); - static void gl_APIENTRY s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset); - - static void gl_APIENTRY s_glTexCoordPointerData(void *self, GLint unit, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen); - static void gl_APIENTRY s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset); - - static void gl_APIENTRY s_glNormalPointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen); - static void gl_APIENTRY s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset); - - static void gl_APIENTRY s_glPointSizePointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen); - static void gl_APIENTRY s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset); - - static void gl_APIENTRY s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset); - static void gl_APIENTRY s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen); - - static void gl_APIENTRY s_glWeightPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen); - static void gl_APIENTRY s_glWeightPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset); - - static void gl_APIENTRY s_glMatrixIndexPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen); - static void gl_APIENTRY s_glMatrixIndexPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset); - - static int gl_APIENTRY s_glFinishRoundTrip(void *self); - - static void * s_getProc(const char *name, void *userData); - - GLDecoderContextData *m_contextData; - emugl::SharedLibrary* m_glesDso; -}; - -#endif diff --git a/emulator/opengl/host/libs/GLESv1_dec/gl.addon b/emulator/opengl/host/libs/GLESv1_dec/gl.addon deleted file mode 100644 index 2331f87..0000000 --- a/emulator/opengl/host/libs/GLESv1_dec/gl.addon +++ /dev/null @@ -1,15 +0,0 @@ -GL_ENTRY(void, glVertexPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glColorPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glNormalPointerOffset, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glPointSizePointerOffset, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glTexCoordPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) - -GL_ENTRY(void, glVertexPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glColorPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glNormalPointerData, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glTexCoordPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glPointSizePointerData, GLenum type, GLsizei stride, void * data, GLuint datalen) - -GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset); -GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen); - diff --git a/emulator/opengl/host/libs/GLESv1_dec/gl.attrib b/emulator/opengl/host/libs/GLESv1_dec/gl.attrib deleted file mode 100644 index 26b793e..0000000 --- a/emulator/opengl/host/libs/GLESv1_dec/gl.attrib +++ /dev/null @@ -1,691 +0,0 @@ -GLOBAL - base_opcode 1024 - encoder_headers "glUtils.h" "GLEncoderUtils.h" - -#void glClipPlanef(GLenum plane, GLfloat *equation) -glClipPlanef - dir equation in - len equation (4 * sizeof(float)) - -#void glFogfv(GLenum pname, GLfloat *params) -glFogfv - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glGetFloatv(GLenum pname, GLfloat *params) -glGetFloatv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glGetLightfv(GLenum light, GLenum pname, GLfloat *params) -glGetLightfv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params) -glGetMaterialfv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params) -glGetTexEnvfv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) -glGetTexParameterfv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glLightModelfv(GLenum pname, GLfloat *params) -glLightModelfv - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glLightfv(GLenum light, GLenum pname, GLfloat *params) -glLightfv - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glLoadMatrixf(GLfloat *m) -glLoadMatrixf - len m (16 * sizeof(GLfloat)) - -#void glMaterialfv(GLenum face, GLenum pname, GLfloat *params) -glMaterialfv - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glMultMatrixf(GLfloat *m) -glMultMatrixf - len m (16 * sizeof(GLfloat)) - -#void glPointParameterfv(GLenum pname, GLfloat *params) -glPointParameterfv - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glTexEnvfv(GLenum target, GLenum pname, GLfloat *params) -glTexEnvfv - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params) -glTexParameterfv - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glBufferData(GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage) -glBufferData - len data size - -#void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data) -glBufferSubData - dir data in - len data size - -#void glClipPlanex(GLenum plane, GLfixed *eqn) -glClipPlanex - dir eqn in - len eqn (4 * sizeof(GLfixed)) - -#void glColorPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) -#we treat the pointer as offset to a VBO -glColorPointer - len pointer (sizeof(unsigned int)) - flag unsupported - -#void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid *data) -glCompressedTexImage2D - len data imageSize - var_flag data nullAllowed - -#void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid *data) -glCompressedTexSubImage2D - len data imageSize - -#void glDeleteBuffers(GLsizei n, GLuint *buffers) -glDeleteBuffers - len buffers (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glDeleteTextures(GLsizei n, GLuint *textures) -glDeleteTextures - len textures (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#this function is marked as unsupported - it shouldn't be called directly -#instead it translated into - glDrawDirectElements and glDrawIndirectElements -#void glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid *indices) -glDrawElements - flag unsupported - - -#void glFogxv(GLenum pname, GLfixed *params) -glFogxv - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetBooleanv(GLenum pname, GLboolean *params) -glGetBooleanv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLboolean)) - -#void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params) -glGetBufferParameteriv - len params (sizeof(GLint)) - dir params out - -#void glGenBuffers(GLsizei n, GLuint *buffers) -glGenBuffers - len buffers (n * sizeof(GLuint)) - dir buffers out - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGenTextures(GLsizei n, GLuint *textures) -glGenTextures - len textures (n * sizeof(GLuint)) - dir textures out - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGetFixedv(GLenum pname, GLfixed *params) -glGetFixedv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetIntegerv(GLenum pname, GLint *params) -glGetIntegerv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glGetLightxv(GLenum light, GLenum pname, GLfixed *params) -glGetLightxv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params) -glGetMaterialxv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetPointerv(GLenum pname, void **params) -glGetPointerv - flag unsupported - -#GLubyte* glGetString(GLenum name) -glGetString - flag unsupported - -#void glGetTexEnviv(GLenum env, GLenum pname, GLint *params) -glGetTexEnviv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params) -glGetTexEnvxv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params) -glGetTexParameteriv - dir params out - len params (sizeof(GLint)) - -#void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params) -glGetTexParameterxv - dir params out - len params (sizeof(GLfixed)) - -#void glLightModelxv(GLenum pname, GLfixed *params) -glLightModelxv - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glLightxv(GLenum light, GLenum pname, GLfixed *params) -glLightxv - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glLoadMatrixx(GLfixed *m) -glLoadMatrixx - len m (16 * sizeof(GLfixed)) - -#void glMaterialxv(GLenum face, GLenum pname, GLfixed *params) -glMaterialxv - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glMultMatrixx(GLfixed *m) -glMultMatrixx - len m (16 * sizeof(GLfixed)) - -#void glNormalPointer(GLenum type, GLsizei stride, GLvoid *pointer) -#we treat the pointer as an offset to a VBO -glNormalPointer - len pointer (sizeof(unsigned int)) - flag unsupported - -#void glPointParameterxv(GLenum pname, GLfixed *params) -glPointParameterxv - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) -glReadPixels - dir pixels out - len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 1) - -#void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) -glTexCoordPointer - len pointer (sizeof(unsigned int)) - flag unsupported - -#void glTexEnviv(GLenum target, GLenum pname, GLint *params) -glTexEnviv - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glTexEnvxv(GLenum target, GLenum pname, GLfixed *params) -glTexEnvxv - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels) -glTexImage2D - dir pixels in - len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 0) - var_flag pixels nullAllowed isLarge - -#void glTexParameteriv(GLenum target, GLenum pname, GLint *params) -glTexParameteriv - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glTexParameterxv(GLenum target, GLenum pname, GLfixed *params) -glTexParameterxv - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) -glTexSubImage2D - len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 0) - var_flag pixels isLarge - -#void glVertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) -# we treat the pointer as an offset to a VBO -glVertexPointer - flag unsupported - -#void glPointSizePointerOES(GLenum type, GLsizei stride, GLvoid *pointer) -glPointSizePointerOES - len pointer (sizeof(unsigned int)) - flag unsupported - -#void glGetClipPlanef(GLenum pname, GLfloat * eqn) -glGetClipPlanef - dir eqn out - len eqn (4 * sizeof(GLfloat)) - -#void glVertexPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) -glVertexPointerData - len data datalen - custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen) - flag custom_decoder - flag not_api - -#void glColorPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) -glColorPointerData - len data datalen - flag custom_decoder - custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen) - flag not_api - -#void glNormalPointerData(GLenum type, GLsizei stride, void *data, GLuint datalen) -glNormalPointerData - len data datalen - flag custom_decoder - custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 3, type, stride, datalen) - flag not_api - -#void glPointSizePointerData(GLenum type, GLsizei stride, void *data, GLuint datalen) -glPointSizePointerData - len data datalen - flag custom_decoder - custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 1, type, stride, datalen) - flag not_api - -#void glTexCoordPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) -glTexCoordPointerData - len data datalen - flag custom_decoder - custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen) - flag not_api - -#void glWeightPointerData(GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -glWeightPointerData - len data datalen - custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen) - flag custom_decoder - flag not_api - -#void glMatrixIndexPointerData(GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -glMatrixIndexPointerData - len data datalen - custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen) - flag custom_decoder - flag not_api - -glVertexPointerOffset - flag custom_decoder - flag not_api -glNormalPointerOffset - flag custom_decoder - flag not_api -glTexCoordPointerOffset - flag custom_decoder - flag not_api -glPointSizePointerOffset - flag custom_decoder - flag not_api -glColorPointerOffset - flag custom_decoder - flag not_api -glWeightPointerOffset - flag custom_decoder - flag not_api -glMatrixIndexPointerOffset - flag custom_decoder - flag not_api - -glDrawElementsData - len data datalen - flag custom_decoder - flag not_api - -glDrawElementsOffset - flag custom_decoder - flag not_api - -glGetCompressedTextureFormats - dir formats out - len formats (count * sizeof(GLint)) - flag custom_decoder - flag not_api - -glFinishRoundTrip - flag custom_decoder - flag not_api - -#gles1 extensions - -#void glDrawTexsvOES(GLshort *coords) -glDrawTexsvOES - len coords (5 * sizeof(GLshort)) - -#void glDrawTexivOES(GLint *coords) -glDrawTexivOES - len coords (5 * sizeof(GLint)) - -#void glDrawTexxvOES(GLfixed *coords) -glDrawTexxvOES - len coords (5 * sizeof(GLfixed)) - -#void glDrawTexfvOES(GLfloat *coords) -glDrawTexfvOES - len coords (5 * sizeof(GLfloat)) - -#glClipPlanexOES(GLenum plane, const GLfixed * equation) -glClipPlanexOES - dir equation in - len equation (4 * sizeof(GLfixed)) - -#glClipPlanexIMG(GLenum plane, const GLfixed * equation) -glClipPlanexIMG - dir equation in - len equation (4 * sizeof(GLfixed)) - -#void glFogxvOES(GLenum pname, GLfixed *params) -glFogxvOES - dir params in - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetClipPlanexOES(GLenum pname, GLfixed * eqn) -glGetClipPlanexOES - dir eqn out - len eqn (4 * sizeof(GLfixed)) - -#void glGetClipPlanex(GLenum pname, GLfixed * eqn) -glGetClipPlanex - dir eqn out - len eqn (4 * sizeof(GLfixed)) - -#void glGetFixedvOES(GLenum pname, GLfixed *params) -glGetFixedvOES - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetLightxvOES(GLenum light, GLenum pname, GLfixed *params) -glGetLightxvOES - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed *params) -glGetMaterialxvOES - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed *params) -glGetTexEnvxvOES - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params) -glGetTexParameterxvOES - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glLightModelxvOES(GLenum pname, GLfixed *params) -glLightModelxvOES - dir params in - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glLightxvOES(GLenum light, GLenum pname, GLfixed *params) -glLightxvOES - dir params in - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glLoadMatrixxOES(GLfixed *m) -glLoadMatrixxOES - dir m in - len m (16 * sizeof(GLfixed)) - -#void glMaterialxvOES(GLenum face, GLenum pname, GLfixed *params) -glMaterialxvOES - dir params in - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glMultMatrixxOES(GLfixed *m) -glMultMatrixxOES - dir m in - len m (16 * sizeof(GLfixed)) - -#void glPointParameterxvOES(GLenum pname, GLfixed *params) -glPointParameterxvOES - dir params in - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glTexEnvxvOES(GLenum target, GLenum pname, GLfixed *params) -glTexEnvxvOES - dir params in - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params) -glTexParameterxvOES - dir params in - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glDeleteRenderbuffersOES(GLsizei n, GLuint *renderbuffers) -glDeleteRenderbuffersOES - dir renderbuffers in - len renderbuffers (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGenRenderbuffersOES(GLsizei n, GLuint *renderbuffers) -glGenRenderbuffersOES - dir renderbuffers out - len renderbuffers (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint *params) -glGetRenderbufferParameterivOES - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glDeleteFramebuffersOES(GLsizei n, GLuint *framebuffers) -glDeleteFramebuffersOES - dir framebuffers in - len framebuffers (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGenFramebuffersOES(GLsizei n, GLuint *framebuffers) -glGenFramebuffersOES - dir framebuffers out - len framebuffers (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint *params) -glGetFramebufferAttachmentParameterivOES - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void* glMapBufferOES(GLenum target, GLenum access) -glMapBufferOES - flag unsupported - -#void glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid ** params) -glGetBufferPointervOES - flag unsupported - -#void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) -glMatrixIndexPointerOES - len pointer (sizeof(unsigned int)) - flag unsupported - -#void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) -glWeightPointerOES - len pointer (sizeof(unsigned int)) - flag unsupported - -#glQueryMatrixxOES(GLfixed * mantissa, GLint * exponent) -glQueryMatrixxOES - dir mantissa out - len mantissa (16 * sizeof(GLfixed)) - dir exponent out - len exponent (16 * sizeof(GLfixed)) - -#void glClipPlanefOES(GLenum plane, GLfloat *equation) -glClipPlanefOES - dir equation in - len equation (4 * sizeof(GLfloat)) - -#void glClipPlanefIMG(GLenum plane, GLfloat *equation) -glClipPlanefIMG - dir equation in - len equation (4 * sizeof(GLfloat)) - -#void glGetClipPlanefOES(GLenum pname, GLfloat * eqn) -glGetClipPlanefOES - dir eqn out - len eqn (4 * sizeof(GLfloat)) - -#void glTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params) -glTexGenfvOES - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glTexGenivOES(GLenum coord, GLenum pname, GLint *params) -glTexGenivOES - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params) -glTexGenxvOES - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params) -glGetTexGenfvOES - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glGetTexGenivOES(GLenum coord, GLenum pname, GLint *params) -glGetTexGenivOES - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params) -glGetTexGenxvOES - len params (glUtilsParamSize(pname) * sizeof(GLfixed)) - -#void glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays) -glDeleteVertexArraysOES - dir arrays in - len arrays (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGenVertexArraysOES(GLsizei n, GLuint *arrays) -glGenVertexArraysOES - dir arrays out - len arrays (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments) -glDiscardFramebufferEXT - dir attachments in - len attachments (numAttachments * sizeof(const GLenum)) - -#void glMultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) -glMultiDrawArraysEXT - flag unsupported - -#void glMultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount) -glMultiDrawElementsEXT - flag unsupported - -#void glMultiDrawArraysSUN(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount) -glMultiDrawArraysSUN - flag unsupported - -#void glMultiDrawElementsSUN(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount) -glMultiDrawElementsSUN - flag unsupported - -#void glDeleteFencesNV(GLsizei n, const GLuint *fences) -glDeleteFencesNV - dir fences in - len fences (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGenFencesNV(GLsizei n, GLuint *fences) -glGenFencesNV - dir fences in - len fences (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) -glGetFenceivNV - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls) -glGetDriverControlsQCOM - dir num out - len num (1 * sizeof(GLint)) - dir driverControls out - len driverControls (size * sizeof(GLuint)) - -#void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) -glGetDriverControlStringQCOM - dir length out - len length (1 * sizeof(GLsizei)) - dir driverControlString out - len driverControlString (1 * sizeof(GLchar)) - -#void glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures) -glExtGetTexturesQCOM - dir textures out - len textures (maxTextures * sizeof(GLuint)) - dir numTextures out - len numTextures (1 * sizeof(GLint)) - -#void glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers) -glExtGetBuffersQCOM - dir buffers out - len buffers (maxBuffers * sizeof(GLuint)) - dir numBuffers out - len numBuffers (1 * sizeof(GLint)) - -#void glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) -glExtGetRenderbuffersQCOM - dir renderbuffers out - len renderbuffers (maxRenderbuffers * sizeof(GLuint)) - dir numRenderbuffers out - len numRenderbuffers (1 * sizeof(GLint)) - -#void glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) -glExtGetFramebuffersQCOM - dir framebuffers out - len framebuffers (maxFramebuffers * sizeof(GLuint)) - dir numFramebuffers out - len numFramebuffers (1 * sizeof(GLint)) - -#void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) -glExtGetTexLevelParameterivQCOM - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) -glExtGetTexSubImageQCOM - dir texels out - len texels (depth * glesv1_enc::pixelDataSize(self, width, height, format, type, 0)) - -#void glExtGetBufferPointervQCOM(GLenum target, GLvoid **params) -glExtGetBufferPointervQCOM - flag unsupported - -#void glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders) -glExtGetShadersQCOM - dir shaders out - len shaders (maxShaders * sizeof(GLuint)) - dir numShaders out - len numShaders (1 * sizeof(GLint)) - -#void glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms) -glExtGetProgramsQCOM - dir programs out - len programs (maxPrograms * sizeof(GLuint)) - dir numPrograms out - len numPrograms (1 * sizeof(GLint)) - -#void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length) -glExtGetProgramBinarySourceQCOM - flag unsupported diff --git a/emulator/opengl/host/libs/GLESv1_dec/gl.in b/emulator/opengl/host/libs/GLESv1_dec/gl.in deleted file mode 100644 index cb4859d..0000000 --- a/emulator/opengl/host/libs/GLESv1_dec/gl.in +++ /dev/null @@ -1,299 +0,0 @@ -GL_ENTRY(void, glAlphaFunc, GLenum func, GLclampf ref) -GL_ENTRY(void, glClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -GL_ENTRY(void, glClearDepthf, GLclampf depth) -GL_ENTRY(void, glClipPlanef, GLenum plane, const GLfloat *equation) -GL_ENTRY(void, glColor4f, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) -GL_ENTRY(void, glDepthRangef, GLclampf zNear, GLclampf zFar) -GL_ENTRY(void, glFogf, GLenum pname, GLfloat param) -GL_ENTRY(void, glFogfv, GLenum pname, const GLfloat *params) -GL_ENTRY(void, glFrustumf, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) -GL_ENTRY(void, glGetClipPlanef, GLenum pname, GLfloat* eqn) -GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat *params) -GL_ENTRY(void, glGetLightfv, GLenum light, GLenum pname, GLfloat *params) -GL_ENTRY(void, glGetMaterialfv, GLenum face, GLenum pname, GLfloat *params) -GL_ENTRY(void, glGetTexEnvfv, GLenum env, GLenum pname, GLfloat *params) -GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat *params) -GL_ENTRY(void, glLightModelf, GLenum pname, GLfloat param) -GL_ENTRY(void, glLightModelfv, GLenum pname, const GLfloat *params) -GL_ENTRY(void, glLightf, GLenum light, GLenum pname, GLfloat param) -GL_ENTRY(void, glLightfv, GLenum light, GLenum pname, const GLfloat *params) -GL_ENTRY(void, glLineWidth, GLfloat width) -GL_ENTRY(void, glLoadMatrixf, const GLfloat *m) -GL_ENTRY(void, glMaterialf, GLenum face, GLenum pname, GLfloat param) -GL_ENTRY(void, glMaterialfv, GLenum face, GLenum pname, const GLfloat *params) -GL_ENTRY(void, glMultMatrixf, const GLfloat *m) -GL_ENTRY(void, glMultiTexCoord4f, GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) -GL_ENTRY(void, glNormal3f, GLfloat nx, GLfloat ny, GLfloat nz) -GL_ENTRY(void, glOrthof, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) -GL_ENTRY(void, glPointParameterf, GLenum pname, GLfloat param) -GL_ENTRY(void, glPointParameterfv, GLenum pname, const GLfloat *params) -GL_ENTRY(void, glPointSize, GLfloat size) -GL_ENTRY(void, glPolygonOffset, GLfloat factor, GLfloat units) -GL_ENTRY(void, glRotatef, GLfloat angle, GLfloat x, GLfloat y, GLfloat z) -GL_ENTRY(void, glScalef, GLfloat x, GLfloat y, GLfloat z) -GL_ENTRY(void, glTexEnvf, GLenum target, GLenum pname, GLfloat param) -GL_ENTRY(void, glTexEnvfv, GLenum target, GLenum pname, const GLfloat *params) -GL_ENTRY(void, glTexParameterf, GLenum target, GLenum pname, GLfloat param) -GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat *params) -GL_ENTRY(void, glTranslatef, GLfloat x, GLfloat y, GLfloat z) -GL_ENTRY(void, glActiveTexture, GLenum texture) -GL_ENTRY(void, glAlphaFuncx, GLenum func, GLclampx ref) -GL_ENTRY(void, glBindBuffer, GLenum target, GLuint buffer) -GL_ENTRY(void, glBindTexture, GLenum target, GLuint texture) -GL_ENTRY(void, glBlendFunc, GLenum sfactor, GLenum dfactor) -GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) -GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) -GL_ENTRY(void, glClear, GLbitfield mask) -GL_ENTRY(void, glClearColorx, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) -GL_ENTRY(void, glClearDepthx, GLclampx depth) -GL_ENTRY(void, glClearStencil, GLint s) -GL_ENTRY(void, glClientActiveTexture, GLenum texture) -GL_ENTRY(void, glColor4ub, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) -GL_ENTRY(void, glColor4x, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) -GL_ENTRY(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) -GL_ENTRY(void, glColorPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) -GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) -GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) -GL_ENTRY(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) -GL_ENTRY(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) -GL_ENTRY(void, glCullFace, GLenum mode) -GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint *buffers) -GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint *textures) -GL_ENTRY(void, glDepthFunc, GLenum func) -GL_ENTRY(void, glDepthMask, GLboolean flag) -GL_ENTRY(void, glDepthRangex, GLclampx zNear, GLclampx zFar) -GL_ENTRY(void, glDisable, GLenum cap) -GL_ENTRY(void, glDisableClientState, GLenum array) -GL_ENTRY(void, glDrawArrays, GLenum mode, GLint first, GLsizei count) -GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) -GL_ENTRY(void, glEnable, GLenum cap) -GL_ENTRY(void, glEnableClientState, GLenum array) -GL_ENTRY(void, glFinish, void) -GL_ENTRY(void, glFlush, void) -GL_ENTRY(void, glFogx, GLenum pname, GLfixed param) -GL_ENTRY(void, glFogxv, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glFrontFace, GLenum mode) -GL_ENTRY(void, glFrustumx, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) -GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean *params) -GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint *params) -GL_ENTRY(void, glClipPlanex, GLenum pname, const GLfixed * eqn) -GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint *buffers) -GL_ENTRY(void, glGenTextures, GLsizei n, GLuint *textures) -GL_ENTRY(GLenum, glGetError, void) -GL_ENTRY(void, glGetFixedv, GLenum pname, GLfixed *params) -GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint *params) -GL_ENTRY(void, glGetLightxv, GLenum light, GLenum pname, GLfixed *params) -GL_ENTRY(void, glGetMaterialxv, GLenum face, GLenum pname, GLfixed *params) -GL_ENTRY(void, glGetPointerv, GLenum pname, GLvoid **params) -GL_ENTRY(const GLubyte *, glGetString, GLenum name) -GL_ENTRY(void, glGetTexEnviv, GLenum env, GLenum pname, GLint *params) -GL_ENTRY(void, glGetTexEnvxv, GLenum env, GLenum pname, GLfixed *params) -GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint *params) -GL_ENTRY(void, glGetTexParameterxv, GLenum target, GLenum pname, GLfixed *params) -GL_ENTRY(void, glHint, GLenum target, GLenum mode) -GL_ENTRY(GLboolean, glIsBuffer, GLuint buffer) -GL_ENTRY(GLboolean, glIsEnabled, GLenum cap) -GL_ENTRY(GLboolean, glIsTexture, GLuint texture) -GL_ENTRY(void, glLightModelx, GLenum pname, GLfixed param) -GL_ENTRY(void, glLightModelxv, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glLightx, GLenum light, GLenum pname, GLfixed param) -GL_ENTRY(void, glLightxv, GLenum light, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glLineWidthx, GLfixed width) -GL_ENTRY(void, glLoadIdentity, void) -GL_ENTRY(void, glLoadMatrixx, const GLfixed *m) -GL_ENTRY(void, glLogicOp, GLenum opcode) -GL_ENTRY(void, glMaterialx, GLenum face, GLenum pname, GLfixed param) -GL_ENTRY(void, glMaterialxv, GLenum face, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glMatrixMode, GLenum mode) -GL_ENTRY(void, glMultMatrixx, const GLfixed *m) -GL_ENTRY(void, glMultiTexCoord4x, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) -GL_ENTRY(void, glNormal3x, GLfixed nx, GLfixed ny, GLfixed nz) -GL_ENTRY(void, glNormalPointer, GLenum type, GLsizei stride, const GLvoid *pointer) -GL_ENTRY(void, glOrthox, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) -GL_ENTRY(void, glPixelStorei, GLenum pname, GLint param) -GL_ENTRY(void, glPointParameterx, GLenum pname, GLfixed param) -GL_ENTRY(void, glPointParameterxv, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glPointSizex, GLfixed size) -GL_ENTRY(void, glPolygonOffsetx, GLfixed factor, GLfixed units) -GL_ENTRY(void, glPopMatrix, void) -GL_ENTRY(void, glPushMatrix, void) -GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) -GL_ENTRY(void, glRotatex, GLfixed angle, GLfixed x, GLfixed y, GLfixed z) -GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert) -GL_ENTRY(void, glSampleCoveragex, GLclampx value, GLboolean invert) -GL_ENTRY(void, glScalex, GLfixed x, GLfixed y, GLfixed z) -GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height) -GL_ENTRY(void, glShadeModel, GLenum mode) -GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask) -GL_ENTRY(void, glStencilMask, GLuint mask) -GL_ENTRY(void, glStencilOp, GLenum fail, GLenum zfail, GLenum zpass) -GL_ENTRY(void, glTexCoordPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) -GL_ENTRY(void, glTexEnvi, GLenum target, GLenum pname, GLint param) -GL_ENTRY(void, glTexEnvx, GLenum target, GLenum pname, GLfixed param) -GL_ENTRY(void, glTexEnviv, GLenum target, GLenum pname, const GLint *params) -GL_ENTRY(void, glTexEnvxv, GLenum target, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) -GL_ENTRY(void, glTexParameteri, GLenum target, GLenum pname, GLint param) -GL_ENTRY(void, glTexParameterx, GLenum target, GLenum pname, GLfixed param) -GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint *params) -GL_ENTRY(void, glTexParameterxv, GLenum target, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) -GL_ENTRY(void, glTranslatex, GLfixed x, GLfixed y, GLfixed z) -GL_ENTRY(void, glVertexPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) -GL_ENTRY(void, glViewport, GLint x, GLint y, GLsizei width, GLsizei height) -GL_ENTRY(void, glPointSizePointerOES, GLenum type, GLsizei stride, const GLvoid *pointer) - -GL_ENTRY(void, glVertexPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glColorPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glNormalPointerOffset, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glPointSizePointerOffset, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glTexCoordPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glWeightPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) -GL_ENTRY(void, glMatrixIndexPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) - -GL_ENTRY(void, glVertexPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glColorPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glNormalPointerData, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glTexCoordPointerData, GLint unit, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glPointSizePointerData, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glWeightPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glMatrixIndexPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) - -GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset) -GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen) -GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats); - -GL_ENTRY(int, glFinishRoundTrip, void) - -#opengl extensions - -GL_ENTRY(void, glBlendEquationSeparateOES, GLenum modeRGB, GLenum modeAlpha) -GL_ENTRY(void, glBlendFuncSeparateOES, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) -GL_ENTRY(void, glBlendEquationOES, GLenum mode) -GL_ENTRY(void, glDrawTexsOES, GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) -GL_ENTRY(void, glDrawTexiOES, GLint x, GLint y, GLint z, GLint width, GLint height) -GL_ENTRY(void, glDrawTexxOES, GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) -GL_ENTRY(void, glDrawTexsvOES, const GLshort *coords) -GL_ENTRY(void, glDrawTexivOES, const GLint *coords) -GL_ENTRY(void, glDrawTexxvOES, const GLfixed *coords) -GL_ENTRY(void, glDrawTexfOES, GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) -GL_ENTRY(void, glDrawTexfvOES, const GLfloat *coords) -GL_ENTRY(void, glEGLImageTargetTexture2DOES, GLenum target, GLeglImageOES image) -GL_ENTRY(void, glEGLImageTargetRenderbufferStorageOES, GLenum target, GLeglImageOES image) -GL_ENTRY(void, glAlphaFuncxOES, GLenum func, GLclampx ref) -GL_ENTRY(void, glClearColorxOES, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) -GL_ENTRY(void, glClearDepthxOES, GLclampx depth) -GL_ENTRY(void, glClipPlanexOES, GLenum plane, const GLfixed * equation) -GL_ENTRY(void, glClipPlanexIMG, GLenum plane, const GLfixed * equation) -GL_ENTRY(void, glColor4xOES, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) -GL_ENTRY(void, glDepthRangexOES, GLclampx zNear, GLclampx zFar) -GL_ENTRY(void, glFogxOES, GLenum pname, GLfixed param) -GL_ENTRY(void, glFogxvOES, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glFrustumxOES, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) -GL_ENTRY(void, glGetClipPlanexOES, GLenum pname, GLfixed* eqn) -GL_ENTRY(void, glGetClipPlanex, GLenum pname, GLfixed* eqn) -GL_ENTRY(void, glGetFixedvOES, GLenum pname, GLfixed *params) -GL_ENTRY(void, glGetLightxvOES, GLenum light, GLenum pname, GLfixed *params) -GL_ENTRY(void, glGetMaterialxvOES, GLenum face, GLenum pname, GLfixed *params) -GL_ENTRY(void, glGetTexEnvxvOES, GLenum env, GLenum pname, GLfixed *params) -GL_ENTRY(void, glGetTexParameterxvOES, GLenum target, GLenum pname, GLfixed *params) -GL_ENTRY(void, glLightModelxOES, GLenum pname, GLfixed param) -GL_ENTRY(void, glLightModelxvOES, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glLightxOES, GLenum light, GLenum pname, GLfixed param) -GL_ENTRY(void, glLightxvOES, GLenum light, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glLineWidthxOES, GLfixed width) -GL_ENTRY(void, glLoadMatrixxOES, const GLfixed *m) -GL_ENTRY(void, glMaterialxOES, GLenum face, GLenum pname, GLfixed param) -GL_ENTRY(void, glMaterialxvOES, GLenum face, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glMultMatrixxOES, const GLfixed *m) -GL_ENTRY(void, glMultiTexCoord4xOES, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) -GL_ENTRY(void, glNormal3xOES, GLfixed nx, GLfixed ny, GLfixed nz) -GL_ENTRY(void, glOrthoxOES, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) -GL_ENTRY(void, glPointParameterxOES, GLenum pname, GLfixed param) -GL_ENTRY(void, glPointParameterxvOES, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glPointSizexOES, GLfixed size) -GL_ENTRY(void, glPolygonOffsetxOES, GLfixed factor, GLfixed units) -GL_ENTRY(void, glRotatexOES, GLfixed angle, GLfixed x, GLfixed y, GLfixed z) -GL_ENTRY(void, glSampleCoveragexOES, GLclampx value, GLboolean invert) -GL_ENTRY(void, glScalexOES, GLfixed x, GLfixed y, GLfixed z) -GL_ENTRY(void, glTexEnvxOES, GLenum target, GLenum pname, GLfixed param) -GL_ENTRY(void, glTexEnvxvOES, GLenum target, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glTexParameterxOES, GLenum target, GLenum pname, GLfixed param) -GL_ENTRY(void, glTexParameterxvOES, GLenum target, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glTranslatexOES, GLfixed x, GLfixed y, GLfixed z) -GL_ENTRY(GLboolean, glIsRenderbufferOES, GLuint renderbuffer) -GL_ENTRY(void, glBindRenderbufferOES, GLenum target, GLuint renderbuffer) -GL_ENTRY(void, glDeleteRenderbuffersOES, GLsizei n, const GLuint* renderbuffers) -GL_ENTRY(void, glGenRenderbuffersOES, GLsizei n, GLuint* renderbuffers) -GL_ENTRY(void, glRenderbufferStorageOES, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) -GL_ENTRY(void, glGetRenderbufferParameterivOES, GLenum target, GLenum pname, GLint* params) -GL_ENTRY(GLboolean, glIsFramebufferOES, GLuint framebuffer) -GL_ENTRY(void, glBindFramebufferOES, GLenum target, GLuint framebuffer) -GL_ENTRY(void, glDeleteFramebuffersOES, GLsizei n, const GLuint* framebuffers) -GL_ENTRY(void, glGenFramebuffersOES, GLsizei n, GLuint* framebuffers) -GL_ENTRY(GLenum, glCheckFramebufferStatusOES, GLenum target) -GL_ENTRY(void, glFramebufferRenderbufferOES, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) -GL_ENTRY(void, glFramebufferTexture2DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) -GL_ENTRY(void, glGetFramebufferAttachmentParameterivOES, GLenum target, GLenum attachment, GLenum pname, GLint* params) -GL_ENTRY(void, glGenerateMipmapOES, GLenum target) -GL_ENTRY(void*, glMapBufferOES, GLenum target, GLenum access) -GL_ENTRY(GLboolean, glUnmapBufferOES, GLenum target) -GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, GLvoid* *params) -GL_ENTRY(void, glCurrentPaletteMatrixOES, GLuint matrixpaletteindex) -GL_ENTRY(void, glLoadPaletteFromModelViewMatrixOES, void) -GL_ENTRY(void, glMatrixIndexPointerOES, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer) -GL_ENTRY(void, glWeightPointerOES, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer) -GL_ENTRY(GLbitfield, glQueryMatrixxOES, GLfixed * mantissa, GLint * exponent) -GL_ENTRY(void, glDepthRangefOES, GLclampf zNear, GLclampf zFar) -GL_ENTRY(void, glFrustumfOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) -GL_ENTRY(void, glOrthofOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) -GL_ENTRY(void, glClipPlanefOES, GLenum plane, const GLfloat *equation) -GL_ENTRY(void, glClipPlanefIMG, GLenum plane, const GLfloat *equation) -GL_ENTRY(void, glGetClipPlanefOES, GLenum pname, GLfloat * eqn) -GL_ENTRY(void, glClearDepthfOES, GLclampf depth) -GL_ENTRY(void, glTexGenfOES, GLenum coord, GLenum pname, GLfloat param) -GL_ENTRY(void, glTexGenfvOES, GLenum coord, GLenum pname, const GLfloat *params) -GL_ENTRY(void, glTexGeniOES, GLenum coord, GLenum pname, GLint param) -GL_ENTRY(void, glTexGenivOES, GLenum coord, GLenum pname, const GLint *params) -GL_ENTRY(void, glTexGenxOES, GLenum coord, GLenum pname, GLfixed param) -GL_ENTRY(void, glTexGenxvOES, GLenum coord, GLenum pname, const GLfixed *params) -GL_ENTRY(void, glGetTexGenfvOES, GLenum coord, GLenum pname, GLfloat *params) -GL_ENTRY(void, glGetTexGenivOES, GLenum coord, GLenum pname, GLint *params) -GL_ENTRY(void, glGetTexGenxvOES, GLenum coord, GLenum pname, GLfixed *params) -GL_ENTRY(void, glBindVertexArrayOES, GLuint array) -GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays) -GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays) -GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array) -GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments) -GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) -GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid*const *indices, GLsizei primcount) -GL_ENTRY(void, glMultiDrawArraysSUN, GLenum mode, GLint *first, GLsizei *count, GLsizei primcount) -GL_ENTRY(void, glMultiDrawElementsSUN, GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount) -GL_ENTRY(void, glRenderbufferStorageMultisampleIMG, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) -GL_ENTRY(void, glFramebufferTexture2DMultisampleIMG, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) -GL_ENTRY(void, glDeleteFencesNV, GLsizei n, const GLuint *fences) -GL_ENTRY(void, glGenFencesNV, GLsizei n, GLuint *fences) -GL_ENTRY(GLboolean, glIsFenceNV, GLuint fence) -GL_ENTRY(GLboolean, glTestFenceNV, GLuint fence) -GL_ENTRY(void, glGetFenceivNV, GLuint fence, GLenum pname, GLint *params) -GL_ENTRY(void, glFinishFenceNV, GLuint fence) -GL_ENTRY(void, glSetFenceNV, GLuint fence, GLenum condition) -GL_ENTRY(void, glGetDriverControlsQCOM, GLint *num, GLsizei size, GLuint *driverControls) -GL_ENTRY(void, glGetDriverControlStringQCOM, GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) -GL_ENTRY(void, glEnableDriverControlQCOM, GLuint driverControl) -GL_ENTRY(void, glDisableDriverControlQCOM, GLuint driverControl) -GL_ENTRY(void, glExtGetTexturesQCOM, GLuint *textures, GLint maxTextures, GLint *numTextures) -GL_ENTRY(void, glExtGetBuffersQCOM, GLuint *buffers, GLint maxBuffers, GLint *numBuffers) -GL_ENTRY(void, glExtGetRenderbuffersQCOM, GLuint * renderbuffers, GLint maxRenderbuffers, GLint * numRenderbuffers) -GL_ENTRY(void, glExtGetFramebuffersQCOM, GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) -GL_ENTRY(void, glExtGetTexLevelParameterivQCOM, GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) -GL_ENTRY(void, glExtTexObjectStateOverrideiQCOM, GLenum target, GLenum pname, GLint param) -GL_ENTRY(void, glExtGetTexSubImageQCOM, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) -GL_ENTRY(void, glExtGetBufferPointervQCOM, GLenum target, GLvoid* *params) -GL_ENTRY(void, glExtGetShadersQCOM, GLuint *shaders, GLint maxShaders, GLint *numShaders) -GL_ENTRY(void, glExtGetProgramsQCOM, GLuint *programs, GLint maxPrograms, GLint *numPrograms) -GL_ENTRY(GLboolean, glExtIsProgramBinaryQCOM, GLuint program) -GL_ENTRY(void, glExtGetProgramBinarySourceQCOM, GLuint program, GLenum shadertype, GLchar *source, GLint *length) -GL_ENTRY(void, glStartTilingQCOM, GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) -GL_ENTRY(void, glEndTilingQCOM, GLbitfield preserveMask) - diff --git a/emulator/opengl/host/libs/GLESv1_dec/gl.types b/emulator/opengl/host/libs/GLESv1_dec/gl.types deleted file mode 100644 index 2d9a3b0..0000000 --- a/emulator/opengl/host/libs/GLESv1_dec/gl.types +++ /dev/null @@ -1,34 +0,0 @@ -GLbitfield 32 0x%08x -GLboolean 8 %d -GLclampf 32 %f -GLclampx 32 0x%08x -GLeglImageOES 32 %p -GLenum 32 0x%08x -GLfixed 32 0x%08x -GLfloat 32 %f -GLint 32 %d -GLintptr 32 %p -GLshort 16 %d -GLsizei 32 %d -GLsizeiptr 32 %p -GLubyte 8 0x%02x -GLuint 32 %u -GLvoid 0 %x -GLchar 8 %d -GLenum* 32 0x%08x -GLboolean* 32 0x%08x -GLclampf* 32 0x%08x -GLclampx* 32 0x%08x -GLeglImageOES* 32 0x%08x -GLfixed* 32 0x%08x -GLfloat* 32 0x%08x -GLint* 32 0x%08x -GLshort* 32 0x%08x -GLsizei* 32 0x%08x -GLubyte* 32 0x%08x -GLuint* 32 0x%08x -GLvoid* 32 0x%08x -GLchar* 32 0x%08x -GLvoid** 32 0x%08x -void* 32 0x%08x -GLvoid*const* 32 0x%08x diff --git a/emulator/opengl/host/libs/GLESv1_dec/gl_types.h b/emulator/opengl/host/libs/GLESv1_dec/gl_types.h deleted file mode 100644 index 36fabfb..0000000 --- a/emulator/opengl/host/libs/GLESv1_dec/gl_types.h +++ /dev/null @@ -1,20 +0,0 @@ -/* -* 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_TYPES__H -#define __GL_TYPES__H - -#include "gl_base_types.h" -#endif diff --git a/emulator/opengl/host/libs/GLESv2_dec/Android.mk b/emulator/opengl/host/libs/GLESv2_dec/Android.mk deleted file mode 100644 index 0ad6ddb..0000000 --- a/emulator/opengl/host/libs/GLESv2_dec/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -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) -$(call emugl-gen-decoder,$(LOCAL_PATH),gl2) - -# For gl2_types.h ! -$(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-host64-static-library,lib64GLESv2_dec) -$(call emugl-import, lib64OpenglCodecCommon) -$(call emugl-gen-decoder,$(LOCAL_PATH),gl2) - -# For gl2_types.h ! -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) - -$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS)) - -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 deleted file mode 100644 index 712dcc7..0000000 --- a/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -* 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> - -static inline void* SafePointerFromUInt(GLuint value) { - return (void*)(uintptr_t)value; -} - -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 = emugl::SharedLibrary::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); - } - - glGetCompressedTextureFormats = s_glGetCompressedTextureFormats; - glVertexAttribPointerData = s_glVertexAttribPointerData; - glVertexAttribPointerOffset = s_glVertexAttribPointerOffset; - - glDrawElementsOffset = s_glDrawElementsOffset; - glDrawElementsData = s_glDrawElementsData; - glShaderString = s_glShaderString; - 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, SafePointerFromUInt(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, SafePointerFromUInt(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 deleted file mode 100644 index 8910da9..0000000 --- a/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* 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 "GLDecoderContextData.h" -#include "emugl/common/shared_library.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; - emugl::SharedLibrary* 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 diff --git a/emulator/opengl/host/libs/GLESv2_dec/gl2.attrib b/emulator/opengl/host/libs/GLESv2_dec/gl2.attrib deleted file mode 100644 index 3a6da47..0000000 --- a/emulator/opengl/host/libs/GLESv2_dec/gl2.attrib +++ /dev/null @@ -1,591 +0,0 @@ -GLOBAL - base_opcode 2048 - encoder_headers <string.h> "glUtils.h" "GL2EncoderUtils.h" - -#void glBindAttribLocation(GLuint program, GLuint index, GLchar *name) -glBindAttribLocation - len name (strlen(name) + 1) - -#void glBufferData(GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage) -glBufferData - len data size - var_flag data nullAllowed isLarge - -#void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data) -glBufferSubData - len data size - var_flag data isLarge - -#void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid *data) -glCompressedTexImage2D - len data imageSize - var_flag data nullAllowed isLarge - -#void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid *data) -glCompressedTexSubImage2D - len data imageSize - var_flag data isLarge - -#void glDeleteBuffers(GLsizei n, GLuint *buffers) -glDeleteBuffers - len buffers (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glDeleteFramebuffers(GLsizei n, GLuint *framebuffers) -glDeleteFramebuffers - len framebuffers (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers) -glDeleteRenderbuffers - len renderbuffers (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glDeleteTextures(GLsizei n, GLuint *textures) -glDeleteTextures - len textures (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid *indices) -glDrawElements - flag unsupported - -#void glGenBuffers(GLsizei n, GLuint *buffers) -glGenBuffers - len buffers (n * sizeof(GLuint)) - dir buffers out - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGenFramebuffers(GLsizei n, GLuint *framebuffers) -glGenFramebuffers - len framebuffers (n * sizeof(GLuint)) - dir framebuffers out - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers) -glGenRenderbuffers - len renderbuffers (n * sizeof(GLuint)) - dir renderbuffers out - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGenTextures(GLsizei n, GLuint *textures) -glGenTextures - len textures (n * sizeof(GLuint)) - dir textures out - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) -glGetActiveAttrib - len name bufsize - dir name out - var_flag name nullAllowed - dir length out - len length (sizeof(GLsizei)) - var_flag length nullAllowed - dir size out - len size (sizeof(GLint)) - dir type out - len type (sizeof(GLenum)) - -#void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) -glGetActiveUniform - len name bufsize - dir name out - var_flag name nullAllowed - dir length out - len length (sizeof(GLsizei)) - var_flag length nullAllowed - dir size out - len size (sizeof(GLint)) - dir type out - len type (sizeof(GLenum)) - - -#void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) -glGetAttachedShaders - len shaders (maxcount*sizeof(GLuint)) - dir shaders out - dir count out - var_flag count nullAllowed - len count (sizeof(GLsizei)) - -#int glGetAttribLocation(GLuint program, GLchar *name) -glGetAttribLocation - len name (strlen(name) + 1) - -#void glGetBooleanv(GLenum pname, GLboolean *params) -glGetBooleanv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLboolean)) - -#void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params) -glGetBufferParameteriv - len params (sizeof(GLint)) - dir params out - -#void glGetFloatv(GLenum pname, GLfloat *params) -glGetFloatv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params) -glGetFramebufferAttachmentParameteriv - dir params out - len params (sizeof(GLint)) - -#void glGetIntegerv(GLenum pname, GLint *params) -glGetIntegerv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glGetProgramiv(GLuint program, GLenum pname, GLint *params) -glGetProgramiv - dir params out - len params sizeof(GLint) -#XXX - might change if extension constants that return more then one value - - -#void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) -glGetProgramInfoLog - dir infolog out - len infolog bufsize - dir length out - len length sizeof(GLsizei) - var_flag length nullAllowed - -#void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) -glGetRenderbufferParameteriv - dir params out - len params sizeof(GLint) -# XXX - might change if pname with value larger then one is added - -#void glGetShaderiv(GLuint shader, GLenum pname, GLint *params) -glGetShaderiv - dir params out - len params sizeof(GLint) -# XXX - might change if pname with value larger then one is added - -#void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog) -glGetShaderInfoLog - dir length out - len length (sizeof(GLsizei)) - var_flag length nullAllowed - dir infolog out - len infolog bufsize - - -#void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision) -glGetShaderPrecisionFormat - dir range out - len range (2 * sizeof(GLint)) - dir precision out - len precision (sizeof(GLint)) - -#void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source) -glGetShaderSource - dir length out - len length (sizeof(GLsizei)) - var_flag length nullAllowed - dir source out - len source bufsize - -#GLubyte* glGetString(GLenum name) -glGetString - flag unsupported - -#void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) -glGetTexParameterfv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params) -glGetTexParameteriv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glGetUniformfv(GLuint program, GLint location, GLfloat *params) -glGetUniformfv - dir params out - len params glSizeof(glesv2_enc::uniformType(self, program, location)) - -#void glGetUniformiv(GLuint program, GLint location, GLint *params) -glGetUniformiv - dir params out - len params glSizeof(glesv2_enc::uniformType(self, program, location)) - -#int glGetUniformLocation(GLuint program, GLchar *name) -glGetUniformLocation - len name (strlen(name) + 1) - -# client-state shall be handled locally by the encoder in most cases. -# however, GL_CURRENT_VERTEX_ATTRIB and potential others are handled by the server side, -# thus we still need to implement it. -#void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) -glGetVertexAttribfv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) - -#see glGetVertexAttribfv for comments -#void glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params) -glGetVertexAttribiv - dir params out - len params (glUtilsParamSize(pname) * sizeof(GLint)) - - - -#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) -glReadPixels - dir pixels out - len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 1) - -#void glShaderBinary(GLsizei n, GLuint *shaders, GLenum binaryformat, GLvoid *binary, GLsizei length) -glShaderBinary - flag unsupported - -#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels) -glTexImage2D - dir pixels in - len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 0) - var_flag pixels nullAllowed isLarge - -#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params) -glTexParameterfv - len params (glUtilsParamSize(pname) * sizeof(GLfloat)) -#void glTexParameteriv(GLenum target, GLenum pname, GLint *params) -glTexParameteriv - len params (glUtilsParamSize(pname) * sizeof(GLint)) - -#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) -glTexSubImage2D - len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 0) - var_flag pixels nullAllowed isLarge - -#void glUniform1fv(GLint location, GLsizei count, GLfloat *v) -glUniform1fv - len v (count * sizeof(GLfloat)) - -#void glUniform1iv(GLint location, GLsizei count, GLint *v) -glUniform1iv - len v (count * sizeof(GLint)) - -#void glUniform2fv(GLint location, GLsizei count, GLfloat *v) -glUniform2fv - len v (count * 2 * sizeof(GLfloat)) - -#void glUniform2iv(GLint location, GLsizei count, GLint *v) -glUniform2iv - len v (count * 2 * sizeof(GLint)) - -#void glUniform3fv(GLint location, GLsizei count, GLfloat *v) -glUniform3fv - len v (count * 3 * sizeof(GLfloat)) - -#void glUniform3iv(GLint location, GLsizei count, GLint *v) -glUniform3iv - len v (3 * count * sizeof(GLint)) - -#void glUniform4fv(GLint location, GLsizei count, GLfloat *v) -glUniform4fv - len v (4 * count * sizeof(GLfloat)) - -#void glUniform4iv(GLint location, GLsizei count, GLint *v) -glUniform4iv - len v (4 * count * sizeof(GLint)) - -#void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value) -glUniformMatrix2fv - len value (count * 4 * sizeof(GLfloat)) - -#void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value) -glUniformMatrix3fv - len value (count * 9 * sizeof(GLfloat)) - -#void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value) -glUniformMatrix4fv - len value (count * 16 * sizeof(GLfloat)) - -#void glVertexAttrib1fv(GLuint indx, GLfloat *values) -glVertexAttrib1fv - len values (sizeof(GLfloat)) -#void glVertexAttrib2fv(GLuint indx, GLfloat *values) -glVertexAttrib2fv - len values (2 * sizeof(GLfloat)) - -#void glVertexAttrib3fv(GLuint indx, GLfloat *values) -glVertexAttrib3fv - len values (3 * sizeof(GLfloat)) - -#void glVertexAttrib4fv(GLuint indx, GLfloat *values) -glVertexAttrib4fv - len values (4 * sizeof(GLfloat)) - -#void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *ptr) -glVertexAttribPointer - flag unsupported - -#void glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) -glGetProgramBinaryOES - flag unsupported - -#void glProgramBinaryOES(GLuint program, GLenum binaryFormat, GLvoid *binary, GLint length) -glProgramBinaryOES - flag unsupported - -#void* glMapBufferOES(GLenum target, GLenum access) -glMapBufferOES - flag unsupported - -#void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid *pixels) -glTexImage3DOES - len pixels glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0) - var_flag pixels nullAllowed isLarge - -#void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *pixels) -glTexSubImage3DOES - len pixels glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0) - var_flag pixels isLarge - -#void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLvoid *data) -glCompressedTexImage3DOES - len data imageSize - var_flag data isLarge - -#void glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, GLvoid *data) -glCompressedTexSubImage3DOES - len data imageSize - var_flag data isLarge - -#void glDeleteVertexArraysOES(GLsizei n, GLuint *arrays) -glDeleteVertexArraysOES - len arrays (n * sizeof(GLuint)) - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - -#void glGenVertexArraysOES(GLsizei n, GLuint *arrays) -glGenVertexArraysOES - len arrays (n * sizeof(GLuint)) - dir arrays out - param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } - - -#void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, GLenum *attachments) -glDiscardFramebufferEXT - len attachments (numAttachments * sizeof(GLenum)) - -#void glMultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) -glMultiDrawArraysEXT - flag unsupported -#void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount) -glMultiDrawElementsEXT - flag unsupported - - -# handled by encoder -#void glShaderSource(GLuint shader, GLsizei count, GLstr *string, const GLint *length) -glShaderSource - flag unsupported - - - -#void glGetPerfMonitorGroupsAMD(GLint *numGroups, GLsizei groupsSize, GLuint *groups) -glGetPerfMonitorGroupsAMD - flag unsupported - -#void glGetPerfMonitorCountersAMD(GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters) -glGetPerfMonitorCountersAMD - flag unsupported - -#void glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString) -glGetPerfMonitorGroupStringAMD - flag unsupported - -#void glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString) -glGetPerfMonitorCounterStringAMD - flag unsupported - -#void glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid *data) -glGetPerfMonitorCounterInfoAMD - flag unsupported - -#void glGenPerfMonitorsAMD(GLsizei n, GLuint *monitors) -glGenPerfMonitorsAMD - flag unsupported - -#void glDeletePerfMonitorsAMD(GLsizei n, GLuint *monitors) -glDeletePerfMonitorsAMD - flag unsupported - -#void glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList) -glSelectPerfMonitorCountersAMD - flag unsupported - -#void glBeginPerfMonitorAMD(GLuint monitor) -glBeginPerfMonitorAMD - flag unsupported - -#void glEndPerfMonitorAMD(GLuint monitor) -glEndPerfMonitorAMD - flag unsupported - -#void glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten) -glGetPerfMonitorCounterDataAMD - flag unsupported - -#void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) -glRenderbufferStorageMultisampleIMG - flag unsupported - -#void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) -glFramebufferTexture2DMultisampleIMG - flag unsupported - -#void glDeleteFencesNV(GLsizei n, GLuint *fences) -glDeleteFencesNV - flag unsupported - -#void glGenFencesNV(GLsizei n, GLuint *fences) -glGenFencesNV - flag unsupported - -#GLboolean glIsFenceNV(GLuint fence) -glIsFenceNV - flag unsupported - -#GLboolean glTestFenceNV(GLuint fence) -glTestFenceNV - flag unsupported - -#void glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) -glGetFenceivNV - flag unsupported - -#void glFinishFenceNV(GLuint fence) -glFinishFenceNV - flag unsupported - -#void glSetFenceNV(GLuint fence, GLenum condition) -glSetFenceNV - flag unsupported - -#void glCoverageMaskNV(GLboolean mask) -glCoverageMaskNV - flag unsupported - -#void glCoverageOperationNV(GLenum operation) -glCoverageOperationNV - flag unsupported - -#void glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls) -glGetDriverControlsQCOM - flag unsupported - -#void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) -glGetDriverControlStringQCOM - flag unsupported - -#void glEnableDriverControlQCOM(GLuint driverControl) -glEnableDriverControlQCOM - flag unsupported - -#void glDisableDriverControlQCOM(GLuint driverControl) -glDisableDriverControlQCOM - flag unsupported - -#void glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures) -glExtGetTexturesQCOM - flag unsupported - -#void glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers) -glExtGetBuffersQCOM - flag unsupported - -#void glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) -glExtGetRenderbuffersQCOM - flag unsupported - -#void glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) -glExtGetFramebuffersQCOM - flag unsupported - -#void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) -glExtGetTexLevelParameterivQCOM - flag unsupported - -#void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param) -glExtTexObjectStateOverrideiQCOM - flag unsupported - -#void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) -glExtGetTexSubImageQCOM - flag unsupported - -#void glExtGetBufferPointervQCOM(GLenum target, GLvoidptr *params) -glExtGetBufferPointervQCOM - flag unsupported - -#void glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders) -glExtGetShadersQCOM - flag unsupported - -#void glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms) -glExtGetProgramsQCOM - flag unsupported - -#GLboolean glExtIsProgramBinaryQCOM(GLuint program) -glExtIsProgramBinaryQCOM - flag unsupported - -#void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length) -glExtGetProgramBinarySourceQCOM - flag unsupported - -#void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) -glStartTilingQCOM - flag unsupported - -#void glEndTilingQCOM(GLbitfield preserveMask) -glEndTilingQCOM - flag unsupported - - -#void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void * data, GLuint datalen) -glVertexAttribPointerData - len data datalen - custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen) - flag custom_decoder - flag not_api - -glVertexAttribPointerOffset - flag custom_decoder - flag not_api - -#client-state, handled by the encoder -#GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer) -glGetVertexAttribPointerv - flag unsupported - -glDrawElementsData - len data datalen - flag custom_decoder - flag not_api - -glDrawElementsOffset - flag custom_decoder - flag not_api - -#GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats) -glGetCompressedTextureFormats - dir formats out - len formats (count * sizeof(GLint)) - flag custom_decoder - flag not_api - -#GL_ENTRY(void, glShaderString, GLuint shader, GLchar *string, GLsizei len) -glShaderString - len string len - flag custom_decoder - flag not_api - -glFinishRoundTrip - flag custom_decoder - flag not_api - diff --git a/emulator/opengl/host/libs/GLESv2_dec/gl2.in b/emulator/opengl/host/libs/GLESv2_dec/gl2.in deleted file mode 100644 index f60db16..0000000 --- a/emulator/opengl/host/libs/GLESv2_dec/gl2.in +++ /dev/null @@ -1,214 +0,0 @@ -GL_ENTRY(void, glActiveTexture, GLenum texture) -GL_ENTRY(void, glAttachShader, GLuint program, GLuint shader) -GL_ENTRY(void, glBindAttribLocation, GLuint program, GLuint index, const GLchar* name) -GL_ENTRY(void, glBindBuffer, GLenum target, GLuint buffer) -GL_ENTRY(void, glBindFramebuffer, GLenum target, GLuint framebuffer) -GL_ENTRY(void, glBindRenderbuffer, GLenum target, GLuint renderbuffer) -GL_ENTRY(void, glBindTexture, GLenum target, GLuint texture) -GL_ENTRY(void, glBlendColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -GL_ENTRY(void, glBlendEquation, GLenum mode ) -GL_ENTRY(void, glBlendEquationSeparate, GLenum modeRGB, GLenum modeAlpha) -GL_ENTRY(void, glBlendFunc, GLenum sfactor, GLenum dfactor) -GL_ENTRY(void, glBlendFuncSeparate, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) -GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) -GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) -GL_ENTRY(GLenum, glCheckFramebufferStatus, GLenum target) -GL_ENTRY(void, glClear, GLbitfield mask) -GL_ENTRY(void, glClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -GL_ENTRY(void, glClearDepthf, GLclampf depth) -GL_ENTRY(void, glClearStencil, GLint s) -GL_ENTRY(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) -GL_ENTRY(void, glCompileShader, GLuint shader) -GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) -GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) -GL_ENTRY(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) -GL_ENTRY(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) -GL_ENTRY(GLuint, glCreateProgram, void) -GL_ENTRY(GLuint, glCreateShader, GLenum type) -GL_ENTRY(void, glCullFace, GLenum mode) -GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint* buffers) -GL_ENTRY(void, glDeleteFramebuffers, GLsizei n, const GLuint* framebuffers) -GL_ENTRY(void, glDeleteProgram, GLuint program) -GL_ENTRY(void, glDeleteRenderbuffers, GLsizei n, const GLuint* renderbuffers) -GL_ENTRY(void, glDeleteShader, GLuint shader) -GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint* textures) -GL_ENTRY(void, glDepthFunc, GLenum func) -GL_ENTRY(void, glDepthMask, GLboolean flag) -GL_ENTRY(void, glDepthRangef, GLclampf zNear, GLclampf zFar) -GL_ENTRY(void, glDetachShader, GLuint program, GLuint shader) -GL_ENTRY(void, glDisable, GLenum cap) -GL_ENTRY(void, glDisableVertexAttribArray, GLuint index) -GL_ENTRY(void, glDrawArrays, GLenum mode, GLint first, GLsizei count) -GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) -GL_ENTRY(void, glEnable, GLenum cap) -GL_ENTRY(void, glEnableVertexAttribArray, GLuint index) -GL_ENTRY(void, glFinish, void) -GL_ENTRY(void, glFlush, void) -GL_ENTRY(void, glFramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) -GL_ENTRY(void, glFramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) -GL_ENTRY(void, glFrontFace, GLenum mode) -GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint* buffers) -GL_ENTRY(void, glGenerateMipmap, GLenum target) -GL_ENTRY(void, glGenFramebuffers, GLsizei n, GLuint* framebuffers) -GL_ENTRY(void, glGenRenderbuffers, GLsizei n, GLuint* renderbuffers) -GL_ENTRY(void, glGenTextures, GLsizei n, GLuint* textures) -GL_ENTRY(void, glGetActiveAttrib, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) -GL_ENTRY(void, glGetActiveUniform, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) -GL_ENTRY(void, glGetAttachedShaders, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) -GL_ENTRY(int, glGetAttribLocation, GLuint program, const GLchar* name) -GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean* params) -GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint* params) -GL_ENTRY(GLenum, glGetError, void) -GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat* params) -GL_ENTRY(void, glGetFramebufferAttachmentParameteriv, GLenum target, GLenum attachment, GLenum pname, GLint* params) -GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint* params) -GL_ENTRY(void, glGetProgramiv, GLuint program, GLenum pname, GLint* params) -GL_ENTRY(void, glGetProgramInfoLog, GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) -GL_ENTRY(void, glGetRenderbufferParameteriv, GLenum target, GLenum pname, GLint* params) -GL_ENTRY(void, glGetShaderiv, GLuint shader, GLenum pname, GLint* params) -GL_ENTRY(void, glGetShaderInfoLog, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) -GL_ENTRY(void, glGetShaderPrecisionFormat, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) -GL_ENTRY(void, glGetShaderSource, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) -GL_ENTRY(const GLubyte*, glGetString, GLenum name) -GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat* params) -GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint* params) -GL_ENTRY(void, glGetUniformfv, GLuint program, GLint location, GLfloat* params) -GL_ENTRY(void, glGetUniformiv, GLuint program, GLint location, GLint* params) -GL_ENTRY(int, glGetUniformLocation, GLuint program, const GLchar* name) -GL_ENTRY(void, glGetVertexAttribfv, GLuint index, GLenum pname, GLfloat* params) -GL_ENTRY(void, glGetVertexAttribiv, GLuint index, GLenum pname, GLint* params) -GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer) -GL_ENTRY(void, glHint, GLenum target, GLenum mode) -GL_ENTRY(GLboolean, glIsBuffer, GLuint buffer) -GL_ENTRY(GLboolean, glIsEnabled, GLenum cap) -GL_ENTRY(GLboolean, glIsFramebuffer, GLuint framebuffer) -GL_ENTRY(GLboolean, glIsProgram, GLuint program) -GL_ENTRY(GLboolean, glIsRenderbuffer, GLuint renderbuffer) -GL_ENTRY(GLboolean, glIsShader, GLuint shader) -GL_ENTRY(GLboolean, glIsTexture, GLuint texture) -GL_ENTRY(void, glLineWidth, GLfloat width) -GL_ENTRY(void, glLinkProgram, GLuint program) -GL_ENTRY(void, glPixelStorei, GLenum pname, GLint param) -GL_ENTRY(void, glPolygonOffset, GLfloat factor, GLfloat units) -GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) -GL_ENTRY(void, glReleaseShaderCompiler, void) -GL_ENTRY(void, glRenderbufferStorage, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) -GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert) -GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height) -GL_ENTRY(void, glShaderBinary, GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length) -GL_ENTRY(void, glShaderSource, GLuint shader, GLsizei count, const GLchar*const* string, const GLint* length) -GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask) -GL_ENTRY(void, glStencilFuncSeparate, GLenum face, GLenum func, GLint ref, GLuint mask) -GL_ENTRY(void, glStencilMask, GLuint mask) -GL_ENTRY(void, glStencilMaskSeparate, GLenum face, GLuint mask) -GL_ENTRY(void, glStencilOp, GLenum fail, GLenum zfail, GLenum zpass) -GL_ENTRY(void, glStencilOpSeparate, GLenum face, GLenum fail, GLenum zfail, GLenum zpass) -GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) -GL_ENTRY(void, glTexParameterf, GLenum target, GLenum pname, GLfloat param) -GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat* params) -GL_ENTRY(void, glTexParameteri, GLenum target, GLenum pname, GLint param) -GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint* params) -GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) -GL_ENTRY(void, glUniform1f, GLint location, GLfloat x) -GL_ENTRY(void, glUniform1fv, GLint location, GLsizei count, const GLfloat* v) -GL_ENTRY(void, glUniform1i, GLint location, GLint x) -GL_ENTRY(void, glUniform1iv, GLint location, GLsizei count, const GLint* v) -GL_ENTRY(void, glUniform2f, GLint location, GLfloat x, GLfloat y) -GL_ENTRY(void, glUniform2fv, GLint location, GLsizei count, const GLfloat* v) -GL_ENTRY(void, glUniform2i, GLint location, GLint x, GLint y) -GL_ENTRY(void, glUniform2iv, GLint location, GLsizei count, const GLint* v) -GL_ENTRY(void, glUniform3f, GLint location, GLfloat x, GLfloat y, GLfloat z) -GL_ENTRY(void, glUniform3fv, GLint location, GLsizei count, const GLfloat* v) -GL_ENTRY(void, glUniform3i, GLint location, GLint x, GLint y, GLint z) -GL_ENTRY(void, glUniform3iv, GLint location, GLsizei count, const GLint* v) -GL_ENTRY(void, glUniform4f, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -GL_ENTRY(void, glUniform4fv, GLint location, GLsizei count, const GLfloat* v) -GL_ENTRY(void, glUniform4i, GLint location, GLint x, GLint y, GLint z, GLint w) -GL_ENTRY(void, glUniform4iv, GLint location, GLsizei count, const GLint* v) -GL_ENTRY(void, glUniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) -GL_ENTRY(void, glUniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) -GL_ENTRY(void, glUniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) -GL_ENTRY(void, glUseProgram, GLuint program) -GL_ENTRY(void, glValidateProgram, GLuint program) -GL_ENTRY(void, glVertexAttrib1f, GLuint indx, GLfloat x) -GL_ENTRY(void, glVertexAttrib1fv, GLuint indx, const GLfloat* values) -GL_ENTRY(void, glVertexAttrib2f, GLuint indx, GLfloat x, GLfloat y) -GL_ENTRY(void, glVertexAttrib2fv, GLuint indx, const GLfloat* values) -GL_ENTRY(void, glVertexAttrib3f, GLuint indx, GLfloat x, GLfloat y, GLfloat z) -GL_ENTRY(void, glVertexAttrib3fv, GLuint indx, const GLfloat* values) -GL_ENTRY(void, glVertexAttrib4f, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -GL_ENTRY(void, glVertexAttrib4fv, GLuint indx, const GLfloat* values) -GL_ENTRY(void, glVertexAttribPointer, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) -GL_ENTRY(void, glViewport, GLint x, GLint y, GLsizei width, GLsizei height) -GL_ENTRY(void, glEGLImageTargetTexture2DOES, GLenum target, GLeglImageOES image) -GL_ENTRY(void, glEGLImageTargetRenderbufferStorageOES, GLenum target, GLeglImageOES image) -GL_ENTRY(void, glGetProgramBinaryOES, GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) -GL_ENTRY(void, glProgramBinaryOES, GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length) -GL_ENTRY(void*, glMapBufferOES, GLenum target, GLenum access) -GL_ENTRY(GLboolean, glUnmapBufferOES, GLenum target) -#GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, GLvoid** params) -GL_ENTRY(void, glTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) -GL_ENTRY(void, glTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) -GL_ENTRY(void, glCopyTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) -GL_ENTRY(void, glCompressedTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) -GL_ENTRY(void, glCompressedTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) -GL_ENTRY(void, glFramebufferTexture3DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) -GL_ENTRY(void, glBindVertexArrayOES, GLuint array) -GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays) -GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays) -GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array) -GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments) -GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) -GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid*const* indices, GLsizei primcount) - -#not supported -GL_ENTRY(void, glGetPerfMonitorGroupsAMD, GLint *numGroups, GLsizei groupsSize, GLuint *groups) -GL_ENTRY(void, glGetPerfMonitorCountersAMD, GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters) -GL_ENTRY(void, glGetPerfMonitorGroupStringAMD, GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString) -GL_ENTRY(void, glGetPerfMonitorCounterStringAMD, GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString) -GL_ENTRY(void, glGetPerfMonitorCounterInfoAMD, GLuint group, GLuint counter, GLenum pname, GLvoid *data) -GL_ENTRY(void, glGenPerfMonitorsAMD, GLsizei n, GLuint *monitors) -GL_ENTRY(void, glDeletePerfMonitorsAMD, GLsizei n, GLuint *monitors) -GL_ENTRY(void, glSelectPerfMonitorCountersAMD, GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList) -GL_ENTRY(void, glBeginPerfMonitorAMD, GLuint monitor) -GL_ENTRY(void, glEndPerfMonitorAMD, GLuint monitor) -GL_ENTRY(void, glGetPerfMonitorCounterDataAMD, GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten) - -GL_ENTRY(void, glRenderbufferStorageMultisampleIMG, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) -GL_ENTRY(void, glFramebufferTexture2DMultisampleIMG, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) -GL_ENTRY(void, glDeleteFencesNV, GLsizei n, const GLuint *fences) -GL_ENTRY(void, glGenFencesNV, GLsizei n, GLuint *fences) -GL_ENTRY(GLboolean, glIsFenceNV, GLuint fence) -GL_ENTRY(GLboolean, glTestFenceNV, GLuint fence) -GL_ENTRY(void, glGetFenceivNV, GLuint fence, GLenum pname, GLint *params) -GL_ENTRY(void, glFinishFenceNV, GLuint fence) -GL_ENTRY(void, glSetFenceNV, GLuint fence, GLenum condition) -GL_ENTRY(void, glCoverageMaskNV, GLboolean mask) -GL_ENTRY(void, glCoverageOperationNV, GLenum operation) -GL_ENTRY(void, glGetDriverControlsQCOM, GLint *num, GLsizei size, GLuint *driverControls) -GL_ENTRY(void, glGetDriverControlStringQCOM, GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) -GL_ENTRY(void, glEnableDriverControlQCOM, GLuint driverControl) -GL_ENTRY(void, glDisableDriverControlQCOM, GLuint driverControl) -GL_ENTRY(void, glExtGetTexturesQCOM, GLuint *textures, GLint maxTextures, GLint *numTextures) -GL_ENTRY(void, glExtGetBuffersQCOM, GLuint *buffers, GLint maxBuffers, GLint *numBuffers) -GL_ENTRY(void, glExtGetRenderbuffersQCOM, GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) -GL_ENTRY(void, glExtGetFramebuffersQCOM, GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) -GL_ENTRY(void, glExtGetTexLevelParameterivQCOM, GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) -GL_ENTRY(void, glExtTexObjectStateOverrideiQCOM, GLenum target, GLenum pname, GLint param) -GL_ENTRY(void, glExtGetTexSubImageQCOM, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) -GL_ENTRY(void, glExtGetBufferPointervQCOM, GLenum target, GLvoidptr *params) -GL_ENTRY(void, glExtGetShadersQCOM, GLuint *shaders, GLint maxShaders, GLint *numShaders) -GL_ENTRY(void, glExtGetProgramsQCOM, GLuint *programs, GLint maxPrograms, GLint *numPrograms) -GL_ENTRY(GLboolean, glExtIsProgramBinaryQCOM, GLuint program) -GL_ENTRY(void, glExtGetProgramBinarySourceQCOM, GLuint program, GLenum shadertype, GLchar *source, GLint *length) -GL_ENTRY(void, glStartTilingQCOM, GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) -GL_ENTRY(void, glEndTilingQCOM, GLbitfield preserveMask) - -# add-ons -GL_ENTRY(void, glVertexAttribPointerData, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void * data, GLuint datalen) -GL_ENTRY(void, glVertexAttribPointerOffset, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset) -GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset) -GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen) -GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats) -GL_ENTRY(void, glShaderString, GLuint shader, const GLchar* string, GLsizei len) -GL_ENTRY(int, glFinishRoundTrip, void) diff --git a/emulator/opengl/host/libs/GLESv2_dec/gl2.types b/emulator/opengl/host/libs/GLESv2_dec/gl2.types deleted file mode 100644 index 86e10f9..0000000 --- a/emulator/opengl/host/libs/GLESv2_dec/gl2.types +++ /dev/null @@ -1,38 +0,0 @@ -GLbitfield 32 0x%08x -GLboolean 8 %d -GLclampf 32 %f -GLclampx 32 0x%08x -GLeglImageOES 32 %p -GLenum 32 0x%08x -GLfixed 32 0x%08x -GLfloat 32 %f -GLint 32 %d -GLintptr 32 %p -GLshort 16 %d -GLsizei 32 %d -GLsizeiptr 32 %p -GLubyte 8 0x%02x -GLuint 32 %u -GLvoid 0 %x -GLchar 8 %d -GLenum* 32 0x%08x -GLboolean* 32 0x%08x -GLclampf* 32 0x%08x -GLclampx* 32 0x%08x -GLeglImageOES* 32 0x%08x -GLfixed* 32 0x%08x -GLfloat* 32 0x%08x -GLint* 32 0x%08x -GLshort* 32 0x%08x -GLsizei* 32 0x%08x -GLubyte* 32 0x%08x -GLuint* 32 0x%08x -GLvoid* 32 0x%08x -GLchar* 32 0x%08x -GLchar** 32 0x%08x -GLvoid** 32 0x%08x -void* 32 0x%08x -GLstr* 32 0x%08x -GLvoidptr* 32 0x%08x -GLchar*const* 32 0x%08x -GLvoid*const* 32 0x%08x diff --git a/emulator/opengl/host/libs/GLESv2_dec/gl2_types.h b/emulator/opengl/host/libs/GLESv2_dec/gl2_types.h deleted file mode 100644 index bfff61d..0000000 --- a/emulator/opengl/host/libs/GLESv2_dec/gl2_types.h +++ /dev/null @@ -1,21 +0,0 @@ -/* -* 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_2_TYPES_H_ -#define _GL_2_TYPES_H_ -#include "gl_base_types.h" - -typedef void *GLvoidptr; -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/Android.mk b/emulator/opengl/host/libs/Translator/EGL/Android.mk deleted file mode 100644 index 298c502..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/Android.mk +++ /dev/null @@ -1,56 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -host_OS_SRCS := -host_common_LDLIBS := - -ifeq ($(HOST_OS),linux) - host_OS_SRCS = EglX11Api.cpp - host_common_LDLIBS += -lX11 -lGL -ldl -lpthread -endif - -ifeq ($(HOST_OS),darwin) - host_OS_SRCS = EglMacApi.cpp \ - MacNative.m \ - MacPixelFormatsAttribs.m - - host_common_LDLIBS += -Wl,-framework,AppKit -endif - -ifeq ($(HOST_OS),windows) - host_OS_SRCS = EglWindowsApi.cpp - host_common_LDLIBS += -lopengl32 -lgdi32 -endif - -host_common_SRC_FILES := \ - $(host_OS_SRCS) \ - ThreadInfo.cpp \ - EglImp.cpp \ - EglConfig.cpp \ - EglContext.cpp \ - EglGlobalInfo.cpp \ - EglValidate.cpp \ - EglSurface.cpp \ - EglWindowSurface.cpp \ - EglPbufferSurface.cpp \ - EglPixmapSurface.cpp \ - EglThreadInfo.cpp \ - EglDisplay.cpp \ - ClientAPIExts.cpp - -### EGL host implementation ######################## -$(call emugl-begin-host-shared-library,libEGL_translator) -$(call emugl-import,libGLcommon) - -LOCAL_LDLIBS += $(host_common_LDLIBS) -LOCAL_SRC_FILES := $(host_common_SRC_FILES) - -$(call emugl-end-module) - -### EGL host implementation, 64-bit ######################## -$(call emugl-begin-host64-shared-library,lib64EGL_translator) -$(call emugl-import,lib64GLcommon) - -LOCAL_LDLIBS += $(host_common_LDLIBS) -LOCAL_SRC_FILES := $(host_common_SRC_FILES) - -$(call emugl-end-module) diff --git a/emulator/opengl/host/libs/Translator/EGL/ClientAPIExts.cpp b/emulator/opengl/host/libs/Translator/EGL/ClientAPIExts.cpp deleted file mode 100644 index 42d5764..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/ClientAPIExts.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* -* 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. -*/ -#include "ClientAPIExts.h" -#include "EglGlobalInfo.h" -#include "GLcommon/GLutils.h" -#include "GLcommon/TranslatorIfaces.h" -#include "ThreadInfo.h" -#include <GLES/gl.h> -#include <GLES/glext.h> - -namespace ClientAPIExts -{ - -// -// define function pointer type for each extention function -// typename has the form __egl_{funcname}_t -// -#define FUNC_TYPE(fname) __egl_ ## fname ## _t -#define API_ENTRY(fname,params,args) \ - typedef void (GL_APIENTRY *FUNC_TYPE(fname)) params; - -#define API_ENTRY_RET(rtype,fname,params,args) \ - typedef rtype (GL_APIENTRY *FUNC_TYPE(fname)) params; - -#include "ClientAPIExts.in" -#undef API_ENTRY -#undef API_ENTRY_RET - -///// -// Define static table to store the function value for each -// client API. functions pointers will get initialized through -// ClientAPIExts::initClientFuncs function after each client API has been -// loaded. -///// -#define API_ENTRY(fname,params,args) \ - FUNC_TYPE(fname) fname; - -#define API_ENTRY_RET(rtype,fname,params,args) \ - API_ENTRY(fname,params,args) - -static struct _ext_table -{ -#include "ClientAPIExts.in" -} s_client_extensions[MAX_GLES_VERSION-1]; - -#undef API_ENTRY -#undef API_ENTRY_RET - -// -// This function initialized each entry in the s_client_extensions -// struct at the givven index using the givven client interface -// -void initClientFuncs(GLESiface *iface, int idx) -{ -#define API_ENTRY(fname,params,args) \ - s_client_extensions[idx].fname = \ - (FUNC_TYPE(fname))iface->getProcAddress(#fname); - -#define API_ENTRY_RET(rtype,fname,params,args) \ - API_ENTRY(fname,params,args) - - // - // reset all func pointers to NULL - // - memset(&s_client_extensions[idx], 0, sizeof(struct _ext_table)); - - // - // And now query the GLES library for each proc address - // -#include "ClientAPIExts.in" -#undef API_ENTRY -#undef API_ENTRY_RET -} - -// -// Define implementation for each extension function which checks -// the current context version and calls to the correct client API -// function. -// -#define API_ENTRY(fname,params,args) \ - static void _egl_ ## fname params \ - { \ - ThreadInfo* thread = getThreadInfo(); \ - if (!thread->eglContext.Ptr()) { \ - return; \ - } \ - int idx = (int)thread->eglContext->version() - 1; \ - if (!s_client_extensions[idx].fname) { \ - return; \ - } \ - (*s_client_extensions[idx].fname) args; \ - } - -#define API_ENTRY_RET(rtype,fname,params,args) \ - static rtype _egl_ ## fname params \ - { \ - ThreadInfo* thread = getThreadInfo(); \ - if (!thread->eglContext.Ptr()) { \ - return (rtype)0; \ - } \ - int idx = (int)thread->eglContext->version() - 1; \ - if (!s_client_extensions[idx].fname) { \ - return (rtype)0; \ - } \ - return (*s_client_extensions[idx].fname) args; \ - } - -#include "ClientAPIExts.in" -#undef API_ENTRY -#undef API_ENTRY_RET - -// -// Define a table to map function names to the local _egl_ version of -// the extension function, to be used in eglGetProcAddress. -// -#define API_ENTRY(fname,params,args) \ - { #fname, (__translatorMustCastToProperFunctionPointerType)_egl_ ## fname}, -#define API_ENTRY_RET(rtype,fname,params,args) \ - API_ENTRY(fname,params,args) - -static struct _client_ext_funcs { - const char *fname; - __translatorMustCastToProperFunctionPointerType proc; -} s_client_ext_funcs[] = { -#include "ClientAPIExts.in" -}; -static const int numExtFuncs = sizeof(s_client_ext_funcs) / - sizeof(s_client_ext_funcs[0]); - -#undef API_ENTRY -#undef API_ENTRY_RET - -// -// returns the __egl_ version of the givven extension function name. -// -__translatorMustCastToProperFunctionPointerType getProcAddress(const char *fname) -{ - for (int i=0; i<numExtFuncs; i++) { - if (!strcmp(fname, s_client_ext_funcs[i].fname)) { - return s_client_ext_funcs[i].proc; - } - } - return NULL; -} - -} // of namespace ClientAPIExts diff --git a/emulator/opengl/host/libs/Translator/EGL/ClientAPIExts.h b/emulator/opengl/host/libs/Translator/EGL/ClientAPIExts.h deleted file mode 100644 index 130b44a..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/ClientAPIExts.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -* 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 _CLIENT_APIS_EXTS_H -#define _CLIENT_APIS_EXTS_H - -#include "GLcommon/TranslatorIfaces.h" - -namespace ClientAPIExts -{ - -void initClientFuncs(GLESiface *iface, int idx); -__translatorMustCastToProperFunctionPointerType getProcAddress(const char *fname); - -} // of namespace ClientAPIExts - -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/ClientAPIExts.in b/emulator/opengl/host/libs/Translator/EGL/ClientAPIExts.in deleted file mode 100644 index c3162eb..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/ClientAPIExts.in +++ /dev/null @@ -1,201 +0,0 @@ -// -// Each extension function should have one of the following -// macro definitions: -// API_ENTRY(funcname, paramlist, arglist) -// -or- (in case funciton has return value) -// API_ENTRY_RET(return_type,funcname, paramlist, arglist) -// -API_ENTRY(glEGLImageTargetTexture2DOES, - (GLenum target, GLeglImageOES image), - (target, image)) - -API_ENTRY(glEGLImageTargetRenderbufferStorageOES, - (GLenum target, GLeglImageOES image), - (target, image)) - -API_ENTRY(glBlendEquationSeparateOES, - (GLenum modeRGB, GLenum modeAlpha), - (modeRGB, modeAlpha)) - -API_ENTRY(glBlendFuncSeparateOES, - (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha), - (srcRGB, dstRGB, srcAlpha, dstAlpha)) - -API_ENTRY(glBlendEquationOES, - (GLenum mode), - (mode)) - -API_ENTRY(glCurrentPaletteMatrixOES, - (GLuint matrixpaletteindex), - (matrixpaletteindex)) - -API_ENTRY(glLoadPaletteFromModelViewMatrixOES, - (void), - ()) - -API_ENTRY(glMatrixIndexPointerOES, - (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer), - (size, type, stride, pointer)) - -API_ENTRY(glWeightPointerOES, - (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer), - (size, type, stride, pointer)) - -API_ENTRY(glDepthRangefOES, - (GLclampf zNear, GLclampf zFar), - (zNear, zFar)) - -API_ENTRY(glFrustumfOES, - (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), - (left, right, bottom, top, zNear, zFar)) - -API_ENTRY(glOrthofOES, - (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar), - (left, right, bottom, top, zNear, zFar)) - -API_ENTRY(glClipPlanefOES, - (GLenum plane, const GLfloat *equation), - (plane, equation)) - -API_ENTRY(glGetClipPlanefOES, - (GLenum pname, GLfloat * eqn), - (pname, eqn)) - -API_ENTRY(glClearDepthfOES, - (GLclampf depth), - (depth)) - -API_ENTRY(glPointSizePointerOES, - (GLenum type, GLsizei stride, const GLvoid *pointer), - (type, stride, pointer)) - -API_ENTRY(glTexGenfOES, - (GLenum coord, GLenum pname, GLfloat param), - (coord, pname, param)) - -API_ENTRY(glTexGenfvOES, - (GLenum coord, GLenum pname, const GLfloat *params), - (coord, pname, params)) - -API_ENTRY(glTexGeniOES, - (GLenum coord, GLenum pname, GLint param), - (coord, pname, param)) - -API_ENTRY(glTexGenivOES, - (GLenum coord, GLenum pname, const GLint *params), - (coord, pname, params)) - -API_ENTRY(glTexGenxOES, - (GLenum coord, GLenum pname, GLfixed param), - (coord, pname, param)) - -API_ENTRY(glTexGenxvOES, - (GLenum coord, GLenum pname, const GLfixed *params), - (coord, pname, params)) - -API_ENTRY(glGetTexGenfvOES, - (GLenum coord, GLenum pname, GLfloat *params), - (coord, pname, params)) - -API_ENTRY(glGetTexGenivOES, - (GLenum coord, GLenum pname, GLint *params), - (coord, pname, params)) - -API_ENTRY(glGetTexGenxvOES, - (GLenum coord, GLenum pname, GLfixed *params), - (coord, pname, params)) - -API_ENTRY_RET(GLboolean, - glIsRenderbufferOES, - (GLuint renderbuffer), - (renderbuffer)) - -API_ENTRY(glBindRenderbufferOES, - (GLenum target, GLuint renderbuffer), - (target, renderbuffer)) - -API_ENTRY(glDeleteRenderbuffersOES, - (GLsizei n, const GLuint* renderbuffers), - (n, renderbuffers)) - -API_ENTRY(glGenRenderbuffersOES, - (GLsizei n, GLuint* renderbuffers), - (n, renderbuffers)) - -API_ENTRY(glRenderbufferStorageOES, - (GLenum target, GLenum internalformat, GLsizei width, GLsizei height), - (target, internalformat, width, height)) - -API_ENTRY(glGetRenderbufferParameterivOES, - (GLenum target, GLenum pname, GLint* params), - (target, pname, params)) - -API_ENTRY_RET(GLboolean, - glIsFramebufferOES, - (GLuint framebuffer), - (framebuffer)) - -API_ENTRY(glBindFramebufferOES, - (GLenum target, GLuint framebuffer), - (target, framebuffer)) - -API_ENTRY(glDeleteFramebuffersOES, - (GLsizei n, const GLuint* framebuffers), - (n, framebuffers)) - -API_ENTRY(glGenFramebuffersOES, - (GLsizei n, GLuint* framebuffers), - (n, framebuffers)) - -API_ENTRY_RET(GLenum, - glCheckFramebufferStatusOES, - (GLenum target), - (target)) - -API_ENTRY(glFramebufferTexture2DOES, - (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), - (target, attachment, textarget, texture, level)) - -API_ENTRY(glFramebufferRenderbufferOES, - (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), - (target, attachment, renderbuffertarget, renderbuffer)) - -API_ENTRY(glGetFramebufferAttachmentParameterivOES, - (GLenum target, GLenum attachment, GLenum pname, GLint* params), - (target, attachment, pname, params)) - -API_ENTRY(glGenerateMipmapOES, - (GLenum target), - (target)) - -API_ENTRY(glDrawTexsOES, - (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height), - (x, y, z, width, height)) - -API_ENTRY(glDrawTexiOES, - (GLint x, GLint y, GLint z, GLint width, GLint height), - (x, y, z, width, height)) - -API_ENTRY(glDrawTexfOES, - (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height), - (x, y, z, width, height)) - -API_ENTRY(glDrawTexxOES, - (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height), - (x, y, z, width, height)) - -API_ENTRY(glDrawTexsvOES, - (const GLshort *coords), - (coords)) - -API_ENTRY(glDrawTexivOES, - (const GLint *coords), - (coords)) - -API_ENTRY(glDrawTexfvOES, - (const GLfloat *coords), - (coords)) - -API_ENTRY(glDrawTexxvOES, - (const GLfixed *coords), - (coords)) diff --git a/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp b/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp deleted file mode 100644 index 66a691c..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglConfig.cpp +++ /dev/null @@ -1,348 +0,0 @@ -/* -* 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. -*/ -#include "EglConfig.h" - -EglConfig::EglConfig(EGLint red_size, - EGLint green_size, - EGLint blue_size, - EGLint alpha_size, - EGLenum caveat, - EGLint config_id, - EGLint depth_size, - EGLint frame_buffer_level, - EGLint max_pbuffer_width, - EGLint max_pbuffer_height, - EGLint max_pbuffer_size, - EGLBoolean native_renderable, - EGLint renderable_type, - EGLint native_visual_id, - EGLint native_visual_type, - EGLint samples_per_pixel, - EGLint stencil_size, - EGLint surface_type, - EGLenum transparent_type, - EGLint trans_red_val, - EGLint trans_green_val, - EGLint trans_blue_val, - EGLNativePixelFormatType frmt): - - m_buffer_size(red_size + green_size + blue_size + alpha_size), - m_red_size(red_size), - m_green_size(green_size), - m_blue_size(blue_size), - m_alpha_size(alpha_size), - m_bind_to_tex_rgb(EGL_FALSE), //not supported for now - m_bind_to_tex_rgba(EGL_FALSE), //not supported for now - m_caveat(caveat), - m_config_id(config_id), - m_native_config_id(config_id), - m_frame_buffer_level(frame_buffer_level), - m_depth_size(depth_size), - m_max_pbuffer_width(max_pbuffer_width), - m_max_pbuffer_height(max_pbuffer_height), - m_max_pbuffer_size(max_pbuffer_size), - m_max_swap_interval(MAX_SWAP_INTERVAL), - m_min_swap_interval(MIN_SWAP_INTERVAL), - m_native_renderable(native_renderable), - m_renderable_type(renderable_type), - m_native_visual_id(native_visual_id), - m_native_visual_type(native_visual_type), - m_sample_buffers_num(samples_per_pixel > 0 ?1:0), - m_samples_per_pixel(samples_per_pixel), - m_stencil_size(stencil_size), - m_surface_type(surface_type), - m_transparent_type(transparent_type), - m_trans_red_val(trans_red_val), - m_trans_green_val(trans_green_val), - m_trans_blue_val(trans_blue_val), - m_conformant(((red_size + green_size + blue_size + alpha_size > 0) && - (caveat!=EGL_NON_CONFORMANT_CONFIG)) ? - m_renderable_type : 0), - m_nativeFormat(frmt) {}; - - - EglConfig::EglConfig(const EglConfig& conf):m_buffer_size(conf.m_buffer_size), - m_red_size(conf.m_red_size), - m_green_size(conf.m_green_size), - m_blue_size(conf.m_blue_size), - m_alpha_size(conf.m_alpha_size), - m_bind_to_tex_rgb(conf.m_bind_to_tex_rgb), - m_bind_to_tex_rgba(conf.m_bind_to_tex_rgba), - m_caveat(conf.m_caveat), - m_config_id(conf.m_config_id), - m_native_config_id(conf.m_native_config_id), - m_frame_buffer_level(conf.m_frame_buffer_level), - m_depth_size(conf.m_depth_size), - m_max_pbuffer_width(conf.m_max_pbuffer_width), - m_max_pbuffer_height(conf.m_max_pbuffer_height), - m_max_pbuffer_size(conf.m_max_pbuffer_size), - m_max_swap_interval(conf.m_max_swap_interval), - m_min_swap_interval(conf.m_min_swap_interval), - m_native_renderable(conf.m_native_renderable), - m_renderable_type(conf.m_renderable_type), - m_native_visual_id(conf.m_native_visual_id), - m_native_visual_type(conf.m_native_visual_type), - m_sample_buffers_num(conf.m_sample_buffers_num), - m_samples_per_pixel(conf.m_samples_per_pixel), - m_stencil_size(conf.m_stencil_size), - m_surface_type(conf.m_surface_type), - m_transparent_type(conf.m_transparent_type), - m_trans_red_val(conf.m_trans_red_val), - m_trans_green_val(conf.m_trans_green_val), - m_trans_blue_val(conf.m_trans_blue_val), - m_conformant(conf.m_conformant), - m_nativeFormat(conf.m_nativeFormat) {}; - - -EglConfig::EglConfig(const EglConfig& conf, - EGLint config_id, - EGLint red_size, - EGLint green_size, - EGLint blue_size, - EGLint alpha_size): - - m_buffer_size(red_size + green_size + blue_size + alpha_size), - m_red_size(red_size), - m_green_size(green_size), - m_blue_size(blue_size), - m_alpha_size(alpha_size), - m_bind_to_tex_rgb(conf.m_bind_to_tex_rgb), - m_bind_to_tex_rgba(conf.m_bind_to_tex_rgba), - m_caveat(conf.m_caveat), - m_config_id(config_id), - m_native_config_id(conf.m_native_config_id), - m_frame_buffer_level(conf.m_frame_buffer_level), - m_depth_size(conf.m_depth_size), - m_max_pbuffer_width(conf.m_max_pbuffer_width), - m_max_pbuffer_height(conf.m_max_pbuffer_height), - m_max_pbuffer_size(conf.m_max_pbuffer_size), - m_max_swap_interval(conf.m_max_swap_interval), - m_min_swap_interval(conf.m_min_swap_interval), - m_native_renderable(conf.m_native_renderable), - m_renderable_type(conf.m_renderable_type), - m_native_visual_id(conf.m_native_visual_id), - m_native_visual_type(conf.m_native_visual_type), - m_sample_buffers_num(conf.m_sample_buffers_num), - m_samples_per_pixel(conf.m_samples_per_pixel), - m_stencil_size(conf.m_stencil_size), - m_surface_type(conf.m_surface_type), - m_transparent_type(conf.m_transparent_type), - m_trans_red_val(conf.m_trans_red_val), - m_trans_green_val(conf.m_trans_green_val), - m_trans_blue_val(conf.m_trans_blue_val), - m_conformant(conf.m_conformant), - m_nativeFormat(conf.m_nativeFormat) {}; - - -bool EglConfig::getConfAttrib(EGLint attrib,EGLint* val) const { - switch(attrib) { - case EGL_BUFFER_SIZE: - *val = m_buffer_size; - break; - case EGL_RED_SIZE: - *val = m_red_size; - break; - case EGL_GREEN_SIZE: - *val = m_green_size; - break; - case EGL_BLUE_SIZE: - *val = m_blue_size; - break; - case EGL_ALPHA_SIZE: - *val = m_alpha_size; - break; - case EGL_BIND_TO_TEXTURE_RGB: - *val = m_bind_to_tex_rgb; - break; - case EGL_BIND_TO_TEXTURE_RGBA: - *val = m_bind_to_tex_rgba; - break; - case EGL_CONFIG_CAVEAT: - *val = m_caveat; - break; - case EGL_CONFIG_ID: - *val = m_config_id; - break; - case EGL_DEPTH_SIZE: - *val = m_depth_size; - break; - case EGL_LEVEL: - *val = m_frame_buffer_level; - break; - case EGL_MAX_PBUFFER_WIDTH: - *val = m_max_pbuffer_width; - break; - case EGL_MAX_PBUFFER_HEIGHT: - *val = m_max_pbuffer_height; - break; - case EGL_MAX_PBUFFER_PIXELS: - *val = m_max_pbuffer_size; - break; - case EGL_MAX_SWAP_INTERVAL: - *val = m_max_swap_interval; - break; - case EGL_MIN_SWAP_INTERVAL: - *val = m_min_swap_interval; - break; - case EGL_NATIVE_RENDERABLE: - *val = m_native_renderable; - break; - case EGL_NATIVE_VISUAL_ID: - *val = m_native_visual_id; - break; - case EGL_NATIVE_VISUAL_TYPE: - *val = m_native_visual_type; - break; - case EGL_RENDERABLE_TYPE: - *val = m_renderable_type; - break; - case EGL_SAMPLE_BUFFERS: - *val = m_sample_buffers_num; - break; - case EGL_SAMPLES: - *val = m_samples_per_pixel; - break; - case EGL_STENCIL_SIZE: - *val = m_stencil_size; - break; - case EGL_SURFACE_TYPE: - *val = m_surface_type; - break; - case EGL_TRANSPARENT_TYPE: - *val =m_transparent_type; - break; - case EGL_TRANSPARENT_RED_VALUE: - *val = m_trans_red_val; - break; - case EGL_TRANSPARENT_GREEN_VALUE: - *val = m_trans_green_val; - break; - case EGL_TRANSPARENT_BLUE_VALUE: - *val = m_trans_blue_val; - break; - case EGL_CONFORMANT: - *val = m_conformant; - break; - default: - return false; - } - return true; -} - -// checking compitabilty between *this configuration and another configuration -// the compitability is checked againsed red,green,blue,buffer stencil and depth sizes -bool EglConfig::compitableWith(const EglConfig& conf) const { - - if(m_buffer_size != conf.m_buffer_size) return false; - if(m_red_size != conf.m_red_size) return false; - if(m_green_size != conf.m_green_size) return false; - if(m_blue_size != conf.m_blue_size) return false; - if(m_depth_size != conf.m_depth_size) return false; - if(m_stencil_size != conf.m_stencil_size) return false; - - return true; -} - -//following the sorting EGLconfig as in spec -bool EglConfig::operator<(const EglConfig& conf) const { - //0 - if(m_conformant != conf.m_conformant) { - return m_conformant != 0; //We want the conformant ones first - } - //1 - if(m_caveat != conf.m_caveat) { - return m_caveat < conf.m_caveat; // EGL_NONE < EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG - } - //2 TODO: - - //3 - if(m_buffer_size != conf.m_buffer_size) { - return m_buffer_size < conf.m_buffer_size; - } - //4 - if(m_sample_buffers_num != conf.m_sample_buffers_num) { - return m_sample_buffers_num < conf.m_sample_buffers_num; - } - //5 - if(m_samples_per_pixel != conf.m_samples_per_pixel) { - return m_samples_per_pixel < conf.m_samples_per_pixel; - } - //6 - if(m_depth_size != conf.m_depth_size) { - return m_depth_size < conf.m_depth_size; - } - //7 - if(m_stencil_size != conf.m_stencil_size) { - return m_stencil_size < conf.m_stencil_size; - } - //8 implementation defined - if(m_native_visual_type != conf.m_native_visual_type) { - return m_native_visual_type < conf.m_native_visual_type; - } - //9 - return m_config_id < conf.m_config_id; -} - -bool EglConfig::operator>=(const EglConfig& conf) const { - return !((*this) < conf); -} -#define CHECK_PROP(dummy,prop_name,op) \ - if((dummy.prop_name != EGL_DONT_CARE) && (dummy.prop_name op prop_name)) return false; -#define CHECK_PROP_CAST(dummy,prop_name,op) \ - if((((EGLint)dummy.prop_name) != EGL_DONT_CARE) && (dummy.prop_name op prop_name)) return false; -//checking if config stands for all the selection crateria of dummy as defined by EGL spec -bool EglConfig::choosen(const EglConfig& dummy) { - - //atleast - CHECK_PROP(dummy,m_buffer_size,>); - CHECK_PROP(dummy,m_red_size,>); - CHECK_PROP(dummy,m_green_size,>); - CHECK_PROP(dummy,m_blue_size,>); - CHECK_PROP(dummy,m_alpha_size,>); - CHECK_PROP(dummy,m_depth_size,>); - CHECK_PROP(dummy,m_stencil_size,>); - CHECK_PROP(dummy,m_sample_buffers_num,>); - CHECK_PROP(dummy,m_samples_per_pixel,>); - - //exact - CHECK_PROP(dummy,m_frame_buffer_level,!=); - CHECK_PROP(dummy,m_config_id,!=); - CHECK_PROP(dummy,m_native_visual_type,!=); - CHECK_PROP(dummy,m_max_swap_interval ,!=); - CHECK_PROP(dummy,m_min_swap_interval ,!=); - CHECK_PROP(dummy,m_trans_red_val ,!=); - CHECK_PROP(dummy,m_trans_green_val ,!=); - CHECK_PROP(dummy,m_trans_blue_val ,!=); - //exact - when cast to EGLint is needed when comparing to EGL_DONT_CARE - CHECK_PROP_CAST(dummy,m_bind_to_tex_rgb ,!=); - CHECK_PROP_CAST(dummy,m_bind_to_tex_rgba,!=); - CHECK_PROP_CAST(dummy,m_caveat,!=); - CHECK_PROP_CAST(dummy,m_native_renderable ,!=); - CHECK_PROP_CAST(dummy,m_transparent_type ,!=); - - //mask - if(dummy.m_surface_type != EGL_DONT_CARE && - ((dummy.m_surface_type & m_surface_type) != dummy.m_surface_type)) return false; - - if(dummy.m_conformant != (EGLenum)EGL_DONT_CARE && - ((dummy.m_conformant & m_conformant) != dummy.m_conformant)) return false; - - if(dummy.m_renderable_type != EGL_DONT_CARE && - ((dummy.m_renderable_type & m_renderable_type) != dummy.m_renderable_type)) return false; - - //passed all checks - return true; -} diff --git a/emulator/opengl/host/libs/Translator/EGL/EglConfig.h b/emulator/opengl/host/libs/Translator/EGL/EglConfig.h deleted file mode 100644 index 3d733f9..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglConfig.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -* 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 EGL_CONFIG_H -#define EGL_CONFIG_H - -#include<EGL/egl.h> -#include<EGL/eglinternalplatform.h> - -#define MIN_SWAP_INTERVAL 1 -#define MAX_SWAP_INTERVAL 10 - - -class EglConfig { -public: - bool getConfAttrib(EGLint attrib,EGLint* val) const; - bool operator<(const EglConfig& conf) const; - bool operator>=(const EglConfig& conf) const; - bool compitableWith(const EglConfig& conf) const; //compitability - bool choosen(const EglConfig& dummy); - EGLint surfaceType(){ return m_surface_type;}; - EGLint id(){return m_config_id;}; - EGLint nativeId(){return m_native_config_id;}; - EGLNativePixelFormatType nativeConfig(){ return m_nativeFormat;} - - EglConfig(EGLint red_size, - EGLint green_size, - EGLint blue_size, - EGLint alpha_size, - EGLenum caveat, - EGLint config_id, - EGLint depth_size, - EGLint frame_buffer_level, - EGLint max_pbuffer_width, - EGLint max_pbuffer_height, - EGLint max_pbuffer_size, - EGLBoolean native_renderable, - EGLint renderable_type, - EGLint native_visual_id, - EGLint native_visual_type, - EGLint samples_per_pixel, - EGLint stencil_size, - EGLint surface_type, - EGLenum transparent_type, - EGLint trans_red_val, - EGLint trans_green_val, - EGLint trans_blue_val, - EGLNativePixelFormatType frmt); - - EglConfig(const EglConfig& conf); - - EglConfig(const EglConfig& conf, - EGLint config_id, - EGLint red_size, - EGLint green_size, - EGLint blue_size, - EGLint alpha_size); - -private: - - const EGLint m_buffer_size; - const EGLint m_red_size; - const EGLint m_green_size; - const EGLint m_blue_size; - const EGLint m_alpha_size; - const EGLBoolean m_bind_to_tex_rgb; - const EGLBoolean m_bind_to_tex_rgba; - const EGLenum m_caveat; - const EGLint m_config_id; - const EGLint m_native_config_id; - const EGLint m_frame_buffer_level; - const EGLint m_depth_size; - const EGLint m_max_pbuffer_width; - const EGLint m_max_pbuffer_height; - const EGLint m_max_pbuffer_size; - const EGLint m_max_swap_interval; - const EGLint m_min_swap_interval; - const EGLBoolean m_native_renderable; - const EGLint m_renderable_type; - const EGLint m_native_visual_id; - const EGLint m_native_visual_type; - const EGLint m_sample_buffers_num; - const EGLint m_samples_per_pixel; - const EGLint m_stencil_size; - const EGLint m_surface_type; - const EGLenum m_transparent_type; - const EGLint m_trans_red_val; - const EGLint m_trans_green_val; - const EGLint m_trans_blue_val; - const EGLenum m_conformant; - - const EGLNativePixelFormatType m_nativeFormat; -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp b/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp deleted file mode 100644 index bc33f1f..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* -* 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. -*/ -#include "EglContext.h" -#include "EglDisplay.h" -#include "EglGlobalInfo.h" -#include "EglOsApi.h" - -unsigned int EglContext::s_nextContextHndl = 0; - -extern EglGlobalInfo* g_eglInfo; // defined in EglImp.cpp - -bool EglContext::usingSurface(SurfacePtr surface) { - return surface.Ptr() == m_read.Ptr() || surface.Ptr() == m_draw.Ptr(); -} - -EglContext::EglContext(EglDisplay *dpy, EGLNativeContextType context,ContextPtr shared_context, - EglConfig* config,GLEScontext* glesCtx,GLESVersion ver,ObjectNameManager* mngr): -m_dpy(dpy), -m_native(context), -m_config(config), -m_glesContext(glesCtx), -m_read(NULL), -m_draw(NULL), -m_version(ver), -m_mngr(mngr) -{ - m_shareGroup = shared_context.Ptr()? - mngr->attachShareGroup(context,shared_context->nativeType()): - mngr->createShareGroup(context); - m_hndl = ++s_nextContextHndl; -} - -EglContext::~EglContext() -{ - - // - // remove the context in the underlying OS layer - // - EglOS::destroyContext(m_dpy->nativeType(),m_native); - - // - // call the client-api to remove the GLES context - // - g_eglInfo->getIface(version())->deleteGLESContext(m_glesContext); - - if (m_mngr) - { - m_mngr->deleteShareGroup(m_native); - } -} - -void EglContext::setSurfaces(SurfacePtr read,SurfacePtr draw) -{ - m_read = read; - m_draw = draw; -} - -bool EglContext::getAttrib(EGLint attrib,EGLint* value) { - switch(attrib) { - case EGL_CONFIG_ID: - *value = m_config->id(); - break; - default: - return false; - } - return true; -} - -bool EglContext::attachImage(unsigned int imageId,ImagePtr img){ - if(m_attachedImages.find(imageId) == m_attachedImages.end()){ - m_attachedImages[imageId] = img; - return true; - } - return false; -} - -void EglContext::detachImage(unsigned int imageId){ - m_attachedImages.erase(imageId); -} - diff --git a/emulator/opengl/host/libs/Translator/EGL/EglContext.h b/emulator/opengl/host/libs/Translator/EGL/EglContext.h deleted file mode 100644 index d8eb05e..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglContext.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -* 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 EGL_CONTEXT_H -#define EGL_CONTEXT_H - -#include <map> -#include <EGL/egl.h> -#include <GLcommon/GLutils.h> -#include <GLcommon/TranslatorIfaces.h> -#include <GLcommon/objectNameManager.h> - -#include "emugl/common/smart_ptr.h" - -#include "EglConfig.h" -#include "EglSurface.h" - - - -class EglContext; -typedef emugl::SmartPtr<EglContext> ContextPtr; - -class EglDisplay; - -class EglContext { - -public: - - EglContext(EglDisplay *dpy, EGLNativeContextType context,ContextPtr shared_context,EglConfig* config,GLEScontext* glesCtx,GLESVersion ver,ObjectNameManager* mngr); - bool usingSurface(SurfacePtr surface); - EGLNativeContextType nativeType(){return m_native;}; - bool getAttrib(EGLint attrib,EGLint* value); - SurfacePtr read(){ return m_read;}; - SurfacePtr draw(){ return m_draw;}; - ShareGroupPtr getShareGroup(){return m_shareGroup;} - EglConfig* getConfig(){ return m_config;}; - GLESVersion version(){return m_version;}; - GLEScontext* getGlesContext(){return m_glesContext;} - void setSurfaces(SurfacePtr read,SurfacePtr draw); - unsigned int getHndl(){return m_hndl;} - bool attachImage(unsigned int imageId,ImagePtr img); - void detachImage(unsigned int imageId); - - ~EglContext(); - -private: - static unsigned int s_nextContextHndl; - EglDisplay *m_dpy; - EGLNativeContextType m_native; - EglConfig* m_config; - GLEScontext* m_glesContext; - ShareGroupPtr m_shareGroup; - SurfacePtr m_read; - SurfacePtr m_draw; - GLESVersion m_version; - ObjectNameManager *m_mngr; - unsigned int m_hndl; - ImagesHndlMap m_attachedImages; -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp deleted file mode 100644 index 24b9a0d..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/* -* 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. -*/ -#include "EglDisplay.h" -#include "EglOsApi.h" -#include <GLcommon/GLutils.h> - -EglDisplay::EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault) : - m_dpy(dpy), - m_initialized(false), - m_configInitialized(false), - m_isDefault(isDefault), - m_nextEglImageId(0), - m_globalSharedContext(NULL) -{ - m_manager[GLES_1_1] = new ObjectNameManager(&m_globalNameSpace); - m_manager[GLES_2_0] = new ObjectNameManager(&m_globalNameSpace); -}; - -EglDisplay::~EglDisplay() { - emugl::Mutex::AutoLock mutex(m_lock); - - // - // Destroy the global context if one was created. - // (should be true for windows platform only) - // - if (m_globalSharedContext != NULL) { - EglOS::destroyContext( m_dpy, m_globalSharedContext); - } - - if(m_isDefault) { - EglOS::releaseDisplay(m_dpy); - } - - - for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end(); it++) { - EglConfig* pConfig = *it; - if(pConfig) delete pConfig; - } - - delete m_manager[GLES_1_1]; - delete m_manager[GLES_2_0]; - EglOS::deleteDisplay(m_dpy); -} - -EGLNativeInternalDisplayType EglDisplay::nativeType(){return m_dpy;} - -void EglDisplay::initialize(int renderableType) { - emugl::Mutex::AutoLock mutex(m_lock); - m_initialized = true; - initConfigurations(renderableType); - m_configInitialized = true; -} - -bool EglDisplay::isInitialize() { return m_initialized;} - -void EglDisplay::terminate(){ - emugl::Mutex::AutoLock mutex(m_lock); - m_contexts.clear(); - m_surfaces.clear(); - m_initialized = false; -} - -static bool compareEglConfigsPtrs(EglConfig* first,EglConfig* second) { - return *first < *second ; -} - -void EglDisplay::addMissingConfigs(void) -{ - m_configs.sort(compareEglConfigsPtrs); - - EGLConfig match; - EGLNativePixelFormatType tmpfrmt = PIXEL_FORMAT_INITIALIZER; - EglConfig dummy(5, 6, 5, 0, // RGB_565 - EGL_DONT_CARE,EGL_DONT_CARE, - 16, // Depth - EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE, - EGL_DONT_CARE, EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE,EGL_DONT_CARE,tmpfrmt); - - if(!doChooseConfigs(dummy, &match, 1)) - { - return; - } - - const EglConfig* config = (EglConfig*)match; - - int bSize; - config->getConfAttrib(EGL_BUFFER_SIZE,&bSize); - - if(bSize == 16) - { - return; - } - - int max_config_id = 0; - - for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() ;it++) { - EGLint id; - (*it)->getConfAttrib(EGL_CONFIG_ID, &id); - if(id > max_config_id) - max_config_id = id; - } - - EglConfig* newConfig = new EglConfig(*config,max_config_id+1,5,6,5,0); - - m_configs.push_back(newConfig); -} - -void EglDisplay::initConfigurations(int renderableType) { - if(m_configInitialized) return; - EglOS::queryConfigs(m_dpy,renderableType,m_configs); - - addMissingConfigs(); - m_configs.sort(compareEglConfigsPtrs); -} - -EglConfig* EglDisplay::getConfig(EGLConfig conf) { - emugl::Mutex::AutoLock mutex(m_lock); - - for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() ;it++) { - if(static_cast<EGLConfig>(*it) == conf) { - return (*it); - - } - } - return NULL; -} - -SurfacePtr EglDisplay::getSurface(EGLSurface surface) { - emugl::Mutex::AutoLock mutex(m_lock); - /* surface is "key" in map<unsigned int, SurfacePtr>. */ - unsigned int hndl = SafeUIntFromPointer(surface); - SurfacesHndlMap::iterator it = m_surfaces.find(hndl); - return it != m_surfaces.end() ? - (*it).second : - SurfacePtr(NULL); -} - -ContextPtr EglDisplay::getContext(EGLContext ctx) { - emugl::Mutex::AutoLock mutex(m_lock); - /* ctx is "key" in map<unsigned int, ContextPtr>. */ - unsigned int hndl = SafeUIntFromPointer(ctx); - ContextsHndlMap::iterator it = m_contexts.find(hndl); - return it != m_contexts.end() ? - (*it).second : - ContextPtr(NULL); -} - -bool EglDisplay::removeSurface(EGLSurface s) { - emugl::Mutex::AutoLock mutex(m_lock); - /* s is "key" in map<unsigned int, SurfacePtr>. */ - unsigned int hndl = SafeUIntFromPointer(s); - SurfacesHndlMap::iterator it = m_surfaces.find(hndl); - if(it != m_surfaces.end()) { - m_surfaces.erase(it); - return true; - } - return false; -} - -bool EglDisplay::removeSurface(SurfacePtr s) { - emugl::Mutex::AutoLock mutex(m_lock); - - SurfacesHndlMap::iterator it; - for(it = m_surfaces.begin(); it!= m_surfaces.end();it++) - { - if((*it).second.Ptr() == s.Ptr()) { - break; - } - } - if(it != m_surfaces.end()) { - m_surfaces.erase(it); - return true; - } - return false; -} - -bool EglDisplay::removeContext(EGLContext ctx) { - emugl::Mutex::AutoLock mutex(m_lock); - /* ctx is "key" in map<unsigned int, ContextPtr>. */ - unsigned int hndl = SafeUIntFromPointer(ctx); - ContextsHndlMap::iterator it = m_contexts.find(hndl); - if(it != m_contexts.end()) { - m_contexts.erase(it); - return true; - } - return false; -} - -bool EglDisplay::removeContext(ContextPtr ctx) { - emugl::Mutex::AutoLock mutex(m_lock); - - ContextsHndlMap::iterator it; - for(it = m_contexts.begin(); it != m_contexts.end();it++) { - if((*it).second.Ptr() == ctx.Ptr()){ - break; - } - } - if(it != m_contexts.end()) { - m_contexts.erase(it); - return true; - } - return false; -} - -EglConfig* EglDisplay::getConfig(EGLint id) { - emugl::Mutex::AutoLock mutex(m_lock); - - for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() ;it++) { - if((*it)->id() == id) { - return (*it); - - } - } - return NULL; -} - -int EglDisplay::getConfigs(EGLConfig* configs,int config_size) { - emugl::Mutex::AutoLock mutex(m_lock); - int i = 0; - for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && i < config_size ;i++,it++) { - configs[i] = static_cast<EGLConfig>(*it); - } - return i; -} - -int EglDisplay::chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size) { - emugl::Mutex::AutoLock mutex(m_lock); - return doChooseConfigs(dummy, configs, config_size); -} - -int EglDisplay::doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size) { - int added = 0; - for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && (added < config_size || !configs);it++) { - - if( (*it)->choosen(dummy)){ - if(configs) { - configs[added] = static_cast<EGLConfig>(*it); - } - added++; - } - } - //no need to sort since the configurations are saved already in sorted maner - return added; -} - -EGLSurface EglDisplay::addSurface(SurfacePtr s ) { - emugl::Mutex::AutoLock mutex(m_lock); - unsigned int hndl = s.Ptr()->getHndl(); - EGLSurface ret =reinterpret_cast<EGLSurface> (hndl); - - if(m_surfaces.find(hndl) != m_surfaces.end()) { - return ret; - } - - m_surfaces[hndl] = s; - return ret; -} - -EGLContext EglDisplay::addContext(ContextPtr ctx ) { - emugl::Mutex::AutoLock mutex(m_lock); - - unsigned int hndl = ctx.Ptr()->getHndl(); - EGLContext ret = reinterpret_cast<EGLContext> (hndl); - - if(m_contexts.find(hndl) != m_contexts.end()) { - return ret; - } - m_contexts[hndl] = ctx; - return ret; -} - - -EGLImageKHR EglDisplay::addImageKHR(ImagePtr img) { - emugl::Mutex::AutoLock mutex(m_lock); - do { ++m_nextEglImageId; } while(m_nextEglImageId == 0); - img->imageId = m_nextEglImageId; - m_eglImages[m_nextEglImageId] = img; - return reinterpret_cast<EGLImageKHR>(m_nextEglImageId); -} - -ImagePtr EglDisplay::getImage(EGLImageKHR img) { - emugl::Mutex::AutoLock mutex(m_lock); - /* img is "key" in map<unsigned int, ImagePtr>. */ - unsigned int hndl = SafeUIntFromPointer(img); - ImagesHndlMap::iterator i( m_eglImages.find(hndl) ); - return (i != m_eglImages.end()) ? (*i).second :ImagePtr(NULL); -} - -bool EglDisplay:: destroyImageKHR(EGLImageKHR img) { - emugl::Mutex::AutoLock mutex(m_lock); - /* img is "key" in map<unsigned int, ImagePtr>. */ - unsigned int hndl = SafeUIntFromPointer(img); - ImagesHndlMap::iterator i( m_eglImages.find(hndl) ); - if (i != m_eglImages.end()) - { - m_eglImages.erase(i); - return true; - } - return false; -} - -EGLNativeContextType EglDisplay::getGlobalSharedContext(){ - emugl::Mutex::AutoLock mutex(m_lock); -#ifndef _WIN32 - // find an existing OpenGL context to share with, if exist - EGLNativeContextType ret = - (EGLNativeContextType)m_manager[GLES_1_1]->getGlobalContext(); - if (!ret) - ret = (EGLNativeContextType)m_manager[GLES_2_0]->getGlobalContext(); - return ret; -#else - if (!m_globalSharedContext) { - // - // On windows we create a dummy context to serve as the - // "global context" which all contexts share with. - // This is because on windows it is not possible to share - // with a context which is already current. This dummy context - // will never be current to any thread so it is safe to share with. - // Create that context using the first config - if (m_configs.size() < 1) { - // Should not happen! config list should be initialized at this point - return NULL; - } - EglConfig *cfg = (*m_configs.begin()); - m_globalSharedContext = EglOS::createContext(m_dpy,cfg,NULL); - } - - return m_globalSharedContext; -#endif -} diff --git a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h deleted file mode 100644 index 47a2598..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -* 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 EGL_DISPLAY_H -#define EGL_DISPLAY_H - -#include <list> -#include <map> -#include <EGL/egl.h> -#include <EGL/eglext.h> -#include "emugl/common/mutex.h" -#include "emugl/common/smart_ptr.h" - -#include "EglConfig.h" -#include "EglContext.h" -#include "EglSurface.h" -#include "EglWindowSurface.h" - - - - -typedef std::list<EglConfig*> ConfigsList; -typedef std::map< unsigned int, ContextPtr> ContextsHndlMap; -typedef std::map< unsigned int, SurfacePtr> SurfacesHndlMap; - -class EglDisplay { -public: - - - EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault = true); - EGLNativeInternalDisplayType nativeType(); - int nConfigs(){ return m_configs.size();} - int getConfigs(EGLConfig* configs,int config_size); - int chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size); - EglConfig* getConfig(EGLConfig conf); - EglConfig* getConfig(EGLint id ); - - EGLSurface addSurface(SurfacePtr s ); - SurfacePtr getSurface(EGLSurface surface); - bool removeSurface(EGLSurface s); - bool removeSurface(SurfacePtr s); - - EGLContext addContext(ContextPtr ctx ); - ContextPtr getContext(EGLContext ctx); - bool removeContext(EGLContext ctx); - bool removeContext(ContextPtr ctx); - ObjectNameManager* getManager(GLESVersion ver){ return m_manager[ver];} - - ~EglDisplay(); - void initialize(int renderableType); - void terminate(); - bool isInitialize(); - - ImagePtr getImage(EGLImageKHR img); - EGLImageKHR addImageKHR(ImagePtr); - bool destroyImageKHR(EGLImageKHR img); - EGLNativeContextType getGlobalSharedContext(); - -private: - int doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size); - void addMissingConfigs(void); - void initConfigurations(int renderableType); - - EGLNativeInternalDisplayType m_dpy; - bool m_initialized; - bool m_configInitialized; - bool m_isDefault; - ConfigsList m_configs; - ContextsHndlMap m_contexts; - SurfacesHndlMap m_surfaces; - GlobalNameSpace m_globalNameSpace; - ObjectNameManager *m_manager[MAX_GLES_VERSION]; - emugl::Mutex m_lock; - ImagesHndlMap m_eglImages; - unsigned int m_nextEglImageId; - EGLNativeContextType m_globalSharedContext; -}; - -#endif - - diff --git a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp deleted file mode 100644 index 95b696e..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* -* 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. -*/ -#include "EglGlobalInfo.h" -#include "EglOsApi.h" -#include <string.h> -#include "ClientAPIExts.h" - -int EglGlobalInfo::m_refCount = 0; -EglGlobalInfo* EglGlobalInfo::m_singleton = NULL; - - -EglGlobalInfo::EglGlobalInfo(){ - m_default = EglOS::getDefaultDisplay(); -#ifdef _WIN32 - EglOS::initPtrToWglFunctions(); -#endif - memset(m_gles_ifaces,0,sizeof(m_gles_ifaces)); - memset(m_gles_extFuncs_inited,0,sizeof(m_gles_extFuncs_inited)); -} - -EglGlobalInfo* EglGlobalInfo::getInstance() { - if(!m_singleton) { - m_singleton = new EglGlobalInfo(); - m_refCount = 0; - } - m_refCount++; - return m_singleton; -} - -void EglGlobalInfo::delInstance() { - m_refCount--; - if(m_refCount <= 0 && m_singleton) { - delete m_singleton; - m_singleton = NULL; - } - -} - -EglDisplay* EglGlobalInfo::addDisplay(EGLNativeDisplayType dpy,EGLNativeInternalDisplayType idpy) { - //search if it is not already exists - emugl::Mutex::AutoLock mutex(m_lock); - for(DisplaysMap::iterator it = m_displays.begin(); it != m_displays.end() ;it++) { - if((*it).second == dpy) return (*it).first; - } - - if (!EglOS::validNativeDisplay(idpy)) - return NULL; - - EglDisplay* p_dpy = new EglDisplay(idpy); - if(p_dpy) { - m_displays[p_dpy] = dpy; - return p_dpy; - } - return NULL; -} - -bool EglGlobalInfo::removeDisplay(EGLDisplay dpy) { - emugl::Mutex::AutoLock mutex(m_lock); - for(DisplaysMap::iterator it = m_displays.begin(); it != m_displays.end() ;it++) { - if(static_cast<EGLDisplay>((*it).first) == dpy) { - delete (*it).first; - m_displays.erase(it); - return true; - } - } - return false; -} - -EglDisplay* EglGlobalInfo::getDisplay(EGLNativeDisplayType dpy) { - emugl::Mutex::AutoLock mutex(m_lock); - for(DisplaysMap::iterator it = m_displays.begin(); it != m_displays.end() ;it++) { - if((*it).second == dpy) return (*it).first; - } - return NULL; -} - -EglDisplay* EglGlobalInfo::getDisplay(EGLDisplay dpy) { - emugl::Mutex::AutoLock mutex(m_lock); - DisplaysMap::iterator it = m_displays.find(static_cast<EglDisplay*>(dpy)); - return (it != m_displays.end() ? (*it).first : NULL); -} - -EGLNativeInternalDisplayType EglGlobalInfo::generateInternalDisplay(EGLNativeDisplayType dpy){ - return EglOS::getInternalDisplay(dpy); -} - -void EglGlobalInfo::initClientExtFuncTable(GLESVersion ver) -{ - emugl::Mutex::AutoLock mutex(m_lock); - if (!m_gles_extFuncs_inited[ver]) { - ClientAPIExts::initClientFuncs(m_gles_ifaces[ver], (int)ver - 1); - m_gles_extFuncs_inited[ver] = true; - } -} diff --git a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h deleted file mode 100644 index f56b79e..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -* 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 EGL_GLOBAL_INFO -#define EGL_GLOBAL_INFO - -#include "EglDisplay.h" -#include "EglConfig.h" -#include "EglContext.h" - -#include <GLcommon/TranslatorIfaces.h> -#include "emugl/common/mutex.h" -#include <list> -#include <EGL/egl.h> - -typedef std::map<EglDisplay*,EGLNativeDisplayType>DisplaysMap; - - -class EglGlobalInfo { - -public: - EglDisplay* addDisplay(EGLNativeDisplayType dpy,EGLNativeInternalDisplayType idpy); - EglDisplay* getDisplay(EGLNativeDisplayType dpy); - EglDisplay* getDisplay(EGLDisplay dpy); - bool removeDisplay(EGLDisplay dpy); - EGLNativeInternalDisplayType getDefaultNativeDisplay(){ return m_default;}; - EGLNativeInternalDisplayType generateInternalDisplay(EGLNativeDisplayType dpy); - - void setIface(GLESiface* iface,GLESVersion ver) { m_gles_ifaces[ver] = iface;}; - GLESiface* getIface(GLESVersion ver){ return m_gles_ifaces[ver];} - - int nDisplays() const { return m_displays.size();}; - - void initClientExtFuncTable(GLESVersion ver); - - static EglGlobalInfo* getInstance(); - static void delInstance(); - -private: - EglGlobalInfo(); - ~EglGlobalInfo(){}; - - static EglGlobalInfo* m_singleton; - static int m_refCount; - - DisplaysMap m_displays; - EGLNativeInternalDisplayType m_default; - GLESiface* m_gles_ifaces[MAX_GLES_VERSION]; - bool m_gles_extFuncs_inited[MAX_GLES_VERSION]; - emugl::Mutex m_lock; -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp deleted file mode 100644 index 30d358f..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp +++ /dev/null @@ -1,1068 +0,0 @@ -/* -* 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. -*/ -#ifdef _WIN32 -#undef EGLAPI -#define EGLAPI __declspec(dllexport) -#endif - -#include <EGL/egl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <stdio.h> -#include "ThreadInfo.h" -#include <GLcommon/TranslatorIfaces.h> -#include "emugl/common/shared_library.h" - -#include "EglWindowSurface.h" -#include "EglPbufferSurface.h" -#include "EglPixmapSurface.h" -#include "EglGlobalInfo.h" -#include "EglThreadInfo.h" -#include "EglValidate.h" -#include "EglDisplay.h" -#include "EglContext.h" -#include "EglConfig.h" -#include "EglOsApi.h" -#include "ClientAPIExts.h" - -#define MAJOR 1 -#define MINOR 4 - -//declarations - -EglImage *attachEGLImage(unsigned int imageId); -void detachEGLImage(unsigned int imageId); -GLEScontext* getGLESContext(); - -#define tls_thread EglThreadInfo::get() - -EglGlobalInfo* g_eglInfo = NULL; -emugl::Mutex s_eglLock; - -void initGlobalInfo() -{ - emugl::Mutex::AutoLock mutex(s_eglLock); - if (!g_eglInfo) { - g_eglInfo = EglGlobalInfo::getInstance(); - } -} - -static EGLiface s_eglIface = { - getGLESContext : getGLESContext, - eglAttachEGLImage:attachEGLImage, - eglDetachEGLImage:detachEGLImage -}; - -/***************************************** supported extentions ***********************************************************************/ - -//extentions -#define EGL_EXTENTIONS 2 - -//decleration -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image); - -// extentions descriptors -static ExtentionDescriptor s_eglExtentions[] = { - {"eglCreateImageKHR" ,(__eglMustCastToProperFunctionPointerType)eglCreateImageKHR}, - {"eglDestroyImageKHR",(__eglMustCastToProperFunctionPointerType)eglDestroyImageKHR} - }; -static int s_eglExtentionsSize = sizeof(s_eglExtentions) / - sizeof(ExtentionDescriptor); - -/****************************************************************************************************************************************/ -//macros for accessing global egl info & tls objects - -#define CURRENT_THREAD() do {} while (0); - -#define RETURN_ERROR(ret,err) \ - CURRENT_THREAD() \ - if(tls_thread->getError() == EGL_SUCCESS) { \ - tls_thread->setError(err); \ - } \ - return ret; - -#define VALIDATE_DISPLAY_RETURN(EGLDisplay,ret) \ - EglDisplay* dpy = g_eglInfo->getDisplay(EGLDisplay); \ - if(!dpy){ \ - RETURN_ERROR(ret,EGL_BAD_DISPLAY); \ - } \ - if(!dpy->isInitialize()) { \ - RETURN_ERROR(ret,EGL_NOT_INITIALIZED); \ - } - -#define VALIDATE_CONFIG_RETURN(EGLConfig,ret) \ - EglConfig* cfg = dpy->getConfig(EGLConfig); \ - if(!cfg) { \ - RETURN_ERROR(ret,EGL_BAD_CONFIG); \ - } - -#define VALIDATE_SURFACE_RETURN(EGLSurface,ret,varName) \ - SurfacePtr varName = dpy->getSurface(EGLSurface); \ - if(!varName.Ptr()) { \ - RETURN_ERROR(ret,EGL_BAD_SURFACE); \ - } - -#define VALIDATE_CONTEXT_RETURN(EGLContext,ret) \ - ContextPtr ctx = dpy->getContext(EGLContext); \ - if(!ctx.Ptr()) { \ - RETURN_ERROR(ret,EGL_BAD_CONTEXT); \ - } - - -#define VALIDATE_DISPLAY(EGLDisplay) \ - VALIDATE_DISPLAY_RETURN(EGLDisplay,EGL_FALSE) - -#define VALIDATE_CONFIG(EGLConfig) \ - VALIDATE_CONFIG_RETURN(EGLConfig,EGL_FALSE) - -#define VALIDATE_SURFACE(EGLSurface,varName) \ - VALIDATE_SURFACE_RETURN(EGLSurface,EGL_FALSE,varName) - -#define VALIDATE_CONTEXT(EGLContext) \ - VALIDATE_CONTEXT_RETURN(EGLContext,EGL_FALSE) - - -GLEScontext* getGLESContext() -{ - ThreadInfo* thread = getThreadInfo(); - return thread->glesContext; -} - -EGLAPI EGLint EGLAPIENTRY eglGetError(void) { - CURRENT_THREAD(); - EGLint err = tls_thread->getError(); - tls_thread->setError(EGL_SUCCESS); - return err; -} - -EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) { - EglDisplay* dpy = NULL; - EGLNativeInternalDisplayType internalDisplay = NULL; - - initGlobalInfo(); - - if ((dpy = g_eglInfo->getDisplay(display_id))) { - return dpy; - } else { - - if( display_id == EGL_DEFAULT_DISPLAY) { - internalDisplay = g_eglInfo->getDefaultNativeDisplay(); - } else { - internalDisplay = g_eglInfo->generateInternalDisplay(display_id); - } - - dpy = g_eglInfo->addDisplay(display_id,internalDisplay); - if(dpy) return dpy; - return EGL_NO_DISPLAY; - } -} - - -#define TRANSLATOR_GETIFACE_NAME "__translator_getIfaces" - -static __translator_getGLESIfaceFunc loadIfaces(const char* libName){ - emugl::SharedLibrary* libGLES = emugl::SharedLibrary::open(libName); - - if(!libGLES) return NULL; - __translator_getGLESIfaceFunc func = (__translator_getGLESIfaceFunc)libGLES->findSymbol(TRANSLATOR_GETIFACE_NAME); - if(!func) return NULL; - return func; -} - -#define LIB_GLES_CM_NAME EMUGL_LIBNAME("GLES_CM_translator") -#define LIB_GLES_V2_NAME EMUGL_LIBNAME("GLES_V2_translator") - -EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay display, EGLint *major, EGLint *minor) { - - initGlobalInfo(); - - EglDisplay* dpy = g_eglInfo->getDisplay(display); - if(!dpy) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_DISPLAY); - } - - if(major) *major = MAJOR; - if(minor) *minor = MINOR; - - __translator_getGLESIfaceFunc func = NULL; - int renderableType = EGL_OPENGL_ES_BIT; - - if(!g_eglInfo->getIface(GLES_1_1)) { - func = loadIfaces(LIB_GLES_CM_NAME); - if(func){ - g_eglInfo->setIface(func(&s_eglIface),GLES_1_1); - } else { - fprintf(stderr,"could not find ifaces for GLES CM 1.1\n"); - return EGL_FALSE; - } - } - if(!g_eglInfo->getIface(GLES_2_0)) { - func = loadIfaces(LIB_GLES_V2_NAME); - if(func){ - renderableType |= EGL_OPENGL_ES2_BIT; - g_eglInfo->setIface(func(&s_eglIface),GLES_2_0); - } else { - fprintf(stderr,"could not find ifaces for GLES 2.0\n"); - } - } - dpy->initialize(renderableType); - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay display) { - VALIDATE_DISPLAY(display); - dpy->terminate(); - return EGL_TRUE; -} - -EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay display, EGLint name) { - VALIDATE_DISPLAY(display); - static const char* vendor = "Google"; - static const char* version = "1.4"; - static const char* extensions = "EGL_KHR_image_base EGL_KHR_gl_texture_2D_image"; - if(!EglValidate::stringName(name)) { - RETURN_ERROR(NULL,EGL_BAD_PARAMETER); - } - switch(name) { - case EGL_VENDOR: - return vendor; - case EGL_VERSION: - return version; - case EGL_EXTENSIONS: - return extensions; - } - return NULL; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay display, EGLConfig *configs, - EGLint config_size, EGLint *num_config) { - VALIDATE_DISPLAY(display); - if(!num_config) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER); - } - - if(configs == NULL) { - *num_config = dpy->nConfigs(); - } else { - *num_config = dpy->getConfigs(configs,config_size); - } - - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *attrib_list, - EGLConfig *configs, EGLint config_size, - EGLint *num_config) { - VALIDATE_DISPLAY(display); - if(!num_config) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER); - } - - //selection defaults - // NOTE: Some variables below are commented out to reduce compiler warnings. - // TODO(digit): Look if these variables are really needed or not, and if so - // fix the code to do it properly. - EGLint surface_type = EGL_WINDOW_BIT; - EGLint renderable_type = EGL_OPENGL_ES_BIT; - //EGLBoolean bind_to_tex_rgb = EGL_DONT_CARE; - //EGLBoolean bind_to_tex_rgba = EGL_DONT_CARE; - EGLenum caveat = EGL_DONT_CARE; - EGLint config_id = EGL_DONT_CARE; - EGLBoolean native_renderable = EGL_DONT_CARE; - EGLint native_visual_type = EGL_DONT_CARE; - //EGLint max_swap_interval = EGL_DONT_CARE; - //EGLint min_swap_interval = EGL_DONT_CARE; - EGLint trans_red_val = EGL_DONT_CARE; - EGLint trans_green_val = EGL_DONT_CARE; - EGLint trans_blue_val = EGL_DONT_CARE; - EGLenum transparent_type = EGL_NONE; - //EGLint buffer_size = 0; - EGLint red_size = 0; - EGLint green_size = 0; - EGLint blue_size = 0; - EGLint alpha_size = 0; - EGLint depth_size = 0; - EGLint frame_buffer_level = 0; - //EGLint sample_buffers_num = 0; - EGLint samples_per_pixel = 0; - EGLint stencil_size = 0; - - if(!EglValidate::noAttribs(attrib_list)) { //there are attribs - int i = 0 ; - bool hasConfigId = false; - while(attrib_list[i] != EGL_NONE && !hasConfigId) { - switch(attrib_list[i]) { - case EGL_MAX_PBUFFER_WIDTH: - case EGL_MAX_PBUFFER_HEIGHT: - case EGL_MAX_PBUFFER_PIXELS: - case EGL_NATIVE_VISUAL_ID: - break; //we dont care from those selection crateria - case EGL_LEVEL: - if(attrib_list[i+1] == EGL_DONT_CARE) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - frame_buffer_level = attrib_list[i+1]; - break; - case EGL_BUFFER_SIZE: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - //buffer_size = attrib_list[i+1]; - break; - case EGL_RED_SIZE: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - red_size = attrib_list[i+1]; - break; - case EGL_GREEN_SIZE: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - green_size = attrib_list[i+1]; - break; - case EGL_BLUE_SIZE: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - blue_size = attrib_list[i+1]; - break; - case EGL_ALPHA_SIZE: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - alpha_size = attrib_list[i+1]; - break; - case EGL_BIND_TO_TEXTURE_RGB: - //bind_to_tex_rgb = attrib_list[i+1]; - break; - case EGL_BIND_TO_TEXTURE_RGBA: - //bind_to_tex_rgba = attrib_list[i+1]; - break; - case EGL_CONFIG_CAVEAT: - if(attrib_list[i+1] != EGL_NONE && attrib_list[i+1] != EGL_SLOW_CONFIG && attrib_list[i+1] != EGL_NON_CONFORMANT_CONFIG) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - caveat = attrib_list[i+1]; - break; - case EGL_CONFIG_ID: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - config_id = attrib_list[i+1]; - hasConfigId = true; - break; - case EGL_DEPTH_SIZE: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - depth_size = attrib_list[i+1]; - break; - case EGL_MAX_SWAP_INTERVAL: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - //max_swap_interval = attrib_list[i+1]; - break; - case EGL_MIN_SWAP_INTERVAL: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - //min_swap_interval = attrib_list[i+1]; - break; - case EGL_NATIVE_RENDERABLE: - native_renderable = attrib_list[i+1]; - break; - case EGL_RENDERABLE_TYPE: - renderable_type = attrib_list[i+1]; - break; - case EGL_NATIVE_VISUAL_TYPE: - native_visual_type = attrib_list[i+1]; - break; - if(attrib_list[i+1] < 0 || attrib_list[i+1] > 1 ) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - case EGL_SAMPLE_BUFFERS: - //sample_buffers_num = attrib_list[i+1]; - break; - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - case EGL_SAMPLES: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - samples_per_pixel = attrib_list[i+1]; - break; - case EGL_STENCIL_SIZE: - if(attrib_list[i+1] < 0) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - stencil_size = attrib_list[i+1]; - break; - case EGL_SURFACE_TYPE: - surface_type = attrib_list[i+1]; - break; - case EGL_TRANSPARENT_TYPE: - if(attrib_list[i+1] != EGL_NONE && attrib_list[i+1] != EGL_TRANSPARENT_RGB ) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - transparent_type = attrib_list[i+1]; - break; - case EGL_TRANSPARENT_RED_VALUE: - trans_red_val = attrib_list[i+1]; - break; - case EGL_TRANSPARENT_GREEN_VALUE: - trans_green_val = attrib_list[i+1]; - break; - case EGL_TRANSPARENT_BLUE_VALUE: - trans_blue_val = attrib_list[i+1]; - break; - default: - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - i+=2; - } - if(hasConfigId) { - EglConfig* pConfig = dpy->getConfig(config_id); - if(pConfig) { - if(configs) { - configs[0] = static_cast<EGLConfig>(pConfig); - } - *num_config = 1; - return EGL_TRUE; - } else { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - } - } - EGLNativePixelFormatType tmpfrmt = PIXEL_FORMAT_INITIALIZER; - EglConfig dummy(red_size,green_size,blue_size,alpha_size,caveat,config_id,depth_size, - frame_buffer_level,0,0,0,native_renderable,renderable_type,0,native_visual_type, - samples_per_pixel,stencil_size,surface_type,transparent_type, - trans_red_val,trans_green_val,trans_blue_val,tmpfrmt); - - *num_config = dpy->chooseConfigs(dummy,configs,config_size); - - - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay display, EGLConfig config, - EGLint attribute, EGLint *value) { - VALIDATE_DISPLAY(display); - VALIDATE_CONFIG(config); - if(!EglValidate::confAttrib(attribute)){ - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - return cfg->getConfAttrib(attribute,value)? EGL_TRUE:EGL_FALSE; -} - -EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay display, EGLConfig config, - EGLNativeWindowType win, - const EGLint *attrib_list) { - VALIDATE_DISPLAY_RETURN(display,EGL_NO_SURFACE); - VALIDATE_CONFIG_RETURN(config,EGL_NO_SURFACE); - - if(!(cfg->surfaceType() & EGL_WINDOW_BIT)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_MATCH); - } - if(!EglOS::validNativeWin(dpy->nativeType(),win)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_NATIVE_WINDOW); - } - if(!EglValidate::noAttribs(attrib_list)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE); - } - if(EglWindowSurface::alreadyAssociatedWithConfig(win)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC); - } - - unsigned int width,height; - if(!EglOS::checkWindowPixelFormatMatch(dpy->nativeType(),win,cfg,&width,&height)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC); - } - SurfacePtr wSurface(new EglWindowSurface(dpy, win,cfg,width,height)); - if(!wSurface.Ptr()) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC); - } - return dpy->addSurface(wSurface); -} - -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, - const EGLint *attrib_list) { - VALIDATE_DISPLAY_RETURN(display,EGL_NO_SURFACE); - VALIDATE_CONFIG_RETURN(config,EGL_NO_SURFACE); - if(!(cfg->surfaceType() & EGL_PBUFFER_BIT)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_MATCH); - } - - - SurfacePtr pbSurface(new EglPbufferSurface(dpy,cfg)); - if(!pbSurface.Ptr()) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC); - } - - if(!EglValidate::noAttribs(attrib_list)) { //there are attribs - int i = 0 ; - while(attrib_list[i] != EGL_NONE) { - if(!pbSurface->setAttrib(attrib_list[i],attrib_list[i+1])) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE); - } - i+=2; - } - } - - EGLint width,height,largest,texTarget,texFormat; - EglPbufferSurface* tmpPbSurfacePtr = static_cast<EglPbufferSurface*>(pbSurface.Ptr()); - tmpPbSurfacePtr->getDim(&width,&height,&largest); - tmpPbSurfacePtr->getTexInfo(&texTarget,&texFormat); - - if(!EglValidate::pbufferAttribs(width,height,texFormat == EGL_NO_TEXTURE,texTarget == EGL_NO_TEXTURE)) { - //TODO: RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_VALUE); dont have bad_value - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE); - } - - EGLNativeSurfaceType pb = EglOS::createPbufferSurface(dpy->nativeType(),cfg,tmpPbSurfacePtr); - if(!pb) { - //TODO: RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_VALUE); dont have bad value - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE); - } - - tmpPbSurfacePtr->setNativePbuffer(pb); - return dpy->addSurface(pbSurface); -} - -EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay display, EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint *attrib_list) { - VALIDATE_DISPLAY_RETURN(display,EGL_NO_SURFACE); - VALIDATE_CONFIG_RETURN(config,EGL_NO_SURFACE); - if(!(cfg->surfaceType() & EGL_PIXMAP_BIT)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_MATCH); - } - if(!EglValidate::noAttribs(attrib_list)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE); - } - if(EglPixmapSurface::alreadyAssociatedWithConfig(pixmap)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC); - } - - unsigned int width,height; - if(!EglOS::checkPixmapPixelFormatMatch(dpy->nativeType(),pixmap,cfg,&width,&height)) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC); - } - SurfacePtr pixSurface(new EglPixmapSurface(dpy, pixmap,cfg)); - if(!pixSurface.Ptr()) { - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC); - } - - return dpy->addSurface(pixSurface); -} - -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay display, EGLSurface surface) { - VALIDATE_DISPLAY(display); - SurfacePtr srfc = dpy->getSurface(surface); - if(!srfc.Ptr()) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE); - } - - dpy->removeSurface(surface); - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay display, EGLSurface surface, - EGLint attribute, EGLint *value) { - VALIDATE_DISPLAY(display); - VALIDATE_SURFACE(surface,srfc); - - if(!srfc->getAttrib(attribute,value)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay display, EGLSurface surface, - EGLint attribute, EGLint value) { - VALIDATE_DISPLAY(display); - VALIDATE_SURFACE(surface,srfc); - if(!srfc->setAttrib(attribute,value)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - return EGL_TRUE; -} - -EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay display, EGLConfig config, - EGLContext share_context, - const EGLint *attrib_list) { - VALIDATE_DISPLAY_RETURN(display,EGL_NO_CONTEXT); - VALIDATE_CONFIG_RETURN(config,EGL_NO_CONTEXT); - - GLESVersion version = GLES_1_1; - if(!EglValidate::noAttribs(attrib_list)) { - int i = 0; - while(attrib_list[i] != EGL_NONE) { - switch(attrib_list[i]) { - case EGL_CONTEXT_CLIENT_VERSION: - if(attrib_list[i+1] == 2) { - version = GLES_2_0; - } else { - version = GLES_1_1; - } - break; - default: - RETURN_ERROR(EGL_NO_CONTEXT,EGL_BAD_ATTRIBUTE); - } - i+=2; - } - } - GLESiface* iface = g_eglInfo->getIface(version); - GLEScontext* glesCtx = NULL; - if(iface) { - glesCtx = iface->createGLESContext(); - } else { // there is no interface for this gles version - RETURN_ERROR(EGL_NO_CONTEXT,EGL_BAD_ATTRIBUTE); - } - - ContextPtr sharedCtxPtr; - if(share_context != EGL_NO_CONTEXT) { - sharedCtxPtr = dpy->getContext(share_context); - if(!sharedCtxPtr.Ptr()) { - RETURN_ERROR(EGL_NO_CONTEXT,EGL_BAD_CONTEXT); - } - } - - EGLNativeContextType globalSharedContext = dpy->getGlobalSharedContext(); - EGLNativeContextType nativeContext = EglOS::createContext(dpy->nativeType(),cfg,globalSharedContext); - - if(nativeContext) { - ContextPtr ctx(new EglContext(dpy, nativeContext,sharedCtxPtr,cfg,glesCtx,version,dpy->getManager(version))); - return dpy->addContext(ctx); - } else { - iface->deleteGLESContext(glesCtx); - } - -return EGL_NO_CONTEXT; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay display, EGLContext context) { - VALIDATE_DISPLAY(display); - VALIDATE_CONTEXT(context); - - dpy->removeContext(context); - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay display, EGLSurface draw, - EGLSurface read, EGLContext context) { - VALIDATE_DISPLAY(display); - - - bool releaseContext = EglValidate::releaseContext(context,read,draw); - if(!releaseContext && EglValidate::badContextMatch(context,read,draw)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_MATCH); - } - - ThreadInfo* thread = getThreadInfo(); - ContextPtr prevCtx = thread->eglContext; - - if(releaseContext) { //releasing current context - if(prevCtx.Ptr()) { - g_eglInfo->getIface(prevCtx->version())->flush(); - if(!EglOS::makeCurrent(dpy->nativeType(),NULL,NULL,NULL)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ACCESS); - } - thread->updateInfo(ContextPtr(NULL),dpy,NULL,ShareGroupPtr(NULL),dpy->getManager(prevCtx->version())); - } - } else { //assining new context - VALIDATE_CONTEXT(context); - VALIDATE_SURFACE(draw,newDrawSrfc); - VALIDATE_SURFACE(read,newReadSrfc); - - EglSurface* newDrawPtr = newDrawSrfc.Ptr(); - EglSurface* newReadPtr = newReadSrfc.Ptr(); - ContextPtr newCtx = ctx; - - if (newCtx.Ptr() && prevCtx.Ptr()) { - if (newCtx.Ptr() == prevCtx.Ptr()) { - if (newDrawPtr == prevCtx->draw().Ptr() && - newReadPtr == prevCtx->read().Ptr()) { - // nothing to do - return EGL_TRUE; - } - } - else { - // Make sure previous context is detached from surfaces - releaseContext = true; - } - } - - //surfaces compitability check - if(!((*ctx->getConfig()).compitableWith((*newDrawPtr->getConfig()))) || - !((*ctx->getConfig()).compitableWith((*newReadPtr->getConfig())))) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_MATCH); - } - - EGLNativeInternalDisplayType nativeDisplay = dpy->nativeType(); - EGLNativeSurfaceType nativeRead = newReadPtr->native(); - EGLNativeSurfaceType nativeDraw = newDrawPtr->native(); - //checking native window validity - if(newReadPtr->type() == EglSurface::WINDOW && !EglOS::validNativeWin(nativeDisplay,nativeRead)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_WINDOW); - } - if(newDrawPtr->type() == EglSurface::WINDOW && !EglOS::validNativeWin(nativeDisplay,nativeDraw)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_WINDOW); - } - - //checking native pixmap validity - if(newReadPtr->type() == EglSurface::PIXMAP && !EglOS::validNativePixmap(nativeDisplay,nativeRead)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_PIXMAP); - } - if(newDrawPtr->type() == EglSurface::PIXMAP && !EglOS::validNativePixmap(nativeDisplay,nativeDraw)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_PIXMAP); - } - if(prevCtx.Ptr()) { - g_eglInfo->getIface(prevCtx->version())->flush(); - } - if(!EglOS::makeCurrent(dpy->nativeType(),newReadPtr,newDrawPtr,newCtx->nativeType())) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_ACCESS); - } - //TODO: handle the following errors - // EGL_BAD_CURRENT_SURFACE , EGL_CONTEXT_LOST , EGL_BAD_ACCESS - - thread->updateInfo(newCtx,dpy,newCtx->getGlesContext(),newCtx->getShareGroup(),dpy->getManager(newCtx->version())); - newCtx->setSurfaces(newReadSrfc,newDrawSrfc); - g_eglInfo->getIface(newCtx->version())->initContext(newCtx->getGlesContext(),newCtx->getShareGroup()); - - // Initialize the GLES extension function table used in - // eglGetProcAddress for the context's GLES version if not - // yet initialized. We initialize it here to make sure we call the - // GLES getProcAddress after when a context is bound. - g_eglInfo->initClientExtFuncTable(newCtx->version()); - } - - // release previous context surface binding - if(prevCtx.Ptr() && releaseContext) { - prevCtx->setSurfaces(SurfacePtr(NULL),SurfacePtr(NULL)); - } - - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay display, EGLContext context, - EGLint attribute, EGLint *value) { - VALIDATE_DISPLAY(display); - VALIDATE_CONTEXT(context); - - if(!ctx->getAttrib(attribute,value)){ - RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE); - } - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay display, EGLSurface surface) { - VALIDATE_DISPLAY(display); - VALIDATE_SURFACE(surface,Srfc); - ThreadInfo* thread = getThreadInfo(); - ContextPtr currentCtx = thread->eglContext; - - - //if surface not window return - if(Srfc->type() != EglSurface::WINDOW){ - RETURN_ERROR(EGL_TRUE,EGL_SUCCESS); - } - - if(!currentCtx.Ptr() || !currentCtx->usingSurface(Srfc) || !EglOS::validNativeWin(dpy->nativeType(),Srfc.Ptr()->native())) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE); - } - - EglOS::swapBuffers(dpy->nativeType(),Srfc->native()); - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay display, EGLint interval) { - VALIDATE_DISPLAY(display); - ThreadInfo* thread = getThreadInfo(); - ContextPtr currCtx = thread->eglContext; - if(currCtx.Ptr()) { - if(!currCtx->read().Ptr() || !currCtx->draw().Ptr() || currCtx->draw()->type()!=EglSurface::WINDOW) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_CURRENT_SURFACE); - } - EglOS::swapInterval(dpy->nativeType(),currCtx->draw()->native(),interval); - } else { - RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE); - } - return EGL_TRUE; -} - - -EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void) { - ThreadInfo* thread = getThreadInfo(); - EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay); - ContextPtr ctx = thread->eglContext; - if(dpy && ctx.Ptr()){ - // This double check is required because a context might still be current after it is destroyed - in which case - // its handle should be invalid, that is EGL_NO_CONTEXT should be returned even though the context is current - EGLContext c = (EGLContext)SafePointerFromUInt(ctx->getHndl()); - if(dpy->getContext(c).Ptr()) - { - return c; - } - } - return EGL_NO_CONTEXT; -} - -EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { - if(!EglValidate::surfaceTarget(readdraw)) return EGL_NO_SURFACE; - - ThreadInfo* thread = getThreadInfo(); - EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay); - ContextPtr ctx = thread->eglContext; - - if(dpy && ctx.Ptr()) { - SurfacePtr surface = readdraw == EGL_READ ? ctx->read() : ctx->draw(); - if(surface.Ptr()) - { - // This double check is required because a surface might still be - // current after it is destroyed - in which case its handle should - // be invalid, that is EGL_NO_SURFACE should be returned even - // though the surface is current. - EGLSurface s = (EGLSurface)SafePointerFromUInt(surface->getHndl()); - surface = dpy->getSurface(s); - if(surface.Ptr()) - { - return s; - } - } - } - return EGL_NO_SURFACE; -} - -EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) { - ThreadInfo* thread = getThreadInfo(); - return (thread->eglContext.Ptr()) ? thread->eglDisplay : EGL_NO_DISPLAY; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void) { - EGLenum api = eglQueryAPI(); - eglBindAPI(EGL_OPENGL_ES_API); - EGLBoolean ret = eglWaitClient(); - eglBindAPI(api); - return ret; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) { - if(!EglValidate::engine(engine)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER); - } - ThreadInfo* thread = getThreadInfo(); - ContextPtr currCtx = thread->eglContext; - EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay); - if(currCtx.Ptr()) { - SurfacePtr read = currCtx->read(); - SurfacePtr draw = currCtx->draw(); - - EGLNativeInternalDisplayType nativeDisplay = dpy->nativeType(); - if(read.Ptr()) { - if(read->type() == EglSurface::WINDOW && - !EglOS::validNativeWin(nativeDisplay,read->native())) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE); - } - if(read->type() == EglSurface::PIXMAP && - !EglOS::validNativePixmap(nativeDisplay,read->native())) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE); - } - } - if(draw.Ptr()) { - if(draw->type() == EglSurface::WINDOW && - !EglOS::validNativeWin(nativeDisplay,draw->native())) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE); - } - if(draw->type() == EglSurface::PIXMAP && - !EglOS::validNativePixmap(nativeDisplay,draw->native())) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE); - } - } - } - EglOS::waitNative(); - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api) { - if(!EglValidate::supportedApi(api)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER); - } - CURRENT_THREAD(); - tls_thread->setApi(api); - return EGL_TRUE; -} - -EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void) { - CURRENT_THREAD(); - return tls_thread->getApi(); -} - -EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void) { - ThreadInfo* thread = getThreadInfo(); - ContextPtr currCtx = thread->eglContext; - if(currCtx.Ptr()) { - if(!currCtx->read().Ptr() || !currCtx->draw().Ptr()) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_CURRENT_SURFACE); - } - g_eglInfo->getIface(currCtx->version())->finish(); - } - return EGL_TRUE; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) { - ThreadInfo* thread = getThreadInfo(); - EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay); - return eglMakeCurrent(dpy,EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT); -} - -EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY - eglGetProcAddress(const char *procname){ - __eglMustCastToProperFunctionPointerType retVal = NULL; - - initGlobalInfo(); - - if(!strncmp(procname,"egl",3)) { //EGL proc - for(int i=0;i < s_eglExtentionsSize;i++){ - if(strcmp(procname,s_eglExtentions[i].name) == 0){ - retVal = s_eglExtentions[i].address; - break; - } - } - } - else { - // Look at the clientAPI (GLES) supported extension - // function table. - retVal = ClientAPIExts::getProcAddress(procname); - } - return retVal; -} - -//not supported for now -/************************* NOT SUPPORTED FOR NOW ***********************/ -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer( - EGLDisplay display, EGLenum buftype, EGLClientBuffer buffer, - EGLConfig config, const EGLint *attrib_list) { - VALIDATE_DISPLAY(display); - VALIDATE_CONFIG(config); - //we do not support for now openVG, and the only client API resources which may be bound in this fashion are OpenVG - RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_PARAMETER); -} - -EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay display, EGLSurface surface, - EGLNativePixmapType target) { - VALIDATE_DISPLAY(display); - VALIDATE_SURFACE(surface,srfc); - if(!EglOS::validNativePixmap(dpy->nativeType(),NULL)) { - RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_PIXMAP); - } - - //we do not need to support this for android , since we are not gonna use pixmaps - RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_PIXMAP); -} - -/***********************************************************************/ - - - -//do last ( only if needed) -/*********************************************************************************************************/ -EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { -//TODO: -return 0; -} - -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { -//TODO: -return 0; -} -/*********************************************************************************************************/ - - -/************************** KHR IMAGE *************************************************************/ -EglImage *attachEGLImage(unsigned int imageId) -{ - ThreadInfo* thread = getThreadInfo(); - EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay); - ContextPtr ctx = thread->eglContext; - if (ctx.Ptr()) { - ImagePtr img = dpy->getImage(reinterpret_cast<EGLImageKHR>(imageId)); - if(img.Ptr()) { - ctx->attachImage(imageId,img); - return img.Ptr(); - } - } - return NULL; -} - -void detachEGLImage(unsigned int imageId) -{ - ThreadInfo* thread = getThreadInfo(); - ContextPtr ctx = thread->eglContext; - if (ctx.Ptr()) { - ctx->detachImage(imageId); - } -} - - -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) -{ - VALIDATE_DISPLAY(display); - VALIDATE_CONTEXT(context); - - // We only support EGL_GL_TEXTURE_2D images - if (target != EGL_GL_TEXTURE_2D_KHR) { - RETURN_ERROR(EGL_NO_IMAGE_KHR,EGL_BAD_PARAMETER); - } - - ThreadInfo* thread = getThreadInfo(); - ShareGroupPtr sg = thread->shareGroup; - if (sg.Ptr() != NULL) { - unsigned int globalTexName = sg->getGlobalName(TEXTURE, SafeUIntFromPointer(buffer)); - if (!globalTexName) return EGL_NO_IMAGE_KHR; - - ImagePtr img( new EglImage() ); - if (img.Ptr() != NULL) { - - ObjectDataPtr objData = sg->getObjectData(TEXTURE, SafeUIntFromPointer(buffer)); - if (!objData.Ptr()) return EGL_NO_IMAGE_KHR; - - TextureData *texData = (TextureData *)objData.Ptr(); - if(!texData->width || !texData->height) return EGL_NO_IMAGE_KHR; - img->width = texData->width; - img->height = texData->height; - img->border = texData->border; - img->internalFormat = texData->internalFormat; - img->globalTexName = globalTexName; - return dpy->addImageKHR(img); - } - } - - return EGL_NO_IMAGE_KHR; -} - - -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image) -{ - VALIDATE_DISPLAY(display); - return dpy->destroyImageKHR(image) ? EGL_TRUE:EGL_FALSE; -} - -/*********************************************************************************/ diff --git a/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp b/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp deleted file mode 100644 index eeaa25c..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* -* 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. -*/ -#include "EglOsApi.h" -#include "MacNative.h" -#define MAX_PBUFFER_MIPMAP_LEVEL 1 - -namespace EglOS { - -static std::list<EGLNativePixelFormatType> s_nativeConfigs; - -EGLNativeDisplayType getDefaultDisplay() {return 0;} - -bool releaseDisplay(EGLNativeDisplayType dpy) { - return true; -} - -static EglConfig* pixelFormatToConfig(int index,int renderableType,EGLNativePixelFormatType* frmt){ - if(!frmt) return NULL; - - EGLint red,green,blue,alpha,depth,stencil; - EGLint supportedSurfaces,visualType,visualId; - EGLint transparentType,samples; - EGLint tRed,tGreen,tBlue; - EGLint pMaxWidth,pMaxHeight,pMaxPixels; - EGLint configId,level; - EGLint window,pbuffer; - EGLint doubleBuffer,colorSize; - - getPixelFormatAttrib(*frmt,MAC_HAS_DOUBLE_BUFFER,&doubleBuffer); - if(!doubleBuffer) return NULL; //pixel double buffer - - supportedSurfaces = 0; - - getPixelFormatAttrib(*frmt,MAC_DRAW_TO_WINDOW,&window); - getPixelFormatAttrib(*frmt,MAC_DRAW_TO_PBUFFER,&pbuffer); - - if(window) supportedSurfaces |= EGL_WINDOW_BIT; - if(pbuffer) supportedSurfaces |= EGL_PBUFFER_BIT; - - if(!supportedSurfaces) return NULL; - - //default values - visualId = 0; - visualType = EGL_NONE; - EGLenum caveat = EGL_NONE; - EGLBoolean renderable = EGL_FALSE; - pMaxWidth = PBUFFER_MAX_WIDTH; - pMaxHeight = PBUFFER_MAX_HEIGHT; - pMaxPixels = PBUFFER_MAX_PIXELS; - samples = 0; - level = 0; - tRed = tGreen = tBlue = 0; - - transparentType = EGL_NONE; - - getPixelFormatAttrib(*frmt,MAC_SAMPLES_PER_PIXEL,&samples); - getPixelFormatAttrib(*frmt,MAC_COLOR_SIZE,&colorSize); - /* All configs can end up having an alpha channel even if none was requested. - * The default config chooser in GLSurfaceView will therefore not find any - * matching config. Thus, make sure alpha is zero (or at least signalled as - * zero to the calling EGL layer) for the configs where it was intended to - * be zero. */ - if (getPixelFormatDefinitionAlpha(index) == 0) - alpha = 0; - else - getPixelFormatAttrib(*frmt,MAC_ALPHA_SIZE,&alpha); - getPixelFormatAttrib(*frmt,MAC_DEPTH_SIZE,&depth); - getPixelFormatAttrib(*frmt,MAC_STENCIL_SIZE,&stencil); - - red = green = blue = (colorSize / 4); //TODO: ask guy if it is OK - - return new EglConfig(red,green,blue,alpha,caveat,(EGLint)index,depth,level,pMaxWidth,pMaxHeight,pMaxPixels,renderable,renderableType, - visualId,visualType,samples,stencil,supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt); -} - - -static void initNativeConfigs(){ - int nConfigs = getNumPixelFormats(); - if(s_nativeConfigs.empty()){ - for(int i=0; i < nConfigs ;i++){ - EGLNativePixelFormatType frmt = getPixelFormat(i); - if(frmt){ - s_nativeConfigs.push_back(frmt); - } - } - } -} - -void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listOut) { - int i = 0 ; - initNativeConfigs(); - for(std::list<EGLNativePixelFormatType>::iterator it = s_nativeConfigs.begin(); it != s_nativeConfigs.end();it++){ - EGLNativePixelFormatType frmt = *it; - EglConfig* conf = pixelFormatToConfig(i++,renderableType,&frmt); - if(conf){ - listOut.push_front(conf); - }; - } -} - -bool validNativeDisplay(EGLNativeInternalDisplayType dpy) { - return true; -} - -bool validNativeWin(EGLNativeDisplayType dpy, EGLNativeWindowType win) { - unsigned int width,height; - return nsGetWinDims(win,&width,&height); -} - -bool validNativeWin(EGLNativeDisplayType dpy, EGLNativeSurfaceType win) { - return validNativeWin(dpy,(EGLNativeWindowType)win); -} - -//no support for pixmap in mac -bool validNativePixmap(EGLNativeDisplayType dpy, EGLNativeSurfaceType pix) { - - return true; -} - -bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) { - int r,g,b; - bool ret = nsGetWinDims(win,width,height); - - cfg->getConfAttrib(EGL_RED_SIZE,&r); - cfg->getConfAttrib(EGL_GREEN_SIZE,&g); - cfg->getConfAttrib(EGL_BLUE_SIZE,&b); - bool match = nsCheckColor(win,r + g + b); - - return ret && match; -} - -//no support for pixmap in mac -bool checkPixmapPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height) { - return false; -} - -EGLNativeSurfaceType createPbufferSurface(EGLNativeDisplayType dpy,EglConfig* cfg,EglPbufferSurface* srfc){ - EGLint width,height,hasMipmap,tmp; - EGLint target,format; - GLenum glTexFormat = GL_RGBA, glTexTarget = GL_TEXTURE_2D; - srfc->getDim(&width,&height,&tmp); - srfc->getTexInfo(&format,&target); - switch (format) { - case EGL_TEXTURE_RGB: - glTexFormat = GL_RGB; - break; - case EGL_TEXTURE_RGBA: - glTexFormat = GL_RGBA; - break; - } - srfc->getAttrib(EGL_MIPMAP_TEXTURE,&hasMipmap); - EGLint maxMipmap = hasMipmap ? MAX_PBUFFER_MIPMAP_LEVEL:0; - return (EGLNativeSurfaceType)nsCreatePBuffer(glTexTarget,glTexFormat,maxMipmap,width,height); -} - -bool releasePbuffer(EGLNativeDisplayType dis,EGLNativeSurfaceType pb) { - nsDestroyPBuffer(pb); - return true; -} - -EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) { - return nsCreateContext(cfg->nativeConfig(),sharedContext); -} - -bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx) { - nsDestroyContext(ctx); - return true; -} - -bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){ - - // check for unbind - if (ctx == NULL && read == NULL && draw == NULL) { - nsWindowMakeCurrent(NULL, NULL); - return true; - } - else if (ctx == NULL || read == NULL || draw == NULL) { - // error ! - return false; - } - - //dont supporting diffrent read & draw surfaces on Mac - if(read->native() != draw->native()) return false; - switch(draw->type()){ - case EglSurface::WINDOW: - nsWindowMakeCurrent(ctx,draw->native()); - break; - case EglSurface::PBUFFER: - { - EGLint hasMipmap; - draw->getAttrib(EGL_MIPMAP_TEXTURE,&hasMipmap); - int mipmapLevel = hasMipmap ? MAX_PBUFFER_MIPMAP_LEVEL:0; - nsPBufferMakeCurrent(ctx,draw->native(),mipmapLevel); - break; - } - case EglSurface::PIXMAP: // not supported on Mac - default: - return false; - } - return true; -} - -void swapBuffers(EGLNativeDisplayType dpy,EGLNativeSurfaceType srfc){ - nsSwapBuffers(); -} - -void waitNative(){} - -void swapInterval(EGLNativeDisplayType dpy,EGLNativeSurfaceType win,int interval){ - nsSwapInterval(&interval); -} - -EGLNativeSurfaceType createWindowSurface(EGLNativeWindowType wnd){ - return (EGLNativeSurfaceType)wnd; -} - -EGLNativeSurfaceType createPixmapSurface(EGLNativePixmapType pix){ - return (EGLNativeSurfaceType)pix; -} - -void destroySurface(EGLNativeSurfaceType srfc){ -} - -EGLNativeInternalDisplayType getInternalDisplay(EGLNativeDisplayType dpy){ - return (EGLNativeInternalDisplayType)dpy; -} - -void deleteDisplay(EGLNativeInternalDisplayType idpy){ -} - -}; diff --git a/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h b/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h deleted file mode 100644 index 942c705..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -* 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 EGL_OS_API_H -#define EGL_OS_API_H - -#include <EGL/egl.h> -#include <EGL/eglinternalplatform.h> -#ifdef __APPLE__ -#include <OpenGL/gl.h> -#else -#include <GL/gl.h> -#endif -#include "EglConfig.h" -#include "EglDisplay.h" -#include "EglPbufferSurface.h" - -#define PBUFFER_MAX_WIDTH 32767 -#define PBUFFER_MAX_HEIGHT 32767 -#define PBUFFER_MAX_PIXELS 32767*32767 - -namespace EglOS{ - - void queryConfigs(EGLNativeInternalDisplayType dpy,int renderable_type,ConfigsList& listOut); - bool releasePbuffer(EGLNativeInternalDisplayType dis,EGLNativeSurfaceType pb); - bool destroyContext(EGLNativeInternalDisplayType dpy,EGLNativeContextType ctx); - bool releaseDisplay(EGLNativeInternalDisplayType dpy); - bool validNativeDisplay(EGLNativeInternalDisplayType dpy); - bool validNativeWin(EGLNativeInternalDisplayType dpy,EGLNativeSurfaceType win); - bool validNativeWin(EGLNativeInternalDisplayType dpy,EGLNativeWindowType win); - bool validNativePixmap(EGLNativeInternalDisplayType dpy,EGLNativeSurfaceType pix); - bool checkWindowPixelFormatMatch(EGLNativeInternalDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height); - bool checkPixmapPixelFormatMatch(EGLNativeInternalDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height); - bool makeCurrent(EGLNativeInternalDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType); - void swapBuffers(EGLNativeInternalDisplayType dpy,EGLNativeSurfaceType srfc); - void swapInterval(EGLNativeInternalDisplayType dpy,EGLNativeSurfaceType win,int interval); - void waitNative(); - - EGLNativeInternalDisplayType getDefaultDisplay(); - EGLNativeInternalDisplayType getInternalDisplay(EGLNativeDisplayType dpy); - void deleteDisplay(EGLNativeInternalDisplayType idpy); - EGLNativeSurfaceType createPbufferSurface(EGLNativeInternalDisplayType dpy,EglConfig* cfg,EglPbufferSurface* pb); - EGLNativeContextType createContext(EGLNativeInternalDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext); - EGLNativeSurfaceType createWindowSurface(EGLNativeWindowType wnd); - EGLNativeSurfaceType createPixmapSurface(EGLNativePixmapType pix); - void destroySurface(EGLNativeSurfaceType srfc); -#ifdef _WIN32 - void initPtrToWglFunctions(); -#endif -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.cpp b/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.cpp deleted file mode 100644 index 8bcb31a..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -* 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. -*/ -#include "EglPbufferSurface.h" - -bool EglPbufferSurface::setAttrib(EGLint attrib,EGLint val) { - switch(attrib) { - case EGL_WIDTH: - if(val < 0) return false; - m_width = val; - break; - case EGL_HEIGHT: - if(val < 0) return false; - m_height = val; - break; - case EGL_LARGEST_PBUFFER: - m_largest = val; - break; - case EGL_TEXTURE_FORMAT: - if(val != EGL_NO_TEXTURE && val != EGL_TEXTURE_RGB && val != EGL_TEXTURE_RGBA) return false; - m_texFormat = val; - break; - case EGL_TEXTURE_TARGET: - if(val != EGL_NO_TEXTURE && val != EGL_TEXTURE_2D) return false; - m_texTarget = val; - break; - case EGL_MIPMAP_TEXTURE: - m_texMipmap = val; - break; - default: - return false; - } - return true; -} - -bool EglPbufferSurface::getAttrib(EGLint attrib,EGLint* val) { - switch(attrib) { - case EGL_CONFIG_ID: - *val = m_config->id(); - break; - case EGL_WIDTH: - *val = m_width; - break; - case EGL_HEIGHT: - *val = m_height; - break; - case EGL_LARGEST_PBUFFER: - *val = m_largest; - break; - case EGL_TEXTURE_FORMAT: - *val = m_texFormat; - break; - case EGL_TEXTURE_TARGET: - *val = m_texTarget; - break; - case EGL_MIPMAP_TEXTURE: - *val = m_texMipmap; - break; - default: - return false; - } - return true; -} diff --git a/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.h b/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.h deleted file mode 100644 index 9740170..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglPbufferSurface.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* 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 EGL_PBUFFER_SURFACE_H -#define EGL_PBUFFER_SURFACE_H - -#include "EglSurface.h" - -class EglDisplay; - -class EglPbufferSurface:public EglSurface { -public: - EglPbufferSurface(EglDisplay *dpy, EglConfig* config): - EglSurface(dpy,PBUFFER,config,0,0), - m_texFormat(EGL_NO_TEXTURE), - m_texTarget(EGL_NO_TEXTURE), - m_texMipmap(EGL_FALSE), - m_largest(EGL_FALSE){}; - - void setNativePbuffer(EGLNativeSurfaceType srfc){ m_native = srfc;}; - bool setAttrib(EGLint attrib,EGLint val); - bool getAttrib(EGLint attrib,EGLint* val); - void getDim(EGLint* width,EGLint* height,EGLint* largest){ - *width = m_width; - *height = m_height; - *largest = m_largest; - }; - - void getTexInfo(EGLint* format,EGLint* target){ *format = m_texFormat; *target = m_texTarget;} - -private: - EGLint m_texFormat; - EGLint m_texTarget; - EGLint m_texMipmap; - EGLint m_largest; -}; -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.cpp b/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.cpp deleted file mode 100644 index 2087594..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* -* 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. -*/ -#include "EglPixmapSurface.h" -#include "EglOsApi.h" - -std::set<EGLNativePixmapType> EglPixmapSurface::s_associatedPixmaps; - -bool EglPixmapSurface::alreadyAssociatedWithConfig(EGLNativePixmapType pix) { - return s_associatedPixmaps.find(pix) != s_associatedPixmaps.end(); - -} - -EglPixmapSurface::EglPixmapSurface(EglDisplay *dpy, - EGLNativePixmapType pix, - EglConfig* config) : - EglSurface(dpy, PIXMAP,config,0,0), - m_pixmap(pix) -{ - s_associatedPixmaps.insert(pix); - m_native = EglOS::createPixmapSurface(pix); -} - -EglPixmapSurface::~EglPixmapSurface() { - s_associatedPixmaps.erase(m_pixmap); -} - -bool EglPixmapSurface::getAttrib(EGLint attrib,EGLint* val) { - switch(attrib) { - case EGL_CONFIG_ID: - *val = m_config->id(); - break; - case EGL_WIDTH: - *val = m_width; - break; - case EGL_HEIGHT: - *val = m_height; - break; - case EGL_LARGEST_PBUFFER: - case EGL_TEXTURE_FORMAT: - case EGL_TEXTURE_TARGET: - case EGL_MIPMAP_TEXTURE: - break; - default: - return false; - } - return true; -} diff --git a/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.h b/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.h deleted file mode 100644 index f027eab..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglPixmapSurface.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -* 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 EGL_PIXMAP_SURFACE_H -#define EGL_PIXMAP_SURFACE_H - -#include <set> -#include <EGL/egl.h> -#include "EglSurface.h" - -class EglDisplay; - -class EglPixmapSurface: public EglSurface { -public: - EglPixmapSurface(EglDisplay *dpy, EGLNativePixmapType pix,EglConfig* config); - ~EglPixmapSurface(); - - bool getAttrib(EGLint attrib,EGLint* val); - - static bool alreadyAssociatedWithConfig(EGLNativePixmapType pix); -private: - EGLNativePixmapType m_pixmap; - static std::set<EGLNativePixmapType> s_associatedPixmaps; -}; -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglSurface.cpp b/emulator/opengl/host/libs/Translator/EGL/EglSurface.cpp deleted file mode 100644 index 7f658b6..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglSurface.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -* 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. -*/ -#include "EglSurface.h" -#include "EglOsApi.h" - -unsigned int EglSurface::s_nextSurfaceHndl = 0; - -EglSurface::~EglSurface(){ - - if(m_type == EglSurface::PBUFFER) { - EglOS::releasePbuffer(m_dpy->nativeType(),m_native); - } - - if(m_native) EglOS::destroySurface(m_native); -} - -bool EglSurface::setAttrib(EGLint attrib,EGLint val) { - switch(attrib) { - case EGL_WIDTH: - case EGL_HEIGHT: - case EGL_LARGEST_PBUFFER: - case EGL_TEXTURE_FORMAT: - case EGL_TEXTURE_TARGET: - case EGL_MIPMAP_TEXTURE: - break; - default: - return false; - } - return true; -} diff --git a/emulator/opengl/host/libs/Translator/EGL/EglSurface.h b/emulator/opengl/host/libs/Translator/EGL/EglSurface.h deleted file mode 100644 index ba28ae8..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglSurface.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -* 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 EGL_SURFACE_H -#define EGL_SURFACE_H - -#include <map> - -#include <EGL/egl.h> -#include <EGL/eglinternalplatform.h> -#include "emugl/common/smart_ptr.h" -#include "EglConfig.h" - -class EglSurface; -typedef emugl::SmartPtr<EglSurface> SurfacePtr; - -class EglDisplay; - -class EglSurface { -public: - typedef enum { - WINDOW = 0, - PBUFFER = 1, - PIXMAP = 3 - } ESurfaceType; - ESurfaceType type(){ return m_type;}; - EGLNativeSurfaceType native(){return m_native;} - virtual bool setAttrib(EGLint attrib,EGLint val); - virtual bool getAttrib(EGLint attrib,EGLint* val) = 0; - void setDim(int width,int height){ m_width = width; m_height = height;}; - EglConfig* getConfig(){return m_config;}; - unsigned int getHndl(){return m_hndl;}; - virtual ~EglSurface(); - -private: - static unsigned int s_nextSurfaceHndl; - ESurfaceType m_type; - unsigned int m_hndl; - -protected: - EglSurface(EglDisplay *dpy, - ESurfaceType type, - EglConfig* config, - EGLint width, - EGLint height) : - m_type(type), - m_config(config), - m_width(width), - m_height(height), - m_native(NULL), - m_dpy(dpy) - { - m_hndl = ++s_nextSurfaceHndl; - } - -protected: - EglConfig* m_config; - EGLint m_width; - EGLint m_height; - EGLNativeSurfaceType m_native; - EglDisplay *m_dpy; -}; -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp deleted file mode 100644 index 6481774..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* -* 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. -*/ -#include "EglThreadInfo.h" -#include "EglOsApi.h" - -#include "emugl/common/lazy_instance.h" -#include "emugl/common/thread_store.h" - -namespace { - -class EglThreadInfoStore : public emugl::ThreadStore { -public: - EglThreadInfoStore() : emugl::ThreadStore(&destructor) {} -private: - static void destructor(void* value) { - delete static_cast<EglThreadInfo*>(value); - } -}; - -} // namespace - -EglThreadInfo::EglThreadInfo() : - m_err(EGL_SUCCESS), m_api(EGL_OPENGL_ES_API) {} - -static emugl::LazyInstance<EglThreadInfoStore> s_tls = LAZY_INSTANCE_INIT; - -EglThreadInfo* EglThreadInfo::get(void) -{ - EglThreadInfo *ti = static_cast<EglThreadInfo*>(s_tls->get()); - if (!ti) { - ti = new EglThreadInfo(); - s_tls->set(ti); - } - return ti; -} - diff --git a/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.h b/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.h deleted file mode 100644 index 9d2df10..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -* 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 EGL_THREAD_INFO_H -#define EGL_THREAD_INFO_H - -#include <EGL/egl.h> -#include "EglDisplay.h" -#include "EglContext.h" -#include "EglSurface.h" -#include "EglPbufferSurface.h" - -class EglThreadInfo { -public: - - EglThreadInfo(); - void setError(EGLint err) { m_err = err;} - EGLint getError(){ return m_err;} - void destroyContextIfNotCurrent(ContextPtr context ); - void setApi(EGLenum api){m_api = api;} - EGLenum getApi(){return m_api;} - - static EglThreadInfo* get(void) __attribute__((const)); - -private: - EglDisplay* m_currentDisplay; - EGLint m_err; - EGLenum m_api; -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp b/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp deleted file mode 100644 index d87f9b9..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglValidate.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* -* 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. -*/ -#include "EglValidate.h" -#include <GLcommon/GLutils.h> - -bool EglValidate::confAttrib(EGLint attrib) { - switch(attrib) { - case EGL_BUFFER_SIZE: - case EGL_RED_SIZE: - case EGL_GREEN_SIZE: - case EGL_BLUE_SIZE: - case EGL_ALPHA_SIZE: - case EGL_BIND_TO_TEXTURE_RGB: - case EGL_BIND_TO_TEXTURE_RGBA: - case EGL_CONFIG_CAVEAT: - case EGL_CONFIG_ID: - case EGL_DEPTH_SIZE: - case EGL_LEVEL: - case EGL_MAX_PBUFFER_WIDTH: - case EGL_MAX_PBUFFER_HEIGHT: - case EGL_MAX_PBUFFER_PIXELS: - case EGL_MAX_SWAP_INTERVAL: - case EGL_MIN_SWAP_INTERVAL: - case EGL_RENDERABLE_TYPE: - case EGL_NATIVE_RENDERABLE: - case EGL_NATIVE_VISUAL_ID: - case EGL_NATIVE_VISUAL_TYPE: - case EGL_SAMPLE_BUFFERS: - case EGL_SAMPLES: - case EGL_STENCIL_SIZE: - case EGL_SURFACE_TYPE: - case EGL_TRANSPARENT_TYPE: - case EGL_TRANSPARENT_RED_VALUE: - case EGL_TRANSPARENT_GREEN_VALUE: - case EGL_TRANSPARENT_BLUE_VALUE: - case EGL_CONFORMANT: - return true; - } - return false; -} - -bool EglValidate::noAttribs(const EGLint* attrib) { - return !attrib || attrib[0] == EGL_NONE ; -} - -bool EglValidate::pbufferAttribs(EGLint width,EGLint height,bool isTexFormatNoTex,bool isTexTargetNoTex) { - if(!isTexFormatNoTex) { - if (!(isPowerOf2(width) && isPowerOf2(height))) return false; - } - return isTexFormatNoTex == isTexTargetNoTex ; -} - -bool EglValidate::releaseContext(EGLContext ctx,EGLSurface s1,EGLSurface s2) { - return (ctx == EGL_NO_CONTEXT) && - (s1 == EGL_NO_SURFACE) && - (s2 == EGL_NO_SURFACE); -} - -bool EglValidate::badContextMatch(EGLContext ctx,EGLSurface s1,EGLSurface s2) { - return ctx != EGL_NO_CONTEXT ? (s1 == EGL_NO_SURFACE || s2 == EGL_NO_SURFACE): - (s1 != EGL_NO_SURFACE || s2 != EGL_NO_SURFACE); -} - -bool EglValidate::surfaceTarget(EGLint target) { - return target == EGL_READ || target == EGL_DRAW; -} - -bool EglValidate::engine(EGLint engine) { - return engine == EGL_CORE_NATIVE_ENGINE; -} - -bool EglValidate::stringName(EGLint name) { - return name == EGL_VENDOR || - name == EGL_VERSION || - name == EGL_EXTENSIONS; -} - -bool EglValidate::supportedApi(EGLenum api) { - return api == EGL_OPENGL_ES_API; -} diff --git a/emulator/opengl/host/libs/Translator/EGL/EglValidate.h b/emulator/opengl/host/libs/Translator/EGL/EglValidate.h deleted file mode 100644 index 532584f..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglValidate.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -* 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 EGL_VALIDATE_H -#define EGL_VALIDATE_H - -#include <EGL/egl.h> - -class EglValidate { -public: - static bool confAttrib(EGLint attrib); - static bool noAttribs(const EGLint* attrib); - static bool pbufferAttribs(EGLint width,EGLint height,bool texFormatIsNoTex,bool texTargetIsNoTex); - static bool releaseContext(EGLContext ctx,EGLSurface s1,EGLSurface s2); - static bool badContextMatch(EGLContext ctx,EGLSurface s1,EGLSurface s2); - static bool surfaceTarget(EGLint target); - static bool engine(EGLint engine); - static bool stringName(EGLint name); - static bool supportedApi(EGLenum api); -}; -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.cpp b/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.cpp deleted file mode 100644 index 7bff896..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* -* 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. -*/ -#include "EglWindowSurface.h" -#include "EglOsApi.h" - -std::set<EGLNativeWindowType> EglWindowSurface::s_associatedWins; - -bool EglWindowSurface::alreadyAssociatedWithConfig(EGLNativeWindowType win) { - return s_associatedWins.find(win) != s_associatedWins.end(); - -} - -EglWindowSurface::EglWindowSurface(EglDisplay *dpy, - EGLNativeWindowType win, - EglConfig* config, - unsigned int width,unsigned int height) : - EglSurface(dpy, WINDOW,config,width,height), - m_win(win) -{ - s_associatedWins.insert(win); - m_native = EglOS::createWindowSurface(win); -} - -EglWindowSurface:: ~EglWindowSurface() { - s_associatedWins.erase(m_win); -} - -bool EglWindowSurface::getAttrib(EGLint attrib,EGLint* val) { - switch(attrib) { - case EGL_CONFIG_ID: - *val = m_config->id(); - break; - case EGL_WIDTH: - *val = m_width; - break; - case EGL_HEIGHT: - *val = m_height; - break; - case EGL_LARGEST_PBUFFER: - case EGL_TEXTURE_FORMAT: - case EGL_TEXTURE_TARGET: - case EGL_MIPMAP_TEXTURE: - break; - default: - return false; - } - return true; -} diff --git a/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.h b/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.h deleted file mode 100644 index 460a293..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglWindowSurface.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -* 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 EGL_WINDOW_SURFACE_H -#define EGL_WINDOW_SURFACE_H - -#include <set> -#include <EGL/egl.h> -#include "EglSurface.h" -#include "EglConfig.h" - -class EglDisplay; - -class EglWindowSurface: public EglSurface { -public: - EglWindowSurface(EglDisplay *dpy, EGLNativeWindowType win,EglConfig* config,unsigned width,unsigned int height); - ~EglWindowSurface(); - bool getAttrib(EGLint attrib,EGLint* val); - - static bool alreadyAssociatedWithConfig(EGLNativeWindowType win); -private: - EGLNativeWindowType m_win; - static std::set<EGLNativeWindowType> s_associatedWins; -}; -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp b/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp deleted file mode 100644 index 5b48fcb..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp +++ /dev/null @@ -1,594 +0,0 @@ -/* -* 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. -*/ -#include "EglOsApi.h" -#include <windows.h> -#include <wingdi.h> -#include <GL/wglext.h> -#include <stdio.h> - -#define IS_TRUE(a) \ - if(a != true) return NULL; - -struct DisplayInfo{ - DisplayInfo():dc(NULL),hwnd(NULL),isPixelFormatSet(false){}; - DisplayInfo(HDC hdc,HWND wnd):isPixelFormatSet(false){dc = hdc; hwnd = wnd;}; - HDC dc; - HWND hwnd; - bool isPixelFormatSet; -}; - -struct TlsData { - std::map<int,DisplayInfo> m_map; -}; - -static DWORD s_tlsIndex = 0; - -static TlsData *getTLS() { - TlsData *tls = (TlsData *)TlsGetValue(s_tlsIndex); - if (!tls) { - tls = new TlsData(); - TlsSetValue(s_tlsIndex, tls); - } - return tls; -} - -class WinDisplay{ -public: - enum { DEFAULT_DISPLAY = 0 }; - WinDisplay(){}; - DisplayInfo& getInfo(int configurationIndex){ return getTLS()->m_map[configurationIndex];} - HDC getDC(int configId){return getTLS()->m_map[configId].dc;} - void setInfo(int configurationIndex,const DisplayInfo& info); - bool isPixelFormatSet(int cfgId){ return getTLS()->m_map[cfgId].isPixelFormatSet;} - void pixelFormatWasSet(int cfgId){getTLS()->m_map[cfgId].isPixelFormatSet = true;} - bool infoExists(int configurationIndex); - void releaseAll(); -}; - -void WinDisplay::releaseAll(){ - TlsData * tls = getTLS(); - - for(std::map<int,DisplayInfo>::iterator it = tls->m_map.begin(); it != tls->m_map.end();it++){ - if((*it).second.hwnd){ - DestroyWindow((*it).second.hwnd); - } - DeleteDC((*it).second.dc); - } -} - -bool WinDisplay::infoExists(int configurationIndex){ - return getTLS()->m_map.find(configurationIndex) != getTLS()->m_map.end(); -} - -void WinDisplay::setInfo(int configurationIndex,const DisplayInfo& info){ - getTLS()->m_map[configurationIndex] = info; -} - -struct WglExtProcs{ - PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB; - PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; - PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB; - PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB; - PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB; - PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB; - PFNWGLMAKECONTEXTCURRENTARBPROC wglMakeContextCurrentARB; - PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; -}; - -static WglExtProcs* s_wglExtProcs = NULL; - -class SrfcInfo{ -public: - typedef enum { - WINDOW = 0, - PBUFFER = 1, - PIXMAP = 2 - }SurfaceType; - explicit SrfcInfo(HWND wnd); - explicit SrfcInfo(HPBUFFERARB pb); - explicit SrfcInfo(HBITMAP bmap); - HWND getHwnd(){ return m_hwnd;}; - HDC getDC(){ return m_hdc;}; - HBITMAP getBmap(){ return m_bmap;}; - HPBUFFERARB getPbuffer(){ return m_pb;}; - ~SrfcInfo(); -private: - HWND m_hwnd; - HPBUFFERARB m_pb; - HBITMAP m_bmap; - HDC m_hdc; - SurfaceType m_type; -}; - -SrfcInfo::SrfcInfo(HBITMAP bmap):m_hwnd(NULL), - m_pb(NULL), - m_hdc(NULL), - m_type(PIXMAP){ - m_bmap = bmap; -} - -SrfcInfo::SrfcInfo(HWND wnd):m_pb(NULL), - m_bmap(NULL), - m_type(WINDOW){ - m_hwnd = wnd; - m_hdc = GetDC(wnd); -} - -SrfcInfo::SrfcInfo(HPBUFFERARB pb):m_hwnd(NULL), - m_bmap(NULL), - m_type(PBUFFER){ - m_pb = pb; - if(s_wglExtProcs->wglGetPbufferDCARB){ - m_hdc = s_wglExtProcs->wglGetPbufferDCARB(pb); - } -} - -SrfcInfo::~SrfcInfo(){ - if(m_type == WINDOW){ - ReleaseDC(m_hwnd,m_hdc); - } -} - -namespace EglOS{ - - - -PROC wglGetExtentionsProcAddress(HDC hdc,const char *extension_name,const char* proc_name) -{ - // this is pointer to function which returns pointer to string with list of all wgl extensions - PFNWGLGETEXTENSIONSSTRINGARBPROC _wglGetExtensionsStringARB = NULL; - - // determine pointer to wglGetExtensionsStringEXT function - _wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB"); - if(!_wglGetExtensionsStringARB){ - fprintf(stderr,"could not get wglGetExtensionsStringARB\n"); - return NULL; - } - - if (!_wglGetExtensionsStringARB || strstr(_wglGetExtensionsStringARB(hdc), extension_name) == NULL) - { - fprintf(stderr,"extension %s was not found\n",extension_name); - // string was not found - return NULL; - } - - // extension is supported - return wglGetProcAddress(proc_name); -} - -LRESULT CALLBACK dummyWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -HWND createDummyWindow(){ - - WNDCLASSEX wcx; - wcx.cbSize = sizeof(wcx); // size of structure - wcx.style = CS_OWNDC |CS_HREDRAW |CS_VREDRAW; // redraw if size changes - wcx.lpfnWndProc = dummyWndProc; // points to window procedure - wcx.cbClsExtra = 0; // no extra class memory - wcx.cbWndExtra = sizeof(void*); // save extra window memory, to store VasWindow instance - wcx.hInstance = NULL; // handle to instance - wcx.hIcon = NULL; // predefined app. icon - wcx.hCursor = NULL; - wcx.hbrBackground = NULL; // no background brush - wcx.lpszMenuName = NULL; // name of menu resource - wcx.lpszClassName = "DummyWin"; // name of window class - wcx.hIconSm = (HICON) NULL; // small class icon - - RegisterClassEx(&wcx); - - HWND hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, - "DummyWin", - "Dummy", - WS_POPUP, - 0, - 0, - 1, - 1, - NULL, - NULL, - 0,0); - return hwnd; -} - -EGLNativeInternalDisplayType getDefaultDisplay() { - if (!s_tlsIndex) s_tlsIndex = TlsAlloc(); - WinDisplay* dpy = new WinDisplay(); - - HWND hwnd = createDummyWindow(); - HDC hdc = GetDC(hwnd); - dpy->setInfo(WinDisplay::DEFAULT_DISPLAY,DisplayInfo(hdc,hwnd)); - return static_cast<EGLNativeInternalDisplayType>(dpy); -} - -EGLNativeInternalDisplayType getInternalDisplay(EGLNativeDisplayType display){ - if (!s_tlsIndex) s_tlsIndex = TlsAlloc(); - WinDisplay* dpy = new WinDisplay(); - dpy->setInfo(WinDisplay::DEFAULT_DISPLAY,DisplayInfo(display,NULL)); - return dpy; -} - -static HDC getDummyDC(EGLNativeInternalDisplayType display,int cfgId){ - - HDC dpy = NULL; - if(!display->infoExists(cfgId)){ - HWND hwnd = createDummyWindow(); - dpy = GetDC(hwnd); - display->setInfo(cfgId,DisplayInfo(dpy,hwnd)); - } else { - dpy = display->getDC(cfgId); - } - return dpy; -} -void initPtrToWglFunctions(){ - HWND hwnd = createDummyWindow(); - HDC dpy = GetDC(hwnd); - if(!hwnd || !dpy){ - fprintf(stderr,"error while getting DC\n"); - return; - } - EGLNativeContextType ctx = NULL; - PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd - 1, // version number - PFD_DRAW_TO_WINDOW | // support window - PFD_SUPPORT_OPENGL | // support OpenGL - PFD_DOUBLEBUFFER, // double buffered - PFD_TYPE_RGBA, // RGBA type - 24, // 24-bit color depth - 0, 0, 0, 0, 0, 0, // color bits ignored - 0, // no alpha buffer - 0, // shift bit ignored - 0, // no accumulation buffer - 0, 0, 0, 0, // accum bits ignored - 32, // 32-bit z-buffer - 0, // no stencil buffer - 0, // no auxiliary buffer - PFD_MAIN_PLANE, // main layer - 0, // reserved - 0, 0, 0 // layer masks ignored - }; - - int iPixelFormat,err; - iPixelFormat = ChoosePixelFormat(dpy, &pfd); - if(iPixelFormat < 0){ - fprintf(stderr,"error while choosing pixel format\n"); - return; - } - if(!SetPixelFormat(dpy,iPixelFormat,&pfd)){ - - int err = GetLastError(); - fprintf(stderr,"error while setting pixel format 0x%x\n",err); - return; - } - - - ctx = wglCreateContext(dpy); - if(!ctx){ - err = GetLastError(); - fprintf(stderr,"error while creating dummy context %d\n",err); - } - if(!wglMakeCurrent(dpy,ctx)){ - err = GetLastError(); - fprintf(stderr,"error while making dummy context current %d\n",err); - } - - if(!s_wglExtProcs){ - s_wglExtProcs = new WglExtProcs(); - s_wglExtProcs->wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetExtentionsProcAddress(dpy,"WGL_ARB_pixel_format","wglGetPixelFormatAttribivARB"); - s_wglExtProcs->wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetExtentionsProcAddress(dpy,"WGL_ARB_pixel_format","wglChoosePixelFormatARB"); - s_wglExtProcs->wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)wglGetExtentionsProcAddress(dpy,"WGL_ARB_pbuffer","wglCreatePbufferARB"); - s_wglExtProcs->wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetExtentionsProcAddress(dpy,"WGL_ARB_pbuffer","wglReleasePbufferDCARB"); - s_wglExtProcs->wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)wglGetExtentionsProcAddress(dpy,"WGL_ARB_pbuffer","wglDestroyPbufferARB"); - s_wglExtProcs->wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)wglGetExtentionsProcAddress(dpy,"WGL_ARB_pbuffer","wglGetPbufferDCARB"); - s_wglExtProcs->wglMakeContextCurrentARB = (PFNWGLMAKECONTEXTCURRENTARBPROC)wglGetExtentionsProcAddress(dpy,"WGL_ARB_make_current_read","wglMakeContextCurrentARB"); - s_wglExtProcs->wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetExtentionsProcAddress(dpy,"WGL_EXT_swap_control","wglSwapIntervalEXT"); - } - - wglMakeCurrent(dpy,NULL); - DestroyWindow(hwnd); - DeleteDC(dpy); -} - -bool releaseDisplay(EGLNativeInternalDisplayType dpy) { - dpy->releaseAll(); - return true; -} - -void deleteDisplay(EGLNativeInternalDisplayType idpy){ - if(idpy){ - delete idpy; - } -} - - -static bool initPixelFormat(HDC dc){ - PIXELFORMATDESCRIPTOR pfd; - unsigned int numpf; - int iPixelFormat; - - if(s_wglExtProcs->wglChoosePixelFormatARB) { - int i0 = 0; - float f0 = 0.0f; - return s_wglExtProcs->wglChoosePixelFormatARB(dc,&i0, &f0, 1, &iPixelFormat, &numpf); - } else { - return ChoosePixelFormat(dc,&pfd); - } -} - -EglConfig* pixelFormatToConfig(EGLNativeInternalDisplayType display,int renderableType,EGLNativePixelFormatType* frmt,int index){ - - EGLint red,green,blue,alpha,depth,stencil; - EGLint supportedSurfaces,visualType,visualId; - EGLint transparentType,samples; - EGLint tRed,tGreen,tBlue; - EGLint pMaxWidth,pMaxHeight,pMaxPixels; - EGLint level; - EGLint window,bitmap,pbuffer,transparent; - HDC dpy = getDummyDC(display,WinDisplay::DEFAULT_DISPLAY); - - if(frmt->iPixelType != PFD_TYPE_RGBA) return NULL; // other formats are not supported yet - if(!((frmt->dwFlags & PFD_SUPPORT_OPENGL) && (frmt->dwFlags & PFD_DOUBLEBUFFER))) return NULL; //pixel format does not supports opengl or double buffer - if( 0 != (frmt->dwFlags & (PFD_GENERIC_FORMAT | PFD_NEED_PALETTE )) ) return NULL; //discard generic pixel formats as well as pallete pixel formats - - int attribs [] = { - WGL_DRAW_TO_WINDOW_ARB, - WGL_DRAW_TO_BITMAP_ARB, - WGL_DRAW_TO_PBUFFER_ARB, - WGL_TRANSPARENT_ARB, - WGL_TRANSPARENT_RED_VALUE_ARB, - WGL_TRANSPARENT_GREEN_VALUE_ARB, - WGL_TRANSPARENT_BLUE_VALUE_ARB - }; - - supportedSurfaces = 0; - if(!s_wglExtProcs->wglGetPixelFormatAttribivARB) return NULL; - - IS_TRUE(s_wglExtProcs->wglGetPixelFormatAttribivARB(dpy,index,0,1,&attribs[0],&window)); - IS_TRUE(s_wglExtProcs->wglGetPixelFormatAttribivARB(dpy,index,0,1,&attribs[1],&bitmap)); - IS_TRUE(s_wglExtProcs->wglGetPixelFormatAttribivARB(dpy,index,0,1,&attribs[2],&pbuffer)); - if(window) supportedSurfaces |= EGL_WINDOW_BIT; - if(bitmap) supportedSurfaces |= EGL_PIXMAP_BIT; - if(pbuffer) supportedSurfaces |= EGL_PBUFFER_BIT; - - - if(!supportedSurfaces) return NULL; - - //default values - visualId = 0; - visualType = EGL_NONE; - EGLenum caveat = EGL_NONE; - EGLBoolean renderable = EGL_FALSE; - pMaxWidth = PBUFFER_MAX_WIDTH; - pMaxHeight = PBUFFER_MAX_HEIGHT; - pMaxPixels = PBUFFER_MAX_PIXELS; - samples = 0 ; - level = 0 ; - - IS_TRUE(s_wglExtProcs->wglGetPixelFormatAttribivARB(dpy,index,0,1,&attribs[3],&transparent)); - if(transparent) { - transparentType = EGL_TRANSPARENT_RGB; - IS_TRUE(s_wglExtProcs->wglGetPixelFormatAttribivARB(dpy,index,0,1,&attribs[4],&tRed)); - IS_TRUE(s_wglExtProcs->wglGetPixelFormatAttribivARB(dpy,index,0,1,&attribs[5],&tGreen)); - IS_TRUE(s_wglExtProcs->wglGetPixelFormatAttribivARB(dpy,index,0,1,&attribs[6],&tBlue)); - } else { - transparentType = EGL_NONE; - } - - red = frmt->cRedBits; - green = frmt->cGreenBits; - blue = frmt->cBlueBits; - alpha = frmt->cAlphaBits; - depth = frmt->cDepthBits; - stencil = frmt->cStencilBits; - return new EglConfig(red,green,blue,alpha,caveat,(EGLint)index,depth,level,pMaxWidth,pMaxHeight,pMaxPixels,renderable,renderableType, - visualId,visualType,samples,stencil,supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt); -} - - -void queryConfigs(EGLNativeInternalDisplayType display,int renderableType,ConfigsList& listOut) { - PIXELFORMATDESCRIPTOR pfd; - int iPixelFormat = 1; - HDC dpy = getDummyDC(display,WinDisplay::DEFAULT_DISPLAY); - - // - // We need to call wglChoosePixelFormat at least once, - // seems that the driver needs to initialize itself. - // do it here during initialization. - // - initPixelFormat(dpy); - - //quering num of formats - int maxFormat = DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd); - - //inserting rest of formats - for(;iPixelFormat <= maxFormat; iPixelFormat++) { - DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd); - EglConfig* pConfig = pixelFormatToConfig(display,renderableType,&pfd,iPixelFormat); - if(pConfig) listOut.push_back(pConfig); - } -} - -bool validNativeDisplay(EGLNativeInternalDisplayType dpy) { - return dpy != NULL; -} - -bool validNativeWin(EGLNativeInternalDisplayType dpy,EGLNativeWindowType win) { - return IsWindow(win); -} - -bool validNativeWin(EGLNativeInternalDisplayType dpy,EGLNativeSurfaceType win) { - if (!win) return false; - return validNativeWin(dpy,win->getHwnd()); -} - -bool validNativePixmap(EGLNativeInternalDisplayType dpy,EGLNativeSurfaceType pix) { - BITMAP bm; - if (!pix) return false; - return GetObject(pix->getBmap(), sizeof(BITMAP), (LPSTR)&bm); -} - -bool checkWindowPixelFormatMatch(EGLNativeInternalDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) { - RECT r; - if(!GetClientRect(win,&r)) return false; - *width = r.right - r.left; - *height = r.bottom - r.top; - HDC dc = GetDC(win); - EGLNativePixelFormatType nativeConfig = cfg->nativeConfig(); - bool ret = SetPixelFormat(dc,cfg->nativeId(),&nativeConfig); - DeleteDC(dc); - return ret; -} - -bool checkPixmapPixelFormatMatch(EGLNativeInternalDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height){ - - BITMAP bm; - if(!GetObject(pix, sizeof(BITMAP), (LPSTR)&bm)) return false; - - *width = bm.bmWidth; - *height = bm.bmHeight; - - return true; -} - -EGLNativeSurfaceType createPbufferSurface(EGLNativeInternalDisplayType display,EglConfig* cfg,EglPbufferSurface* pbSurface) { - - - HDC dpy = getDummyDC(display,cfg->nativeId()); - EGLint width,height,largest,texTarget,texFormat; - pbSurface->getDim(&width,&height,&largest); - pbSurface->getTexInfo(&texTarget,&texFormat); - - int wglTexFormat = WGL_NO_TEXTURE_ARB; - int wglTexTarget = (texTarget == EGL_TEXTURE_2D)? WGL_TEXTURE_2D_ARB: - WGL_NO_TEXTURE_ARB; - - switch(texFormat) { - case EGL_TEXTURE_RGB: - wglTexFormat = WGL_TEXTURE_RGB_ARB; - break; - case EGL_TEXTURE_RGBA: - wglTexFormat = WGL_TEXTURE_RGBA_ARB; - break; - } - - int pbAttribs[] = { - WGL_TEXTURE_TARGET_ARB ,wglTexTarget, - WGL_TEXTURE_FORMAT_ARB ,wglTexFormat, - 0 - }; - if(!s_wglExtProcs->wglCreatePbufferARB) return NULL; - EGLNativePbufferType pb = s_wglExtProcs->wglCreatePbufferARB(dpy,cfg->nativeId(),width,height,pbAttribs); - if(!pb) { - GetLastError(); - return NULL; - } - return new SrfcInfo(pb); -} - -bool releasePbuffer(EGLNativeInternalDisplayType display,EGLNativeSurfaceType pb) { - if (!pb) return false; - if(!s_wglExtProcs->wglReleasePbufferDCARB || !s_wglExtProcs->wglDestroyPbufferARB) return false; - if(!s_wglExtProcs->wglReleasePbufferDCARB(pb->getPbuffer(),pb->getDC()) || !s_wglExtProcs->wglDestroyPbufferARB(pb->getPbuffer())){ - GetLastError(); - return false; - } - return true; -} - -EGLNativeContextType createContext(EGLNativeInternalDisplayType display,EglConfig* cfg,EGLNativeContextType sharedContext) { - - EGLNativeContextType ctx = NULL; - HDC dpy = getDummyDC(display,cfg->nativeId()); - - if(!display->isPixelFormatSet(cfg->nativeId())){ - EGLNativePixelFormatType nativeConfig = cfg->nativeConfig(); - if(!SetPixelFormat(dpy,cfg->nativeId(),&nativeConfig)){ - return NULL; - } - display->pixelFormatWasSet(cfg->nativeId()); - } - - ctx = wglCreateContext(dpy); - - if(ctx && sharedContext) { - if(!wglShareLists(sharedContext,ctx)) { - wglDeleteContext(ctx); - return NULL; - } - } - return ctx; -} - -bool destroyContext(EGLNativeInternalDisplayType dpy,EGLNativeContextType ctx) { - if(!wglDeleteContext(ctx)) { - GetLastError(); - return false; - } - return true; -} - - -bool makeCurrent(EGLNativeInternalDisplayType display,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx) { - - HDC hdcRead = read ? read->native()->getDC(): NULL; - HDC hdcDraw = draw ? draw->native()->getDC(): NULL; - bool retVal = false; - - - if(hdcRead == hdcDraw){ - bool ret = wglMakeCurrent(hdcDraw,ctx); - return ret; - } else if (!s_wglExtProcs->wglMakeContextCurrentARB ) { - return false; - } - retVal = s_wglExtProcs->wglMakeContextCurrentARB(hdcDraw,hdcRead,ctx); - - return retVal; -} - -void swapBuffers(EGLNativeInternalDisplayType display,EGLNativeSurfaceType srfc){ - if(srfc && !SwapBuffers(srfc->getDC())) { - GetLastError(); - } -} - - -void waitNative(){} - -void swapInterval(EGLNativeInternalDisplayType dpy,EGLNativeSurfaceType win,int interval) { - - if (s_wglExtProcs->wglSwapIntervalEXT){ - s_wglExtProcs->wglSwapIntervalEXT(interval); - } -} - -EGLNativeSurfaceType createWindowSurface(EGLNativeWindowType wnd){ - return new SrfcInfo(wnd); -} - -EGLNativeSurfaceType createPixmapSurface(EGLNativePixmapType pix){ - return new SrfcInfo(pix); -} - -void destroySurface(EGLNativeSurfaceType srfc){ - delete srfc; -} - - -}; diff --git a/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp b/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp deleted file mode 100644 index 41cf8c4..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* -* 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. -*/ -#include "EglOsApi.h" -#include "emugl/common/mutex.h" - -#include <string.h> -#include <X11/Xlib.h> -#include <GL/glx.h> - - -class ErrorHandler{ -public: -ErrorHandler(EGLNativeDisplayType dpy); -~ErrorHandler(); -int getLastError(){ return s_lastErrorCode;}; - -private: -static int s_lastErrorCode; -int (*m_oldErrorHandler) (Display *, XErrorEvent *); -static emugl::Mutex s_lock; -static int errorHandlerProc(EGLNativeDisplayType dpy,XErrorEvent* event); - -}; - -class SrfcInfo{ -public: - typedef enum{ - WINDOW = 0, - PBUFFER = 1, - PIXMAP - }SurfaceType; - SrfcInfo(GLXDrawable drawable,SurfaceType type):m_type(type), - m_srfc(drawable){}; - GLXDrawable srfc(){return m_srfc;}; -private: - SurfaceType m_type; - GLXDrawable m_srfc; -}; - -int ErrorHandler::s_lastErrorCode = 0; -emugl::Mutex ErrorHandler::s_lock; - -ErrorHandler::ErrorHandler(EGLNativeDisplayType dpy){ - emugl::Mutex::AutoLock mutex(s_lock); - XSync(dpy,False); - s_lastErrorCode = 0; - m_oldErrorHandler = XSetErrorHandler(errorHandlerProc); -} - -ErrorHandler::~ErrorHandler(){ - emugl::Mutex::AutoLock mutex(s_lock); - XSetErrorHandler(m_oldErrorHandler); - s_lastErrorCode = 0; -} - -int ErrorHandler::errorHandlerProc(EGLNativeDisplayType dpy,XErrorEvent* event){ - s_lastErrorCode = event->error_code; - return 0; -} - -#define IS_SUCCESS(a) \ - if(a != Success) return 0; - -namespace EglOS { - -EGLNativeDisplayType getDefaultDisplay() {return XOpenDisplay(0);} - -bool releaseDisplay(EGLNativeDisplayType dpy) { - return XCloseDisplay(dpy); -} - -EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,int renderableType,EGLNativePixelFormatType* frmt){ - - int bSize,red,green,blue,alpha,depth,stencil; - int supportedSurfaces,visualType,visualId; - int caveat,transparentType,samples; - int tRed=0,tGreen=0,tBlue=0; - int pMaxWidth,pMaxHeight,pMaxPixels; - int tmp; - int configId,level,renderable; - int doubleBuffer; - - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_TRANSPARENT_TYPE,&tmp)); - if(tmp == GLX_TRANSPARENT_INDEX) { - return NULL; // not supporting transparent index - } else if( tmp == GLX_NONE) { - transparentType = EGL_NONE; - } else { - transparentType = EGL_TRANSPARENT_RGB; - - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_TRANSPARENT_RED_VALUE,&tRed)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_TRANSPARENT_GREEN_VALUE,&tGreen)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_TRANSPARENT_BLUE_VALUE,&tBlue)); - } - - - // - // filter out single buffer configurations - // - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_DOUBLEBUFFER,&doubleBuffer)); - if (!doubleBuffer) return NULL; - - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_BUFFER_SIZE,&bSize)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_RED_SIZE,&red)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_GREEN_SIZE,&green)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_BLUE_SIZE,&blue)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_ALPHA_SIZE,&alpha)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_DEPTH_SIZE,&depth)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_STENCIL_SIZE,&stencil)); - - - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_X_RENDERABLE,&renderable)); - - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_X_VISUAL_TYPE,&visualType)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_VISUAL_ID,&visualId)); - - //supported surfaces types - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_DRAWABLE_TYPE,&tmp)); - supportedSurfaces = 0; - if(tmp & GLX_WINDOW_BIT && visualId != 0) { - supportedSurfaces |= EGL_WINDOW_BIT; - } else { - visualId = 0; - visualType = EGL_NONE; - } - if(tmp & GLX_PBUFFER_BIT) supportedSurfaces |= EGL_PBUFFER_BIT; - - caveat = 0; - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_CONFIG_CAVEAT,&tmp)); - if (tmp == GLX_NONE) caveat = EGL_NONE; - else if(tmp == GLX_SLOW_CONFIG) caveat = EGL_SLOW_CONFIG; - else if(tmp == GLX_NON_CONFORMANT_CONFIG) caveat = EGL_NON_CONFORMANT_CONFIG; - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_MAX_PBUFFER_WIDTH,&pMaxWidth)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_MAX_PBUFFER_HEIGHT,&pMaxHeight)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_MAX_PBUFFER_HEIGHT,&pMaxPixels)); - - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_LEVEL,&level)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_FBCONFIG_ID,&configId)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_SAMPLES,&samples)); - //Filter out configs that does not support RGBA - IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_RENDER_TYPE,&tmp)); - if (!(tmp & GLX_RGBA_BIT)) { - return NULL; - } - - return new EglConfig(red,green,blue,alpha,caveat,configId,depth,level,pMaxWidth,pMaxHeight, - pMaxPixels,renderable,renderableType,visualId,visualType,samples,stencil, - supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt); -} - -void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listOut) { - int n; - EGLNativePixelFormatType* frmtList = glXGetFBConfigs(dpy,0,&n); - for(int i =0 ;i < n ; i++) { - EglConfig* conf = pixelFormatToConfig(dpy,renderableType,&frmtList[i]); - if(conf) listOut.push_back(conf); - } - XFree(frmtList); -} - -bool validNativeDisplay(EGLNativeInternalDisplayType dpy) { - return dpy != NULL; -} - -bool validNativeWin(EGLNativeDisplayType dpy,EGLNativeWindowType win) { - Window root; - int tmp; - unsigned int utmp; - ErrorHandler handler(dpy); - if(!XGetGeometry(dpy,win,&root,&tmp,&tmp,&utmp,&utmp,&utmp,&utmp)) return false; - return handler.getLastError() == 0; -} - -bool validNativeWin(EGLNativeDisplayType dpy,EGLNativeSurfaceType win) { - if (!win) return false; - return validNativeWin(dpy,win->srfc()); -} - -bool validNativePixmap(EGLNativeDisplayType dpy,EGLNativeSurfaceType pix) { - Window root; - int tmp; - unsigned int utmp; - ErrorHandler handler(dpy); - if(!XGetGeometry(dpy,pix ? pix->srfc() : 0,&root,&tmp,&tmp,&utmp,&utmp,&utmp,&utmp)) return false; - return handler.getLastError() == 0; -} - -bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) { -//TODO: to check what does ATI & NVIDIA enforce on win pixelformat - unsigned int depth,configDepth,border; - int r,g,b,x,y; - IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_RED_SIZE,&r)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_GREEN_SIZE,&g)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_BLUE_SIZE,&b)); - configDepth = r + g + b; - Window root; - if(!XGetGeometry(dpy,win,&root,&x,&y,width,height,&border,&depth)) return false; - return depth >= configDepth; -} - -bool checkPixmapPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height) { - unsigned int depth,configDepth,border; - int r,g,b,x,y; - IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_RED_SIZE,&r)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_GREEN_SIZE,&g)); - IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_BLUE_SIZE,&b)); - configDepth = r + g + b; - Window root; - if(!XGetGeometry(dpy,pix,&root,&x,&y,width,height,&border,&depth)) return false; - return depth >= configDepth; -} - -EGLNativeSurfaceType createPbufferSurface(EGLNativeDisplayType dpy,EglConfig* cfg,EglPbufferSurface* srfc){ - EGLint width,height,largest; - srfc->getDim(&width,&height,&largest); - - int attribs[] = { - GLX_PBUFFER_WIDTH ,width, - GLX_PBUFFER_HEIGHT ,height, - GLX_LARGEST_PBUFFER ,largest, - None - }; - GLXPbuffer pb = glXCreatePbuffer(dpy,cfg->nativeConfig(),attribs); - return pb ? new SrfcInfo(pb,SrfcInfo::PBUFFER) : NULL; -} - -bool releasePbuffer(EGLNativeDisplayType dis,EGLNativeSurfaceType pb) { - if (!pb) return false; - glXDestroyPbuffer(dis,pb->srfc()); - - return true; -} - -EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) { - ErrorHandler handler(dpy); - EGLNativeContextType retVal = glXCreateNewContext(dpy,cfg->nativeConfig(),GLX_RGBA_TYPE,sharedContext,true); - return handler.getLastError() == 0 ? retVal : NULL; -} - -bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx) { - glXDestroyContext(dpy,ctx); - return true; -} - -bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){ - - ErrorHandler handler(dpy); - bool retval = false; - if (!ctx && !read && !draw) { - // unbind - retval = glXMakeContextCurrent(dpy, 0, 0, NULL); - } - else if (ctx && read && draw) { - retval = glXMakeContextCurrent(dpy,draw->native()->srfc(),read->native()->srfc(),ctx); - } - return (handler.getLastError() == 0) && retval; -} - -void swapBuffers(EGLNativeDisplayType dpy,EGLNativeSurfaceType srfc){ - if (srfc) { - glXSwapBuffers(dpy,srfc->srfc()); - } -} - -void waitNative() { - glXWaitX(); -} - -void swapInterval(EGLNativeDisplayType dpy,EGLNativeSurfaceType win,int interval){ - const char* extensions = glXQueryExtensionsString(dpy,DefaultScreen(dpy)); - typedef void (*GLXSWAPINTERVALEXT)(Display*,GLXDrawable,int); - GLXSWAPINTERVALEXT glXSwapIntervalEXT = NULL; - - if(strstr(extensions,"EXT_swap_control")) { - glXSwapIntervalEXT = (GLXSWAPINTERVALEXT)glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT"); - } - if(glXSwapIntervalEXT && win) { - glXSwapIntervalEXT(dpy,win->srfc(),interval); - } -} - -EGLNativeSurfaceType createWindowSurface(EGLNativeWindowType wnd){ - return new SrfcInfo(wnd,SrfcInfo::WINDOW); -} - -EGLNativeSurfaceType createPixmapSurface(EGLNativePixmapType pix){ - return new SrfcInfo(pix,SrfcInfo::PIXMAP); -} - -void destroySurface(EGLNativeSurfaceType srfc){ - delete srfc; -}; - -EGLNativeInternalDisplayType getInternalDisplay(EGLNativeDisplayType dpy){ - return dpy; -} - -void deleteDisplay(EGLNativeInternalDisplayType idpy){ -} - -}; diff --git a/emulator/opengl/host/libs/Translator/EGL/MacNative.h b/emulator/opengl/host/libs/Translator/EGL/MacNative.h deleted file mode 100644 index c8a1df2..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/MacNative.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* 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 MAC_NATIVE_H -#define MAC_NATIVE_H - -typedef enum { // Mac equivalence - MAC_HAS_DOUBLE_BUFFER = 5, // NSOpenGLPFADoubleBuffer - MAC_DRAW_TO_WINDOW = 80, // NSOpenGLPFAWindow - MAC_DRAW_TO_PBUFFER = 90, // NSOpenGLPFAPixelBuffer - MAC_SAMPLES_PER_PIXEL = 56, // NSOpenGLPFASamples - MAC_COLOR_SIZE = 8, // NSOpenGLPFAColorSize - MAC_ALPHA_SIZE = 11, // NSOpenGLPFAAlphaSize - MAC_DEPTH_SIZE = 12, // NSOpenGLPFADepthSize - MAC_STENCIL_SIZE = 13 // NSOpenGLPFAStencilSize - } MacPixelFormatAttribs; - - -extern "C"{ - -int getNumPixelFormats(); -void* getPixelFormat(int i); -int getPixelFormatDefinitionAlpha(int i); -void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val); -void* nsCreateContext(void* format,void* share); -void nsWindowMakeCurrent(void* context,void* nativeWin); -void nsPBufferMakeCurrent(void* context,void* nativePBuffer,int level); -void nsSwapBuffers(); -void nsSwapInterval(int *interval); -void nsDestroyContext(void* context); -void* nsCreatePBuffer(GLenum target,GLenum format,int maxMip,int width,int height); -void nsDestroyPBuffer(void* pbuffer); -bool nsGetWinDims(void* win,unsigned int* width,unsigned int* height); -bool nsCheckColor(void* win,int colorSize); - -} - -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/MacNative.m b/emulator/opengl/host/libs/Translator/EGL/MacNative.m deleted file mode 100644 index a2cea93..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/MacNative.m +++ /dev/null @@ -1,207 +0,0 @@ -/* -* 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. -*/ -#include <stdio.h> -#include <Cocoa/Cocoa.h> -#include <OpenGL/OpenGL.h> -#include "MacPixelFormatsAttribs.h" - -// -// EmuGLContext inherit from NSOpenGLContext -// and adds binding state for the context to know -// if it was last bounded to a pbuffer or a window. -// This is because after the context was bounded to -// a Pbuffer, before we bind it to a window we must -// release it form the pbuffer by calling the -// clearDrawable method. We do not want to call clearDrawable -// more than really needed since when it is called at a time -// that a window is bounded to the context it will clear the -// window content causing flickering effect. -// Thererfore we call clearDrawable only when we bind the context -// to a window and it was previously bound to a Pbuffer. -// -@interface EmuGLContext : NSOpenGLContext { - @private - int boundToPbuffer; - int boundToWin; -} - -- (id) initWithFormat:(NSOpenGLPixelFormat *)pixelFormat shareContext:(NSOpenGLContext *)share; -- (void) preBind:(int)forPbuffer; -@end - -@implementation EmuGLContext -- (id) initWithFormat:(NSOpenGLPixelFormat *)pixelFormat shareContext:(NSOpenGLContext *)share -{ - self = [super initWithFormat:pixelFormat shareContext:share]; - if (self != nil) { - boundToPbuffer = 0; - boundToWin = 0; - } - return self; -} - -- (void) preBind:(int)forPbuffer -{ - if ((!forPbuffer && boundToPbuffer)) { - [self clearDrawable]; - } - boundToPbuffer = forPbuffer; - boundToWin = !boundToPbuffer; -} -@end - -int getNumPixelFormats(){ - int size; - NSOpenGLPixelFormatAttribute** attrib_lists = getPixelFormatsAttributes(&size); - return size; -} - -void* getPixelFormat(int i){ - int size; - NSOpenGLPixelFormatAttribute** attrib_lists = getPixelFormatsAttributes(&size); - return [[NSOpenGLPixelFormat alloc] initWithAttributes:attrib_lists[i]]; -} - -int getPixelFormatDefinitionAlpha(int i) { - int size; - NSOpenGLPixelFormatAttribute** attrib_lists = getPixelFormatsAttributes(&size); - NSOpenGLPixelFormatAttribute* attribs = attrib_lists[i]; - while (*attribs) { - switch (*attribs) { - // These are the ones that take a value, according to the current - // NSOpenGLPixelFormat docs - case NSOpenGLPFAAuxBuffers: - case NSOpenGLPFAColorSize: - case NSOpenGLPFADepthSize: - case NSOpenGLPFAStencilSize: - case NSOpenGLPFAAccumSize: - case NSOpenGLPFARendererID: - case NSOpenGLPFAScreenMask: - attribs += 2; - break; - case NSOpenGLPFAAlphaSize: - return attribs[1]; - break; - // All other attributes are boolean attributes that don't take a value - default: - attribs++; - } - } - return 0; -} - -void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val){ - NSOpenGLPixelFormat *frmt = (NSOpenGLPixelFormat *)pixelFormat; - [frmt getValues:val forAttribute:attrib forVirtualScreen:0]; -} - -void* nsCreateContext(void* format,void* share){ - NSOpenGLPixelFormat* frmt = (NSOpenGLPixelFormat*)format; - return [[EmuGLContext alloc] initWithFormat:frmt shareContext:share]; -} - -void nsPBufferMakeCurrent(void* context,void* nativePBuffer,int level){ - EmuGLContext* ctx = (EmuGLContext *)context; - NSOpenGLPixelBuffer* pbuff = (NSOpenGLPixelBuffer *)nativePBuffer; - if(ctx == nil){ - [NSOpenGLContext clearCurrentContext]; - } else { - if(pbuff != nil){ - [ctx preBind:1]; - [ctx setPixelBuffer:pbuff cubeMapFace:0 mipMapLevel:level currentVirtualScreen:0]; - [ctx makeCurrentContext]; - } - } -} - -void nsWindowMakeCurrent(void* context,void* nativeWin){ - EmuGLContext* ctx = (EmuGLContext *)context; - NSView* win = (NSView *)nativeWin; - if(ctx == nil){ - [NSOpenGLContext clearCurrentContext]; - } else if (win != nil) { - [ctx preBind:0]; - [ctx setView: win]; - [ctx makeCurrentContext]; - } -} - -void nsSwapBuffers(){ - NSOpenGLContext* ctx = [NSOpenGLContext currentContext]; - if(ctx != nil){ - [ctx flushBuffer]; - } -} - -void nsSwapInterval(int *interval){ - NSOpenGLContext* ctx = [NSOpenGLContext currentContext]; - if( ctx != nil){ - [ctx setValues:interval forParameter:NSOpenGLCPSwapInterval]; - } -} - - -void nsDestroyContext(void* context){ - EmuGLContext *ctx = (EmuGLContext*)context; - if(ctx != nil){ - [ctx release]; - } -} - - -void* nsCreatePBuffer(GLenum target,GLenum format,int maxMip,int width,int height){ - return [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:target - textureInternalFormat:format - textureMaxMipMapLevel:maxMip - pixelsWide:width pixelsHigh:height]; - -} - -void nsDestroyPBuffer(void* pbuffer){ - NSOpenGLPixelBuffer *pbuf = (NSOpenGLPixelBuffer*)pbuffer; - if(pbuf != nil){ - [pbuf release]; - } -} - -bool nsGetWinDims(void* win,unsigned int* width,unsigned int* height){ - NSView* view = (NSView*)win; - if(view != nil){ - NSRect rect = [view bounds]; - *width = rect.size.width; - *height = rect.size.height; - return true; - } - return false; -} - -bool nsCheckColor(void* win,int colorSize){ - NSView* view = (NSView*)win; - if(view != nil){ - NSWindow* wnd = [view window]; - if(wnd != nil){ - NSWindowDepth limit = [wnd depthLimit]; - NSWindowDepth defaultLimit = [NSWindow defaultDepthLimit]; - - int depth = (limit != 0) ? NSBitsPerPixelFromDepth(limit): - NSBitsPerPixelFromDepth(defaultLimit); - return depth >= colorSize; - - } - } - return false; - -} diff --git a/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h b/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h deleted file mode 100644 index 692ac22..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -* 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 MAC_PIXELS_FORMATS_ATTRIBS_H -#define MAC_PIXELS_FORMATS_ATTRIBS_H - -#include <Cocoa/Cocoa.h> -NSOpenGLPixelFormatAttribute** getPixelFormatsAttributes(int* size); - -#endif diff --git a/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m b/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m deleted file mode 100644 index f5bc49c..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/MacPixelFormatsAttribs.m +++ /dev/null @@ -1,214 +0,0 @@ -/* -* 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 "MacPixelFormatsAttribs.h" - -static NSOpenGLPixelFormatAttribute attrs32_1[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,32, - NSOpenGLPFADepthSize ,24, - NSOpenGLPFAStencilSize ,8, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs32_2[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,32, - NSOpenGLPFAAlphaSize ,8, - NSOpenGLPFADepthSize ,24, - NSOpenGLPFAStencilSize ,8, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs32_3[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,32, - NSOpenGLPFAAlphaSize ,8, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs32_4[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,32, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs32_5[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,32, - NSOpenGLPFADepthSize ,24, - NSOpenGLPFASamples ,2, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs32_6[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,32, - NSOpenGLPFADepthSize ,24, - NSOpenGLPFASamples ,4, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs32_7[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,32, - NSOpenGLPFAAlphaSize ,8, - NSOpenGLPFADepthSize ,24, - NSOpenGLPFAStencilSize ,8, - NSOpenGLPFASamples ,4, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs16_1[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,16, - NSOpenGLPFADepthSize ,24, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs16_2[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,16, - NSOpenGLPFADepthSize ,24, - NSOpenGLPFAStencilSize ,8, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs64_1[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,64, - NSOpenGLPFAAlphaSize ,16, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs64_2[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,64, - NSOpenGLPFAAlphaSize ,16, - NSOpenGLPFADepthSize ,24, - NSOpenGLPFAStencilSize ,8, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs64_3[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,64, - NSOpenGLPFAAlphaSize ,16, - NSOpenGLPFADepthSize ,24, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs64_4[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,64, - NSOpenGLPFADepthSize ,24, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs64_5[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,64, - NSOpenGLPFADepthSize ,24, - NSOpenGLPFAStencilSize ,8, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs128_1[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,128, - NSOpenGLPFAAlphaSize ,32, - 0 -}; - -static NSOpenGLPixelFormatAttribute attrs128_2[] = -{ - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAWindow, - NSOpenGLPFAPixelBuffer, - NSOpenGLPFAColorSize ,128, - NSOpenGLPFAAlphaSize ,32, - NSOpenGLPFADepthSize ,24, - 0 -}; - -NSOpenGLPixelFormatAttribute** getPixelFormatsAttributes(int* size){ -static NSOpenGLPixelFormatAttribute* arr[] = -{ - attrs16_1, - attrs16_2, - attrs32_1, - attrs32_2, - attrs32_3, - attrs32_4, - attrs32_5, - attrs32_6, - attrs32_7, - attrs64_1, - attrs64_2, - attrs64_3, - attrs64_4, - attrs64_5, - attrs128_1, - attrs128_2 -}; - *size = sizeof(arr)/sizeof(arr[0]); - return arr; -} diff --git a/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp deleted file mode 100644 index 1571b3a..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* -* 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. -*/ - -#include "ThreadInfo.h" - -#include "emugl/common/lazy_instance.h" -#include "emugl/common/thread_store.h" - -#include <stdio.h> - -// Set TRACE_THREADINFO to 1 to debug creation/destruction of ThreadInfo -// instances. -#define TRACE_THREADINFO 0 - -#if TRACE_THREADINFO -#define LOG_THREADINFO(x...) fprintf(stderr, x) -#else -#define LOG_THREADINFO(x...) -#endif - -namespace { - -class ThreadInfoStore : public ::emugl::ThreadStore { -public: - ThreadInfoStore() : ::emugl::ThreadStore(&destructor) {} - - size_t getInstanceCount() const { return mNumInstances; } - -private: - static void destructor(void* value) { - LOG_THREADINFO("%s: EFL %p (%d instances)\n", __FUNCTION__, - value, mNumInstances); - delete static_cast<ThreadInfo*>(value); - mNumInstances--; - } - - static size_t mNumInstances; -}; - -size_t ThreadInfoStore::mNumInstances = 0; - -} // namespace - - -void ThreadInfo::updateInfo(ContextPtr eglCtx, - EglDisplay* dpy, - GLEScontext* glesCtx, - ShareGroupPtr share, - ObjectNameManager* manager) { - - eglContext = eglCtx; - eglDisplay = dpy; - glesContext = glesCtx; - shareGroup = share; - objManager = manager; -} - -static ::emugl::LazyInstance<ThreadInfoStore> s_tls = LAZY_INSTANCE_INIT; - -ThreadInfo *getThreadInfo() -{ - ThreadInfo *ti = static_cast<ThreadInfo*>(s_tls->get()); - if (!ti) { - ti = new ThreadInfo(); - s_tls->set(ti); - LOG_THREADINFO("%s: EGL %p (%d instances)\n", __FUNCTION__, - ti, (int)ThreadInfoStore::getInstanceCount()); - } - return ti; -} diff --git a/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.h b/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.h deleted file mode 100644 index ffc6e5f..0000000 --- a/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* 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 THREAD_INFO_H -#define THREAD_INFO_H - -#include "EglContext.h" - -class EglDisplay; -class GLEScontext; - -struct ThreadInfo { - ThreadInfo():eglDisplay(NULL),glesContext(NULL),objManager(NULL){} - - void updateInfo(ContextPtr eglctx, - EglDisplay* dpy, - GLEScontext* glesCtx, - ShareGroupPtr share, - ObjectNameManager* manager); - - ContextPtr eglContext; - EglDisplay* eglDisplay; - GLEScontext* glesContext; - ShareGroupPtr shareGroup; - ObjectNameManager* objManager; -}; - -ThreadInfo* getThreadInfo(); - -#endif diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk b/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk deleted file mode 100644 index 48cb5c4..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -host_common_SRC_FILES := \ - GLEScmImp.cpp \ - GLEScmUtils.cpp \ - GLEScmContext.cpp \ - GLEScmValidate.cpp - - -### GLES_CM host implementation (On top of OpenGL) ######################## -$(call emugl-begin-host-shared-library,libGLES_CM_translator) -$(call emugl-import,libGLcommon) -LOCAL_SRC_FILES := $(host_common_SRC_FILES) -$(call emugl-end-module) - - -### GLES_CM host implementation, 64-bit ######################## -$(call emugl-begin-host64-shared-library,lib64GLES_CM_translator) -$(call emugl-import,lib64GLcommon) -LOCAL_SRC_FILES := $(host_common_SRC_FILES) -$(call emugl-end-module) diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp deleted file mode 100644 index 66adefb..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* -* 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. -*/ -#include "GLDispatch.h" -#include <stdio.h> -#include <OpenglOsUtils/osDynLibrary.h> - -#ifdef __linux__ -#include <GL/glx.h> -#elif defined(WIN32) -#include <windows.h> -#endif - -typedef void (*GL_FUNC_PTR)(); - -static GL_FUNC_PTR getGLFuncAddress(const char *funcName) { - GL_FUNC_PTR ret = NULL; -#ifdef __linux__ - static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("libGL.so"); - ret = (GL_FUNC_PTR)glXGetProcAddress((const GLubyte*)funcName); -#elif defined(WIN32) - static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("opengl32"); - ret = (GL_FUNC_PTR)wglGetProcAddress(funcName); -#endif - if(!ret && libGL){ - ret = libGL->findSymbol(funcName); - } - return ret; -} - -#define LOAD_GL_FUNC(name) { void * funcAddrs = NULL; \ - funcAddrs = (void *)getGLFuncAddress(#name); \ - if(funcAddrs) \ - *(void**)(&name) = funcAddrs; \ - else \ - fprintf(stderr,"could not load func %s\n",#name); } - -GLDispatch::GLDispatch():m_isLoaded(false){}; - - -void GLDispatch::dispatchFuncs() { - emugl::Mutex::AutoLock mutex(m_lock); - if(m_isLoaded) - return; - LOAD_GL_FUNC(glActiveTexture); - LOAD_GL_FUNC(glAlphaFunc); - LOAD_GL_FUNC(glBegin); - LOAD_GL_FUNC(glBindBuffer); - LOAD_GL_FUNC(glBindTexture); - LOAD_GL_FUNC(glBlendFunc); - LOAD_GL_FUNC(glBufferData); - LOAD_GL_FUNC(glBufferSubData); - LOAD_GL_FUNC(glClear); - LOAD_GL_FUNC(glClearColor); - LOAD_GL_FUNC(glClearDepth); - LOAD_GL_FUNC(glClearStencil); - LOAD_GL_FUNC(glClientActiveTexture); - LOAD_GL_FUNC(glClipPlane); - LOAD_GL_FUNC(glColor4d); - LOAD_GL_FUNC(glColor4f); - LOAD_GL_FUNC(glColor4fv); - LOAD_GL_FUNC(glColor4ub); - LOAD_GL_FUNC(glColor4ubv); - LOAD_GL_FUNC(glColorMask); - LOAD_GL_FUNC(glColorPointer); - LOAD_GL_FUNC(glCompressedTexImage2D); - LOAD_GL_FUNC(glCompressedTexSubImage2D); - LOAD_GL_FUNC(glCopyTexImage2D); - LOAD_GL_FUNC(glCopyTexSubImage2D); - LOAD_GL_FUNC(glCullFace); - LOAD_GL_FUNC(glDeleteBuffers); - LOAD_GL_FUNC(glDeleteTextures); - LOAD_GL_FUNC(glDepthFunc); - LOAD_GL_FUNC(glDepthMask); - LOAD_GL_FUNC(glDepthRange); - LOAD_GL_FUNC(glDisable); - LOAD_GL_FUNC(glDisableClientState); - LOAD_GL_FUNC(glDrawArrays); - LOAD_GL_FUNC(glDrawElements); - LOAD_GL_FUNC(glEnable); - LOAD_GL_FUNC(glEnableClientState); - LOAD_GL_FUNC(glEnd); - LOAD_GL_FUNC(glFinish); - LOAD_GL_FUNC(glFlush); - LOAD_GL_FUNC(glFogf); - LOAD_GL_FUNC(glFogfv); - LOAD_GL_FUNC(glFrontFace); - LOAD_GL_FUNC(glFrustum); - LOAD_GL_FUNC(glGenBuffers); - LOAD_GL_FUNC(glGenTextures); - LOAD_GL_FUNC(glGetBooleanv); - LOAD_GL_FUNC(glGetBufferParameteriv); - LOAD_GL_FUNC(glGetClipPlane); - LOAD_GL_FUNC(glGetDoublev); - LOAD_GL_FUNC(glGetError); - LOAD_GL_FUNC(glGetFloatv); - LOAD_GL_FUNC(glGetIntegerv); - LOAD_GL_FUNC(glGetLightfv); - LOAD_GL_FUNC(glGetMaterialfv); - LOAD_GL_FUNC(glGetPointerv); - LOAD_GL_FUNC(glGetString); - LOAD_GL_FUNC(glGetTexEnvfv); - LOAD_GL_FUNC(glGetTexEnviv); - LOAD_GL_FUNC(glGetTexParameterfv); - LOAD_GL_FUNC(glGetTexParameteriv); - LOAD_GL_FUNC(glHint); - LOAD_GL_FUNC(glIsBuffer); - LOAD_GL_FUNC(glIsEnabled); - LOAD_GL_FUNC(glIsTexture); - LOAD_GL_FUNC(glLightf); - LOAD_GL_FUNC(glLightfv); - LOAD_GL_FUNC(glLightModelf); - LOAD_GL_FUNC(glLightModelfv); - LOAD_GL_FUNC(glLineWidth); - LOAD_GL_FUNC(glLoadIdentity); - LOAD_GL_FUNC(glLoadMatrixf); - LOAD_GL_FUNC(glLogicOp); - LOAD_GL_FUNC(glMaterialf); - LOAD_GL_FUNC(glMaterialfv); - LOAD_GL_FUNC(glMultiTexCoord2fv); - LOAD_GL_FUNC(glMultiTexCoord2sv); - LOAD_GL_FUNC(glMultiTexCoord3fv); - LOAD_GL_FUNC(glMultiTexCoord3sv); - LOAD_GL_FUNC(glMultiTexCoord4fv); - LOAD_GL_FUNC(glMultiTexCoord4sv); - LOAD_GL_FUNC(glMultiTexCoord4f); - LOAD_GL_FUNC(glMultMatrixf); - LOAD_GL_FUNC(glNormal3f); - LOAD_GL_FUNC(glNormal3fv); - LOAD_GL_FUNC(glNormal3sv); - LOAD_GL_FUNC(glOrtho); - LOAD_GL_FUNC(glPointParameterf); - LOAD_GL_FUNC(glPointParameterfv); - LOAD_GL_FUNC(glPointSize); - LOAD_GL_FUNC(glPolygonOffset); - LOAD_GL_FUNC(glRotatef); - LOAD_GL_FUNC(glScalef); - LOAD_GL_FUNC(glTexEnvf); - LOAD_GL_FUNC(glTexEnvfv); - LOAD_GL_FUNC(glTexParameterf); - LOAD_GL_FUNC(glTexParameterfv); - LOAD_GL_FUNC(glMatrixMode); - LOAD_GL_FUNC(glNormalPointer); - LOAD_GL_FUNC(glPixelStorei); - LOAD_GL_FUNC(glPopMatrix); - LOAD_GL_FUNC(glPushMatrix); - LOAD_GL_FUNC(glReadPixels); - LOAD_GL_FUNC(glSampleCoverage); - LOAD_GL_FUNC(glScissor); - LOAD_GL_FUNC(glShadeModel); - LOAD_GL_FUNC(glStencilFunc); - LOAD_GL_FUNC(glStencilMask); - LOAD_GL_FUNC(glStencilOp); - LOAD_GL_FUNC(glTexCoordPointer); - LOAD_GL_FUNC(glTexEnvi); - LOAD_GL_FUNC(glTexEnviv); - LOAD_GL_FUNC(glTexImage2D); - LOAD_GL_FUNC(glTexParameteri); - LOAD_GL_FUNC(glTexParameteriv); - LOAD_GL_FUNC(glTexSubImage2D); - LOAD_GL_FUNC(glTranslatef); - LOAD_GL_FUNC(glVertexPointer); - LOAD_GL_FUNC(glViewport); - - m_isLoaded = true; -} diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h deleted file mode 100644 index ae8c9f8..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h +++ /dev/null @@ -1,158 +0,0 @@ -/* -* 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 GLDISPATCHH -#define GLDISPATCHH - -#include <GLES/gl.h> -#include "emugl/common/mutex.h" - -#define GLAPIENTRY GL_APIENTRY - -typedef double GLclampd; /* double precision float in [0,1] */ -typedef double GLdouble; /* double precision float */ - -class GLDispatch -{ -public: - - GLDispatch(); - void dispatchFuncs(); - - void (GLAPIENTRY *glActiveTexture) ( GLenum texture ); - void (GLAPIENTRY *glAlphaFunc) (GLenum func, GLclampf ref); - void (GLAPIENTRY *glBegin)( GLenum mode ); - void (GLAPIENTRY *glBindBuffer) (GLenum target, GLuint buffer); - void (GLAPIENTRY *glBindTexture) (GLenum target, GLuint texture); - void (GLAPIENTRY *glBlendFunc) (GLenum sfactor, GLenum dfactor); - void (GLAPIENTRY *glBufferData) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); - void (GLAPIENTRY *glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); - void (GLAPIENTRY *glClear) (GLbitfield mask); - void (GLAPIENTRY *glClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void (GLAPIENTRY *glClearDepth) (GLclampd depth); - void (GLAPIENTRY *glClearStencil) (GLint s); - void (GLAPIENTRY *glClientActiveTexture) ( GLenum texture ); - void (GLAPIENTRY *glClipPlane) (GLenum plane, const GLdouble *equation); - void (GLAPIENTRY *glColor4d) (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); - void (GLAPIENTRY *glColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); - void (GLAPIENTRY *glColor4fv) ( const GLfloat *v ); - void (GLAPIENTRY *glColor4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); - void (GLAPIENTRY *glColor4ubv) ( const GLubyte *v ); - void (GLAPIENTRY *glColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); - void (GLAPIENTRY *glColorPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - void (GLAPIENTRY *glCompressedTexImage2D) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); - void (GLAPIENTRY *glCompressedTexSubImage2D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); - void (GLAPIENTRY *glCopyTexImage2D) (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); - void (GLAPIENTRY *glCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); - void (GLAPIENTRY *glCullFace) (GLenum mode); - void (GLAPIENTRY *glDeleteBuffers) (GLsizei n, const GLuint *buffers); - void (GLAPIENTRY *glDeleteTextures) (GLsizei n, const GLuint *textures); - void (GLAPIENTRY *glDepthFunc) (GLenum func); - void (GLAPIENTRY *glDepthMask) (GLboolean flag); - void (GLAPIENTRY *glDepthRange) (GLclampd zNear, GLclampd zFar); - void (GLAPIENTRY *glDisable) (GLenum cap); - void (GLAPIENTRY *glDisableClientState) (GLenum array); - void (GLAPIENTRY *glDrawArrays) (GLenum mode, GLint first, GLsizei count); - void (GLAPIENTRY *glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); - void (GLAPIENTRY *glEnable) (GLenum cap); - void (GLAPIENTRY *glEnableClientState) (GLenum array); - void (GLAPIENTRY *glEnd) ( void ); - void (GLAPIENTRY *glFinish) (void); - void (GLAPIENTRY *glFlush) (void); - void (GLAPIENTRY *glFogf) (GLenum pname, GLfloat param); - void (GLAPIENTRY *glFogfv) (GLenum pname, const GLfloat *params); - void (GLAPIENTRY *glFrontFace) (GLenum mode); - void (GLAPIENTRY *glFrustum) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); - void (GLAPIENTRY *glGenBuffers) (GLsizei n, GLuint *buffers); - void (GLAPIENTRY *glGenTextures) (GLsizei n, GLuint *textures); - void (GLAPIENTRY *glGetBooleanv) (GLenum pname, GLboolean *params); - void (GLAPIENTRY *glGetBufferParameteriv) (GLenum, GLenum, GLint *); - void (GLAPIENTRY *glGetClipPlane) (GLenum plane, GLdouble *equation); - void (GLAPIENTRY *glGetDoublev) ( GLenum pname, GLdouble *params ); - GLenum (GLAPIENTRY *glGetError) (void); - void (GLAPIENTRY *glGetFloatv) (GLenum pname, GLfloat *params); - void (GLAPIENTRY *glGetIntegerv) (GLenum pname, GLint *params); - void (GLAPIENTRY *glGetLightfv) (GLenum light, GLenum pname, GLfloat *params); - void (GLAPIENTRY *glGetMaterialfv) (GLenum face, GLenum pname, GLfloat *params); - void (GLAPIENTRY *glGetPointerv) (GLenum pname, GLvoid* *params); - const GLubyte * (GLAPIENTRY *glGetString) (GLenum name); - void (GLAPIENTRY *glGetTexEnvfv) (GLenum target, GLenum pname, GLfloat *params); - void (GLAPIENTRY *glGetTexEnviv) (GLenum target, GLenum pname, GLint *params); - void (GLAPIENTRY *glGetTexParameterfv) (GLenum target, GLenum pname, GLfloat *params); - void (GLAPIENTRY *glGetTexParameteriv) (GLenum target, GLenum pname, GLint *params); - void (GLAPIENTRY *glHint) (GLenum target, GLenum mode); - GLboolean (GLAPIENTRY *glIsBuffer) (GLuint); - GLboolean (GLAPIENTRY *glIsEnabled) (GLenum cap); - GLboolean (GLAPIENTRY *glIsTexture) (GLuint texture); - void (GLAPIENTRY *glLightf) (GLenum light, GLenum pname, GLfloat param); - void (GLAPIENTRY *glLightfv) (GLenum light, GLenum pname, const GLfloat *params); - void (GLAPIENTRY *glLightModelf) (GLenum pname, GLfloat param); - void (GLAPIENTRY *glLightModelfv) (GLenum pname, const GLfloat *params); - void (GLAPIENTRY *glLineWidth) (GLfloat width); - void (GLAPIENTRY *glLoadIdentity) (void); - void (GLAPIENTRY *glLoadMatrixf) (const GLfloat *m); - void (GLAPIENTRY *glLogicOp) (GLenum opcode); - void (GLAPIENTRY *glMaterialf) (GLenum face, GLenum pname, GLfloat param); - void (GLAPIENTRY *glMaterialfv) (GLenum face, GLenum pname, const GLfloat *params); - void (GLAPIENTRY *glMultiTexCoord2fv) ( GLenum target, const GLfloat *v ); - void (GLAPIENTRY *glMultiTexCoord2sv) ( GLenum target, const GLshort *v ); - void (GLAPIENTRY *glMultiTexCoord3fv) ( GLenum target, const GLfloat *v ); - void (GLAPIENTRY *glMultiTexCoord3sv) ( GLenum target, const GLshort *v ); - void (GLAPIENTRY *glMultiTexCoord4f) ( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); - void (GLAPIENTRY *glMultiTexCoord4fv) ( GLenum target, const GLfloat *v ); - void (GLAPIENTRY *glMultiTexCoord4sv) ( GLenum target, const GLshort *v ); - void (GLAPIENTRY *glMultMatrixf) (const GLfloat *m); - void (GLAPIENTRY *glNormal3f) (GLfloat nx, GLfloat ny, GLfloat nz); - void (GLAPIENTRY *glNormal3fv) ( const GLfloat *v ); - void (GLAPIENTRY *glNormal3sv) ( const GLshort *v ); - void (GLAPIENTRY *glOrtho) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); - void (GLAPIENTRY *glPointParameterf) (GLenum, GLfloat); - void (GLAPIENTRY *glPointParameterfv) (GLenum, const GLfloat *); - void (GLAPIENTRY *glPointSize) (GLfloat size); - void (GLAPIENTRY *glPolygonOffset) (GLfloat factor, GLfloat units); - void (GLAPIENTRY *glRotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); - void (GLAPIENTRY *glScalef) (GLfloat x, GLfloat y, GLfloat z); - void (GLAPIENTRY *glTexEnvf) (GLenum target, GLenum pname, GLfloat param); - void (GLAPIENTRY *glTexEnvfv) (GLenum target, GLenum pname, const GLfloat *params); - void (GLAPIENTRY *glTexParameterf) (GLenum target, GLenum pname, GLfloat param); - void (GLAPIENTRY *glTexParameterfv) (GLenum target, GLenum pname, const GLfloat *params); - void (GLAPIENTRY *glMatrixMode) (GLenum mode); - void (GLAPIENTRY *glNormalPointer) (GLenum type, GLsizei stride, const GLvoid *pointer); - void (GLAPIENTRY *glPixelStorei) (GLenum pname, GLint param); - void (GLAPIENTRY *glPopMatrix) (void); - void (GLAPIENTRY *glPushMatrix) (void); - void (GLAPIENTRY *glReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); - void (GLAPIENTRY *glSampleCoverage) ( GLclampf value, GLboolean invert ); - void (GLAPIENTRY *glScissor) (GLint x, GLint y, GLsizei width, GLsizei height); - void (GLAPIENTRY *glShadeModel) (GLenum mode); - void (GLAPIENTRY *glStencilFunc) (GLenum func, GLint ref, GLuint mask); - void (GLAPIENTRY *glStencilMask) (GLuint mask); - void (GLAPIENTRY *glStencilOp) (GLenum fail, GLenum zfail, GLenum zpass); - void (GLAPIENTRY *glTexCoordPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - void (GLAPIENTRY *glTexEnvi) (GLenum target, GLenum pname, GLint param); - void (GLAPIENTRY *glTexEnviv) (GLenum target, GLenum pname, const GLint *params); - void (GLAPIENTRY *glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); - void (GLAPIENTRY *glTexParameteri) (GLenum target, GLenum pname, GLint param); - void (GLAPIENTRY *glTexParameteriv) (GLenum target, GLenum pname, const GLint *params); - void (GLAPIENTRY *glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); - void (GLAPIENTRY *glTranslatef) (GLfloat x, GLfloat y, GLfloat z); - void (GLAPIENTRY *glVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - void (GLAPIENTRY *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height); -private: - bool m_isLoaded; - emugl::Mutex m_lock; -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp deleted file mode 100644 index 6476c02..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/* -* 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. -*/ - -#include "GLEScmContext.h" -#include "GLEScmUtils.h" -#include <GLcommon/GLutils.h> -#include <GLcommon/GLconversion_macros.h> -#include <string.h> -#include <GLES/gl.h> -#include <GLES/glext.h> - -void GLEScmContext::init() { - emugl::Mutex::AutoLock mutex(s_lock); - if(!m_initialized) { - s_glDispatch.dispatchFuncs(GLES_1_1); - GLEScontext::init(); - - m_texCoords = new GLESpointer[s_glSupport.maxTexUnits]; - m_map[GL_TEXTURE_COORD_ARRAY] = &m_texCoords[m_clientActiveTexture]; - - buildStrings((const char*)dispatcher().glGetString(GL_VENDOR), - (const char*)dispatcher().glGetString(GL_RENDERER), - (const char*)dispatcher().glGetString(GL_VERSION), - "OpenGL ES-CM 1.1"); - } - m_initialized = true; -} - -GLEScmContext::GLEScmContext():GLEScontext(),m_texCoords(NULL),m_pointsIndex(-1), m_clientActiveTexture(0) { - - m_map[GL_COLOR_ARRAY] = new GLESpointer(); - m_map[GL_NORMAL_ARRAY] = new GLESpointer(); - m_map[GL_VERTEX_ARRAY] = new GLESpointer(); - m_map[GL_POINT_SIZE_ARRAY_OES] = new GLESpointer(); -} - - -void GLEScmContext::setActiveTexture(GLenum tex) { - m_activeTexture = tex - GL_TEXTURE0; -} - -void GLEScmContext::setClientActiveTexture(GLenum tex) { - m_clientActiveTexture = tex - GL_TEXTURE0; - m_map[GL_TEXTURE_COORD_ARRAY] = &m_texCoords[m_clientActiveTexture]; -} - -GLEScmContext::~GLEScmContext(){ - if(m_texCoords){ - delete[] m_texCoords; - m_texCoords = NULL; - } - m_map[GL_TEXTURE_COORD_ARRAY] = NULL; -} - - -//setting client side arr -void GLEScmContext::setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,GLboolean normalized, int index){ - if( arr == NULL) return; - switch(arrayType) { - case GL_VERTEX_ARRAY: - s_glDispatch.glVertexPointer(size,dataType,stride,arr); - break; - case GL_NORMAL_ARRAY: - s_glDispatch.glNormalPointer(dataType,stride,arr); - break; - case GL_TEXTURE_COORD_ARRAY: - s_glDispatch.glTexCoordPointer(size,dataType,stride,arr); - break; - case GL_COLOR_ARRAY: - s_glDispatch.glColorPointer(size,dataType,stride,arr); - break; - case GL_POINT_SIZE_ARRAY_OES: - m_pointsIndex = index; - break; - } -} - - -void GLEScmContext::setupArrayPointerHelper(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLenum array_id,GLESpointer* p){ - unsigned int size = p->getSize(); - GLenum dataType = p->getType(); - - if(needConvert(cArrs,first,count,type,indices,direct,p,array_id)){ - //conversion has occured - ArrayData currentArr = cArrs.getCurrentArray(); - setupArr(currentArr.data,array_id,currentArr.type,size,currentArr.stride,GL_FALSE, cArrs.getCurrentIndex()); - ++cArrs; - } else { - setupArr(p->getData(),array_id,dataType,size,p->getStride(), GL_FALSE); - } -} - -void GLEScmContext::setupArraysPointers(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct) { - ArraysMap::iterator it; - m_pointsIndex = -1; - - //going over all clients arrays Pointers - for ( it=m_map.begin() ; it != m_map.end(); it++ ) { - - GLenum array_id = (*it).first; - GLESpointer* p = (*it).second; - if(!isArrEnabled(array_id)) continue; - if(array_id == GL_TEXTURE_COORD_ARRAY) continue; //handling textures later - setupArrayPointerHelper(cArrs,first,count,type,indices,direct,array_id,p); - } - - unsigned int activeTexture = m_clientActiveTexture + GL_TEXTURE0; - - s_lock.lock(); - int maxTexUnits = s_glSupport.maxTexUnits; - s_lock.unlock(); - - //converting all texture coords arrays - for(int i=0; i< maxTexUnits;i++) { - - unsigned int tex = GL_TEXTURE0+i; - setClientActiveTexture(tex); - s_glDispatch.glClientActiveTexture(tex); - - GLenum array_id = GL_TEXTURE_COORD_ARRAY; - GLESpointer* p = m_map[array_id]; - if(!isArrEnabled(array_id)) continue; - setupArrayPointerHelper(cArrs,first,count,type,indices,direct,array_id,p); - } - - setClientActiveTexture(activeTexture); - s_glDispatch.glClientActiveTexture(activeTexture); -} - -void GLEScmContext::drawPointsData(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices_in,bool isElemsDraw) { - const char *pointsArr = NULL; - int stride = 0; - GLESpointer* p = m_map[GL_POINT_SIZE_ARRAY_OES]; - - //choosing the right points sizes array source - if(m_pointsIndex >= 0) { //point size array was converted - pointsArr = (const char*)(cArrs[m_pointsIndex].data); - stride = cArrs[m_pointsIndex].stride; - } else { - pointsArr = static_cast<const char*>(p->getData()); - stride = p->getStride(); - } - - if(stride == 0){ - stride = sizeof(GLfloat); - } - - - if(isElemsDraw) { - int tSize = type == GL_UNSIGNED_SHORT ? 2 : 1; - - int i = 0; - while(i<count) - { - int sStart = i; - int sCount = 1; - -#define INDEX \ - (type == GL_UNSIGNED_SHORT ? \ - static_cast<const GLushort*>(indices_in)[i]: \ - static_cast<const GLubyte*>(indices_in)[i]) - - GLfloat pSize = *((GLfloat*)(pointsArr+(INDEX*stride))); - i++; - - while(i < count && pSize == *((GLfloat*)(pointsArr+(INDEX*stride)))) - { - sCount++; - i++; - } - - s_glDispatch.glPointSize(pSize); - s_glDispatch.glDrawElements(GL_POINTS, sCount, type, (char*)indices_in+sStart*tSize); - } - } else { - int i = 0; - while(i<count) - { - int sStart = i; - int sCount = 1; - GLfloat pSize = *((GLfloat*)(pointsArr+((first+i)*stride))); - i++; - - while(i < count && pSize == *((GLfloat*)(pointsArr+((first+i)*stride)))) - { - sCount++; - i++; - } - - s_glDispatch.glPointSize(pSize); - s_glDispatch.glDrawArrays(GL_POINTS, first+sStart, sCount); - } - } -} - -void GLEScmContext::drawPointsArrs(GLESConversionArrays& arrs,GLint first,GLsizei count) { - drawPointsData(arrs,first,count,0,NULL,false); -} - -void GLEScmContext::drawPointsElems(GLESConversionArrays& arrs,GLsizei count,GLenum type,const GLvoid* indices_in) { - drawPointsData(arrs,0,count,type,indices_in,true); -} - -bool GLEScmContext::needConvert(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id) { - - bool usingVBO = p->isVBO(); - GLenum arrType = p->getType(); - /* - conversion is not necessary in the following cases: - (*) array type is byte but it is not vertex or texture array - (*) array type is not fixed - */ - if((arrType != GL_FIXED) && (arrType != GL_BYTE)) return false; - if((arrType == GL_BYTE && (array_id != GL_VERTEX_ARRAY)) && - (arrType == GL_BYTE && (array_id != GL_TEXTURE_COORD_ARRAY)) ) return false; - - - bool byteVBO = (arrType == GL_BYTE) && usingVBO; - if(byteVBO){ - p->redirectPointerData(); - } - - if(!usingVBO || byteVBO) { - if (direct) { - convertDirect(cArrs,first,count,array_id,p); - } else { - convertIndirect(cArrs,count,type,indices,array_id,p); - } - } else { - if (direct) { - convertDirectVBO(cArrs,first,count,array_id,p) ; - } else { - convertIndirectVBO(cArrs,count,type,indices,array_id,p); - } - } - return true; -} - -const GLESpointer* GLEScmContext::getPointer(GLenum arrType) { - GLenum type = - arrType == GL_VERTEX_ARRAY_POINTER ? GL_VERTEX_ARRAY : - arrType == GL_NORMAL_ARRAY_POINTER ? GL_NORMAL_ARRAY : - arrType == GL_TEXTURE_COORD_ARRAY_POINTER ? GL_TEXTURE_COORD_ARRAY : - arrType == GL_COLOR_ARRAY_POINTER ? GL_COLOR_ARRAY : - arrType == GL_POINT_SIZE_ARRAY_POINTER_OES ? GL_POINT_SIZE_ARRAY_OES : - 0; - if(type != 0) - { - return GLEScontext::getPointer(type); - } - return NULL; -} - -void GLEScmContext::initExtensionString() { - *s_glExtensions = "GL_OES_blend_func_separate GL_OES_blend_equation_separate GL_OES_blend_subtract " - "GL_OES_byte_coordinates GL_OES_compressed_paletted_texture GL_OES_point_size_array " - "GL_OES_point_sprite GL_OES_single_precision GL_OES_stencil_wrap GL_OES_texture_env_crossbar " - "GL_OES_texture_mirored_repeat GL_OES_EGL_image GL_OES_element_index_uint GL_OES_draw_texture " - "GL_OES_texture_cube_map GL_OES_draw_texture "; - if (s_glSupport.GL_OES_READ_FORMAT) - *s_glExtensions+="GL_OES_read_format "; - if (s_glSupport.GL_EXT_FRAMEBUFFER_OBJECT) { - *s_glExtensions+="GL_OES_framebuffer_object GL_OES_depth24 GL_OES_depth32 GL_OES_fbo_render_mipmap " - "GL_OES_rgb8_rgba8 GL_OES_stencil1 GL_OES_stencil4 GL_OES_stencil8 "; - } - if (s_glSupport.GL_EXT_PACKED_DEPTH_STENCIL) - *s_glExtensions+="GL_OES_packed_depth_stencil "; - if (s_glSupport.GL_EXT_TEXTURE_FORMAT_BGRA8888) - *s_glExtensions+="GL_EXT_texture_format_BGRA8888 GL_APPLE_texture_format_BGRA8888 "; - if (s_glSupport.GL_ARB_MATRIX_PALETTE && s_glSupport.GL_ARB_VERTEX_BLEND) { - *s_glExtensions+="GL_OES_matrix_palette "; - GLint max_palette_matrices=0; - GLint max_vertex_units=0; - dispatcher().glGetIntegerv(GL_MAX_PALETTE_MATRICES_OES,&max_palette_matrices); - dispatcher().glGetIntegerv(GL_MAX_VERTEX_UNITS_OES,&max_vertex_units); - if (max_palette_matrices>=32 && max_vertex_units>=4) - *s_glExtensions+="GL_OES_extended_matrix_palette "; - } - *s_glExtensions+="GL_OES_compressed_ETC1_RGB8_texture "; -} - -int GLEScmContext::getMaxTexUnits() { - return getCaps()->maxTexUnits; -} - -bool GLEScmContext::glGetBooleanv(GLenum pname, GLboolean *params) -{ - GLint iParam; - - if(glGetIntegerv(pname, &iParam)) - { - *params = (iParam != 0); - return true; - } - - return false; -} - -bool GLEScmContext::glGetFixedv(GLenum pname, GLfixed *params) -{ - GLint iParam; - - if(glGetIntegerv(pname, &iParam)) - { - *params = I2X(iParam); - return true; - } - - return false; -} - -bool GLEScmContext::glGetFloatv(GLenum pname, GLfloat *params) -{ - GLint iParam; - - if(glGetIntegerv(pname, &iParam)) - { - *params = (GLfloat)iParam; - return true; - } - - return false; -} - -bool GLEScmContext::glGetIntegerv(GLenum pname, GLint *params) -{ - if(GLEScontext::glGetIntegerv(pname, params)) - return true; - - const GLESpointer* ptr = NULL; - - switch(pname){ - case GL_VERTEX_ARRAY_BUFFER_BINDING: - case GL_VERTEX_ARRAY_SIZE: - case GL_VERTEX_ARRAY_STRIDE: - case GL_VERTEX_ARRAY_TYPE: - ptr = getPointer(GL_VERTEX_ARRAY_POINTER); - break; - - case GL_NORMAL_ARRAY_BUFFER_BINDING: - case GL_NORMAL_ARRAY_STRIDE: - case GL_NORMAL_ARRAY_TYPE: - ptr = getPointer(GL_NORMAL_ARRAY_POINTER); - break; - - case GL_COLOR_ARRAY_BUFFER_BINDING: - case GL_COLOR_ARRAY_SIZE: - case GL_COLOR_ARRAY_STRIDE: - case GL_COLOR_ARRAY_TYPE: - ptr = getPointer(GL_COLOR_ARRAY_POINTER); - break; - - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: - case GL_TEXTURE_COORD_ARRAY_SIZE: - case GL_TEXTURE_COORD_ARRAY_STRIDE: - case GL_TEXTURE_COORD_ARRAY_TYPE: - ptr = getPointer(GL_TEXTURE_COORD_ARRAY_POINTER); - break; - - case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: - case GL_POINT_SIZE_ARRAY_STRIDE_OES: - case GL_POINT_SIZE_ARRAY_TYPE_OES: - ptr = getPointer(GL_POINT_SIZE_ARRAY_POINTER_OES); - break; - - default: - return false; - } - - switch(pname) - { - case GL_VERTEX_ARRAY_BUFFER_BINDING: - case GL_NORMAL_ARRAY_BUFFER_BINDING: - case GL_COLOR_ARRAY_BUFFER_BINDING: - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: - case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: - *params = ptr ? ptr->getBufferName() : 0; - break; - - case GL_VERTEX_ARRAY_STRIDE: - case GL_NORMAL_ARRAY_STRIDE: - case GL_COLOR_ARRAY_STRIDE: - case GL_TEXTURE_COORD_ARRAY_STRIDE: - case GL_POINT_SIZE_ARRAY_STRIDE_OES: - *params = ptr ? ptr->getStride() : 0; - break; - - case GL_VERTEX_ARRAY_SIZE: - case GL_COLOR_ARRAY_SIZE: - case GL_TEXTURE_COORD_ARRAY_SIZE: - *params = ptr ? ptr->getSize() : 0; - break; - - case GL_VERTEX_ARRAY_TYPE: - case GL_NORMAL_ARRAY_TYPE: - case GL_COLOR_ARRAY_TYPE: - case GL_TEXTURE_COORD_ARRAY_TYPE: - case GL_POINT_SIZE_ARRAY_TYPE_OES: - *params = ptr ? ptr->getType() : 0; - break; - } - - return true; -} diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h deleted file mode 100644 index fbb7023..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* 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_CM_CONTEX_H -#define GLES_CM_CONTEX_H - -#include <GLcommon/GLDispatch.h> -#include <GLcommon/GLESpointer.h> -#include <GLcommon/GLESbuffer.h> -#include <GLcommon/GLEScontext.h> -#include <map> -#include <vector> -#include <string> - - -typedef std::map<GLfloat,std::vector<int> > PointSizeIndices; - -class GLEScmContext: public GLEScontext -{ -public: - void init(); - GLEScmContext(); - - void setActiveTexture(GLenum tex); - void setClientActiveTexture(GLenum tex); - GLenum getActiveTexture() { return GL_TEXTURE0 + m_activeTexture;}; - GLenum getClientActiveTexture() { return GL_TEXTURE0 + m_clientActiveTexture;}; - void setupArraysPointers(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct); - void drawPointsArrs(GLESConversionArrays& arrs,GLint first,GLsizei count); - void drawPointsElems(GLESConversionArrays& arrs,GLsizei count,GLenum type,const GLvoid* indices); - virtual const GLESpointer* getPointer(GLenum arrType); - int getMaxTexUnits(); - - 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); - - ~GLEScmContext(); -protected: - - bool needConvert(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id); -private: - void setupArrayPointerHelper(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLenum array_id,GLESpointer* p); - void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,GLboolean normalized, int pointsIndex = -1); - void drawPoints(PointSizeIndices* points); - void drawPointsData(GLESConversionArrays& arrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices_in,bool isElemsDraw); - void initExtensionString(); - - GLESpointer* m_texCoords; - int m_pointsIndex; - unsigned int m_clientActiveTexture; -}; - -#endif - diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp deleted file mode 100644 index dd74750..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp +++ /dev/null @@ -1,2355 +0,0 @@ -/* -* 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. -*/ - -#ifdef _WIN32 -#undef GL_API -#define GL_API __declspec(dllexport) -#define GL_APICALL __declspec(dllexport) -#endif -#define GL_GLEXT_PROTOTYPES -#include "GLEScmContext.h" -#include "GLEScmValidate.h" -#include "GLEScmUtils.h" -#include <GLcommon/TextureUtils.h> - -#include <stdio.h> -#include <GLcommon/gldefs.h> -#include <GLcommon/GLDispatch.h> -#include <GLcommon/GLconversion_macros.h> -#include <GLcommon/TranslatorIfaces.h> -#include <GLcommon/FramebufferData.h> -#include <GLES/gl.h> -#include <GLES/glext.h> -#include <cmath> -#include <map> - -extern "C" { - -//decleration -static void initContext(GLEScontext* ctx,ShareGroupPtr grp); -static void deleteGLESContext(GLEScontext* ctx); -static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp); -static GLEScontext* createGLESContext(); -static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName); - -} - -/************************************** GLES EXTENSIONS *********************************************************/ -//extentions descriptor -typedef std::map<std::string, __translatorMustCastToProperFunctionPointerType> ProcTableMap; -ProcTableMap *s_glesExtensions = NULL; -/****************************************************************************************************************/ - -static EGLiface* s_eglIface = NULL; -static GLESiface s_glesIface = { - createGLESContext:createGLESContext, - initContext :initContext, - deleteGLESContext:deleteGLESContext, - flush :(FUNCPTR)glFlush, - finish :(FUNCPTR)glFinish, - setShareGroup :setShareGroup, - getProcAddress :getProcAddress -}; - -#include <GLcommon/GLESmacros.h> - -extern "C" { - -static void initContext(GLEScontext* ctx,ShareGroupPtr grp) { - if (!ctx->isInitialized()) { - ctx->setShareGroup(grp); - ctx->init(); - glBindTexture(GL_TEXTURE_2D,0); - glBindTexture(GL_TEXTURE_CUBE_MAP_OES,0); - } -} - -static GLEScontext* createGLESContext() { - return new GLEScmContext(); -} - -static void deleteGLESContext(GLEScontext* ctx) { - if(ctx) delete ctx; -} - -static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp) { - if(ctx) { - ctx->setShareGroup(grp); - } -} -static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName) { - GET_CTX_RET(NULL) - ctx->getGlobalLock(); - static bool proc_table_initialized = false; - if (!proc_table_initialized) { - proc_table_initialized = true; - if (!s_glesExtensions) - s_glesExtensions = new ProcTableMap(); - else - s_glesExtensions->clear(); - (*s_glesExtensions)["glEGLImageTargetTexture2DOES"] = (__translatorMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES; - (*s_glesExtensions)["glEGLImageTargetRenderbufferStorageOES"]=(__translatorMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES; - (*s_glesExtensions)["glBlendEquationSeparateOES"] = (__translatorMustCastToProperFunctionPointerType)glBlendEquationSeparateOES; - (*s_glesExtensions)["glBlendFuncSeparateOES"] = (__translatorMustCastToProperFunctionPointerType)glBlendFuncSeparateOES; - (*s_glesExtensions)["glBlendEquationOES"] = (__translatorMustCastToProperFunctionPointerType)glBlendEquationOES; - - if (ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND) { - (*s_glesExtensions)["glCurrentPaletteMatrixOES"] = (__translatorMustCastToProperFunctionPointerType)glCurrentPaletteMatrixOES; - (*s_glesExtensions)["glLoadPaletteFromModelViewMatrixOES"]=(__translatorMustCastToProperFunctionPointerType)glLoadPaletteFromModelViewMatrixOES; - (*s_glesExtensions)["glMatrixIndexPointerOES"] = (__translatorMustCastToProperFunctionPointerType)glMatrixIndexPointerOES; - (*s_glesExtensions)["glWeightPointerOES"] = (__translatorMustCastToProperFunctionPointerType)glWeightPointerOES; - } - (*s_glesExtensions)["glDepthRangefOES"] = (__translatorMustCastToProperFunctionPointerType)glDepthRangef; - (*s_glesExtensions)["glFrustumfOES"] = (__translatorMustCastToProperFunctionPointerType)glFrustumf; - (*s_glesExtensions)["glOrthofOES"] = (__translatorMustCastToProperFunctionPointerType)glOrthof; - (*s_glesExtensions)["glClipPlanefOES"] = (__translatorMustCastToProperFunctionPointerType)glClipPlanef; - (*s_glesExtensions)["glGetClipPlanefOES"] = (__translatorMustCastToProperFunctionPointerType)glGetClipPlanef; - (*s_glesExtensions)["glClearDepthfOES"] = (__translatorMustCastToProperFunctionPointerType)glClearDepthf; - (*s_glesExtensions)["glPointSizePointerOES"] = (__translatorMustCastToProperFunctionPointerType)glPointSizePointerOES; - (*s_glesExtensions)["glTexGenfOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenfOES; - (*s_glesExtensions)["glTexGenfvOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenfvOES; - (*s_glesExtensions)["glTexGeniOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGeniOES; - (*s_glesExtensions)["glTexGenivOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenivOES; - (*s_glesExtensions)["glTexGenxOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenxOES; - (*s_glesExtensions)["glTexGenxvOES"] = (__translatorMustCastToProperFunctionPointerType)glTexGenxvOES; - (*s_glesExtensions)["glGetTexGenfvOES"] = (__translatorMustCastToProperFunctionPointerType)glGetTexGenfvOES; - (*s_glesExtensions)["glGetTexGenivOES"] = (__translatorMustCastToProperFunctionPointerType)glGetTexGenivOES; - (*s_glesExtensions)["glGetTexGenxvOES"] = (__translatorMustCastToProperFunctionPointerType)glGetTexGenxvOES; - if (ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT) { - (*s_glesExtensions)["glIsRenderbufferOES"] = (__translatorMustCastToProperFunctionPointerType)glIsRenderbufferOES; - (*s_glesExtensions)["glBindRenderbufferOES"] = (__translatorMustCastToProperFunctionPointerType)glBindRenderbufferOES; - (*s_glesExtensions)["glDeleteRenderbuffersOES"] = (__translatorMustCastToProperFunctionPointerType)glDeleteRenderbuffersOES; - (*s_glesExtensions)["glGenRenderbuffersOES"] = (__translatorMustCastToProperFunctionPointerType)glGenRenderbuffersOES; - (*s_glesExtensions)["glRenderbufferStorageOES"] = (__translatorMustCastToProperFunctionPointerType)glRenderbufferStorageOES; - (*s_glesExtensions)["glGetRenderbufferParameterivOES"] = (__translatorMustCastToProperFunctionPointerType)glGetRenderbufferParameterivOES; - (*s_glesExtensions)["glIsFramebufferOES"] = (__translatorMustCastToProperFunctionPointerType)glIsFramebufferOES; - (*s_glesExtensions)["glBindFramebufferOES"] = (__translatorMustCastToProperFunctionPointerType)glBindFramebufferOES; - (*s_glesExtensions)["glDeleteFramebuffersOES"] = (__translatorMustCastToProperFunctionPointerType)glDeleteFramebuffersOES; - (*s_glesExtensions)["glGenFramebuffersOES"] = (__translatorMustCastToProperFunctionPointerType)glGenFramebuffersOES; - (*s_glesExtensions)["glCheckFramebufferStatusOES"] = (__translatorMustCastToProperFunctionPointerType)glCheckFramebufferStatusOES; - (*s_glesExtensions)["glFramebufferTexture2DOES"] = (__translatorMustCastToProperFunctionPointerType)glFramebufferTexture2DOES; - (*s_glesExtensions)["glFramebufferRenderbufferOES"] = (__translatorMustCastToProperFunctionPointerType)glFramebufferRenderbufferOES; - (*s_glesExtensions)["glGetFramebufferAttachmentParameterivOES"] = (__translatorMustCastToProperFunctionPointerType)glGetFramebufferAttachmentParameterivOES; - (*s_glesExtensions)["glGenerateMipmapOES"] = (__translatorMustCastToProperFunctionPointerType)glGenerateMipmapOES; - } - (*s_glesExtensions)["glDrawTexsOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexsOES; - (*s_glesExtensions)["glDrawTexiOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexiOES; - (*s_glesExtensions)["glDrawTexfOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexfOES; - (*s_glesExtensions)["glDrawTexxOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexxOES; - (*s_glesExtensions)["glDrawTexsvOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexsvOES; - (*s_glesExtensions)["glDrawTexivOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexivOES; - (*s_glesExtensions)["glDrawTexfvOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexfvOES; - (*s_glesExtensions)["glDrawTexxvOES"] = (__translatorMustCastToProperFunctionPointerType)glDrawTexxvOES; - } - __translatorMustCastToProperFunctionPointerType ret=NULL; - ProcTableMap::iterator val = s_glesExtensions->find(procName); - if (val!=s_glesExtensions->end()) - ret = val->second; - ctx->releaseGlobalLock(); - - return ret; -} - -GL_API GLESiface* __translator_getIfaces(EGLiface* eglIface){ - s_eglIface = eglIface; - return & s_glesIface; -} - -} - -static ObjectLocalName TextureLocalName(GLenum target, unsigned int tex) { - GET_CTX_RET(0); - return (tex!=0? tex : ctx->getDefaultTextureName(target)); -} - -static TextureData* getTextureData(ObjectLocalName tex){ - GET_CTX_RET(NULL); - - if(!ctx->shareGroup()->isObject(TEXTURE,tex)) - { - return NULL; - } - - TextureData *texData = NULL; - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(TEXTURE,tex); - if(!objData.Ptr()){ - texData = new TextureData(); - ctx->shareGroup()->setObjectData(TEXTURE, tex, ObjectDataPtr(texData)); - } else { - texData = (TextureData*)objData.Ptr(); - } - return texData; -} - -static TextureData* getTextureTargetData(GLenum target){ - GET_CTX_RET(NULL); - unsigned int tex = ctx->getBindedTexture(target); - return getTextureData(TextureLocalName(target,tex)); -} - -GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer) { - GET_CTX_RET(GL_FALSE) - - if(buffer && ctx->shareGroup().Ptr()) { - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(VERTEXBUFFER,buffer); - return objData.Ptr() ? ((GLESbuffer*)objData.Ptr())->wasBinded():GL_FALSE; - } - return GL_FALSE; -} - -GL_API GLboolean GL_APIENTRY glIsEnabled( GLenum cap) { - GET_CTX_CM_RET(GL_FALSE) - RET_AND_SET_ERROR_IF(!GLEScmValidate::capability(cap,ctx->getMaxLights(),ctx->getMaxClipPlanes()),GL_INVALID_ENUM,GL_FALSE); - - if (cap == GL_POINT_SIZE_ARRAY_OES) - return ctx->isArrEnabled(cap); - else if (cap==GL_TEXTURE_GEN_STR_OES) - return (ctx->dispatcher().glIsEnabled(GL_TEXTURE_GEN_S) && - ctx->dispatcher().glIsEnabled(GL_TEXTURE_GEN_T) && - ctx->dispatcher().glIsEnabled(GL_TEXTURE_GEN_R)); - else - return ctx->dispatcher().glIsEnabled(cap); -} - -GL_API GLboolean GL_APIENTRY glIsTexture( GLuint texture) { - GET_CTX_RET(GL_FALSE) - - if(texture == 0) // Special case - return GL_FALSE; - - TextureData* tex = getTextureData(texture); - return tex ? tex->wasBound : GL_FALSE; -} - -GL_API GLenum GL_APIENTRY glGetError(void) { - GET_CTX_RET(GL_NO_ERROR) - GLenum err = ctx->getGLerror(); - if(err != GL_NO_ERROR) { - ctx->setGLerror(GL_NO_ERROR); - return err; - } - - return ctx->dispatcher().glGetError(); -} - -GL_API const GLubyte * GL_APIENTRY glGetString( GLenum name) { - - GET_CTX_RET(NULL) - switch(name) { - case GL_VENDOR: - return (const GLubyte*)ctx->getVendorString(); - case GL_RENDERER: - return (const GLubyte*)ctx->getRendererString(); - case GL_VERSION: - return (const GLubyte*)ctx->getVersionString(); - case GL_EXTENSIONS: - return (const GLubyte*)ctx->getExtensionString(); - default: - RET_AND_SET_ERROR_IF(true,GL_INVALID_ENUM,NULL); - } -} - -GL_API void GL_APIENTRY glActiveTexture( GLenum texture) { - GET_CTX_CM() - SET_ERROR_IF(!GLEScmValidate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM); - ctx->setActiveTexture(texture); - ctx->dispatcher().glActiveTexture(texture); -} - -GL_API void GL_APIENTRY glAlphaFunc( GLenum func, GLclampf ref) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::alphaFunc(func),GL_INVALID_ENUM); - ctx->dispatcher().glAlphaFunc(func,ref); -} - - -GL_API void GL_APIENTRY glAlphaFuncx( GLenum func, GLclampx ref) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::alphaFunc(func),GL_INVALID_ENUM); - ctx->dispatcher().glAlphaFunc(func,X2F(ref)); -} - - -GL_API void GL_APIENTRY glBindBuffer( GLenum target, GLuint buffer) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::bufferTarget(target),GL_INVALID_ENUM); - - //if buffer wasn't generated before,generate one - if(buffer && ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(VERTEXBUFFER,buffer)){ - ctx->shareGroup()->genName(VERTEXBUFFER,buffer); - ctx->shareGroup()->setObjectData(VERTEXBUFFER,buffer,ObjectDataPtr(new GLESbuffer())); - } - ctx->bindBuffer(target,buffer); - if (buffer) { - GLESbuffer* vbo = (GLESbuffer*)ctx->shareGroup()->getObjectData(VERTEXBUFFER,buffer).Ptr(); - vbo->setBinded(); - } -} - - -GL_API void GL_APIENTRY glBindTexture( GLenum target, GLuint texture) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::textureTarget(target),GL_INVALID_ENUM) - - //for handling default texture (0) - ObjectLocalName localTexName = TextureLocalName(target,texture); - - GLuint globalTextureName = localTexName; - if(ctx->shareGroup().Ptr()){ - globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,localTexName); - //if texture wasn't generated before,generate one - if(!globalTextureName){ - ctx->shareGroup()->genName(TEXTURE,localTexName); - globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,localTexName); - } - - TextureData* texData = getTextureData(localTexName); - if (texData->target==0) - texData->target = target; - //if texture was already bound to another target - SET_ERROR_IF(ctx->GLTextureTargetToLocal(texData->target) != ctx->GLTextureTargetToLocal(target), GL_INVALID_OPERATION); - texData->wasBound = true; - } - - ctx->setBindedTexture(target,texture); - ctx->dispatcher().glBindTexture(target,globalTextureName); -} - -GL_API void GL_APIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::blendSrc(sfactor) || !GLEScmValidate::blendDst(dfactor),GL_INVALID_ENUM) - ctx->dispatcher().glBlendFunc(sfactor,dfactor); -} - -GL_API void GL_APIENTRY glBufferData( GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::bufferTarget(target),GL_INVALID_ENUM); - SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION); - ctx->setBufferData(target,size,data,usage); -} - -GL_API void GL_APIENTRY glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) { - GET_CTX() - SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION); - SET_ERROR_IF(!GLEScmValidate::bufferTarget(target),GL_INVALID_ENUM); - SET_ERROR_IF(!ctx->setBufferSubData(target,offset,size,data),GL_INVALID_VALUE); -} - -GL_API void GL_APIENTRY glClear( GLbitfield mask) { - GET_CTX() - ctx->drawValidate(); - - ctx->dispatcher().glClear(mask); -} - -GL_API void GL_APIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { - GET_CTX() - ctx->dispatcher().glClearColor(red,green,blue,alpha); -} - -GL_API void GL_APIENTRY glClearColorx( GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) { - GET_CTX() - ctx->dispatcher().glClearColor(X2F(red),X2F(green),X2F(blue),X2F(alpha)); -} - - -GL_API void GL_APIENTRY glClearDepthf( GLclampf depth) { - GET_CTX() - ctx->dispatcher().glClearDepth(depth); -} - -GL_API void GL_APIENTRY glClearDepthx( GLclampx depth) { - GET_CTX() - ctx->dispatcher().glClearDepth(X2F(depth)); -} - -GL_API void GL_APIENTRY glClearStencil( GLint s) { - GET_CTX() - ctx->dispatcher().glClearStencil(s); -} - -GL_API void GL_APIENTRY glClientActiveTexture( GLenum texture) { - GET_CTX_CM() - SET_ERROR_IF(!GLEScmValidate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM); - ctx->setClientActiveTexture(texture); - ctx->dispatcher().glClientActiveTexture(texture); - -} - -GL_API void GL_APIENTRY glClipPlanef( GLenum plane, const GLfloat *equation) { - GET_CTX() - GLdouble tmpEquation[4]; - - for(int i = 0; i < 4; i++) { - tmpEquation[i] = static_cast<GLdouble>(equation[i]); - } - ctx->dispatcher().glClipPlane(plane,tmpEquation); -} - -GL_API void GL_APIENTRY glClipPlanex( GLenum plane, const GLfixed *equation) { - GET_CTX() - GLdouble tmpEquation[4]; - for(int i = 0; i < 4; i++) { - tmpEquation[i] = X2D(equation[i]); - } - ctx->dispatcher().glClipPlane(plane,tmpEquation); -} - -GL_API void GL_APIENTRY glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { - GET_CTX() - ctx->dispatcher().glColor4f(red,green,blue,alpha); -} - -GL_API void GL_APIENTRY glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) { - GET_CTX() - ctx->dispatcher().glColor4ub(red,green,blue,alpha); -} - -GL_API void GL_APIENTRY glColor4x( GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) { - GET_CTX() - ctx->dispatcher().glColor4f(X2F(red),X2F(green),X2F(blue),X2F(alpha)); -} - -GL_API void GL_APIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { - GET_CTX() - ctx->dispatcher().glColorMask(red,green,blue,alpha); -} - -GL_API void GL_APIENTRY glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::colorPointerParams(size,stride),GL_INVALID_VALUE); - SET_ERROR_IF(!GLEScmValidate::colorPointerType(type),GL_INVALID_ENUM); - ctx->setPointer(GL_COLOR_ARRAY,size,type,stride,pointer); -} - -GL_API void GL_APIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) { - GET_CTX_CM() - SET_ERROR_IF(!GLEScmValidate::textureTargetEx(target),GL_INVALID_ENUM); - - doCompressedTexImage2D(ctx, target, level, internalformat, - width, height, border, - imageSize, data, (void*)glTexImage2D); -} - -GL_API void GL_APIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) { - GET_CTX_CM() - SET_ERROR_IF(!(GLEScmValidate::texCompImgFrmt(format) && GLEScmValidate::textureTargetEx(target)),GL_INVALID_ENUM); - SET_ERROR_IF(level < 0 || level > log2(ctx->getMaxTexSize()),GL_INVALID_VALUE) - - GLenum uncompressedFrmt; - unsigned char* uncompressed = uncompressTexture(format,uncompressedFrmt,width,height,imageSize,data,level); - ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,uncompressedFrmt,GL_UNSIGNED_BYTE,uncompressed); - delete uncompressed; -} - -GL_API void GL_APIENTRY glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { - GET_CTX() - SET_ERROR_IF(!(GLEScmValidate::pixelFrmt(ctx,internalformat) && GLEScmValidate::textureTargetEx(target)),GL_INVALID_ENUM); - SET_ERROR_IF(border != 0,GL_INVALID_VALUE); - ctx->dispatcher().glCopyTexImage2D(target,level,internalformat,x,y,width,height,border); -} - -GL_API void GL_APIENTRY glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::textureTargetEx(target),GL_INVALID_ENUM); - ctx->dispatcher().glCopyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height); -} - -GL_API void GL_APIENTRY glCullFace( GLenum mode) { - GET_CTX() - ctx->dispatcher().glCullFace(mode); -} - -GL_API void GL_APIENTRY glDeleteBuffers( GLsizei n, const GLuint *buffers) { - GET_CTX() - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i < n; i++){ - ctx->shareGroup()->deleteName(VERTEXBUFFER,buffers[i]); - ctx->unbindBuffer(buffers[i]); - } - } -} - -GL_API void GL_APIENTRY glDeleteTextures( GLsizei n, const GLuint *textures) { - GET_CTX() - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i < n; i++){ - if(textures[i] != 0) - { - TextureData* tData = getTextureData(textures[i]); - // delete the underlying OpenGL texture but only if this - // texture is not a target of EGLImage. - if (!tData || tData->sourceEGLImage == 0) { - const GLuint globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,textures[i]); - ctx->dispatcher().glDeleteTextures(1,&globalTextureName); - } - ctx->shareGroup()->deleteName(TEXTURE,textures[i]); - - if(ctx->getBindedTexture(GL_TEXTURE_2D) == textures[i]) - ctx->setBindedTexture(GL_TEXTURE_2D,0); - if (ctx->getBindedTexture(GL_TEXTURE_CUBE_MAP) == textures[i]) - ctx->setBindedTexture(GL_TEXTURE_CUBE_MAP,0); - } - } - } -} - -GL_API void GL_APIENTRY glDepthFunc( GLenum func) { - GET_CTX() - ctx->dispatcher().glDepthFunc(func); -} - -GL_API void GL_APIENTRY glDepthMask( GLboolean flag) { - GET_CTX() - ctx->dispatcher().glDepthMask(flag); -} - -GL_API void GL_APIENTRY glDepthRangef( GLclampf zNear, GLclampf zFar) { - GET_CTX() - ctx->dispatcher().glDepthRange(zNear,zFar); -} - -GL_API void GL_APIENTRY glDepthRangex( GLclampx zNear, GLclampx zFar) { - GET_CTX() - ctx->dispatcher().glDepthRange(X2F(zNear),X2F(zFar)); -} - -GL_API void GL_APIENTRY glDisable( GLenum cap) { - GET_CTX() - if (cap==GL_TEXTURE_GEN_STR_OES) { - ctx->dispatcher().glDisable(GL_TEXTURE_GEN_S); - ctx->dispatcher().glDisable(GL_TEXTURE_GEN_T); - ctx->dispatcher().glDisable(GL_TEXTURE_GEN_R); - } - else ctx->dispatcher().glDisable(cap); - if (cap==GL_TEXTURE_2D || cap==GL_TEXTURE_CUBE_MAP_OES) - ctx->setTextureEnabled(cap,false); -} - -GL_API void GL_APIENTRY glDisableClientState( GLenum array) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::supportedArrays(array),GL_INVALID_ENUM) - - ctx->enableArr(array,false); - if(array != GL_POINT_SIZE_ARRAY_OES) ctx->dispatcher().glDisableClientState(array); -} - - -GL_API void GL_APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count) { - GET_CTX_CM() - SET_ERROR_IF(count < 0,GL_INVALID_VALUE) - SET_ERROR_IF(!GLEScmValidate::drawMode(mode),GL_INVALID_ENUM) - - ctx->drawValidate(); - - if(!ctx->isArrEnabled(GL_VERTEX_ARRAY)) return; - - GLESConversionArrays tmpArrs; - ctx->setupArraysPointers(tmpArrs,first,count,0,NULL,true); - if(mode == GL_POINTS && ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){ - ctx->drawPointsArrs(tmpArrs,first,count); - } - else - { - ctx->dispatcher().glDrawArrays(mode,first,count); - } -} - -GL_API void GL_APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *elementsIndices) { - GET_CTX_CM() - SET_ERROR_IF(count < 0,GL_INVALID_VALUE) - SET_ERROR_IF((!GLEScmValidate::drawMode(mode) || !GLEScmValidate::drawType(type)),GL_INVALID_ENUM) - if(!ctx->isArrEnabled(GL_VERTEX_ARRAY)) return; - - ctx->drawValidate(); - - const GLvoid* indices = elementsIndices; - 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 + SafeUIntFromPointer(elementsIndices); - } - - ctx->setupArraysPointers(tmpArrs,0,count,type,indices,false); - if(mode == GL_POINTS && ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){ - ctx->drawPointsElems(tmpArrs,count,type,indices); - } - else{ - ctx->dispatcher().glDrawElements(mode,count,type,indices); - } -} - -GL_API void GL_APIENTRY glEnable( GLenum cap) { - GET_CTX() - if (cap==GL_TEXTURE_GEN_STR_OES) { - ctx->dispatcher().glEnable(GL_TEXTURE_GEN_S); - ctx->dispatcher().glEnable(GL_TEXTURE_GEN_T); - ctx->dispatcher().glEnable(GL_TEXTURE_GEN_R); - } - else - ctx->dispatcher().glEnable(cap); - if (cap==GL_TEXTURE_2D || cap==GL_TEXTURE_CUBE_MAP_OES) - ctx->setTextureEnabled(cap,true); -} - -GL_API void GL_APIENTRY glEnableClientState( GLenum array) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::supportedArrays(array),GL_INVALID_ENUM) - - ctx->enableArr(array,true); - if(array != GL_POINT_SIZE_ARRAY_OES) ctx->dispatcher().glEnableClientState(array); -} - -GL_API void GL_APIENTRY glFinish( void) { - GET_CTX() - ctx->dispatcher().glFinish(); -} - -GL_API void GL_APIENTRY glFlush( void) { - GET_CTX() - ctx->dispatcher().glFlush(); -} - -GL_API void GL_APIENTRY glFogf( GLenum pname, GLfloat param) { - GET_CTX() - ctx->dispatcher().glFogf(pname,param); -} - -GL_API void GL_APIENTRY glFogfv( GLenum pname, const GLfloat *params) { - GET_CTX() - ctx->dispatcher().glFogfv(pname,params); -} - -GL_API void GL_APIENTRY glFogx( GLenum pname, GLfixed param) { - GET_CTX() - ctx->dispatcher().glFogf(pname,(pname == GL_FOG_MODE)? static_cast<GLfloat>(param):X2F(param)); -} - -GL_API void GL_APIENTRY glFogxv( GLenum pname, const GLfixed *params) { - GET_CTX() - if(pname == GL_FOG_MODE) { - GLfloat tmpParam = static_cast<GLfloat>(params[0]); - ctx->dispatcher().glFogfv(pname,&tmpParam); - } else { - GLfloat tmpParams[4]; - for(int i=0; i< 4; i++) { - tmpParams[i] = X2F(params[i]); - } - ctx->dispatcher().glFogfv(pname,tmpParams); - } - -} - -GL_API void GL_APIENTRY glFrontFace( GLenum mode) { - GET_CTX() - ctx->dispatcher().glFrontFace(mode); -} - -GL_API void GL_APIENTRY glFrustumf( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) { - GET_CTX() - ctx->dispatcher().glFrustum(left,right,bottom,top,zNear,zFar); -} - -GL_API void GL_APIENTRY glFrustumx( GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) { - GET_CTX() - ctx->dispatcher().glFrustum(X2F(left),X2F(right),X2F(bottom),X2F(top),X2F(zNear),X2F(zFar)); -} - -GL_API void GL_APIENTRY glGenBuffers( GLsizei n, GLuint *buffers) { - GET_CTX() - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i<n ;i++) { - buffers[i] = ctx->shareGroup()->genName(VERTEXBUFFER, 0, true); - //generating vbo object related to this buffer name - ctx->shareGroup()->setObjectData(VERTEXBUFFER,buffers[i],ObjectDataPtr(new GLESbuffer())); - } - } -} - -GL_API void GL_APIENTRY glGenTextures( GLsizei n, GLuint *textures) { - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i<n ;i++) { - textures[i] = ctx->shareGroup()->genName(TEXTURE, 0, true); - } - } -} - -GL_API void GL_APIENTRY glGetBooleanv( GLenum pname, GLboolean *params) { - GET_CTX() - - if(ctx->glGetBooleanv(pname, params)) - { - return; - } - - switch(pname) - { - case GL_FRAMEBUFFER_BINDING_OES: - case GL_RENDERBUFFER_BINDING_OES: - { - GLint name; - glGetIntegerv(pname,&name); - *params = name!=0 ? GL_TRUE: GL_FALSE; - } - break; - case GL_TEXTURE_GEN_STR_OES: - { - GLboolean state_s = GL_FALSE; - GLboolean state_t = GL_FALSE; - GLboolean state_r = GL_FALSE; - ctx->dispatcher().glGetBooleanv(GL_TEXTURE_GEN_S,&state_s); - ctx->dispatcher().glGetBooleanv(GL_TEXTURE_GEN_T,&state_t); - ctx->dispatcher().glGetBooleanv(GL_TEXTURE_GEN_R,&state_r); - *params = state_s && state_t && state_r ? GL_TRUE: GL_FALSE; - } - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS: - *params = (GLboolean)getCompressedFormats(NULL); - break; - case GL_COMPRESSED_TEXTURE_FORMATS: - { - int nparams = getCompressedFormats(NULL); - if (nparams>0) { - int * iparams = new int[nparams]; - getCompressedFormats(iparams); - for (int i=0; i<nparams; i++) params[i] = (GLboolean)iparams[i]; - delete [] iparams; - } - } - break; - default: - ctx->dispatcher().glGetBooleanv(pname,params); - } -} - -GL_API void GL_APIENTRY glGetBufferParameteriv( GLenum target, GLenum pname, GLint *params) { - GET_CTX() - SET_ERROR_IF(!(GLEScmValidate::bufferTarget(target) && GLEScmValidate::bufferParam(pname)),GL_INVALID_ENUM); - SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION); - switch(pname) { - case GL_BUFFER_SIZE: - ctx->getBufferSize(target,params); - break; - case GL_BUFFER_USAGE: - ctx->getBufferUsage(target,params); - break; - } - -} - -GL_API void GL_APIENTRY glGetClipPlanef( GLenum pname, GLfloat eqn[4]) { - GET_CTX() - GLdouble tmpEqn[4]; - - ctx->dispatcher().glGetClipPlane(pname,tmpEqn); - for(int i =0 ;i < 4; i++){ - eqn[i] = static_cast<GLfloat>(tmpEqn[i]); - } -} - -GL_API void GL_APIENTRY glGetClipPlanex( GLenum pname, GLfixed eqn[4]) { - GET_CTX() - GLdouble tmpEqn[4]; - - ctx->dispatcher().glGetClipPlane(pname,tmpEqn); - for(int i =0 ;i < 4; i++){ - eqn[i] = F2X(tmpEqn[i]); - } -} - -GL_API void GL_APIENTRY glGetFixedv( GLenum pname, GLfixed *params) { - GET_CTX() - - if(ctx->glGetFixedv(pname, params)) - { - return; - } - - size_t nParams = glParamSize(pname); - GLfloat fParams[16]; - - switch(pname) - { - case GL_FRAMEBUFFER_BINDING_OES: - case GL_RENDERBUFFER_BINDING_OES: - case GL_TEXTURE_GEN_STR_OES: - glGetFloatv(pname,&fParams[0]); - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS: - *params = I2X(getCompressedFormats(NULL)); - return; - break; - case GL_COMPRESSED_TEXTURE_FORMATS: - { - int nparams = getCompressedFormats(NULL); - if (nparams>0) { - int * iparams = new int[nparams]; - getCompressedFormats(iparams); - for (int i=0; i<nparams; i++) params[i] = I2X(iparams[i]); - delete [] iparams; - } - return; - } - break; - default: - ctx->dispatcher().glGetFloatv(pname,fParams); - } - - if (nParams) - { - for(size_t i =0 ; i < nParams;i++) { - params[i] = F2X(fParams[i]); - } - } -} - -GL_API void GL_APIENTRY glGetFloatv( GLenum pname, GLfloat *params) { - GET_CTX() - - if(ctx->glGetFloatv(pname, params)) - { - return; - } - - GLint i; - - switch (pname) { - case GL_FRAMEBUFFER_BINDING_OES: - case GL_RENDERBUFFER_BINDING_OES: - case GL_TEXTURE_GEN_STR_OES: - glGetIntegerv(pname,&i); - *params = (GLfloat)i; - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS: - *params = (GLfloat)getCompressedFormats(NULL); - break; - case GL_COMPRESSED_TEXTURE_FORMATS: - { - int nparams = getCompressedFormats(NULL); - if (nparams>0) { - int * iparams = new int[nparams]; - getCompressedFormats(iparams); - for (int i=0; i<nparams; i++) params[i] = (GLfloat)iparams[i]; - delete [] iparams; - } - } - break; - default: - ctx->dispatcher().glGetFloatv(pname,params); - } -} - -GL_API void GL_APIENTRY glGetIntegerv( GLenum pname, GLint *params) { - GET_CTX() - - if(ctx->glGetIntegerv(pname, params)) - { - return; - } - - GLint i; - GLfloat f; - - switch(pname) - { - case GL_TEXTURE_GEN_STR_OES: - ctx->dispatcher().glGetIntegerv(GL_TEXTURE_GEN_S,¶ms[0]); - break; - case GL_FRAMEBUFFER_BINDING_OES: - if (ctx->shareGroup().Ptr()) { - ctx->dispatcher().glGetIntegerv(pname,&i); - *params = ctx->shareGroup()->getLocalName(FRAMEBUFFER,i); - } - break; - case GL_RENDERBUFFER_BINDING_OES: - if (ctx->shareGroup().Ptr()) { - ctx->dispatcher().glGetIntegerv(pname,&i); - *params = ctx->shareGroup()->getLocalName(RENDERBUFFER,i); - } - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS: - *params = getCompressedFormats(NULL); - break; - case GL_COMPRESSED_TEXTURE_FORMATS: - getCompressedFormats(params); - break; - case GL_MAX_CLIP_PLANES: - ctx->dispatcher().glGetIntegerv(pname,params); - if(*params > 6) - { - // GLES spec requires only 6, and the ATI driver erronously - // returns 8 (although it supports only 6). This WAR is simple, - // compliant and good enough for developers. - *params = 6; - } - break; - case GL_ALPHA_TEST_REF: - // Both the ATI and nVidia OpenGL drivers return the wrong answer - // here. So return the right one. - ctx->dispatcher().glGetFloatv(pname,&f); - *params = (int)(f * (float)0x7fffffff); - break; - case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: - ctx->dispatcher().glGetIntegerv(pname,params); - if(*params > 16) - { - // GLES spec requires only 2, and the ATI driver erronously - // returns 32 (although it supports only 16). This WAR is simple, - // compliant and good enough for developers. - *params = 16; - } - break; - - default: - ctx->dispatcher().glGetIntegerv(pname,params); - } -} - -GL_API void GL_APIENTRY glGetLightfv( GLenum light, GLenum pname, GLfloat *params) { - GET_CTX() - ctx->dispatcher().glGetLightfv(light,pname,params); -} - -GL_API void GL_APIENTRY glGetLightxv( GLenum light, GLenum pname, GLfixed *params) { - GET_CTX() - GLfloat tmpParams[4]; - - ctx->dispatcher().glGetLightfv(light,pname,tmpParams); - switch (pname){ - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_POSITION: - params[3] = F2X(tmpParams[3]); - case GL_SPOT_DIRECTION: - params[2] = F2X(tmpParams[2]); - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - params[1] = F2X(tmpParams[1]); - break; - default:{ - ctx->setGLerror(GL_INVALID_ENUM); - return; - } - - } - params[0] = F2X(tmpParams[0]); -} - -GL_API void GL_APIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params) { - GET_CTX() - ctx->dispatcher().glGetMaterialfv(face,pname,params); -} - -GL_API void GL_APIENTRY glGetMaterialxv( GLenum face, GLenum pname, GLfixed *params) { - GET_CTX() - GLfloat tmpParams[4]; - ctx->dispatcher().glGetMaterialfv(face,pname,tmpParams); - switch(pname){ - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_EMISSION: - case GL_AMBIENT_AND_DIFFUSE: - params[3] = tmpParams[3]; - params[2] = tmpParams[2]; - params[1] = tmpParams[1]; - case GL_SHININESS: - params[0] = tmpParams[0]; - break; - default:{ - ctx->setGLerror(GL_INVALID_ENUM); - return; - } - } -} - -GL_API void GL_APIENTRY glGetPointerv( GLenum pname, void **params) { - GET_CTX() - const GLESpointer* p = ctx->getPointer(pname); - if(p) { - if(p->isVBO()) - { - *params = SafePointerFromUInt(p->getBufferOffset()); - }else{ - *params = const_cast<void *>(p->getArrayData()); - } - } else { - ctx->setGLerror(GL_INVALID_ENUM); - } - -} - -GL_API void GL_APIENTRY glGetTexEnvfv( GLenum env, GLenum pname, GLfloat *params) { - GET_CTX() - ctx->dispatcher().glGetTexEnvfv(env,pname,params); -} - -GL_API void GL_APIENTRY glGetTexEnviv( GLenum env, GLenum pname, GLint *params) { - GET_CTX() - ctx->dispatcher().glGetTexEnviv(env,pname,params); -} - -GL_API void GL_APIENTRY glGetTexEnvxv( GLenum env, GLenum pname, GLfixed *params) { - GET_CTX() - GLfloat tmpParams[4]; - - ctx->dispatcher().glGetTexEnvfv(env,pname,tmpParams); - if(pname == GL_TEXTURE_ENV_MODE) { - params[0] = static_cast<GLfixed>(tmpParams[0]); - } else { - for(int i=0 ; i < 4 ; i++) - params[i] = F2X(tmpParams[i]); - } -} - -GL_API void GL_APIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params) { - GET_CTX() - if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - for (int i=0;i<4;++i) - params[i] = texData->crop_rect[i]; - } - else { - ctx->dispatcher().glGetTexParameterfv(target,pname,params); - } -} - -GL_API void GL_APIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint *params) { - GET_CTX() - if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - for (int i=0;i<4;++i) - params[i] = texData->crop_rect[i]; - } - else { - ctx->dispatcher().glGetTexParameteriv(target,pname,params); - } -} - -GL_API void GL_APIENTRY glGetTexParameterxv( GLenum target, GLenum pname, GLfixed *params) { - GET_CTX() - if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - for (int i=0;i<4;++i) - params[i] = F2X(texData->crop_rect[i]); - } - else { - GLfloat tmpParam; - ctx->dispatcher().glGetTexParameterfv(target,pname,&tmpParam); - params[0] = static_cast<GLfixed>(tmpParam); - } -} - -GL_API void GL_APIENTRY glHint( GLenum target, GLenum mode) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::hintTargetMode(target,mode),GL_INVALID_ENUM); - ctx->dispatcher().glHint(target,mode); -} - -GL_API void GL_APIENTRY glLightModelf( GLenum pname, GLfloat param) { - GET_CTX() - ctx->dispatcher().glLightModelf(pname,param); -} - -GL_API void GL_APIENTRY glLightModelfv( GLenum pname, const GLfloat *params) { - GET_CTX() - ctx->dispatcher().glLightModelfv(pname,params); -} - -GL_API void GL_APIENTRY glLightModelx( GLenum pname, GLfixed param) { - GET_CTX() - GLfloat tmpParam = static_cast<GLfloat>(param); - ctx->dispatcher().glLightModelf(pname,tmpParam); -} - -GL_API void GL_APIENTRY glLightModelxv( GLenum pname, const GLfixed *params) { - GET_CTX() - GLfloat tmpParams[4]; - if(pname == GL_LIGHT_MODEL_TWO_SIDE) { - tmpParams[0] = X2F(params[0]); - } else if (pname == GL_LIGHT_MODEL_AMBIENT) { - for(int i=0;i<4;i++) { - tmpParams[i] = X2F(params[i]); - } - } - - ctx->dispatcher().glLightModelfv(pname,tmpParams); -} - -GL_API void GL_APIENTRY glLightf( GLenum light, GLenum pname, GLfloat param) { - GET_CTX() - ctx->dispatcher().glLightf(light,pname,param); -} - -GL_API void GL_APIENTRY glLightfv( GLenum light, GLenum pname, const GLfloat *params) { - GET_CTX() - ctx->dispatcher().glLightfv(light,pname,params); -} - -GL_API void GL_APIENTRY glLightx( GLenum light, GLenum pname, GLfixed param) { - GET_CTX() - ctx->dispatcher().glLightf(light,pname,X2F(param)); -} - -GL_API void GL_APIENTRY glLightxv( GLenum light, GLenum pname, const GLfixed *params) { - GET_CTX() - GLfloat tmpParams[4]; - - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_EMISSION: - case GL_POSITION: - tmpParams[3] = X2F(params[3]); - case GL_SPOT_DIRECTION: - tmpParams[2] = X2F(params[2]); - tmpParams[1] = X2F(params[1]); - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - tmpParams[0] = X2F(params[0]); - break; - default: { - ctx->setGLerror(GL_INVALID_ENUM); - return; - } - } - ctx->dispatcher().glLightfv(light,pname,tmpParams); -} - -GL_API void GL_APIENTRY glLineWidth( GLfloat width) { - GET_CTX() - ctx->dispatcher().glLineWidth(width); -} - -GL_API void GL_APIENTRY glLineWidthx( GLfixed width) { - GET_CTX() - ctx->dispatcher().glLineWidth(X2F(width)); -} - -GL_API void GL_APIENTRY glLoadIdentity( void) { - GET_CTX() - ctx->dispatcher().glLoadIdentity(); -} - -GL_API void GL_APIENTRY glLoadMatrixf( const GLfloat *m) { - GET_CTX() - ctx->dispatcher().glLoadMatrixf(m); -} - -GL_API void GL_APIENTRY glLoadMatrixx( const GLfixed *m) { - GET_CTX() - GLfloat mat[16]; - for(int i=0; i< 16 ; i++) { - mat[i] = X2F(m[i]); - } - ctx->dispatcher().glLoadMatrixf(mat); -} - -GL_API void GL_APIENTRY glLogicOp( GLenum opcode) { - GET_CTX() - ctx->dispatcher().glLogicOp(opcode); -} - -GL_API void GL_APIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param) { - GET_CTX() - ctx->dispatcher().glMaterialf(face,pname,param); -} - -GL_API void GL_APIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params) { - GET_CTX() - ctx->dispatcher().glMaterialfv(face,pname,params); -} - -GL_API void GL_APIENTRY glMaterialx( GLenum face, GLenum pname, GLfixed param) { - GET_CTX() - ctx->dispatcher().glMaterialf(face,pname,X2F(param)); -} - -GL_API void GL_APIENTRY glMaterialxv( GLenum face, GLenum pname, const GLfixed *params) { - GET_CTX() - GLfloat tmpParams[4]; - - for(int i=0; i< 4; i++) { - tmpParams[i] = X2F(params[i]); - } - ctx->dispatcher().glMaterialfv(face,pname,tmpParams); -} - -GL_API void GL_APIENTRY glMatrixMode( GLenum mode) { - GET_CTX() - ctx->dispatcher().glMatrixMode(mode); -} - -GL_API void GL_APIENTRY glMultMatrixf( const GLfloat *m) { - GET_CTX() - ctx->dispatcher().glMultMatrixf(m); -} - -GL_API void GL_APIENTRY glMultMatrixx( const GLfixed *m) { - GET_CTX() - GLfloat mat[16]; - for(int i=0; i< 16 ; i++) { - mat[i] = X2F(m[i]); - } - ctx->dispatcher().glMultMatrixf(mat); -} - -GL_API void GL_APIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) { - GET_CTX_CM() - SET_ERROR_IF(!GLEScmValidate::textureEnum(target,ctx->getMaxTexUnits()),GL_INVALID_ENUM); - ctx->dispatcher().glMultiTexCoord4f(target,s,t,r,q); -} - -GL_API void GL_APIENTRY glMultiTexCoord4x( GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) { - GET_CTX_CM() - SET_ERROR_IF(!GLEScmValidate::textureEnum(target,ctx->getMaxTexUnits()),GL_INVALID_ENUM); - ctx->dispatcher().glMultiTexCoord4f(target,X2F(s),X2F(t),X2F(r),X2F(q)); -} - -GL_API void GL_APIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz) { - GET_CTX() - ctx->dispatcher().glNormal3f(nx,ny,nz); -} - -GL_API void GL_APIENTRY glNormal3x( GLfixed nx, GLfixed ny, GLfixed nz) { - GET_CTX() - ctx->dispatcher().glNormal3f(X2F(nx),X2F(ny),X2F(nz)); -} - -GL_API void GL_APIENTRY glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer) { - GET_CTX() - SET_ERROR_IF(stride < 0,GL_INVALID_VALUE); - SET_ERROR_IF(!GLEScmValidate::normalPointerType(type),GL_INVALID_ENUM); - ctx->setPointer(GL_NORMAL_ARRAY,3,type,stride,pointer);//3 normal verctor -} - -GL_API void GL_APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) { - GET_CTX() - ctx->dispatcher().glOrtho(left,right,bottom,top,zNear,zFar); -} - -GL_API void GL_APIENTRY glOrthox( GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) { - GET_CTX() - ctx->dispatcher().glOrtho(X2F(left),X2F(right),X2F(bottom),X2F(top),X2F(zNear),X2F(zFar)); -} - -GL_API void GL_APIENTRY glPixelStorei( GLenum pname, GLint param) { - GET_CTX() - SET_ERROR_IF(!(pname == GL_PACK_ALIGNMENT || pname == GL_UNPACK_ALIGNMENT),GL_INVALID_ENUM); - SET_ERROR_IF(!((param==1)||(param==2)||(param==4)||(param==8)), GL_INVALID_VALUE); - ctx->setUnpackAlignment(param); - ctx->dispatcher().glPixelStorei(pname,param); -} - -GL_API void GL_APIENTRY glPointParameterf( GLenum pname, GLfloat param) { - GET_CTX() - ctx->dispatcher().glPointParameterf(pname,param); -} - -GL_API void GL_APIENTRY glPointParameterfv( GLenum pname, const GLfloat *params) { - GET_CTX() - ctx->dispatcher().glPointParameterfv(pname,params); -} - -GL_API void GL_APIENTRY glPointParameterx( GLenum pname, GLfixed param) -{ - GET_CTX() - ctx->dispatcher().glPointParameterf(pname,X2F(param)); -} - -GL_API void GL_APIENTRY glPointParameterxv( GLenum pname, const GLfixed *params) { - GET_CTX() - - GLfloat tmpParam = X2F(*params) ; - ctx->dispatcher().glPointParameterfv(pname,&tmpParam); -} - -GL_API void GL_APIENTRY glPointSize( GLfloat size) { - GET_CTX() - ctx->dispatcher().glPointSize(size); -} - -GL_API void GL_APIENTRY glPointSizePointerOES( GLenum type, GLsizei stride, const GLvoid *pointer) { - GET_CTX() - SET_ERROR_IF(stride < 0,GL_INVALID_VALUE); - SET_ERROR_IF(!GLEScmValidate::pointPointerType(type),GL_INVALID_ENUM); - ctx->setPointer(GL_POINT_SIZE_ARRAY_OES,1,type,stride,pointer); -} - -GL_API void GL_APIENTRY glPointSizex( GLfixed size) { - GET_CTX() - ctx->dispatcher().glPointSize(X2F(size)); -} - -GL_API void GL_APIENTRY glPolygonOffset( GLfloat factor, GLfloat units) { - GET_CTX() - ctx->dispatcher().glPolygonOffset(factor,units); -} - -GL_API void GL_APIENTRY glPolygonOffsetx( GLfixed factor, GLfixed units) { - GET_CTX() - ctx->dispatcher().glPolygonOffset(X2F(factor),X2F(units)); -} - -GL_API void GL_APIENTRY glPopMatrix(void) { - GET_CTX() - ctx->dispatcher().glPopMatrix(); -} - -GL_API void GL_APIENTRY glPushMatrix(void) { - GET_CTX() - ctx->dispatcher().glPushMatrix(); -} - -GL_API void GL_APIENTRY glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) { - GET_CTX() - SET_ERROR_IF(!(GLEScmValidate::pixelFrmt(ctx,format) && GLEScmValidate::pixelType(ctx,type)),GL_INVALID_ENUM); - SET_ERROR_IF(!(GLEScmValidate::pixelOp(format,type)),GL_INVALID_OPERATION); - - ctx->dispatcher().glReadPixels(x,y,width,height,format,type,pixels); -} - -GL_API void GL_APIENTRY glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { - GET_CTX() - ctx->dispatcher().glRotatef(angle,x,y,z); -} - -GL_API void GL_APIENTRY glRotatex( GLfixed angle, GLfixed x, GLfixed y, GLfixed z) { - GET_CTX() - ctx->dispatcher().glRotatef(angle,X2F(x),X2F(y),X2F(z)); -} - -GL_API void GL_APIENTRY glSampleCoverage( GLclampf value, GLboolean invert) { - GET_CTX() - ctx->dispatcher().glSampleCoverage(value,invert); -} - -GL_API void GL_APIENTRY glSampleCoveragex( GLclampx value, GLboolean invert) { - GET_CTX() - ctx->dispatcher().glSampleCoverage(X2F(value),invert); -} - -GL_API void GL_APIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z) { - GET_CTX() - ctx->dispatcher().glScalef(x,y,z); -} - -GL_API void GL_APIENTRY glScalex( GLfixed x, GLfixed y, GLfixed z) { - GET_CTX() - ctx->dispatcher().glScalef(X2F(x),X2F(y),X2F(z)); -} - -GL_API void GL_APIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height) { - GET_CTX() - ctx->dispatcher().glScissor(x,y,width,height); -} - -GL_API void GL_APIENTRY glShadeModel( GLenum mode) { - GET_CTX() - ctx->dispatcher().glShadeModel(mode); -} - -GL_API void GL_APIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask) { - GET_CTX() - ctx->dispatcher().glStencilFunc(func,ref,mask); -} - -GL_API void GL_APIENTRY glStencilMask( GLuint mask) { - GET_CTX() - ctx->dispatcher().glStencilMask(mask); -} - -GL_API void GL_APIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass) { - GET_CTX() - SET_ERROR_IF(!(GLEScmValidate::stencilOp(fail) && GLEScmValidate::stencilOp(zfail) && GLEScmValidate::stencilOp(zpass)),GL_INVALID_ENUM); - ctx->dispatcher().glStencilOp(fail,zfail,zpass); -} - -GL_API void GL_APIENTRY glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texCoordPointerParams(size,stride),GL_INVALID_VALUE); - SET_ERROR_IF(!GLEScmValidate::texCoordPointerType(type),GL_INVALID_ENUM); - ctx->setPointer(GL_TEXTURE_COORD_ARRAY,size,type,stride,pointer); -} - -GL_API void GL_APIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM); - ctx->dispatcher().glTexEnvf(target,pname,param); -} - -GL_API void GL_APIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM); - ctx->dispatcher().glTexEnvfv(target,pname,params); -} - -GL_API void GL_APIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM); - ctx->dispatcher().glTexEnvi(target,pname,param); -} - -GL_API void GL_APIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM); - ctx->dispatcher().glTexEnviv(target,pname,params); -} - -GL_API void GL_APIENTRY glTexEnvx( GLenum target, GLenum pname, GLfixed param) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM); - GLfloat tmpParam = static_cast<GLfloat>(param); - ctx->dispatcher().glTexEnvf(target,pname,tmpParam); -} - -GL_API void GL_APIENTRY glTexEnvxv( GLenum target, GLenum pname, const GLfixed *params) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texEnv(target,pname),GL_INVALID_ENUM); - - GLfloat tmpParams[4]; - if(pname == GL_TEXTURE_ENV_COLOR) { - for(int i =0;i<4;i++) { - tmpParams[i] = X2F(params[i]); - } - } else { - tmpParams[0] = static_cast<GLfloat>(params[0]); - } - ctx->dispatcher().glTexEnvfv(target,pname,tmpParams); -} - -GL_API void GL_APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { - GET_CTX() - - SET_ERROR_IF(!(GLEScmValidate::textureTargetEx(target) && - GLEScmValidate::pixelFrmt(ctx,internalformat) && - GLEScmValidate::pixelFrmt(ctx,format) && - GLEScmValidate::pixelType(ctx,type)),GL_INVALID_ENUM); - - SET_ERROR_IF(!(GLEScmValidate::pixelOp(format,type) && internalformat == ((GLint)format)),GL_INVALID_OPERATION); - - bool needAutoMipmap = false; - - if (ctx->shareGroup().Ptr()){ - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - if(texData) { - texData->width = width; - texData->height = height; - texData->border = border; - texData->internalFormat = internalformat; - texData->target = target; - - if (texData->sourceEGLImage != 0) { - // - // This texture was a target of EGLImage, - // but now it is re-defined so we need to detach - // from the EGLImage and re-generate global texture name - // for it. - // - if (texData->eglImageDetach) { - (*texData->eglImageDetach)(texData->sourceEGLImage); - } - unsigned int tex = ctx->getBindedTexture(target); - ctx->shareGroup()->replaceGlobalName(TEXTURE, - tex, - texData->oldGlobal); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, texData->oldGlobal); - texData->sourceEGLImage = 0; - texData->oldGlobal = 0; - } - - needAutoMipmap = texData->requiresAutoMipmap; - } - } - - ctx->dispatcher().glTexImage2D(target,level, - internalformat,width,height, - border,format,type,pixels); - - if(needAutoMipmap) - { - ctx->dispatcher().glGenerateMipmapEXT(target); - } -} - -static bool handleMipmapGeneration(GLenum target, GLenum pname, bool param) -{ - GET_CTX_RET(false) - - if(pname == GL_GENERATE_MIPMAP && !ctx->isAutoMipmapSupported()) - { - TextureData *texData = getTextureTargetData(target); - if(texData) - { - texData->requiresAutoMipmap = param; - } - return true; - } - - return false; -} - -GL_API void GL_APIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - - if(handleMipmapGeneration(target, pname, (bool)param)) - return; - - ctx->dispatcher().glTexParameterf(target,pname,param); -} - -GL_API void GL_APIENTRY glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - - if(handleMipmapGeneration(target, pname, (bool)(*params))) - return; - - if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - for (int i=0;i<4;++i) - texData->crop_rect[i] = params[i]; - } - else { - ctx->dispatcher().glTexParameterfv(target,pname,params); - } -} - -GL_API void GL_APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - - if(handleMipmapGeneration(target, pname, (bool)param)) - return; - - ctx->dispatcher().glTexParameteri(target,pname,param); -} - -GL_API void GL_APIENTRY glTexParameteriv( GLenum target, GLenum pname, const GLint *params) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - - if(handleMipmapGeneration(target, pname, (bool)(*params))) - return; - - if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - for (int i=0;i<4;++i) - texData->crop_rect[i] = params[i]; - } - else { - ctx->dispatcher().glTexParameteriv(target,pname,params); - } -} - -GL_API void GL_APIENTRY glTexParameterx( GLenum target, GLenum pname, GLfixed param) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - - if(handleMipmapGeneration(target, pname, (bool)param)) - return; - - ctx->dispatcher().glTexParameterf(target,pname,static_cast<GLfloat>(param)); -} - -GL_API void GL_APIENTRY glTexParameterxv( GLenum target, GLenum pname, const GLfixed *params) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texParams(target,pname),GL_INVALID_ENUM); - - if(handleMipmapGeneration(target, pname, (bool)(*params))) - return; - - if (pname==GL_TEXTURE_CROP_RECT_OES) { - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - for (int i=0;i<4;++i) - texData->crop_rect[i] = X2F(params[i]); - } - else { - GLfloat param = static_cast<GLfloat>(params[0]); - ctx->dispatcher().glTexParameterfv(target,pname,¶m); - } -} - -GL_API void GL_APIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) { - GET_CTX() - SET_ERROR_IF(!(GLEScmValidate::textureTargetEx(target) && - GLEScmValidate::pixelFrmt(ctx,format)&& - GLEScmValidate::pixelType(ctx,type)),GL_INVALID_ENUM); - SET_ERROR_IF(!GLEScmValidate::pixelOp(format,type),GL_INVALID_OPERATION); - - ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels); - - if (ctx->shareGroup().Ptr()){ - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - if(texData && texData->requiresAutoMipmap) - { - ctx->dispatcher().glGenerateMipmapEXT(target); - } - } -} - -GL_API void GL_APIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z) { - GET_CTX() - ctx->dispatcher().glTranslatef(x,y,z); -} - -GL_API void GL_APIENTRY glTranslatex( GLfixed x, GLfixed y, GLfixed z) { - GET_CTX() - ctx->dispatcher().glTranslatef(X2F(x),X2F(y),X2F(z)); -} - -GL_API void GL_APIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::vertexPointerParams(size,stride),GL_INVALID_VALUE); - SET_ERROR_IF(!GLEScmValidate::vertexPointerType(type),GL_INVALID_ENUM); - ctx->setPointer(GL_VERTEX_ARRAY,size,type,stride,pointer); -} - -GL_API void GL_APIENTRY glViewport( GLint x, GLint y, GLsizei width, GLsizei height) { - GET_CTX() - ctx->dispatcher().glViewport(x,y,width,height); -} - -GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) -{ - GET_CTX(); - SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM); - unsigned int imagehndl = SafeUIntFromPointer(image); - 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 - // current binded texture object to the existing global object. - if (ctx->shareGroup().Ptr()) { - ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target)); - unsigned int oldGlobal = ctx->shareGroup()->getGlobalName(TEXTURE, tex); - // Delete old texture object but only if it is not a target of a EGLImage - if (oldGlobal) { - TextureData* oldTexData = getTextureData(tex); - if (!oldTexData || oldTexData->sourceEGLImage == 0) { - ctx->dispatcher().glDeleteTextures(1, &oldGlobal); - } - } - // replace mapping and bind the new global object - ctx->shareGroup()->replaceGlobalName(TEXTURE, tex,img->globalTexName); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName); - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - texData->width = img->width; - texData->height = img->height; - texData->border = img->border; - texData->internalFormat = img->internalFormat; - texData->sourceEGLImage = imagehndl; - texData->eglImageDetach = s_eglIface->eglDetachEGLImage; - texData->oldGlobal = oldGlobal; - } - } -} - -GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) -{ - GET_CTX(); - SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM); - unsigned int imagehndl = SafeUIntFromPointer(image); - EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl); - SET_ERROR_IF(!img,GL_INVALID_VALUE); - SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION); - - // Get current bounded renderbuffer - // raise INVALID_OPERATIOn if no renderbuffer is bounded - GLuint rb = ctx->getRenderbufferBinding(); - SET_ERROR_IF(rb == 0,GL_INVALID_OPERATION); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(RENDERBUFFER,rb); - RenderbufferData *rbData = (RenderbufferData *)objData.Ptr(); - SET_ERROR_IF(!rbData,GL_INVALID_OPERATION); - - // - // flag in the renderbufferData that it is an eglImage target - // - rbData->sourceEGLImage = imagehndl; - rbData->eglImageDetach = s_eglIface->eglDetachEGLImage; - rbData->eglImageGlobalTexName = img->globalTexName; - - // - // if the renderbuffer is attached to a framebuffer - // change the framebuffer attachment in the undelying OpenGL - // to point to the eglImage texture object. - // - if (rbData->attachedFB) { - // update the framebuffer attachment point to the - // underlying texture of the img - GLuint prevFB = ctx->getFramebufferBinding(); - if (prevFB != rbData->attachedFB) { - ctx->dispatcher().glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, - rbData->attachedFB); - } - ctx->dispatcher().glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, - rbData->attachedPoint, - GL_TEXTURE_2D, - img->globalTexName,0); - if (prevFB != rbData->attachedFB) { - ctx->dispatcher().glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, - prevFB); - } - } -} - -/* GL_OES_blend_subtract*/ -GL_API void GL_APIENTRY glBlendEquationOES(GLenum mode) { - GET_CTX() - SET_ERROR_IF(!(GLEScmValidate::blendEquationMode(mode)), GL_INVALID_ENUM); - ctx->dispatcher().glBlendEquation(mode); -} - -/* GL_OES_blend_equation_separate */ -GL_API void GL_APIENTRY glBlendEquationSeparateOES (GLenum modeRGB, GLenum modeAlpha) { - GET_CTX() - SET_ERROR_IF(!(GLEScmValidate::blendEquationMode(modeRGB) && GLEScmValidate::blendEquationMode(modeAlpha)), GL_INVALID_ENUM); - ctx->dispatcher().glBlendEquationSeparate(modeRGB,modeAlpha); -} - -/* GL_OES_blend_func_separate */ -GL_API void GL_APIENTRY glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::blendSrc(srcRGB) || !GLEScmValidate::blendDst(dstRGB) || - !GLEScmValidate::blendSrc(srcAlpha) || ! GLEScmValidate::blendDst(dstAlpha) ,GL_INVALID_ENUM); - ctx->dispatcher().glBlendFuncSeparate(srcRGB,dstRGB,srcAlpha,dstAlpha); -} - -/* GL_OES_framebuffer_object */ -GL_API GLboolean GL_APIENTRY glIsRenderbufferOES(GLuint renderbuffer) { - GET_CTX_RET(GL_FALSE) - RET_AND_SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION,GL_FALSE); - if(renderbuffer && ctx->shareGroup().Ptr()){ - return ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer) ? GL_TRUE :GL_FALSE; - } - return ctx->dispatcher().glIsRenderbufferEXT(renderbuffer); -} - -GL_API void GLAPIENTRY glBindRenderbufferOES(GLenum target, GLuint renderbuffer) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(!GLEScmValidate::renderbufferTarget(target),GL_INVALID_ENUM); - - //if buffer wasn't generated before,generate one - if(renderbuffer && ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer)){ - ctx->shareGroup()->genName(RENDERBUFFER,renderbuffer); - ctx->shareGroup()->setObjectData(RENDERBUFFER, - renderbuffer, - ObjectDataPtr(new RenderbufferData())); - } - - int globalBufferName = (renderbuffer != 0) ? ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer) : 0; - ctx->dispatcher().glBindRenderbufferEXT(target,globalBufferName); - - // update renderbuffer binding state - ctx->setRenderbufferBinding(renderbuffer); -} - -GL_API void GLAPIENTRY glDeleteRenderbuffersOES(GLsizei n, const GLuint *renderbuffers) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - for (int i=0;i<n;++i) { - GLuint globalBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffers[i]); - ctx->dispatcher().glDeleteRenderbuffersEXT(1,&globalBufferName); - } -} - -GL_API void GLAPIENTRY glGenRenderbuffersOES(GLsizei n, GLuint *renderbuffers) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i<n ;i++) { - renderbuffers[i] = ctx->shareGroup()->genName(RENDERBUFFER, 0, true); - ctx->shareGroup()->setObjectData(RENDERBUFFER, - renderbuffers[i], - ObjectDataPtr(new RenderbufferData())); - } - } -} - -GL_API void GLAPIENTRY glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height){ - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(!GLEScmValidate::renderbufferTarget(target) || !GLEScmValidate::renderbufferInternalFrmt(ctx,internalformat) ,GL_INVALID_ENUM); - if (internalformat==GL_RGB565_OES) //RGB565 not supported by GL - internalformat = GL_RGB8_OES; - - // Get current bounded renderbuffer - // raise INVALID_OPERATIOn if no renderbuffer is bounded - GLuint rb = ctx->getRenderbufferBinding(); - SET_ERROR_IF(rb == 0,GL_INVALID_OPERATION); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(RENDERBUFFER,rb); - RenderbufferData *rbData = (RenderbufferData *)objData.Ptr(); - SET_ERROR_IF(!rbData,GL_INVALID_OPERATION); - - // - // if the renderbuffer was an eglImage target, detach from - // the eglImage. - // - if (rbData->sourceEGLImage != 0) { - if (rbData->eglImageDetach) { - (*rbData->eglImageDetach)(rbData->sourceEGLImage); - } - rbData->sourceEGLImage = 0; - rbData->eglImageGlobalTexName = 0; - } - - ctx->dispatcher().glRenderbufferStorageEXT(target,internalformat,width,height); -} - -GL_API void GLAPIENTRY glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(!GLEScmValidate::renderbufferTarget(target) || !GLEScmValidate::renderbufferParams(pname) ,GL_INVALID_ENUM); - - // - // If this is a renderbuffer which is eglimage's target, we - // should query the underlying eglimage's texture object instead. - // - GLuint rb = ctx->getRenderbufferBinding(); - if (rb) { - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(RENDERBUFFER,rb); - RenderbufferData *rbData = (RenderbufferData *)objData.Ptr(); - if (rbData && rbData->sourceEGLImage != 0) { - GLenum texPname; - switch(pname) { - case GL_RENDERBUFFER_WIDTH_OES: - texPname = GL_TEXTURE_WIDTH; - break; - case GL_RENDERBUFFER_HEIGHT_OES: - texPname = GL_TEXTURE_HEIGHT; - break; - case GL_RENDERBUFFER_INTERNAL_FORMAT_OES: - texPname = GL_TEXTURE_INTERNAL_FORMAT; - break; - case GL_RENDERBUFFER_RED_SIZE_OES: - texPname = GL_TEXTURE_RED_SIZE; - break; - case GL_RENDERBUFFER_GREEN_SIZE_OES: - texPname = GL_TEXTURE_GREEN_SIZE; - break; - case GL_RENDERBUFFER_BLUE_SIZE_OES: - texPname = GL_TEXTURE_BLUE_SIZE; - break; - case GL_RENDERBUFFER_ALPHA_SIZE_OES: - texPname = GL_TEXTURE_ALPHA_SIZE; - break; - case GL_RENDERBUFFER_DEPTH_SIZE_OES: - texPname = GL_TEXTURE_DEPTH_SIZE; - break; - case GL_RENDERBUFFER_STENCIL_SIZE_OES: - default: - *params = 0; //XXX - return; - break; - } - - GLint prevTex; - ctx->dispatcher().glGetIntegerv(GL_TEXTURE_BINDING_2D, &prevTex); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, - rbData->eglImageGlobalTexName); - ctx->dispatcher().glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, - texPname, - params); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, prevTex); - return; - } - } - - ctx->dispatcher().glGetRenderbufferParameterivEXT(target,pname,params); -} - -GL_API GLboolean GLAPIENTRY glIsFramebufferOES(GLuint framebuffer) { - GET_CTX_RET(GL_FALSE) - RET_AND_SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION,GL_FALSE); - if (framebuffer && ctx->shareGroup().Ptr()) { - return ctx->shareGroup()->isObject(FRAMEBUFFER,framebuffer) ? GL_TRUE : GL_FALSE; - } - return ctx->dispatcher().glIsFramebufferEXT(framebuffer); -} - -GL_API void GLAPIENTRY glBindFramebufferOES(GLenum target, GLuint framebuffer) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) ,GL_INVALID_ENUM); - if (framebuffer && ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(FRAMEBUFFER,framebuffer)) { - ctx->shareGroup()->genName(FRAMEBUFFER,framebuffer); - ctx->shareGroup()->setObjectData(FRAMEBUFFER, framebuffer, - ObjectDataPtr(new FramebufferData(framebuffer))); - } - int globalBufferName = (framebuffer!=0) ? ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffer) : 0; - ctx->dispatcher().glBindFramebufferEXT(target,globalBufferName); - - // update framebuffer binding state - ctx->setFramebufferBinding(framebuffer); -} - -GL_API void GLAPIENTRY glDeleteFramebuffersOES(GLsizei n, const GLuint *framebuffers) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - for (int i=0;i<n;++i) { - GLuint globalBufferName = ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffers[i]); - ctx->dispatcher().glDeleteFramebuffersEXT(1,&globalBufferName); - } -} - -GL_API void GLAPIENTRY glGenFramebuffersOES(GLsizei n, GLuint *framebuffers) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if (ctx->shareGroup().Ptr()) { - for (int i=0;i<n;i++) { - framebuffers[i] = ctx->shareGroup()->genName(FRAMEBUFFER, 0, true); - ctx->shareGroup()->setObjectData(FRAMEBUFFER, framebuffers[i], - ObjectDataPtr(new FramebufferData(framebuffers[i]))); - } - } -} - -GL_API GLenum GLAPIENTRY glCheckFramebufferStatusOES(GLenum target) { - GET_CTX_RET(0) - RET_AND_SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION,0); - RET_AND_SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) ,GL_INVALID_ENUM,0); - return ctx->dispatcher().glCheckFramebufferStatusEXT(target); -} - -GL_API void GLAPIENTRY glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) || !GLEScmValidate::framebufferAttachment(attachment) || - !GLEScmValidate::textureTargetEx(textarget),GL_INVALID_ENUM); - SET_ERROR_IF(!ctx->shareGroup().Ptr(), GL_INVALID_OPERATION); - - GLuint globalTexName = 0; - if(texture) { - if (!ctx->shareGroup()->isObject(TEXTURE,texture)) { - ctx->shareGroup()->genName(TEXTURE,texture); - } - ObjectLocalName texname = TextureLocalName(textarget,texture); - globalTexName = ctx->shareGroup()->getGlobalName(TEXTURE,texname); - } - - ctx->dispatcher().glFramebufferTexture2DEXT(target,attachment,textarget,globalTexName,level); - - // Update the the current framebuffer object attachment state - GLuint fbName = ctx->getFramebufferBinding(); - ObjectDataPtr fbObj = ctx->shareGroup()->getObjectData(FRAMEBUFFER,fbName); - if (fbObj.Ptr() != NULL) { - FramebufferData *fbData = (FramebufferData *)fbObj.Ptr(); - fbData->setAttachment(attachment, textarget, - texture, ObjectDataPtr(NULL)); - } -} - -GL_API void GLAPIENTRY glFramebufferRenderbufferOES(GLenum target, GLenum attachment,GLenum renderbuffertarget, GLuint renderbuffer) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) || - !GLEScmValidate::framebufferAttachment(attachment) || - !GLEScmValidate::renderbufferTarget(renderbuffertarget), GL_INVALID_ENUM); - - SET_ERROR_IF(!ctx->shareGroup().Ptr(), GL_INVALID_OPERATION); - - GLuint globalBufferName = 0; - ObjectDataPtr obj; - - // generate the renderbuffer object if not yet exist - if (renderbuffer) { - if (!ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer)) { - ctx->shareGroup()->genName(RENDERBUFFER,renderbuffer); - obj = ObjectDataPtr(new RenderbufferData()); - ctx->shareGroup()->setObjectData(RENDERBUFFER, - renderbuffer, - ObjectDataPtr(new RenderbufferData())); - } - else { - obj = ctx->shareGroup()->getObjectData(RENDERBUFFER,renderbuffer); - } - globalBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer); - } - - // Update the the current framebuffer object attachment state - GLuint fbName = ctx->getFramebufferBinding(); - ObjectDataPtr fbObj = ctx->shareGroup()->getObjectData(FRAMEBUFFER,fbName); - if (fbObj.Ptr() != NULL) { - FramebufferData *fbData = (FramebufferData *)fbObj.Ptr(); - fbData->setAttachment(attachment, renderbuffertarget, renderbuffer, obj); - } - - if (renderbuffer && obj.Ptr() != NULL) { - RenderbufferData *rbData = (RenderbufferData *)obj.Ptr(); - if (rbData->sourceEGLImage != 0) { - // - // This renderbuffer object is an eglImage target - // attach the eglimage's texture instead the renderbuffer. - // - ctx->dispatcher().glFramebufferTexture2DEXT(target, - attachment, - GL_TEXTURE_2D, - rbData->eglImageGlobalTexName,0); - return; - } - } - - ctx->dispatcher().glFramebufferRenderbufferEXT(target,attachment,renderbuffertarget,globalBufferName); -} - -GL_API void GLAPIENTRY glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint *params) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(!GLEScmValidate::framebufferTarget(target) || !GLEScmValidate::framebufferAttachment(attachment) || - !GLEScmValidate::framebufferAttachmentParams(pname), GL_INVALID_ENUM); - - // - // Take the attachment attribute from our state - if available - // - GLuint fbName = ctx->getFramebufferBinding(); - if (fbName) { - ObjectDataPtr fbObj = ctx->shareGroup()->getObjectData(FRAMEBUFFER,fbName); - if (fbObj.Ptr() != NULL) { - FramebufferData *fbData = (FramebufferData *)fbObj.Ptr(); - GLenum target; - GLuint name = fbData->getAttachment(attachment, &target, NULL); - if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES) { - *params = target; - return; - } - else if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES) { - *params = name; - return; - } - } - } - - ctx->dispatcher().glGetFramebufferAttachmentParameterivEXT(target,attachment,pname,params); -} - -GL_API void GL_APIENTRY glGenerateMipmapOES(GLenum target) { - GET_CTX() - SET_ERROR_IF(!ctx->getCaps()->GL_EXT_FRAMEBUFFER_OBJECT,GL_INVALID_OPERATION); - SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM); - ctx->dispatcher().glGenerateMipmapEXT(target); -} - -GL_API void GL_APIENTRY glCurrentPaletteMatrixOES(GLuint index) { - GET_CTX() - SET_ERROR_IF(!(ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND),GL_INVALID_OPERATION); - ctx->dispatcher().glCurrentPaletteMatrixARB(index); -} - -GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES() { - GET_CTX() - SET_ERROR_IF(!(ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND),GL_INVALID_OPERATION); - GLint matrix[16]; - ctx->dispatcher().glGetIntegerv(GL_MODELVIEW_MATRIX,matrix); - ctx->dispatcher().glMatrixIndexuivARB(1,(GLuint*)matrix); - -} - -GL_API void GL_APIENTRY glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { - GET_CTX() - SET_ERROR_IF(!(ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND),GL_INVALID_OPERATION); - ctx->dispatcher().glMatrixIndexPointerARB(size,type,stride,pointer); -} - -GL_API void GL_APIENTRY glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { - GET_CTX() - SET_ERROR_IF(!(ctx->getCaps()->GL_ARB_MATRIX_PALETTE && ctx->getCaps()->GL_ARB_VERTEX_BLEND),GL_INVALID_OPERATION); - ctx->dispatcher().glWeightPointerARB(size,type,stride,pointer); - -} - -GL_API void GL_APIENTRY glTexGenfOES (GLenum coord, GLenum pname, GLfloat param) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM); - if (coord == GL_TEXTURE_GEN_STR_OES) { - ctx->dispatcher().glTexGenf(GL_S,pname,param); - ctx->dispatcher().glTexGenf(GL_T,pname,param); - ctx->dispatcher().glTexGenf(GL_R,pname,param); - } - else - ctx->dispatcher().glTexGenf(coord,pname,param); -} - -GL_API void GL_APIENTRY glTexGenfvOES (GLenum coord, GLenum pname, const GLfloat *params) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM); - if (coord == GL_TEXTURE_GEN_STR_OES) { - ctx->dispatcher().glTexGenfv(GL_S,pname,params); - ctx->dispatcher().glTexGenfv(GL_T,pname,params); - ctx->dispatcher().glTexGenfv(GL_R,pname,params); - } - else - ctx->dispatcher().glTexGenfv(coord,pname,params); -} -GL_API void GL_APIENTRY glTexGeniOES (GLenum coord, GLenum pname, GLint param) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM); - if (coord == GL_TEXTURE_GEN_STR_OES) { - ctx->dispatcher().glTexGeni(GL_S,pname,param); - ctx->dispatcher().glTexGeni(GL_T,pname,param); - ctx->dispatcher().glTexGeni(GL_R,pname,param); - } - else - ctx->dispatcher().glTexGeni(coord,pname,param); -} -GL_API void GL_APIENTRY glTexGenivOES (GLenum coord, GLenum pname, const GLint *params) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM); - if (coord == GL_TEXTURE_GEN_STR_OES) { - ctx->dispatcher().glTexGeniv(GL_S,pname,params); - ctx->dispatcher().glTexGeniv(GL_T,pname,params); - ctx->dispatcher().glTexGeniv(GL_R,pname,params); - } - else - ctx->dispatcher().glTexGeniv(coord,pname,params); -} -GL_API void GL_APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param) { - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM); - if (coord == GL_TEXTURE_GEN_STR_OES) { - ctx->dispatcher().glTexGenf(GL_S,pname,X2F(param)); - ctx->dispatcher().glTexGenf(GL_T,pname,X2F(param)); - ctx->dispatcher().glTexGenf(GL_R,pname,X2F(param)); - } - else - ctx->dispatcher().glTexGenf(coord,pname,X2F(param)); -} -GL_API void GL_APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params) { - GLfloat tmpParams[1]; - GET_CTX() - SET_ERROR_IF(!GLEScmValidate::texGen(coord,pname),GL_INVALID_ENUM); - tmpParams[0] = X2F(params[0]); - if (coord == GL_TEXTURE_GEN_STR_OES) { - ctx->dispatcher().glTexGenfv(GL_S,pname,tmpParams); - ctx->dispatcher().glTexGenfv(GL_T,pname,tmpParams); - ctx->dispatcher().glTexGenfv(GL_R,pname,tmpParams); - } - else - ctx->dispatcher().glTexGenfv(coord,pname,tmpParams); -} - -GL_API void GL_APIENTRY glGetTexGenfvOES (GLenum coord, GLenum pname, GLfloat *params) { - GET_CTX() - if (coord == GL_TEXTURE_GEN_STR_OES) - { - GLfloat state_s = GL_FALSE; - GLfloat state_t = GL_FALSE; - GLfloat state_r = GL_FALSE; - ctx->dispatcher().glGetTexGenfv(GL_S,pname,&state_s); - ctx->dispatcher().glGetTexGenfv(GL_T,pname,&state_t); - ctx->dispatcher().glGetTexGenfv(GL_R,pname,&state_r); - *params = state_s && state_t && state_r ? GL_TRUE: GL_FALSE; - } - else - ctx->dispatcher().glGetTexGenfv(coord,pname,params); - -} -GL_API void GL_APIENTRY glGetTexGenivOES (GLenum coord, GLenum pname, GLint *params) { - GET_CTX() - if (coord == GL_TEXTURE_GEN_STR_OES) - { - GLint state_s = GL_FALSE; - GLint state_t = GL_FALSE; - GLint state_r = GL_FALSE; - ctx->dispatcher().glGetTexGeniv(GL_S,pname,&state_s); - ctx->dispatcher().glGetTexGeniv(GL_T,pname,&state_t); - ctx->dispatcher().glGetTexGeniv(GL_R,pname,&state_r); - *params = state_s && state_t && state_r ? GL_TRUE: GL_FALSE; - } - else - ctx->dispatcher().glGetTexGeniv(coord,pname,params); -} - -GL_API void GL_APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params) { - GET_CTX() - GLfloat tmpParams[1]; - - if (coord == GL_TEXTURE_GEN_STR_OES) - { - GLfloat state_s = GL_FALSE; - GLfloat state_t = GL_FALSE; - GLfloat state_r = GL_FALSE; - ctx->dispatcher().glGetTexGenfv(GL_TEXTURE_GEN_S,pname,&state_s); - ctx->dispatcher().glGetTexGenfv(GL_TEXTURE_GEN_T,pname,&state_t); - ctx->dispatcher().glGetTexGenfv(GL_TEXTURE_GEN_R,pname,&state_r); - tmpParams[0] = state_s && state_t && state_r ? GL_TRUE: GL_FALSE; - } - else - ctx->dispatcher().glGetTexGenfv(coord,pname,tmpParams); - - params[0] = F2X(tmpParams[1]); -} - -template <class T, GLenum TypeName> -void glDrawTexOES (T x, T y, T z, T width, T height) { - GET_CTX() - - SET_ERROR_IF((width<=0 || height<=0),GL_INVALID_VALUE); - - ctx->drawValidate(); - - int numClipPlanes; - - GLint viewport[4] = {}; - z = (z>1 ? 1 : (z<0 ? 0 : z)); - - T vertices[4*3] = { - x , y, z, - x , static_cast<T>(y+height), z, - static_cast<T>(x+width), static_cast<T>(y+height), z, - static_cast<T>(x+width), y, z - }; - GLfloat texels[ctx->getMaxTexUnits()][4*2]; - memset((void*)texels, 0, ctx->getMaxTexUnits()*4*2*sizeof(GLfloat)); - - ctx->dispatcher().glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); - ctx->dispatcher().glPushAttrib(GL_TRANSFORM_BIT); - - //setup projection matrix to draw in viewport aligned coordinates - ctx->dispatcher().glMatrixMode(GL_PROJECTION); - ctx->dispatcher().glPushMatrix(); - ctx->dispatcher().glLoadIdentity(); - ctx->dispatcher().glGetIntegerv(GL_VIEWPORT,viewport); - ctx->dispatcher().glOrtho(viewport[0],viewport[0] + viewport[2],viewport[1],viewport[1]+viewport[3],0,-1); - //setup texture matrix - ctx->dispatcher().glMatrixMode(GL_TEXTURE); - ctx->dispatcher().glPushMatrix(); - ctx->dispatcher().glLoadIdentity(); - //setup modelview matrix - ctx->dispatcher().glMatrixMode(GL_MODELVIEW); - ctx->dispatcher().glPushMatrix(); - ctx->dispatcher().glLoadIdentity(); - //backup vbo's - int array_buffer,element_array_buffer; - glGetIntegerv(GL_ARRAY_BUFFER_BINDING,&array_buffer); - glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING,&element_array_buffer); - ctx->dispatcher().glBindBuffer(GL_ARRAY_BUFFER,0); - ctx->dispatcher().glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0); - - //disable clip planes - ctx->dispatcher().glGetIntegerv(GL_MAX_CLIP_PLANES,&numClipPlanes); - for (int i=0;i<numClipPlanes;++i) - ctx->dispatcher().glDisable(GL_CLIP_PLANE0+i); - - int nTexPtrs = 0; - for (int i=0;i<ctx->getMaxTexUnits();++i) { - if (ctx->isTextureUnitEnabled(GL_TEXTURE0+i)) { - TextureData * texData = NULL; - unsigned int texname = ctx->getBindedTexture(GL_TEXTURE0+i,GL_TEXTURE_2D); - ObjectLocalName tex = TextureLocalName(GL_TEXTURE_2D,texname); - ctx->dispatcher().glClientActiveTexture(GL_TEXTURE0+i); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(TEXTURE,tex); - if (objData.Ptr()) { - texData = (TextureData*)objData.Ptr(); - //calculate texels - texels[i][0] = (float)(texData->crop_rect[0])/(float)(texData->width); - texels[i][1] = (float)(texData->crop_rect[1])/(float)(texData->height); - - texels[i][2] = (float)(texData->crop_rect[0])/(float)(texData->width); - texels[i][3] = (float)(texData->crop_rect[3]+texData->crop_rect[1])/(float)(texData->height); - - texels[i][4] = (float)(texData->crop_rect[2]+texData->crop_rect[0])/(float)(texData->width); - texels[i][5] = (float)(texData->crop_rect[3]+texData->crop_rect[1])/(float)(texData->height); - - texels[i][6] = (float)(texData->crop_rect[2]+texData->crop_rect[0])/(float)(texData->width); - texels[i][7] = (float)(texData->crop_rect[1])/(float)(texData->height); - - ctx->dispatcher().glTexCoordPointer(2,GL_FLOAT,0,texels[i]); - nTexPtrs++; - } - } - } - - if (nTexPtrs>0) { - //draw rectangle - only if we have some textures enabled & ready - ctx->dispatcher().glEnableClientState(GL_VERTEX_ARRAY); - ctx->dispatcher().glVertexPointer(3,TypeName,0,vertices); - ctx->dispatcher().glEnableClientState(GL_TEXTURE_COORD_ARRAY); - ctx->dispatcher().glDrawArrays(GL_TRIANGLE_FAN,0,4); - } - - //restore vbo's - ctx->dispatcher().glBindBuffer(GL_ARRAY_BUFFER,array_buffer); - ctx->dispatcher().glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,element_array_buffer); - - //restore matrix state - - ctx->dispatcher().glMatrixMode(GL_MODELVIEW); - ctx->dispatcher().glPopMatrix(); - ctx->dispatcher().glMatrixMode(GL_TEXTURE); - ctx->dispatcher().glPopMatrix(); - ctx->dispatcher().glMatrixMode(GL_PROJECTION); - ctx->dispatcher().glPopMatrix(); - - ctx->dispatcher().glPopAttrib(); - ctx->dispatcher().glPopClientAttrib(); -} - -GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) { - glDrawTexOES<GLshort,GL_SHORT>(x,y,z,width,height); -} - -GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height) { - glDrawTexOES<GLint,GL_INT>(x,y,z,width,height); -} - -GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) { - glDrawTexOES<GLfloat,GL_FLOAT>(x,y,z,width,height); -} - -GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) { - glDrawTexOES<GLfloat,GL_FLOAT>(X2F(x),X2F(y),X2F(z),X2F(width),X2F(height)); -} - -GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort * coords) { - glDrawTexOES<GLshort,GL_SHORT>(coords[0],coords[1],coords[2],coords[3],coords[4]); -} - -GL_API void GL_APIENTRY glDrawTexivOES (const GLint * coords) { - glDrawTexOES<GLint,GL_INT>(coords[0],coords[1],coords[2],coords[3],coords[4]); -} - -GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat * coords) { - glDrawTexOES<GLfloat,GL_FLOAT>(coords[0],coords[1],coords[2],coords[3],coords[4]); -} - -GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed * coords) { - glDrawTexOES<GLfloat,GL_FLOAT>(X2F(coords[0]),X2F(coords[1]),X2F(coords[2]),X2F(coords[3]),X2F(coords[4])); -} diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.cpp deleted file mode 100644 index 891b4e3..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -* 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. -*/ -#include "GLEScmUtils.h" - - -size_t glParamSize(GLenum param) -{ - size_t s = 0; - - switch(param) - { - case GL_MAX_TEXTURE_SIZE: - //case GL_TEXTURE_GEN_MODE_OES: - case GL_TEXTURE_ENV_MODE: - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_SPOT_EXPONENT: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - case GL_SHININESS: - case GL_LIGHT_MODEL_TWO_SIDE: - case GL_POINT_SIZE: - case GL_POINT_SIZE_MIN: - case GL_POINT_SIZE_MAX: - case GL_POINT_FADE_THRESHOLD_SIZE: - case GL_CULL_FACE_MODE: - case GL_FRONT_FACE: - case GL_SHADE_MODEL: - case GL_DEPTH_WRITEMASK: - case GL_DEPTH_CLEAR_VALUE: - case GL_STENCIL_FAIL: - case GL_STENCIL_PASS_DEPTH_FAIL: - case GL_STENCIL_PASS_DEPTH_PASS: - case GL_STENCIL_REF: - case GL_STENCIL_WRITEMASK: - case GL_MATRIX_MODE: - case GL_MODELVIEW_STACK_DEPTH: - case GL_PROJECTION_STACK_DEPTH: - case GL_TEXTURE_STACK_DEPTH: - case GL_ALPHA_TEST_FUNC: - case GL_ALPHA_TEST_REF: - case GL_BLEND_DST: - case GL_BLEND_SRC: - case GL_LOGIC_OP_MODE: - case GL_SCISSOR_TEST: - case GL_MAX_TEXTURE_UNITS: - s = 1; - break; - case GL_ALIASED_LINE_WIDTH_RANGE: - case GL_ALIASED_POINT_SIZE_RANGE: - case GL_DEPTH_RANGE: - case GL_MAX_VIEWPORT_DIMS: - case GL_SMOOTH_POINT_SIZE_RANGE: - case GL_SMOOTH_LINE_WIDTH_RANGE: - s= 2; - break; - case GL_SPOT_DIRECTION: - case GL_POINT_DISTANCE_ATTENUATION: - case GL_CURRENT_NORMAL: - s = 3; - break; - case GL_CURRENT_TEXTURE_COORDS: - case GL_CURRENT_COLOR: - case GL_FOG_COLOR: - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_EMISSION: - case GL_POSITION: - case GL_LIGHT_MODEL_AMBIENT: - case GL_TEXTURE_ENV_COLOR: - case GL_SCISSOR_BOX: - case GL_VIEWPORT: - //case GL_TEXTURE_CROP_RECT_OES: - s = 4; - break; - case GL_MODELVIEW_MATRIX: - case GL_PROJECTION_MATRIX: - case GL_TEXTURE_MATRIX: - s = 16; - default: - s = 1; // assume 1 - } - return s; -} diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.h b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.h deleted file mode 100644 index 38ad6bc..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmUtils.h +++ /dev/null @@ -1,22 +0,0 @@ -/* -* 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_UTILS_H -#define GLES_UTILS_H -#include <GLES/gl.h> -#include <stdlib.h> - -size_t glParamSize(GLenum param); -#endif diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.cpp deleted file mode 100644 index 1970232..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.cpp +++ /dev/null @@ -1,305 +0,0 @@ -/* -* 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. -*/ -#include "GLEScmValidate.h" -#include <GLcommon/GLutils.h> -#include <GLES/gl.h> -#include <GLES/glext.h> -#include <GLcommon/GLEScontext.h> -#include "GLEScmValidate.h" - - -bool GLEScmValidate::lightEnum(GLenum e,unsigned int maxLights) { - return e >=GL_LIGHT0 && e <= (GL_LIGHT0+maxLights); -} - -bool GLEScmValidate::clipPlaneEnum(GLenum e,unsigned int maxClipPlanes) { - return e >=GL_CLIP_PLANE0 && e <= (GL_CLIP_PLANE0+maxClipPlanes); -} - -bool GLEScmValidate::alphaFunc(GLenum f) { - switch(f) { - case GL_NEVER: - case GL_LESS: - case GL_EQUAL: - case GL_LEQUAL: - case GL_GREATER: - case GL_NOTEQUAL: - case GL_GEQUAL: - case GL_ALWAYS: - return true; - } - return false; -} - -bool GLEScmValidate::blendSrc(GLenum s) { - switch(s) { - case GL_ZERO: - case GL_ONE: - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_SRC_ALPHA_SATURATE: - return true; - } - return false; -} - -bool GLEScmValidate::vertexPointerParams(GLint size,GLsizei stride) { - return ((size >=2) && (size <= 4)) && (stride >=0) ; -} - -bool GLEScmValidate::colorPointerParams(GLint size,GLsizei stride) { - return ((size >=3) && (size <= 4)) && (stride >=0) ; -} - -bool GLEScmValidate::texCoordPointerParams(GLint size,GLsizei stride) { - return ((size >=2) && (size <= 4)) && (stride >=0) ; -} - -bool GLEScmValidate::supportedArrays(GLenum arr) { - switch(arr) { - case GL_COLOR_ARRAY: - case GL_NORMAL_ARRAY: - case GL_POINT_SIZE_ARRAY_OES: - case GL_TEXTURE_COORD_ARRAY: - case GL_VERTEX_ARRAY: - return true; - } - return false; -} - -bool GLEScmValidate::hintTargetMode(GLenum target,GLenum mode) { - switch(target) { - case GL_FOG_HINT: - case GL_GENERATE_MIPMAP_HINT: - case GL_LINE_SMOOTH_HINT: - case GL_PERSPECTIVE_CORRECTION_HINT: - case GL_POINT_SMOOTH_HINT: - break; - default: return false; - } - switch(mode) { - case GL_FASTEST: - case GL_NICEST: - case GL_DONT_CARE: - break; - default: return false; - } - return true; -} - -bool GLEScmValidate::texParams(GLenum target,GLenum pname) { - switch(pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_CROP_RECT_OES: - case GL_GENERATE_MIPMAP: - break; - default: - return false; - } - return (target == GL_TEXTURE_2D)||(target == GL_TEXTURE_CUBE_MAP_OES); -} - -bool GLEScmValidate::texEnv(GLenum target,GLenum pname) { - switch(pname) { - case GL_TEXTURE_ENV_MODE: - case GL_TEXTURE_ENV_COLOR: - case GL_COMBINE_RGB: - case GL_COMBINE_ALPHA: - case GL_SRC0_RGB: - case GL_SRC1_RGB: - case GL_SRC2_RGB: - case GL_SRC0_ALPHA: - case GL_SRC1_ALPHA: - case GL_SRC2_ALPHA: - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - case GL_RGB_SCALE: - case GL_ALPHA_SCALE: - case GL_COORD_REPLACE_OES: - break; - default: - return false; - } - return (target == GL_TEXTURE_ENV || target == GL_POINT_SPRITE_OES); -} - -bool GLEScmValidate::capability(GLenum cap,int maxLights,int maxClipPlanes) { - switch(cap) { - case GL_ALPHA_TEST: - case GL_BLEND: - case GL_COLOR_ARRAY: - case GL_COLOR_LOGIC_OP: - case GL_COLOR_MATERIAL: - case GL_CULL_FACE: - case GL_DEPTH_TEST: - case GL_DITHER: - case GL_FOG: - case GL_LIGHTING: - case GL_LINE_SMOOTH: - case GL_MULTISAMPLE: - case GL_NORMAL_ARRAY: - case GL_NORMALIZE: - case GL_POINT_SIZE_ARRAY_OES: - case GL_POINT_SMOOTH: - case GL_POINT_SPRITE_OES: - case GL_POLYGON_OFFSET_FILL: - case GL_RESCALE_NORMAL: - case GL_SAMPLE_ALPHA_TO_COVERAGE: - case GL_SAMPLE_ALPHA_TO_ONE: - case GL_SAMPLE_COVERAGE: - case GL_SCISSOR_TEST: - case GL_STENCIL_TEST: - case GL_TEXTURE_2D: - case GL_TEXTURE_COORD_ARRAY: - case GL_VERTEX_ARRAY: - return true; - } - return GLEScmValidate::lightEnum(cap,maxLights) || GLEScmValidate::clipPlaneEnum(cap,maxClipPlanes); -} - - -bool GLEScmValidate::texCompImgFrmt(GLenum format) { - switch(format) { - case GL_PALETTE4_RGB8_OES: - case GL_PALETTE4_RGBA8_OES: - case GL_PALETTE4_R5_G6_B5_OES: - case GL_PALETTE4_RGBA4_OES: - case GL_PALETTE4_RGB5_A1_OES: - case GL_PALETTE8_RGB8_OES: - case GL_PALETTE8_RGBA8_OES: - case GL_PALETTE8_R5_G6_B5_OES: - case GL_PALETTE8_RGBA4_OES: - case GL_PALETTE8_RGB5_A1_OES: - return true; - } - return false; -} - -bool GLEScmValidate::blendDst(GLenum d) { - switch(d) { - case GL_ZERO: - case GL_ONE: - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - return true; - } - return false; -} - -bool GLEScmValidate::renderbufferInternalFrmt(GLEScontext* ctx, GLenum internalformat) -{ - switch (internalformat) { - case GL_DEPTH_COMPONENT16_OES: - case GL_RGBA4_OES: - case GL_RGB5_A1_OES: - case GL_RGB565_OES: - case GL_STENCIL_INDEX1_OES: - case GL_STENCIL_INDEX4_OES: - case GL_STENCIL_INDEX8_OES: - case GL_RGB8_OES: - case GL_RGBA8_OES: - case GL_DEPTH_COMPONENT24_OES: - case GL_DEPTH_COMPONENT32_OES: - return true; - } - if (ctx->getCaps()->GL_EXT_PACKED_DEPTH_STENCIL && internalformat==GL_DEPTH24_STENCIL8_OES) - return true; - - return false; -} - -bool GLEScmValidate::stencilOp(GLenum param) { - switch (param) { - case GL_KEEP: - case GL_ZERO: - case GL_REPLACE: - case GL_INCR: - case GL_DECR: - case GL_INVERT: - case GL_INCR_WRAP_OES: - case GL_DECR_WRAP_OES: - return true; - } - return false; -} - -bool GLEScmValidate::texGen(GLenum coord, GLenum pname) { - return (coord == GL_TEXTURE_GEN_STR_OES && pname == GL_TEXTURE_GEN_MODE_OES); -} - -bool GLEScmValidate::colorPointerType(GLenum type){ - switch(type){ - case GL_UNSIGNED_BYTE: - case GL_FIXED: - case GL_FLOAT: - return true; - } - return false; -} - -bool GLEScmValidate::normalPointerType(GLenum type){ - - switch(type){ - case GL_BYTE: - case GL_SHORT: - case GL_FLOAT: - case GL_FIXED: - return true; - } - return false; -} - -bool GLEScmValidate::pointPointerType(GLenum type){ - return type == GL_FIXED || type == GL_FLOAT; -} - -bool GLEScmValidate::texCoordPointerType(GLenum type){ - switch(type){ - case GL_BYTE: - case GL_SHORT: - case GL_FLOAT: - case GL_FIXED: - return true; - } - return false; -} - -bool GLEScmValidate::vertexPointerType(GLenum type){ - switch(type){ - case GL_BYTE: - case GL_SHORT: - case GL_FLOAT: - case GL_FIXED: - return true; - } - return false; -} - diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.h b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.h deleted file mode 100644 index 9bc3393..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmValidate.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* 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_CM_VALIDATE_H -#define GLES_CM_VALIDATE_H - -#include <GLES/gl.h> -#include <GLcommon/GLESvalidate.h> -struct GLEScmValidate : public GLESvalidate -{ -static bool blendSrc(GLenum s); -static bool blendDst(GLenum d); -static bool lightEnum(GLenum e,unsigned int maxLIghts); -static bool clipPlaneEnum(GLenum e,unsigned int maxClipPlanes); -static bool alphaFunc(GLenum f); -static bool vertexPointerParams(GLint size,GLsizei stride); -static bool colorPointerParams(GLint size,GLsizei stride); -static bool supportedArrays(GLenum arr); -static bool hintTargetMode(GLenum target,GLenum mode); -static bool capability(GLenum cap,int maxLights,int maxClipPlanes); -static bool texParams(GLenum target,GLenum pname); -static bool texCoordPointerParams(GLint size,GLsizei stride); - -static bool texEnv(GLenum target,GLenum pname); -static bool texCompImgFrmt(GLenum format); - -static bool renderbufferInternalFrmt(GLEScontext * ctx, GLenum internalformat); -static bool stencilOp(GLenum param); -static bool texGen(GLenum coord,GLenum pname); - -static bool colorPointerType(GLenum type); -static bool normalPointerType(GLenum type); -static bool pointPointerType(GLenum type); -static bool texCoordPointerType(GLenum type); -static bool vertexPointerType(GLenum type); -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk b/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk deleted file mode 100644 index c96965b..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk +++ /dev/null @@ -1,26 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -host_common_SRC_FILES := \ - GLESv2Imp.cpp \ - GLESv2Context.cpp \ - GLESv2Validate.cpp \ - ShaderParser.cpp \ - ProgramData.cpp - - -### GLES_V2 host implementation (On top of OpenGL) ######################## -$(call emugl-begin-host-shared-library,libGLES_V2_translator) -$(call emugl-import, libGLcommon) - -LOCAL_SRC_FILES := $(host_common_SRC_FILES) - -$(call emugl-end-module) - - -### GLES_V2 host implementation, 64-bit ############################## -$(call emugl-begin-host64-shared-library,lib64GLES_V2_translator) -$(call emugl-import, lib64GLcommon) - -LOCAL_SRC_FILES := $(host_common_SRC_FILES) - -$(call emugl-end-module) diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp deleted file mode 100644 index f8f674b..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* -* 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. -*/ - -#include "GLESv2Context.h" -#include <string.h> - -void GLESv2Context::init() { - emugl::Mutex::AutoLock mutex(s_lock); - if(!m_initialized) { - s_glDispatch.dispatchFuncs(GLES_2_0); - GLEScontext::init(); - for(int i=0; i < s_glSupport.maxVertexAttribs;i++){ - m_map[i] = new GLESpointer(); - } - setAttribute0value(0.0, 0.0, 0.0, 1.0); - - buildStrings((const char*)dispatcher().glGetString(GL_VENDOR), - (const char*)dispatcher().glGetString(GL_RENDERER), - (const char*)dispatcher().glGetString(GL_VERSION), - "OpenGL ES 2.0"); - } - m_initialized = true; -} - -GLESv2Context::GLESv2Context():GLEScontext(), m_att0Array(NULL), m_att0ArrayLength(0), m_att0NeedsDisable(false){}; - -GLESv2Context::~GLESv2Context() -{ - delete[] m_att0Array; -} - -void GLESv2Context::setAttribute0value(float x, float y, float z, float w) -{ - m_attribute0value[0] = x; - m_attribute0value[1] = y; - m_attribute0value[2] = z; - m_attribute0value[3] = w; -} - -void GLESv2Context::validateAtt0PreDraw(unsigned int count) -{ - m_att0NeedsDisable = false; - - if(count == 0) - return; - - int enabled = 0; - s_glDispatch.glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled); - if(enabled) - return; - - if(count > m_att0ArrayLength) - { - delete [] m_att0Array; - m_att0Array = new GLfloat[4*count]; - m_att0ArrayLength = count; - } - - for(unsigned int i=0; i<count; i++) - memcpy(m_att0Array+i*4, m_attribute0value, 4*sizeof(GLfloat)); - - s_glDispatch.glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, m_att0Array); - s_glDispatch.glEnableVertexAttribArray(0); - - m_att0NeedsDisable = true; -} - -void GLESv2Context::validateAtt0PostDraw(void) -{ - if(m_att0NeedsDisable) - s_glDispatch.glDisableVertexAttribArray(0); - - m_att0NeedsDisable = false; -} - -void GLESv2Context::setupArraysPointers(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct) { - ArraysMap::iterator it; - - //going over all clients arrays Pointers - for ( it=m_map.begin() ; it != m_map.end(); it++ ) { - GLenum array_id = (*it).first; - GLESpointer* p = (*it).second; - if(!isArrEnabled(array_id)) continue; - - unsigned int size = p->getSize(); - - if(needConvert(cArrs,first,count,type,indices,direct,p,array_id)){ - //conversion has occured - ArrayData currentArr = cArrs.getCurrentArray(); - setupArr(currentArr.data,array_id,currentArr.type,size,currentArr.stride, p->getNormalized()); - ++cArrs; - } else { - setupArr(p->getData(),array_id,p->getType(), - size,p->getStride(), p->getNormalized()); - } - } -} - -//setting client side arr -void GLESv2Context::setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,GLboolean normalized, int index){ - if(arr == NULL) return; - s_glDispatch.glVertexAttribPointer(arrayType,size,dataType,normalized,stride,arr); -} - -bool GLESv2Context::needConvert(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id) { - - bool usingVBO = p->isVBO(); - GLenum arrType = p->getType(); - /* - conversion is not necessary in the following cases: - (*) array type is not fixed - */ - if(arrType != GL_FIXED) return false; - - if(!usingVBO) { - if (direct) { - convertDirect(cArrs,first,count,array_id,p); - } else { - convertIndirect(cArrs,count,type,indices,array_id,p); - } - } else { - if (direct) { - convertDirectVBO(cArrs,first,count,array_id,p) ; - } else { - convertIndirectVBO(cArrs,count,type,indices,array_id,p); - } - } - return true; -} - -void GLESv2Context::initExtensionString() { - *s_glExtensions = "GL_OES_EGL_image GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint " - "GL_OES_texture_float GL_OES_texture_float_linear " - "GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture "; - if (s_glSupport.GL_ARB_HALF_FLOAT_PIXEL || s_glSupport.GL_NV_HALF_FLOAT) - *s_glExtensions+="GL_OES_texture_half_float GL_OES_texture_half_float_linear "; - if (s_glSupport.GL_EXT_PACKED_DEPTH_STENCIL) - *s_glExtensions+="GL_OES_packed_depth_stencil "; - if (s_glSupport.GL_ARB_HALF_FLOAT_VERTEX) - *s_glExtensions+="GL_OES_vertex_half_float "; - if (s_glSupport.GL_OES_STANDARD_DERIVATIVES) - *s_glExtensions+="GL_OES_standard_derivatives "; -} - -int GLESv2Context::getMaxTexUnits() { - return getCaps()->maxTexImageUnits; -} diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h deleted file mode 100644 index 7e71177..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -* 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_V2_CONTEXT_H -#define GLES_V2_CONTEXT_H - -#include <GLcommon/GLDispatch.h> -#include <GLcommon/GLEScontext.h> -#include <GLcommon/objectNameManager.h> - - - -class GLESv2Context : public GLEScontext{ -public: - void init(); - GLESv2Context(); - virtual ~GLESv2Context(); - void setupArraysPointers(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct); - int getMaxTexUnits(); - - // This whole att0 thing is about a incompatibility between GLES and OpenGL. - // GLES allows a vertex shader attribute to be in location 0 and have a - // current value, while OpenGL is not very clear about this, which results - // in each implementation doing something different. - void setAttribute0value(float x, float y, float z, float w); - void validateAtt0PreDraw(unsigned int count); - void validateAtt0PostDraw(void); - const float* getAtt0(void) {return m_attribute0value;} - -protected: - bool needConvert(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id); -private: - void setupArr(const GLvoid* arr,GLenum arrayType,GLenum dataType,GLint size,GLsizei stride,GLboolean normalized, int pointsIndex = -1); - void initExtensionString(); - - float m_attribute0value[4]; - GLfloat* m_att0Array; - unsigned int m_att0ArrayLength; - bool m_att0NeedsDisable; -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp deleted file mode 100644 index 7f4cd4f..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp +++ /dev/null @@ -1,2243 +0,0 @@ -/* -* 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. -*/ - -#ifdef _WIN32 -#undef GL_APICALL -#define GL_API __declspec(dllexport) -#define GL_APICALL __declspec(dllexport) -#endif - -#define GL_GLEXT_PROTOTYPES -#include <stdio.h> -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> -#include <GLcommon/TranslatorIfaces.h> -#include <GLcommon/gldefs.h> -#include "GLESv2Context.h" -#include "GLESv2Validate.h" -#include "ShaderParser.h" -#include "ProgramData.h" -#include <GLcommon/TextureUtils.h> -#include <GLcommon/FramebufferData.h> - -extern "C" { - -//decleration -static void initContext(GLEScontext* ctx,ShareGroupPtr grp); -static void deleteGLESContext(GLEScontext* ctx); -static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp); -static GLEScontext* createGLESContext(); -static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName); - -} - -/************************************** GLES EXTENSIONS *********************************************************/ -//extentions descriptor -typedef std::map<std::string, __translatorMustCastToProperFunctionPointerType> ProcTableMap; -ProcTableMap *s_glesExtensions = NULL; -/****************************************************************************************************************/ - -static EGLiface* s_eglIface = NULL; -static GLESiface s_glesIface = { - createGLESContext:createGLESContext, - initContext :initContext, - deleteGLESContext:deleteGLESContext, - flush :(FUNCPTR)glFlush, - finish :(FUNCPTR)glFinish, - setShareGroup :setShareGroup, - getProcAddress :getProcAddress -}; - -#include <GLcommon/GLESmacros.h> - -extern "C" { - -static void initContext(GLEScontext* ctx,ShareGroupPtr grp) { - if (!ctx->isInitialized()) { - ctx->setShareGroup(grp); - ctx->init(); - glBindTexture(GL_TEXTURE_2D,0); - glBindTexture(GL_TEXTURE_CUBE_MAP,0); - } -} -static GLEScontext* createGLESContext() { - return new GLESv2Context(); -} - -static void deleteGLESContext(GLEScontext* ctx) { - delete ctx; -} - -static void setShareGroup(GLEScontext* ctx,ShareGroupPtr grp) { - if(ctx) { - ctx->setShareGroup(grp); - } -} - -static __translatorMustCastToProperFunctionPointerType getProcAddress(const char* procName) { - GET_CTX_RET(NULL) - ctx->getGlobalLock(); - static bool proc_table_initialized = false; - if (!proc_table_initialized) { - proc_table_initialized = true; - if (!s_glesExtensions) - s_glesExtensions = new ProcTableMap(); - else - s_glesExtensions->clear(); - (*s_glesExtensions)["glEGLImageTargetTexture2DOES"] = (__translatorMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES; - (*s_glesExtensions)["glEGLImageTargetRenderbufferStorageOES"]=(__translatorMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES; - } - __translatorMustCastToProperFunctionPointerType ret=NULL; - ProcTableMap::iterator val = s_glesExtensions->find(procName); - if (val!=s_glesExtensions->end()) - ret = val->second; - ctx->releaseGlobalLock(); - - return ret; -} - -GL_APICALL GLESiface* __translator_getIfaces(EGLiface* eglIface){ - s_eglIface = eglIface; - return & s_glesIface; -} - -} - -static void s_attachShader(GLEScontext* ctx, GLuint program, GLuint shader) { - if (ctx && program && shader && ctx->shareGroup().Ptr()) { - ObjectDataPtr shaderData = ctx->shareGroup()->getObjectData(SHADER,shader); - if (!shaderData.Ptr()) return; - ShaderParser* shaderParser = (ShaderParser*)shaderData.Ptr(); - shaderParser->setAttachedProgram(program); - } -} - -static void s_detachShader(GLEScontext* ctx, GLuint shader) { - if (ctx && shader && ctx->shareGroup().Ptr()) { - ObjectDataPtr shaderData = ctx->shareGroup()->getObjectData(SHADER,shader); - if (!shaderData.Ptr()) return; - ShaderParser* shaderParser = (ShaderParser*)shaderData.Ptr(); - shaderParser->setAttachedProgram(0); - if (shaderParser->getDeleteStatus()) { - ctx->shareGroup()->deleteName(SHADER, shader); - } - } -} - -static ObjectLocalName TextureLocalName(GLenum target,unsigned int tex) { - GET_CTX_RET(0); - return (tex!=0? tex : ctx->getDefaultTextureName(target)); -} - -static TextureData* getTextureData(ObjectLocalName tex) { - GET_CTX_RET(NULL); - TextureData *texData = NULL; - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(TEXTURE,tex); - if(!objData.Ptr()){ - texData = new TextureData(); - ctx->shareGroup()->setObjectData(TEXTURE, tex, ObjectDataPtr(texData)); - } else { - texData = (TextureData*)objData.Ptr(); - } - return texData; -} - -static TextureData* getTextureTargetData(GLenum target){ - GET_CTX_RET(NULL); - unsigned int tex = ctx->getBindedTexture(target); - return getTextureData(TextureLocalName(target,tex)); -} - -GL_APICALL void GL_APIENTRY glActiveTexture(GLenum texture){ - GET_CTX_V2(); - SET_ERROR_IF (!GLESv2Validate::textureEnum(texture,ctx->getMaxTexUnits()),GL_INVALID_ENUM); - ctx->setActiveTexture(texture); - ctx->dispatcher().glActiveTexture(texture); -} - -GL_APICALL void GL_APIENTRY glAttachShader(GLuint program, GLuint shader){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader); - SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE); - - ObjectDataPtr programData = ctx->shareGroup()->getObjectData(SHADER,program); - ObjectDataPtr shaderData = ctx->shareGroup()->getObjectData(SHADER,shader); - SET_ERROR_IF(!shaderData.Ptr() || !programData.Ptr() ,GL_INVALID_OPERATION); - SET_ERROR_IF(!(shaderData.Ptr()->getDataType() ==SHADER_DATA) || - !(programData.Ptr()->getDataType()==PROGRAM_DATA) ,GL_INVALID_OPERATION); - - GLenum shaderType = ((ShaderParser*)shaderData.Ptr())->getType(); - ProgramData* pData = (ProgramData*)programData.Ptr(); - SET_ERROR_IF((pData->getAttachedShader(shaderType)!=0), GL_INVALID_OPERATION); - pData->attachShader(shader,shaderType); - s_attachShader(ctx, program, shader); - ctx->dispatcher().glAttachShader(globalProgramName,globalShaderName); - } -} - -GL_APICALL void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::attribName(name),GL_INVALID_OPERATION); - SET_ERROR_IF(!GLESv2Validate::attribIndex(index),GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - - ctx->dispatcher().glBindAttribLocation(globalProgramName,index,name); - } -} - -GL_APICALL void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::bufferTarget(target),GL_INVALID_ENUM); - //if buffer wasn't generated before,generate one - if(buffer && ctx->shareGroup().Ptr() && !ctx->shareGroup()->isObject(VERTEXBUFFER,buffer)){ - ctx->shareGroup()->genName(VERTEXBUFFER,buffer); - ctx->shareGroup()->setObjectData(VERTEXBUFFER,buffer,ObjectDataPtr(new GLESbuffer())); - } - ctx->bindBuffer(target,buffer); - if (buffer) { - GLESbuffer* vbo = (GLESbuffer*)ctx->shareGroup()->getObjectData(VERTEXBUFFER,buffer).Ptr(); - vbo->setBinded(); - } -} - -GL_APICALL void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::framebufferTarget(target),GL_INVALID_ENUM); - - GLuint globalFrameBufferName = framebuffer; - if(framebuffer && ctx->shareGroup().Ptr()){ - globalFrameBufferName = ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffer); - //if framebuffer wasn't generated before,generate one - if(!globalFrameBufferName){ - ctx->shareGroup()->genName(FRAMEBUFFER,framebuffer); - ctx->shareGroup()->setObjectData(FRAMEBUFFER, framebuffer, - ObjectDataPtr(new FramebufferData(framebuffer))); - globalFrameBufferName = ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffer); - } - } - ctx->dispatcher().glBindFramebufferEXT(target,globalFrameBufferName); - - // update framebuffer binding state - ctx->setFramebufferBinding(framebuffer); -} - -GL_APICALL void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::renderbufferTarget(target),GL_INVALID_ENUM); - - GLuint globalRenderBufferName = renderbuffer; - if(renderbuffer && ctx->shareGroup().Ptr()){ - globalRenderBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer); - //if renderbuffer wasn't generated before,generate one - if(!globalRenderBufferName){ - ctx->shareGroup()->genName(RENDERBUFFER,renderbuffer); - ctx->shareGroup()->setObjectData(RENDERBUFFER, - renderbuffer, - ObjectDataPtr(new RenderbufferData())); - globalRenderBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer); - } - } - ctx->dispatcher().glBindRenderbufferEXT(target,globalRenderBufferName); - - // update renderbuffer binding state - ctx->setRenderbufferBinding(renderbuffer); -} - -GL_APICALL void GL_APIENTRY glBindTexture(GLenum target, GLuint texture){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::textureTarget(target),GL_INVALID_ENUM) - - //for handling default texture (0) - ObjectLocalName localTexName = TextureLocalName(target,texture); - - GLuint globalTextureName = localTexName; - if(ctx->shareGroup().Ptr()){ - globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,localTexName); - //if texture wasn't generated before,generate one - if(!globalTextureName){ - ctx->shareGroup()->genName(TEXTURE,localTexName); - globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,localTexName); - } - - TextureData* texData = getTextureData(localTexName); - if (texData->target==0) - texData->target = target; - //if texture was already bound to another target - SET_ERROR_IF(ctx->GLTextureTargetToLocal(texData->target) != ctx->GLTextureTargetToLocal(target), GL_INVALID_OPERATION); - texData->wasBound = true; - } - - ctx->setBindedTexture(target,texture); - ctx->dispatcher().glBindTexture(target,globalTextureName); -} - -GL_APICALL void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){ - GET_CTX(); - ctx->dispatcher().glBlendColor(red,green,blue,alpha); -} - -GL_APICALL void GL_APIENTRY glBlendEquation( GLenum mode ){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::blendEquationMode(mode),GL_INVALID_ENUM) - ctx->dispatcher().glBlendEquation(mode); -} - -GL_APICALL void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::blendEquationMode(modeRGB) && GLESv2Validate::blendEquationMode(modeAlpha)),GL_INVALID_ENUM); - ctx->dispatcher().glBlendEquationSeparate(modeRGB,modeAlpha); -} - -GL_APICALL void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::blendSrc(sfactor) || !GLESv2Validate::blendDst(dfactor),GL_INVALID_ENUM) - ctx->dispatcher().glBlendFunc(sfactor,dfactor); -} - -GL_APICALL void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha){ - GET_CTX(); - SET_ERROR_IF( -!(GLESv2Validate::blendSrc(srcRGB) && GLESv2Validate::blendDst(dstRGB) && GLESv2Validate::blendSrc(srcAlpha) && GLESv2Validate::blendDst(dstAlpha)),GL_INVALID_ENUM); - ctx->dispatcher().glBlendFuncSeparate(srcRGB,dstRGB,srcAlpha,dstAlpha); -} - -GL_APICALL void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::bufferTarget(target),GL_INVALID_ENUM); - SET_ERROR_IF(!GLESv2Validate::bufferUsage(usage),GL_INVALID_ENUM); - SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION); - ctx->setBufferData(target,size,data,usage); -} - -GL_APICALL void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data){ - GET_CTX(); - SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION); - SET_ERROR_IF(!GLESv2Validate::bufferTarget(target),GL_INVALID_ENUM); - SET_ERROR_IF(!ctx->setBufferSubData(target,offset,size,data),GL_INVALID_VALUE); -} - - -GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target){ - GET_CTX_RET(GL_FRAMEBUFFER_COMPLETE); - RET_AND_SET_ERROR_IF(!GLESv2Validate::framebufferTarget(target),GL_INVALID_ENUM,GL_FRAMEBUFFER_COMPLETE); - ctx->drawValidate(); - return ctx->dispatcher().glCheckFramebufferStatusEXT(target); -} - -GL_APICALL void GL_APIENTRY glClear(GLbitfield mask){ - GET_CTX(); - GLbitfield allowed_bits = GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; - GLbitfield has_disallowed_bits = (mask & ~allowed_bits); - SET_ERROR_IF(has_disallowed_bits, GL_INVALID_VALUE); - ctx->drawValidate(); - - ctx->dispatcher().glClear(mask); -} -GL_APICALL void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){ - GET_CTX(); - ctx->dispatcher().glClearColor(red,green,blue,alpha); -} -GL_APICALL void GL_APIENTRY glClearDepthf(GLclampf depth){ - GET_CTX(); - ctx->dispatcher().glClearDepth(depth); -} -GL_APICALL void GL_APIENTRY glClearStencil(GLint s){ - GET_CTX(); - ctx->dispatcher().glClearStencil(s); -} -GL_APICALL void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha){ - GET_CTX(); - ctx->dispatcher().glColorMask(red,green,blue,alpha); -} - -GL_APICALL void GL_APIENTRY glCompileShader(GLuint shader){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader); - SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,shader); - SET_ERROR_IF(objData.Ptr()->getDataType()!= SHADER_DATA,GL_INVALID_OPERATION); - ShaderParser* sp = (ShaderParser*)objData.Ptr(); - ctx->dispatcher().glCompileShader(globalShaderName); - - GLsizei infoLogLength=0; - GLchar* infoLog; - ctx->dispatcher().glGetShaderiv(globalShaderName,GL_INFO_LOG_LENGTH,&infoLogLength); - infoLog = new GLchar[infoLogLength+1]; - ctx->dispatcher().glGetShaderInfoLog(globalShaderName,infoLogLength,NULL,infoLog); - sp->setInfoLog(infoLog); - } -} - -GL_APICALL void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) -{ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::textureTargetEx(target),GL_INVALID_ENUM); - SET_ERROR_IF(level < 0 || imageSize < 0, GL_INVALID_VALUE); - - doCompressedTexImage2D(ctx, target, level, internalformat, - width, height, border, - imageSize, data, (void*)glTexImage2D); -} - -GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::textureTargetEx(target),GL_INVALID_ENUM); - ctx->dispatcher().glCompressedTexSubImage2D(target,level,xoffset,yoffset,width,height,format,imageSize,data); -} - -GL_APICALL void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::pixelFrmt(ctx,internalformat) && GLESv2Validate::textureTargetEx(target)),GL_INVALID_ENUM); - SET_ERROR_IF(border != 0,GL_INVALID_VALUE); - ctx->dispatcher().glCopyTexImage2D(target,level,internalformat,x,y,width,height,border); -} - -GL_APICALL void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::textureTargetEx(target),GL_INVALID_ENUM); - ctx->dispatcher().glCopyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height); -} - -GL_APICALL GLuint GL_APIENTRY glCreateProgram(void){ - GET_CTX_RET(0); - const GLuint globalProgramName = ctx->dispatcher().glCreateProgram(); - if(ctx->shareGroup().Ptr() && globalProgramName) { - ProgramData* programInfo = new ProgramData(); - const GLuint localProgramName = ctx->shareGroup()->genName(SHADER, 0, true); - ctx->shareGroup()->replaceGlobalName(SHADER,localProgramName,globalProgramName); - ctx->shareGroup()->setObjectData(SHADER,localProgramName,ObjectDataPtr(programInfo)); - return localProgramName; - } - if(globalProgramName){ - ctx->dispatcher().glDeleteProgram(globalProgramName); - } - return 0; -} - -GL_APICALL GLuint GL_APIENTRY glCreateShader(GLenum type){ - GET_CTX_V2_RET(0); - RET_AND_SET_ERROR_IF(!GLESv2Validate::shaderType(type),GL_INVALID_ENUM,0); - const GLuint globalShaderName = ctx->dispatcher().glCreateShader(type); - if(ctx->shareGroup().Ptr() && globalShaderName) { - const GLuint localShaderName = ctx->shareGroup()->genName(SHADER, 0, true); - ShaderParser* sp = new ShaderParser(type); - ctx->shareGroup()->replaceGlobalName(SHADER,localShaderName,globalShaderName); - ctx->shareGroup()->setObjectData(SHADER,localShaderName,ObjectDataPtr(sp)); - return localShaderName; - } - if(globalShaderName){ - ctx->dispatcher().glDeleteShader(globalShaderName); - } - return 0; -} - -GL_APICALL void GL_APIENTRY glCullFace(GLenum mode){ - GET_CTX(); - ctx->dispatcher().glCullFace(mode); -} - -GL_APICALL void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers){ - GET_CTX(); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i < n; i++){ - ctx->shareGroup()->deleteName(VERTEXBUFFER,buffers[i]); - } - } -} - -GL_APICALL void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers){ - GET_CTX(); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i < n; i++){ - const GLuint globalFrameBufferName = ctx->shareGroup()->getGlobalName(FRAMEBUFFER,framebuffers[i]); - ctx->shareGroup()->deleteName(FRAMEBUFFER,framebuffers[i]); - ctx->dispatcher().glDeleteFramebuffersEXT(1,&globalFrameBufferName); - } - } -} - -static void s_detachFromFramebuffer(GLuint bufferType, GLuint texture) { - GET_CTX(); - GLuint fbName = ctx->getFramebufferBinding(); - if (!fbName) return; - ObjectDataPtr fbObj = ctx->shareGroup()->getObjectData(FRAMEBUFFER,fbName); - if (fbObj.Ptr() == NULL) return; - FramebufferData *fbData = (FramebufferData *)fbObj.Ptr(); - GLenum target; - const GLenum kAttachments[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT}; - const size_t sizen = sizeof(kAttachments)/sizeof(GLenum); - for (size_t i = 0; i < sizen; ++i ) { - GLuint name = fbData->getAttachment(kAttachments[i], &target, NULL); - if (name != texture) continue; - if (TEXTURE == bufferType && GLESv2Validate::textureTargetEx(target)) { - glFramebufferTexture2D(GL_FRAMEBUFFER, kAttachments[i], target, 0, 0); - } else if (RENDERBUFFER == bufferType && GLESv2Validate::renderbufferTarget(target)) { - glFramebufferRenderbuffer(GL_FRAMEBUFFER, kAttachments[i], target, 0); - } - } -} - -GL_APICALL void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers){ - GET_CTX(); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i < n; i++){ - const GLuint globalRenderBufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffers[i]); - ctx->shareGroup()->deleteName(RENDERBUFFER,renderbuffers[i]); - ctx->dispatcher().glDeleteRenderbuffersEXT(1,&globalRenderBufferName); - s_detachFromFramebuffer(RENDERBUFFER, renderbuffers[i]); - } - } -} - -GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures){ - GET_CTX(); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i < n; i++){ - if (textures[i]!=0) { - TextureData* tData = getTextureData(textures[i]); - // delete the underlying OpenGL texture but only if this - // texture is not a target of EGLImage. - if (!tData || tData->sourceEGLImage == 0) { - const GLuint globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,textures[i]); - ctx->dispatcher().glDeleteTextures(1,&globalTextureName); - } - ctx->shareGroup()->deleteName(TEXTURE,textures[i]); - - if (ctx->getBindedTexture(GL_TEXTURE_2D) == textures[i]) - ctx->setBindedTexture(GL_TEXTURE_2D,0); - if (ctx->getBindedTexture(GL_TEXTURE_CUBE_MAP) == textures[i]) - ctx->setBindedTexture(GL_TEXTURE_CUBE_MAP,0); - s_detachFromFramebuffer(TEXTURE, textures[i]); - } - } - } -} - -GL_APICALL void GL_APIENTRY glDeleteProgram(GLuint program){ - GET_CTX(); - if(program && ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(!globalProgramName, GL_INVALID_VALUE); - - ObjectDataPtr programData = ctx->shareGroup()->getObjectData(SHADER,program); - ProgramData* pData = (ProgramData*)programData.Ptr(); - if (pData && pData->isInUse()) { - pData->setDeleteStatus(true); - return; - } - s_detachShader(ctx, pData->getAttachedVertexShader()); - s_detachShader(ctx, pData->getAttachedFragmentShader()); - - ctx->shareGroup()->deleteName(SHADER,program); - ctx->dispatcher().glDeleteProgram(globalProgramName); - } -} - -GL_APICALL void GL_APIENTRY glDeleteShader(GLuint shader){ - GET_CTX(); - if(shader && ctx->shareGroup().Ptr()) { - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader); - SET_ERROR_IF(!globalShaderName, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,shader); - SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=SHADER_DATA,GL_INVALID_OPERATION); - ShaderParser* sp = (ShaderParser*)objData.Ptr(); - if (sp->getAttachedProgram()) { - sp->setDeleteStatus(true); - } else { - ctx->shareGroup()->deleteName(SHADER,shader); - } - ctx->dispatcher().glDeleteShader(globalShaderName); - } - -} - -GL_APICALL void GL_APIENTRY glDepthFunc(GLenum func){ - GET_CTX(); - ctx->dispatcher().glDepthFunc(func); -} -GL_APICALL void GL_APIENTRY glDepthMask(GLboolean flag){ - GET_CTX(); - ctx->dispatcher().glDepthMask(flag); -} -GL_APICALL void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar){ - GET_CTX(); - ctx->dispatcher().glDepthRange(zNear,zFar); -} - -GL_APICALL void GL_APIENTRY glDetachShader(GLuint program, GLuint shader){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader); - SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE); - - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(!objData.Ptr(),GL_INVALID_OPERATION); - SET_ERROR_IF(!(objData.Ptr()->getDataType()==PROGRAM_DATA) ,GL_INVALID_OPERATION); - - ProgramData* programData = (ProgramData*)objData.Ptr(); - SET_ERROR_IF(!programData->isAttached(shader),GL_INVALID_OPERATION); - programData->detachShader(shader); - - s_detachShader(ctx, shader); - - ctx->dispatcher().glDetachShader(globalProgramName,globalShaderName); - } -} - -GL_APICALL void GL_APIENTRY glDisable(GLenum cap){ - GET_CTX(); - ctx->dispatcher().glDisable(cap); -} - -GL_APICALL void GL_APIENTRY glDisableVertexAttribArray(GLuint index){ - GET_CTX(); - SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE); - ctx->enableArr(index,false); - ctx->dispatcher().glDisableVertexAttribArray(index); -} - -GL_APICALL void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count){ - GET_CTX_V2(); - SET_ERROR_IF(count < 0,GL_INVALID_VALUE) - SET_ERROR_IF(!GLESv2Validate::drawMode(mode),GL_INVALID_ENUM); - - ctx->drawValidate(); - - GLESConversionArrays tmpArrs; - ctx->setupArraysPointers(tmpArrs,first,count,0,NULL,true); - - ctx->validateAtt0PreDraw(count); - - //Enable texture generation for GL_POINTS and gl_PointSize shader variable - //GLES2 assumes this is enabled by default, we need to set this state for GL - if (mode==GL_POINTS) { - ctx->dispatcher().glEnable(GL_POINT_SPRITE); - ctx->dispatcher().glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); - } - - ctx->dispatcher().glDrawArrays(mode,first,count); - - if (mode==GL_POINTS) { - ctx->dispatcher().glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); - ctx->dispatcher().glDisable(GL_POINT_SPRITE); - } - - ctx->validateAtt0PostDraw(); -} - -GL_APICALL void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* elementsIndices){ - GET_CTX_V2(); - SET_ERROR_IF(count < 0,GL_INVALID_VALUE) - SET_ERROR_IF(!(GLESv2Validate::drawMode(mode) && GLESv2Validate::drawType(type)),GL_INVALID_ENUM); - - ctx->drawValidate(); - - 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 + SafeUIntFromPointer(elementsIndices); - } - - GLESConversionArrays tmpArrs; - ctx->setupArraysPointers(tmpArrs,0,count,type,indices,false); - - int maxIndex = ctx->findMaxIndex(count, type, indices); - ctx->validateAtt0PreDraw(maxIndex); - - //See glDrawArrays - if (mode==GL_POINTS) { - ctx->dispatcher().glEnable(GL_POINT_SPRITE); - ctx->dispatcher().glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); - } - - ctx->dispatcher().glDrawElements(mode,count,type,indices); - - if (mode==GL_POINTS) { - ctx->dispatcher().glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); - ctx->dispatcher().glDisable(GL_POINT_SPRITE); - } - - ctx->validateAtt0PostDraw(); -} - -GL_APICALL void GL_APIENTRY glEnable(GLenum cap){ - GET_CTX(); - ctx->dispatcher().glEnable(cap); -} - -GL_APICALL void GL_APIENTRY glEnableVertexAttribArray(GLuint index){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE); - ctx->enableArr(index,true); - ctx->dispatcher().glEnableVertexAttribArray(index); -} - -GL_APICALL void GL_APIENTRY glFinish(void){ - GET_CTX(); - ctx->dispatcher().glFinish(); -} -GL_APICALL void GL_APIENTRY glFlush(void){ - GET_CTX(); - ctx->dispatcher().glFlush(); -} - - -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::framebufferTarget(target) && - GLESv2Validate::renderbufferTarget(renderbuffertarget) && - GLESv2Validate::framebufferAttachment(attachment)),GL_INVALID_ENUM); - SET_ERROR_IF(!ctx->shareGroup().Ptr(), GL_INVALID_OPERATION); - - GLuint globalRenderbufferName = 0; - ObjectDataPtr obj; - - // generate the renderbuffer object if not yet exist - if(renderbuffer) { - if (!ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer)) { - ctx->shareGroup()->genName(RENDERBUFFER,renderbuffer); - obj = ObjectDataPtr(new RenderbufferData()); - ctx->shareGroup()->setObjectData(RENDERBUFFER, - renderbuffer, obj); - } - else { - obj = ctx->shareGroup()->getObjectData(RENDERBUFFER, renderbuffer); - } - - globalRenderbufferName = ctx->shareGroup()->getGlobalName(RENDERBUFFER,renderbuffer); - } - - // Update the the current framebuffer object attachment state - GLuint fbName = ctx->getFramebufferBinding(); - ObjectDataPtr fbObj = ctx->shareGroup()->getObjectData(FRAMEBUFFER,fbName); - if (fbObj.Ptr() != NULL) { - FramebufferData *fbData = (FramebufferData *)fbObj.Ptr(); - fbData->setAttachment(attachment, renderbuffertarget, renderbuffer, obj); - } - - if (renderbuffer && obj.Ptr() != NULL) { - RenderbufferData *rbData = (RenderbufferData *)obj.Ptr(); - if (rbData->sourceEGLImage != 0) { - // - // This renderbuffer object is an eglImage target - // attach the eglimage's texture instead the renderbuffer. - // - ctx->dispatcher().glFramebufferTexture2DEXT(target, - attachment, - GL_TEXTURE_2D, - rbData->eglImageGlobalTexName,0); - return; - } - } - - ctx->dispatcher().glFramebufferRenderbufferEXT(target,attachment,renderbuffertarget,globalRenderbufferName); -} - -GL_APICALL void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::framebufferTarget(target) && - GLESv2Validate::textureTargetEx(textarget) && - GLESv2Validate::framebufferAttachment(attachment)),GL_INVALID_ENUM); - SET_ERROR_IF(level != 0, GL_INVALID_VALUE); - SET_ERROR_IF(!ctx->shareGroup().Ptr(), GL_INVALID_OPERATION); - - GLuint globalTextureName = 0; - - if(texture) { - if (!ctx->shareGroup()->isObject(TEXTURE,texture)) { - ctx->shareGroup()->genName(TEXTURE,texture); - } - ObjectLocalName texname = TextureLocalName(textarget,texture); - globalTextureName = ctx->shareGroup()->getGlobalName(TEXTURE,texname); - } - - ctx->dispatcher().glFramebufferTexture2DEXT(target,attachment,textarget,globalTextureName,level); - - // Update the the current framebuffer object attachment state - GLuint fbName = ctx->getFramebufferBinding(); - ObjectDataPtr fbObj = ctx->shareGroup()->getObjectData(FRAMEBUFFER,fbName); - if (fbObj.Ptr() != NULL) { - FramebufferData *fbData = (FramebufferData *)fbObj.Ptr(); - fbData->setAttachment(attachment, textarget, - texture, ObjectDataPtr(NULL)); - } -} - - -GL_APICALL void GL_APIENTRY glFrontFace(GLenum mode){ - GET_CTX(); - ctx->dispatcher().glFrontFace(mode); -} - -GL_APICALL void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers){ - GET_CTX(); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i<n ;i++) { - buffers[i] = ctx->shareGroup()->genName(VERTEXBUFFER, 0, true); - //generating vbo object related to this buffer name - ctx->shareGroup()->setObjectData(VERTEXBUFFER,buffers[i],ObjectDataPtr(new GLESbuffer())); - } - } -} - -GL_APICALL void GL_APIENTRY glGenerateMipmap(GLenum target){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::textureTargetEx(target),GL_INVALID_ENUM); - ctx->dispatcher().glGenerateMipmapEXT(target); -} - -GL_APICALL void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers){ - GET_CTX(); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i<n ;i++) { - framebuffers[i] = ctx->shareGroup()->genName(FRAMEBUFFER, 0 ,true); - ctx->shareGroup()->setObjectData(FRAMEBUFFER, framebuffers[i], - ObjectDataPtr(new FramebufferData(framebuffers[i]))); - } - } -} - -GL_APICALL void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers){ - GET_CTX(); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i<n ;i++) { - renderbuffers[i] = ctx->shareGroup()->genName(RENDERBUFFER, 0, true); - ctx->shareGroup()->setObjectData(RENDERBUFFER, - renderbuffers[i], - ObjectDataPtr(new RenderbufferData())); - } - } -} - -GL_APICALL void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures){ - GET_CTX(); - SET_ERROR_IF(n<0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()) { - for(int i=0; i<n ;i++) { - textures[i] = ctx->shareGroup()->genName(TEXTURE, 0, true); - } - } -} - -GL_APICALL void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ctx->dispatcher().glGetActiveAttrib(globalProgramName,index,bufsize,length,size,type,name); - } -} - -GL_APICALL void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ctx->dispatcher().glGetActiveUniform(globalProgramName,index,bufsize,length,size,type,name); - } -} - -GL_APICALL void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - ctx->dispatcher().glGetAttachedShaders(globalProgramName,maxcount,count,shaders); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - GLint numShaders=0; - ctx->dispatcher().glGetProgramiv(globalProgramName,GL_ATTACHED_SHADERS,&numShaders); - for(int i=0 ; i < maxcount && i<numShaders ;i++){ - shaders[i] = ctx->shareGroup()->getLocalName(SHADER,shaders[i]); - } - } -} - -GL_APICALL int GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name){ - GET_CTX_RET(-1); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - RET_AND_SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE,-1); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - RET_AND_SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION,-1); - ProgramData* pData = (ProgramData *)objData.Ptr(); - RET_AND_SET_ERROR_IF(pData->getLinkStatus() != GL_TRUE,GL_INVALID_OPERATION,-1); - return ctx->dispatcher().glGetAttribLocation(globalProgramName,name); - } - return -1; -} - -GL_APICALL void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params){ - GET_CTX(); - - if (ctx->glGetBooleanv(pname,params)) - { - return; - } - - switch(pname) - { - case GL_SHADER_COMPILER: - case GL_SHADER_BINARY_FORMATS: - case GL_NUM_SHADER_BINARY_FORMATS: - case GL_MAX_VERTEX_UNIFORM_VECTORS: - case GL_MAX_VARYING_VECTORS: - case GL_MAX_FRAGMENT_UNIFORM_VECTORS: - if(ctx->getCaps()->GL_ARB_ES2_COMPATIBILITY) - ctx->dispatcher().glGetBooleanv(pname,params); - else - { - GLint iparam; - glGetIntegerv(pname,&iparam); - *params = (iparam != 0); - } - break; - - default: - ctx->dispatcher().glGetBooleanv(pname,params); - } -} - -GL_APICALL void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::bufferTarget(target) && GLESv2Validate::bufferParam(pname)),GL_INVALID_ENUM); - SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION); - switch(pname) { - case GL_BUFFER_SIZE: - ctx->getBufferSize(target,params); - break; - case GL_BUFFER_USAGE: - ctx->getBufferUsage(target,params); - break; - } -} - - -GL_APICALL GLenum GL_APIENTRY glGetError(void){ - GET_CTX_RET(GL_NO_ERROR) - GLenum err = ctx->getGLerror(); - if(err != GL_NO_ERROR) { - ctx->setGLerror(GL_NO_ERROR); - return err; - } - return ctx->dispatcher().glGetError(); -} - -GL_APICALL void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params){ - GET_CTX(); - - if (ctx->glGetFloatv(pname,params)) { - return; - } - - GLint i; - - switch (pname) { - case GL_CURRENT_PROGRAM: - case GL_FRAMEBUFFER_BINDING: - case GL_RENDERBUFFER_BINDING: - glGetIntegerv(pname,&i); - *params = (GLfloat)i; - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS: - *params = (GLfloat)getCompressedFormats(NULL); - break; - case GL_COMPRESSED_TEXTURE_FORMATS: - { - int nparams = getCompressedFormats(NULL); - if (nparams>0) { - int * iparams = new int[nparams]; - getCompressedFormats(iparams); - for (int i=0; i<nparams; i++) params[i] = (GLfloat)iparams[i]; - delete [] iparams; - } - } - break; - - case GL_SHADER_COMPILER: - case GL_SHADER_BINARY_FORMATS: - case GL_NUM_SHADER_BINARY_FORMATS: - case GL_MAX_VERTEX_UNIFORM_VECTORS: - case GL_MAX_VARYING_VECTORS: - case GL_MAX_FRAGMENT_UNIFORM_VECTORS: - if(ctx->getCaps()->GL_ARB_ES2_COMPATIBILITY) - ctx->dispatcher().glGetFloatv(pname,params); - else - { - glGetIntegerv(pname,&i); - *params = (GLfloat)i; - } - break; - - case GL_STENCIL_BACK_VALUE_MASK: - case GL_STENCIL_BACK_WRITEMASK: - case GL_STENCIL_VALUE_MASK: - case GL_STENCIL_WRITEMASK: - { - GLint myint = 0; - glGetIntegerv(pname, &myint); - // Two casts are used: since mask is unsigned integer, - // the first cast converts to unsigned integer; - // the second cast converts to float. - *params = (GLfloat)((GLuint)(myint)); - } - break; - - default: - ctx->dispatcher().glGetFloatv(pname,params); - } -} - -GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params){ - int destroyCtx = 0; - GET_CTX(); - - if (!ctx) { - ctx = createGLESContext(); - if (ctx) - destroyCtx = 1; - } - if (ctx->glGetIntegerv(pname,params)) - { - if (destroyCtx) - deleteGLESContext(ctx); - return; - } - - bool es2 = ctx->getCaps()->GL_ARB_ES2_COMPATIBILITY; - GLint i; - - switch (pname) { - case GL_CURRENT_PROGRAM: - if (ctx->shareGroup().Ptr()) { - ctx->dispatcher().glGetIntegerv(pname,&i); - *params = ctx->shareGroup()->getLocalName(SHADER,i); - } - break; - case GL_FRAMEBUFFER_BINDING: - if (ctx->shareGroup().Ptr()) { - ctx->dispatcher().glGetIntegerv(pname,&i); - *params = ctx->shareGroup()->getLocalName(FRAMEBUFFER,i); - } - break; - case GL_RENDERBUFFER_BINDING: - if (ctx->shareGroup().Ptr()) { - ctx->dispatcher().glGetIntegerv(pname,&i); - *params = ctx->shareGroup()->getLocalName(RENDERBUFFER,i); - } - break; - - case GL_NUM_COMPRESSED_TEXTURE_FORMATS: - *params = getCompressedFormats(NULL); - break; - case GL_COMPRESSED_TEXTURE_FORMATS: - getCompressedFormats(params); - break; - - case GL_SHADER_COMPILER: - if(es2) - ctx->dispatcher().glGetIntegerv(pname,params); - else - *params = 1; - break; - - case GL_SHADER_BINARY_FORMATS: - if(es2) - ctx->dispatcher().glGetIntegerv(pname,params); - break; - - case GL_NUM_SHADER_BINARY_FORMATS: - if(es2) - ctx->dispatcher().glGetIntegerv(pname,params); - else - *params = 0; - break; - - case GL_MAX_VERTEX_UNIFORM_VECTORS: - if(es2) - ctx->dispatcher().glGetIntegerv(pname,params); - else - *params = 128; - break; - - case GL_MAX_VARYING_VECTORS: - if(es2) - ctx->dispatcher().glGetIntegerv(pname,params); - else - *params = 8; - break; - - case GL_MAX_FRAGMENT_UNIFORM_VECTORS: - if(es2) - ctx->dispatcher().glGetIntegerv(pname,params); - else - *params = 16; - break; - - case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: - ctx->dispatcher().glGetIntegerv(pname,params); - if(*params > 16) - { - // GLES spec requires only 2, and the ATI driver erronously - // returns 32 (although it supports only 16). This WAR is simple, - // compliant and good enough for developers. - *params = 16; - } - break; - default: - ctx->dispatcher().glGetIntegerv(pname,params); - } - if (destroyCtx) - deleteGLESContext(ctx); -} - -GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::framebufferTarget(target) && - GLESv2Validate::framebufferAttachment(attachment) && - GLESv2Validate::framebufferAttachmentParams(pname)),GL_INVALID_ENUM); - - // - // Take the attachment attribute from our state - if available - // - GLuint fbName = ctx->getFramebufferBinding(); - SET_ERROR_IF (!fbName, GL_INVALID_OPERATION); - if (fbName) { - ObjectDataPtr fbObj = ctx->shareGroup()->getObjectData(FRAMEBUFFER,fbName); - if (fbObj.Ptr() != NULL) { - FramebufferData *fbData = (FramebufferData *)fbObj.Ptr(); - GLenum target; - GLuint name = fbData->getAttachment(attachment, &target, NULL); - if (!name) { - SET_ERROR_IF(pname != GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE && - pname != GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, GL_INVALID_ENUM); - } - if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) { - if (target == GL_TEXTURE_2D) { - *params = GL_TEXTURE; - return; - } - else if (target == GL_RENDERBUFFER) { - *params = GL_RENDERBUFFER; - return; - } else { - *params = GL_NONE; - } - } - else if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { - *params = name; - return; - } - } - } - - ctx->dispatcher().glGetFramebufferAttachmentParameterivEXT(target,attachment,pname,params); -} - -GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::renderbufferTarget(target) && GLESv2Validate::renderbufferParams(pname)),GL_INVALID_ENUM); - - // - // If this is a renderbuffer which is eglimage's target, we - // should query the underlying eglimage's texture object instead. - // - GLuint rb = ctx->getRenderbufferBinding(); - if (rb) { - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(RENDERBUFFER,rb); - RenderbufferData *rbData = (RenderbufferData *)objData.Ptr(); - if (rbData && rbData->sourceEGLImage != 0) { - GLenum texPname; - switch(pname) { - case GL_RENDERBUFFER_WIDTH: - texPname = GL_TEXTURE_WIDTH; - break; - case GL_RENDERBUFFER_HEIGHT: - texPname = GL_TEXTURE_HEIGHT; - break; - case GL_RENDERBUFFER_INTERNAL_FORMAT: - texPname = GL_TEXTURE_INTERNAL_FORMAT; - break; - case GL_RENDERBUFFER_RED_SIZE: - texPname = GL_TEXTURE_RED_SIZE; - break; - case GL_RENDERBUFFER_GREEN_SIZE: - texPname = GL_TEXTURE_GREEN_SIZE; - break; - case GL_RENDERBUFFER_BLUE_SIZE: - texPname = GL_TEXTURE_BLUE_SIZE; - break; - case GL_RENDERBUFFER_ALPHA_SIZE: - texPname = GL_TEXTURE_ALPHA_SIZE; - break; - case GL_RENDERBUFFER_DEPTH_SIZE: - texPname = GL_TEXTURE_DEPTH_SIZE; - break; - case GL_RENDERBUFFER_STENCIL_SIZE: - default: - *params = 0; //XXX - return; - break; - } - - GLint prevTex; - ctx->dispatcher().glGetIntegerv(GL_TEXTURE_BINDING_2D, &prevTex); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, - rbData->eglImageGlobalTexName); - ctx->dispatcher().glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, - texPname, - params); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, prevTex); - return; - } - } - - ctx->dispatcher().glGetRenderbufferParameterivEXT(target,pname,params); -} - - -GL_APICALL void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::programParam(pname),GL_INVALID_ENUM); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - switch(pname) { - case GL_DELETE_STATUS: - { - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ProgramData* programData = (ProgramData*)objData.Ptr(); - params[0] = programData->getDeleteStatus() ? GL_TRUE : GL_FALSE; - } - break; - case GL_LINK_STATUS: - { - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ProgramData* programData = (ProgramData*)objData.Ptr(); - params[0] = programData->getLinkStatus(); - } - break; - //validate status should not return GL_TRUE if link failed - case GL_VALIDATE_STATUS: - { - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ProgramData* programData = (ProgramData*)objData.Ptr(); - if (programData->getLinkStatus()==GL_TRUE) - ctx->dispatcher().glGetProgramiv(globalProgramName,pname,params); - else - params[0] = GL_FALSE; - } - break; - case GL_INFO_LOG_LENGTH: - { - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ProgramData* programData = (ProgramData*)objData.Ptr(); - GLint logLength = strlen(programData->getInfoLog()); - params[0] = (logLength>0) ? logLength+1 : 0; - } - break; - default: - ctx->dispatcher().glGetProgramiv(globalProgramName,pname,params); - } - } -} - -GL_APICALL void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ProgramData* programData = (ProgramData*)objData.Ptr(); - - if (bufsize==0) { - if (length) { - *length = 0; - } - return; - } - - GLsizei logLength; - logLength = strlen(programData->getInfoLog()); - - GLsizei returnLength=0; - if (infolog) { - returnLength = bufsize-1 < logLength ? bufsize-1 : logLength; - strncpy(infolog,programData->getInfoLog(),returnLength+1); - infolog[returnLength] = '\0'; - } - if (length) { - *length = returnLength; - } - } -} - -GL_APICALL void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader); - if (pname == GL_DELETE_STATUS) { - SET_ERROR_IF(globalShaderName == 0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,shader); - SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_VALUE); - SET_ERROR_IF(objData.Ptr()->getDataType()!=SHADER_DATA,GL_INVALID_VALUE); - ShaderParser* sp = (ShaderParser*)objData.Ptr(); - params[0] = (sp->getDeleteStatus()) ? GL_TRUE : GL_FALSE; - return; - } - SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE); - switch(pname) { - case GL_INFO_LOG_LENGTH: - { - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,shader); - SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=SHADER_DATA,GL_INVALID_OPERATION); - ShaderParser* sp = (ShaderParser*)objData.Ptr(); - GLint logLength = strlen(sp->getInfoLog()); - params[0] = (logLength>0) ? logLength+1 : 0; - } - break; - default: - ctx->dispatcher().glGetShaderiv(globalShaderName,pname,params); - } - } -} - - -GL_APICALL void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader); - SET_ERROR_IF(globalShaderName==0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,shader); - SET_ERROR_IF(!objData.Ptr() ,GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=SHADER_DATA,GL_INVALID_OPERATION); - ShaderParser* sp = (ShaderParser*)objData.Ptr(); - - if (bufsize==0) { - if (length) { - *length = 0; - } - return; - } - - GLsizei logLength; - logLength = strlen(sp->getInfoLog()); - - GLsizei returnLength=0; - if (infolog) { - returnLength = bufsize-1 <logLength ? bufsize-1 : logLength; - strncpy(infolog,sp->getInfoLog(),returnLength+1); - infolog[returnLength] = '\0'; - } - if (length) { - *length = returnLength; - } - } -} - -GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision){ - GET_CTX_V2(); - SET_ERROR_IF(!(GLESv2Validate::shaderType(shadertype) && GLESv2Validate::precisionType(precisiontype)),GL_INVALID_ENUM); - - switch (precisiontype) { - case GL_LOW_INT: - case GL_MEDIUM_INT: - case GL_HIGH_INT: - range[0] = range[1] = 16; - *precision = 0; - break; - - case GL_LOW_FLOAT: - case GL_MEDIUM_FLOAT: - case GL_HIGH_FLOAT: - if(ctx->dispatcher().glGetShaderPrecisionFormat != NULL) { - ctx->dispatcher().glGetShaderPrecisionFormat(shadertype,precisiontype,range,precision); - } else { - range[0] = range[1] = 127; - *precision = 24; - } - break; - } -} - -GL_APICALL void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader); - SET_ERROR_IF(globalShaderName == 0,GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,shader); - SET_ERROR_IF(!objData.Ptr(),GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=SHADER_DATA,GL_INVALID_OPERATION); - const char* src = ((ShaderParser*)objData.Ptr())->getOriginalSrc(); - int srcLength = 0; - if (src) { - srcLength = strlen(src); - } - - int returnLength = bufsize<srcLength ? bufsize-1 : srcLength; - if (returnLength) { - strncpy(source,src, returnLength); - source[returnLength] = '\0'; - } - - if (length) - *length = returnLength; - } -} - - -GL_APICALL const GLubyte* GL_APIENTRY glGetString(GLenum name){ - GET_CTX_RET(NULL) - static const GLubyte SHADING[] = "OpenGL ES GLSL ES 1.0.17"; - switch(name) { - case GL_VENDOR: - return (const GLubyte*)ctx->getVendorString(); - case GL_RENDERER: - return (const GLubyte*)ctx->getRendererString(); - case GL_VERSION: - return (const GLubyte*)ctx->getVersionString(); - case GL_SHADING_LANGUAGE_VERSION: - return SHADING; - case GL_EXTENSIONS: - return (const GLubyte*)ctx->getExtensionString(); - default: - RET_AND_SET_ERROR_IF(true,GL_INVALID_ENUM,NULL); - } -} - -GL_APICALL void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM); - ctx->dispatcher().glGetTexParameterfv(target,pname,params); - -} -GL_APICALL void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM); - ctx->dispatcher().glGetTexParameteriv(target,pname,params); -} - -GL_APICALL void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params){ - GET_CTX(); - SET_ERROR_IF(location < 0,GL_INVALID_OPERATION); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ProgramData* pData = (ProgramData *)objData.Ptr(); - SET_ERROR_IF(pData->getLinkStatus() != GL_TRUE,GL_INVALID_OPERATION); - ctx->dispatcher().glGetUniformfv(globalProgramName,location,params); - } -} - -GL_APICALL void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params){ - GET_CTX(); - SET_ERROR_IF(location < 0,GL_INVALID_OPERATION); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ProgramData* pData = (ProgramData *)objData.Ptr(); - SET_ERROR_IF(pData->getLinkStatus() != GL_TRUE,GL_INVALID_OPERATION); - ctx->dispatcher().glGetUniformiv(globalProgramName,location,params); - } -} - -GL_APICALL int GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name){ - GET_CTX_RET(-1); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - RET_AND_SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE,-1); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - RET_AND_SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION,-1); - ProgramData* pData = (ProgramData *)objData.Ptr(); - RET_AND_SET_ERROR_IF(pData->getLinkStatus() != GL_TRUE,GL_INVALID_OPERATION,-1); - return ctx->dispatcher().glGetUniformLocation(globalProgramName,name); - } - return -1; -} - -static bool s_invalidVertexAttribIndex(GLuint index) { - GLint param=0; - glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, ¶m); - return (param < 0 || index >= (GLuint)param); -} - -GL_APICALL void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params){ - GET_CTX_V2(); - SET_ERROR_IF(s_invalidVertexAttribIndex(index), GL_INVALID_VALUE); - const GLESpointer* p = ctx->getPointer(index); - if(p) { - switch(pname){ - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: - *params = 0; - break; - case GL_VERTEX_ATTRIB_ARRAY_ENABLED: - *params = p->isEnable(); - break; - case GL_VERTEX_ATTRIB_ARRAY_SIZE: - *params = p->getSize(); - break; - case GL_VERTEX_ATTRIB_ARRAY_STRIDE: - *params = p->getStride(); - break; - case GL_VERTEX_ATTRIB_ARRAY_TYPE: - *params = p->getType(); - break; - case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: - *params = p->isNormalize(); - break; - case GL_CURRENT_VERTEX_ATTRIB: - if(index == 0) - { - const float* att0 = ctx->getAtt0(); - for(int i=0; i<4; i++) - params[i] = att0[i]; - } - else - ctx->dispatcher().glGetVertexAttribfv(index,pname,params); - break; - default: - ctx->setGLerror(GL_INVALID_ENUM); - } - } else { - ctx->setGLerror(GL_INVALID_VALUE); - } -} - -GL_APICALL void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params){ - GET_CTX_V2(); - SET_ERROR_IF(s_invalidVertexAttribIndex(index), GL_INVALID_VALUE); - const GLESpointer* p = ctx->getPointer(index); - if(p) { - switch(pname){ - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: - *params = 0; - break; - case GL_VERTEX_ATTRIB_ARRAY_ENABLED: - *params = p->isEnable(); - break; - case GL_VERTEX_ATTRIB_ARRAY_SIZE: - *params = p->getSize(); - break; - case GL_VERTEX_ATTRIB_ARRAY_STRIDE: - *params = p->getStride(); - break; - case GL_VERTEX_ATTRIB_ARRAY_TYPE: - *params = p->getType(); - break; - case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: - *params = p->isNormalize(); - break; - case GL_CURRENT_VERTEX_ATTRIB: - if(index == 0) - { - const float* att0 = ctx->getAtt0(); - for(int i=0; i<4; i++) - params[i] = (GLint)att0[i]; - } - else - ctx->dispatcher().glGetVertexAttribiv(index,pname,params); - break; - default: - ctx->setGLerror(GL_INVALID_ENUM); - } - } else { - ctx->setGLerror(GL_INVALID_VALUE); - } -} - -GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer){ - GET_CTX(); - SET_ERROR_IF(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER,GL_INVALID_ENUM); - SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE); - - const GLESpointer* p = ctx->getPointer(index); - if(p) { - *pointer = const_cast<void *>( p->getBufferData()); - } else { - ctx->setGLerror(GL_INVALID_VALUE); - } -} - -GL_APICALL void GL_APIENTRY glHint(GLenum target, GLenum mode){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::hintTargetMode(target,mode),GL_INVALID_ENUM); - ctx->dispatcher().glHint(target,mode); -} - -GL_APICALL GLboolean GL_APIENTRY glIsEnabled(GLenum cap){ - GET_CTX_RET(GL_FALSE); - RET_AND_SET_ERROR_IF(!GLESv2Validate::capability(cap),GL_INVALID_ENUM,GL_FALSE); - return ctx->dispatcher().glIsEnabled(cap); -} - -GL_APICALL GLboolean GL_APIENTRY glIsBuffer(GLuint buffer){ - GET_CTX_RET(GL_FALSE) - if(buffer && ctx->shareGroup().Ptr()) { - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(VERTEXBUFFER,buffer); - return objData.Ptr() ? ((GLESbuffer*)objData.Ptr())->wasBinded():GL_FALSE; - } - return GL_FALSE; -} - -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer){ - GET_CTX_RET(GL_FALSE) - if(framebuffer && ctx->shareGroup().Ptr()){ - return (ctx->shareGroup()->isObject(FRAMEBUFFER,framebuffer) && - ctx->getFramebufferBinding() == framebuffer) ? GL_TRUE :GL_FALSE; - } - return GL_FALSE; -} - -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer){ - GET_CTX_RET(GL_FALSE) - if(renderbuffer && ctx->shareGroup().Ptr()){ - return (ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer) && - ctx->getRenderbufferBinding() == renderbuffer) ? GL_TRUE :GL_FALSE; - } - return GL_FALSE; -} - -GL_APICALL GLboolean GL_APIENTRY glIsTexture(GLuint texture){ - GET_CTX_RET(GL_FALSE) - if (texture==0) - return GL_FALSE; - TextureData* tex = getTextureData(texture); - return tex ? tex->wasBound : GL_FALSE; -} - -GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program){ - GET_CTX_RET(GL_FALSE) - if(program && ctx->shareGroup().Ptr() && - ctx->shareGroup()->isObject(SHADER,program)) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - return ctx->dispatcher().glIsProgram(globalProgramName); - } - return GL_FALSE; -} - -GL_APICALL GLboolean GL_APIENTRY glIsShader(GLuint shader){ - GET_CTX_RET(GL_FALSE) - if(shader && ctx->shareGroup().Ptr() && - ctx->shareGroup()->isObject(SHADER,shader)) { - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader); - return ctx->dispatcher().glIsShader(globalShaderName); - } - return GL_FALSE; -} - -GL_APICALL void GL_APIENTRY glLineWidth(GLfloat width){ - GET_CTX(); - ctx->dispatcher().glLineWidth(width); -} - -GL_APICALL void GL_APIENTRY glLinkProgram(GLuint program){ - GET_CTX(); - GLint linkStatus = GL_FALSE; - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(!objData.Ptr(), GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA, GL_INVALID_OPERATION); - ProgramData* programData = (ProgramData*)objData.Ptr(); - GLint fragmentShader = programData->getAttachedFragmentShader(); - GLint vertexShader = programData->getAttachedVertexShader(); - if (vertexShader != 0 && fragmentShader!=0) { - /* validating that the fragment & vertex shaders were compiled successfuly*/ - GLint fCompileStatus = GL_FALSE; - GLint vCompileStatus = GL_FALSE; - GLuint fragmentShaderGlobal = ctx->shareGroup()->getGlobalName(SHADER,fragmentShader); - GLuint vertexShaderGlobal = ctx->shareGroup()->getGlobalName(SHADER,vertexShader); - ctx->dispatcher().glGetShaderiv(fragmentShaderGlobal,GL_COMPILE_STATUS,&fCompileStatus); - ctx->dispatcher().glGetShaderiv(vertexShaderGlobal,GL_COMPILE_STATUS,&vCompileStatus); - - if(fCompileStatus != 0 && vCompileStatus != 0){ - ctx->dispatcher().glLinkProgram(globalProgramName); - ctx->dispatcher().glGetProgramiv(globalProgramName,GL_LINK_STATUS,&linkStatus); - } - } - programData->setLinkStatus(linkStatus); - - GLsizei infoLogLength=0; - GLchar* infoLog; - ctx->dispatcher().glGetProgramiv(globalProgramName,GL_INFO_LOG_LENGTH,&infoLogLength); - infoLog = new GLchar[infoLogLength+1]; - ctx->dispatcher().glGetProgramInfoLog(globalProgramName,infoLogLength,NULL,infoLog); - programData->setInfoLog(infoLog); - } -} - -GL_APICALL void GL_APIENTRY glPixelStorei(GLenum pname, GLint param){ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::pixelStoreParam(pname),GL_INVALID_ENUM); - SET_ERROR_IF(!((param==1)||(param==2)||(param==4)||(param==8)), GL_INVALID_VALUE); - ctx->setUnpackAlignment(param); - ctx->dispatcher().glPixelStorei(pname,param); -} - -GL_APICALL void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units){ - GET_CTX(); - ctx->dispatcher().glPolygonOffset(factor,units); -} - -GL_APICALL void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::readPixelFrmt(format) && GLESv2Validate::pixelType(ctx,type)),GL_INVALID_ENUM); - SET_ERROR_IF((width < 0 || height < 0),GL_INVALID_VALUE); - SET_ERROR_IF(!(GLESv2Validate::pixelOp(format,type)),GL_INVALID_OPERATION); - SET_ERROR_IF(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE, GL_INVALID_FRAMEBUFFER_OPERATION); - ctx->dispatcher().glReadPixels(x,y,width,height,format,type,pixels); -} - - -GL_APICALL void GL_APIENTRY glReleaseShaderCompiler(void){ - GET_CTX(); - - if(ctx->dispatcher().glReleaseShaderCompiler != NULL) - { - ctx->dispatcher().glReleaseShaderCompiler(); - } -} - -GL_APICALL void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height){ - GET_CTX(); - GLenum internal = internalformat; - switch (internalformat) { - case GL_RGB565: - internal = GL_RGB; - break; - case GL_RGB5_A1: - internal = GL_RGBA; - break; - default: - internal = internalformat; - break; - } - - // Get current bounded renderbuffer - // raise INVALID_OPERATIOn if no renderbuffer is bounded - GLuint rb = ctx->getRenderbufferBinding(); - SET_ERROR_IF(rb == 0,GL_INVALID_OPERATION); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(RENDERBUFFER,rb); - RenderbufferData *rbData = (RenderbufferData *)objData.Ptr(); - SET_ERROR_IF(!rbData,GL_INVALID_OPERATION); - - // - // if the renderbuffer was an eglImage target, detach from - // the eglImage. - // - if (rbData->sourceEGLImage != 0) { - if (rbData->eglImageDetach) { - (*rbData->eglImageDetach)(rbData->sourceEGLImage); - } - rbData->sourceEGLImage = 0; - rbData->eglImageGlobalTexName = 0; - } - - ctx->dispatcher().glRenderbufferStorageEXT(target,internal,width,height); -} - -GL_APICALL void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert){ - GET_CTX(); - ctx->dispatcher().glSampleCoverage(value,invert); -} - -GL_APICALL void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height){ - GET_CTX(); - ctx->dispatcher().glScissor(x,y,width,height); -} - -GL_APICALL void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length){ - GET_CTX(); - - SET_ERROR_IF( (ctx->dispatcher().glShaderBinary == NULL), GL_INVALID_OPERATION); - - if(ctx->shareGroup().Ptr()){ - for(int i=0; i < n ; i++){ - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shaders[i]); - SET_ERROR_IF(globalShaderName == 0,GL_INVALID_VALUE); - ctx->dispatcher().glShaderBinary(1,&globalShaderName,binaryformat,binary,length); - } - } -} - -GL_APICALL void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length){ - GET_CTX_V2(); - SET_ERROR_IF(count < 0,GL_INVALID_VALUE); - if(ctx->shareGroup().Ptr()){ - const GLuint globalShaderName = ctx->shareGroup()->getGlobalName(SHADER,shader); - SET_ERROR_IF(globalShaderName == 0,GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,shader); - SET_ERROR_IF(!objData.Ptr(),GL_INVALID_OPERATION); - SET_ERROR_IF(objData.Ptr()->getDataType()!=SHADER_DATA,GL_INVALID_OPERATION); - ShaderParser* sp = (ShaderParser*)objData.Ptr(); - sp->setSrc(ctx->glslVersion(),count,string,length); - ctx->dispatcher().glShaderSource(globalShaderName,1,sp->parsedLines(),NULL); - } -} - -GL_APICALL void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask){ - GET_CTX(); - ctx->dispatcher().glStencilFunc(func,ref,mask); -} -GL_APICALL void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask){ - GET_CTX(); - ctx->dispatcher().glStencilFuncSeparate(face,func,ref,mask); -} -GL_APICALL void GL_APIENTRY glStencilMask(GLuint mask){ - GET_CTX(); - ctx->dispatcher().glStencilMask(mask); -} - -GL_APICALL void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask){ - GET_CTX(); - ctx->dispatcher().glStencilMaskSeparate(face,mask); -} - -GL_APICALL void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass){ - GET_CTX(); - ctx->dispatcher().glStencilOp(fail,zfail,zpass); -} - -GL_APICALL void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass){ - GET_CTX(); - switch (face) { - case GL_FRONT: - case GL_BACK: - case GL_FRONT_AND_BACK: - break; - default: - SET_ERROR_IF(1, GL_INVALID_ENUM); - } - ctx->dispatcher().glStencilOp(fail,zfail,zpass); -} - -GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::textureTargetEx(target) && - GLESv2Validate::pixelFrmt(ctx,format)&& - GLESv2Validate::pixelType(ctx,type)),GL_INVALID_ENUM); - - SET_ERROR_IF(!GLESv2Validate::pixelFrmt(ctx,internalformat), GL_INVALID_VALUE); - SET_ERROR_IF((format == GL_DEPTH_COMPONENT || internalformat == GL_DEPTH_COMPONENT) && - (type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_INT), GL_INVALID_OPERATION); - - SET_ERROR_IF((type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT) && - (format != GL_DEPTH_COMPONENT || internalformat != GL_DEPTH_COMPONENT), GL_INVALID_OPERATION); - - SET_ERROR_IF(!(GLESv2Validate::pixelOp(format,type) && internalformat == ((GLint)format)),GL_INVALID_OPERATION); - SET_ERROR_IF(border != 0,GL_INVALID_VALUE); - - if (ctx->shareGroup().Ptr()){ - TextureData *texData = getTextureTargetData(target); - if(texData) { - texData->width = width; - texData->height = height; - texData->border = border; - texData->internalFormat = internalformat; - texData->target = target; - - if (texData->sourceEGLImage != 0) { - // - // This texture was a target of EGLImage, - // but now it is re-defined so we need to detach - // from the EGLImage and re-generate global texture name - // for it. - // - if (texData->eglImageDetach) { - (*texData->eglImageDetach)(texData->sourceEGLImage); - } - unsigned int tex = ctx->getBindedTexture(target); - ctx->shareGroup()->replaceGlobalName(TEXTURE, - tex, - texData->oldGlobal); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, texData->oldGlobal); - texData->sourceEGLImage = 0; - texData->oldGlobal = 0; - } - } - } - - if (type==GL_HALF_FLOAT_OES) - type = GL_HALF_FLOAT_NV; - if (pixels==NULL && type==GL_UNSIGNED_SHORT_5_5_5_1) - type = GL_UNSIGNED_SHORT; - ctx->dispatcher().glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels); -} - - -GL_APICALL void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM); - ctx->dispatcher().glTexParameterf(target,pname,param); -} -GL_APICALL void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM); - ctx->dispatcher().glTexParameterfv(target,pname,params); -} -GL_APICALL void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM); - ctx->dispatcher().glTexParameteri(target,pname,param); -} -GL_APICALL void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::textureTarget(target) && GLESv2Validate::textureParams(pname)),GL_INVALID_ENUM); - ctx->dispatcher().glTexParameteriv(target,pname,params); -} - -GL_APICALL void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels){ - GET_CTX(); - SET_ERROR_IF(!(GLESv2Validate::textureTargetEx(target)), GL_INVALID_ENUM); - SET_ERROR_IF(width < 0 || height < 0, GL_INVALID_VALUE); - SET_ERROR_IF(!(GLESv2Validate::pixelFrmt(ctx,format)&& - GLESv2Validate::pixelType(ctx,type)),GL_INVALID_ENUM); - SET_ERROR_IF(!GLESv2Validate::pixelOp(format,type),GL_INVALID_OPERATION); - if (type==GL_HALF_FLOAT_OES) - type = GL_HALF_FLOAT_NV; - - ctx->dispatcher().glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels); - -} - -GL_APICALL void GL_APIENTRY glUniform1f(GLint location, GLfloat x){ - GET_CTX(); - ctx->dispatcher().glUniform1f(location,x); -} -GL_APICALL void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v){ - GET_CTX(); - ctx->dispatcher().glUniform1fv(location,count,v); -} - -GL_APICALL void GL_APIENTRY glUniform1i(GLint location, GLint x){ - GET_CTX(); - ctx->dispatcher().glUniform1i(location,x); -} -GL_APICALL void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v){ - GET_CTX(); - ctx->dispatcher().glUniform1iv(location,count,v); -} -GL_APICALL void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y){ - GET_CTX(); - ctx->dispatcher().glUniform2f(location,x,y); -} -GL_APICALL void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v){ - GET_CTX(); - ctx->dispatcher().glUniform2fv(location,count,v); -} -GL_APICALL void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y){ - GET_CTX(); - ctx->dispatcher().glUniform2i(location,x,y); -} -GL_APICALL void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v){ - GET_CTX(); - ctx->dispatcher().glUniform2iv(location,count,v); -} -GL_APICALL void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z){ - GET_CTX(); - ctx->dispatcher().glUniform3f(location,x,y,z); -} -GL_APICALL void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v){ - GET_CTX(); - ctx->dispatcher().glUniform3fv(location,count,v); -} -GL_APICALL void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z){ - GET_CTX(); - ctx->dispatcher().glUniform3i(location,x,y,z); -} - -GL_APICALL void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v){ - GET_CTX(); - ctx->dispatcher().glUniform3iv(location,count,v); -} - -GL_APICALL void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w){ - GET_CTX(); - ctx->dispatcher().glUniform4f(location,x,y,z,w); -} - -GL_APICALL void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v){ - GET_CTX(); - ctx->dispatcher().glUniform4fv(location,count,v); -} - -GL_APICALL void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w){ - GET_CTX(); - ctx->dispatcher().glUniform4i(location,x,y,z,w); -} - -GL_APICALL void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v){ - GET_CTX(); - ctx->dispatcher().glUniform4iv(location,count,v); -} - -GL_APICALL void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){ - GET_CTX(); - SET_ERROR_IF(transpose != GL_FALSE,GL_INVALID_VALUE); - ctx->dispatcher().glUniformMatrix2fv(location,count,transpose,value); -} - -GL_APICALL void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){ - GET_CTX(); - SET_ERROR_IF(transpose != GL_FALSE,GL_INVALID_VALUE); - ctx->dispatcher().glUniformMatrix3fv(location,count,transpose,value); -} - -GL_APICALL void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){ - GET_CTX(); - SET_ERROR_IF(transpose != GL_FALSE,GL_INVALID_VALUE); - ctx->dispatcher().glUniformMatrix4fv(location,count,transpose,value); -} - -static void s_unUseCurrentProgram() { - GET_CTX(); - GLint localCurrentProgram = 0; - glGetIntegerv(GL_CURRENT_PROGRAM, &localCurrentProgram); - if (!localCurrentProgram) return; - - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,localCurrentProgram); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ProgramData* programData = (ProgramData*)objData.Ptr(); - programData->setInUse(false); - if (programData->getDeleteStatus()) { glDeleteProgram(localCurrentProgram); } -} - -GL_APICALL void GL_APIENTRY glUseProgram(GLuint program){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(program!=0 && globalProgramName==0,GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(objData.Ptr() && (objData.Ptr()->getDataType()!=PROGRAM_DATA),GL_INVALID_OPERATION); - - s_unUseCurrentProgram(); - - ProgramData* programData = (ProgramData*)objData.Ptr(); - if (programData) programData->setInUse(true); - - ctx->dispatcher().glUseProgram(globalProgramName); - } -} - -GL_APICALL void GL_APIENTRY glValidateProgram(GLuint program){ - GET_CTX(); - if(ctx->shareGroup().Ptr()) { - const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(SHADER,program); - SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(SHADER,program); - SET_ERROR_IF(objData.Ptr()->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION); - ProgramData* programData = (ProgramData*)objData.Ptr(); - ctx->dispatcher().glValidateProgram(globalProgramName); - - GLsizei infoLogLength=0; - GLchar* infoLog; - ctx->dispatcher().glGetProgramiv(globalProgramName,GL_INFO_LOG_LENGTH,&infoLogLength); - infoLog = new GLchar[infoLogLength+1]; - ctx->dispatcher().glGetProgramInfoLog(globalProgramName,infoLogLength,NULL,infoLog); - programData->setInfoLog(infoLog); - } -} - -GL_APICALL void GL_APIENTRY glVertexAttrib1f(GLuint indx, GLfloat x){ - GET_CTX_V2(); - ctx->dispatcher().glVertexAttrib1f(indx,x); - if(indx == 0) - ctx->setAttribute0value(x, 0.0, 0.0, 1.0); -} - -GL_APICALL void GL_APIENTRY glVertexAttrib1fv(GLuint indx, const GLfloat* values){ - GET_CTX_V2(); - ctx->dispatcher().glVertexAttrib1fv(indx,values); - if(indx == 0) - ctx->setAttribute0value(values[0], 0.0, 0.0, 1.0); -} - -GL_APICALL void GL_APIENTRY glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y){ - GET_CTX_V2(); - ctx->dispatcher().glVertexAttrib2f(indx,x,y); - if(indx == 0) - ctx->setAttribute0value(x, y, 0.0, 1.0); -} - -GL_APICALL void GL_APIENTRY glVertexAttrib2fv(GLuint indx, const GLfloat* values){ - GET_CTX_V2(); - ctx->dispatcher().glVertexAttrib2fv(indx,values); - if(indx == 0) - ctx->setAttribute0value(values[0], values[1], 0.0, 1.0); -} - -GL_APICALL void GL_APIENTRY glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z){ - GET_CTX_V2(); - ctx->dispatcher().glVertexAttrib3f(indx,x,y,z); - if(indx == 0) - ctx->setAttribute0value(x, y, z, 1.0); -} - -GL_APICALL void GL_APIENTRY glVertexAttrib3fv(GLuint indx, const GLfloat* values){ - GET_CTX_V2(); - ctx->dispatcher().glVertexAttrib3fv(indx,values); - if(indx == 0) - ctx->setAttribute0value(values[0], values[1], values[2], 1.0); -} - -GL_APICALL void GL_APIENTRY glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w){ - GET_CTX_V2(); - ctx->dispatcher().glVertexAttrib4f(indx,x,y,z,w); - if(indx == 0) - ctx->setAttribute0value(x, y, z, w); -} - -GL_APICALL void GL_APIENTRY glVertexAttrib4fv(GLuint indx, const GLfloat* values){ - GET_CTX_V2(); - ctx->dispatcher().glVertexAttrib4fv(indx,values); - if(indx == 0) - ctx->setAttribute0value(values[0], values[1], values[2], values[3]); -} - -GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr){ - GET_CTX(); - SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,indx)),GL_INVALID_VALUE); - if (type == GL_HALF_FLOAT_OES) type = GL_HALF_FLOAT; - ctx->setPointer(indx,size,type,stride,ptr,normalized); -} - -GL_APICALL void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height){ - GET_CTX(); - ctx->dispatcher().glViewport(x,y,width,height); -} - -GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) -{ - GET_CTX(); - SET_ERROR_IF(!GLESv2Validate::textureTargetLimited(target),GL_INVALID_ENUM); - unsigned int imagehndl = SafeUIntFromPointer(image); - 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 - // current binded texture object to the existing global object. - if (ctx->shareGroup().Ptr()) { - ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target)); - unsigned int oldGlobal = ctx->shareGroup()->getGlobalName(TEXTURE, tex); - // Delete old texture object but only if it is not a target of a EGLImage - if (oldGlobal) { - TextureData* oldTexData = getTextureData(tex); - if (!oldTexData || oldTexData->sourceEGLImage == 0) { - ctx->dispatcher().glDeleteTextures(1, &oldGlobal); - } - } - // replace mapping and bind the new global object - ctx->shareGroup()->replaceGlobalName(TEXTURE, tex,img->globalTexName); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName); - TextureData *texData = getTextureTargetData(target); - SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); - texData->width = img->width; - texData->height = img->height; - texData->border = img->border; - texData->internalFormat = img->internalFormat; - texData->sourceEGLImage = imagehndl; - texData->eglImageDetach = s_eglIface->eglDetachEGLImage; - texData->oldGlobal = oldGlobal; - } - } -} - -GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) -{ - GET_CTX(); - SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM); - unsigned int imagehndl = SafeUIntFromPointer(image); - EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl); - SET_ERROR_IF(!img,GL_INVALID_VALUE); - SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION); - - // Get current bounded renderbuffer - // raise INVALID_OPERATIOn if no renderbuffer is bounded - GLuint rb = ctx->getRenderbufferBinding(); - SET_ERROR_IF(rb == 0,GL_INVALID_OPERATION); - ObjectDataPtr objData = ctx->shareGroup()->getObjectData(RENDERBUFFER,rb); - RenderbufferData *rbData = (RenderbufferData *)objData.Ptr(); - SET_ERROR_IF(!rbData,GL_INVALID_OPERATION); - - // - // flag in the renderbufferData that it is an eglImage target - // - rbData->sourceEGLImage = imagehndl; - rbData->eglImageDetach = s_eglIface->eglDetachEGLImage; - rbData->eglImageGlobalTexName = img->globalTexName; - - // - // if the renderbuffer is attached to a framebuffer - // change the framebuffer attachment in the undelying OpenGL - // to point to the eglImage texture object. - // - if (rbData->attachedFB) { - // update the framebuffer attachment point to the - // underlying texture of the img - GLuint prevFB = ctx->getFramebufferBinding(); - if (prevFB != rbData->attachedFB) { - ctx->dispatcher().glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, - rbData->attachedFB); - } - ctx->dispatcher().glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, - rbData->attachedPoint, - GL_TEXTURE_2D, - img->globalTexName,0); - if (prevFB != rbData->attachedFB) { - ctx->dispatcher().glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, - prevFB); - } - } -} diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp deleted file mode 100644 index b711317..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/* -* 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. -*/ -#include "GLESv2Validate.h" -#include <string.h> - -bool GLESv2Validate::blendEquationMode(GLenum mode){ - return mode == GL_FUNC_ADD || - mode == GL_FUNC_SUBTRACT || - mode == GL_FUNC_REVERSE_SUBTRACT; -} - -bool GLESv2Validate::blendSrc(GLenum s) { - switch(s) { - case GL_ZERO: - case GL_ONE: - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - case GL_SRC_ALPHA_SATURATE: - return true; - } - return false; -} - - -bool GLESv2Validate::blendDst(GLenum d) { - switch(d) { - case GL_ZERO: - case GL_ONE: - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - return true; - } - return false; -} - -bool GLESv2Validate::textureParams(GLenum param){ - switch(param) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - return true; - default: - return false; - } -} - -bool GLESv2Validate::hintTargetMode(GLenum target,GLenum mode){ - - switch(mode) { - case GL_FASTEST: - case GL_NICEST: - case GL_DONT_CARE: - break; - default: return false; - } - return target == GL_GENERATE_MIPMAP_HINT || target == GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES; -} - -bool GLESv2Validate::capability(GLenum cap){ - switch(cap){ - case GL_BLEND: - case GL_CULL_FACE: - case GL_DEPTH_TEST: - case GL_DITHER: - case GL_POLYGON_OFFSET_FILL: - case GL_SAMPLE_ALPHA_TO_COVERAGE: - case GL_SAMPLE_COVERAGE: - case GL_SCISSOR_TEST: - case GL_STENCIL_TEST: - return true; - } - return false; -} - -bool GLESv2Validate::pixelStoreParam(GLenum param){ - return param == GL_PACK_ALIGNMENT || param == GL_UNPACK_ALIGNMENT; -} - -bool GLESv2Validate::readPixelFrmt(GLenum format){ - switch(format) { - case GL_ALPHA: - case GL_LUMINANCE_ALPHA: - case GL_RGB: - case GL_RGBA: - return true; - } - return false; -} - - -bool GLESv2Validate::shaderType(GLenum type){ - return type == GL_VERTEX_SHADER || type == GL_FRAGMENT_SHADER; -} - -bool GLESv2Validate::precisionType(GLenum type){ - switch(type){ - case GL_LOW_FLOAT: - case GL_MEDIUM_FLOAT: - case GL_HIGH_FLOAT: - case GL_LOW_INT: - case GL_MEDIUM_INT: - case GL_HIGH_INT: - return true; - } - return false; -} - -bool GLESv2Validate::arrayIndex(GLEScontext * ctx,GLuint index) { - return index < (GLuint)ctx->getCaps()->maxVertexAttribs; -} - -bool GLESv2Validate::pixelType(GLEScontext * ctx,GLenum type) { - if(type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT) - return true; - - return GLESvalidate::pixelType(ctx, type); -} - -bool GLESv2Validate::pixelFrmt(GLEScontext* ctx,GLenum format) { - if(format == GL_DEPTH_COMPONENT) - return true; - - return GLESvalidate::pixelFrmt(ctx, format); -} - -bool GLESv2Validate::attribName(const GLchar* name){ - const GLchar* found = strstr(name,"gl_"); - return (!found) || - (found != name) ; // attrib name does not start with gl_ -} - -bool GLESv2Validate::attribIndex(int index){ - return index >=0 && index < GL_MAX_VERTEX_ATTRIBS; -} - -bool GLESv2Validate::programParam(GLenum pname){ - switch(pname){ - case GL_DELETE_STATUS: - case GL_LINK_STATUS: - case GL_VALIDATE_STATUS: - case GL_INFO_LOG_LENGTH: - case GL_ATTACHED_SHADERS: - case GL_ACTIVE_ATTRIBUTES: - case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: - case GL_ACTIVE_UNIFORMS: - case GL_ACTIVE_UNIFORM_MAX_LENGTH: - return true; - } - return false; -} diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h deleted file mode 100644 index b7cd07d..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -* 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_V2_VALIDATE_H -#define GLES_V2_VALIDATE_H - -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> -#include <GLcommon/GLESvalidate.h> - -struct GLESv2Validate:public GLESvalidate{ -static bool blendEquationMode(GLenum mode); -static bool blendSrc(GLenum s); -static bool blendDst(GLenum d); -static bool textureParams(GLenum param); -static bool hintTargetMode(GLenum target,GLenum mode); -static bool capability(GLenum cap); -static bool pixelStoreParam(GLenum param); -static bool readPixelFrmt(GLenum format); -static bool shaderType(GLenum type); -static bool precisionType(GLenum type); -static bool arrayIndex(GLEScontext * ctx,GLuint index); -static bool pixelType(GLEScontext * ctx,GLenum type); -static bool pixelFrmt(GLEScontext* ctx,GLenum format); -static bool attribName(const GLchar* name); -static bool attribIndex(int index); -static bool programParam(GLenum pname); -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/ProgramData.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/ProgramData.cpp deleted file mode 100644 index b008e91..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/ProgramData.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -* 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. -*/ -#include <GLES2/gl2.h> -#include <GLcommon/objectNameManager.h> -#include "ProgramData.h" - -ProgramData::ProgramData() : ObjectData(PROGRAM_DATA), - AttachedVertexShader(0), - AttachedFragmentShader(0), - LinkStatus(GL_FALSE), - IsInUse(false), - DeleteStatus(false) { - infoLog = new GLchar[1]; - infoLog[0] = '\0'; -} - -ProgramData::~ProgramData () { - delete[] infoLog; -}; - -void ProgramData::setInfoLog(GLchar* log) { - delete[] infoLog; - infoLog = log; -} - -GLchar* ProgramData::getInfoLog() { - return infoLog; -} - -GLuint ProgramData::getAttachedVertexShader() { - return AttachedVertexShader; -} - -GLuint ProgramData::getAttachedFragmentShader() { - return AttachedFragmentShader; -} - -GLuint ProgramData::getAttachedShader(GLenum type) { - GLuint shader = 0; - switch (type) { - case GL_VERTEX_SHADER: - shader = AttachedVertexShader; - break; - case GL_FRAGMENT_SHADER: - shader = AttachedFragmentShader; - break; - } - return shader; -} - -bool ProgramData::attachShader(GLuint shader,GLenum type) { - if (type==GL_VERTEX_SHADER && AttachedVertexShader==0) { - AttachedVertexShader=shader; - return true; - } - else if (type==GL_FRAGMENT_SHADER && AttachedFragmentShader==0) { - AttachedFragmentShader=shader; - return true; - } - return false; -} - -bool ProgramData::isAttached(GLuint shader) { - return (AttachedFragmentShader==shader || AttachedVertexShader==shader); -} - -bool ProgramData::detachShader(GLuint shader) { - if (AttachedVertexShader==shader) { - AttachedVertexShader = 0; - return true; - } - else if (AttachedFragmentShader==shader) { - AttachedFragmentShader = 0; - return true; - } - return false; -} - -void ProgramData::setLinkStatus(GLint status) { - LinkStatus = status; -} - -GLint ProgramData::getLinkStatus() { - return LinkStatus; -} diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/ProgramData.h b/emulator/opengl/host/libs/Translator/GLES_V2/ProgramData.h deleted file mode 100644 index 7ce5801..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/ProgramData.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* 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 PROGRAM_DATA_H -#define PROGRAM_DATA_H - -class ProgramData:public ObjectData{ -public: - ProgramData(); - virtual ~ProgramData(); - - GLuint getAttachedVertexShader(); - GLuint getAttachedFragmentShader(); - GLuint getAttachedShader(GLenum type); - - bool attachShader(GLuint shader,GLenum type); - bool isAttached(GLuint shader); - bool detachShader(GLuint shader); - - void setLinkStatus(GLint status); - GLint getLinkStatus(); - - void setInfoLog(GLchar *log); - GLchar* getInfoLog(); - - bool isInUse() const { return IsInUse; } - void setInUse(bool inUse) { IsInUse = inUse; } - - bool getDeleteStatus() const { return DeleteStatus; } - void setDeleteStatus(bool status) { DeleteStatus = status; } -private: - GLuint AttachedVertexShader; - GLuint AttachedFragmentShader; - GLint LinkStatus; - GLchar* infoLog; - bool IsInUse; - bool DeleteStatus; -}; -#endif diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp deleted file mode 100644 index 4e14a29..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp +++ /dev/null @@ -1,348 +0,0 @@ -/* -* 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 "ShaderParser.h" -#include <stdlib.h> -#include <string.h> - -ShaderParser::ShaderParser():ObjectData(SHADER_DATA), - m_type(0), - m_originalSrc(NULL), - m_parsedLines(NULL), - m_deleteStatus(false), - m_program(0) { - m_infoLog = new GLchar[1]; - m_infoLog[0] = '\0'; -}; - -ShaderParser::ShaderParser(GLenum type):ObjectData(SHADER_DATA), - m_type(type), - m_originalSrc(NULL), - m_parsedLines(NULL), - m_deleteStatus(false), - m_program(0) { - - m_infoLog = new GLchar[1]; - m_infoLog[0] = '\0'; -}; - -void ShaderParser::setSrc(const Version& ver,GLsizei count,const GLchar* const* strings,const GLint* length){ - m_src.clear(); - for(int i = 0;i<count;i++){ - m_src.append(strings[i]); - } - //store original source - if (m_originalSrc) - free(m_originalSrc); - m_originalSrc = strdup(m_src.c_str()); - - clearParsedSrc(); - - // parseGLSLversion must be called first since #version should be the - // first token in the shader source. - parseGLSLversion(); - parseBuiltinConstants(); - /* - version 1.30.10 is the first version of GLSL Language containing precision qualifiers - if the glsl version is less than 1.30.10 than we will use a shader parser which omits - all precision qualifiers from the shader source , otherwise we will use a shader parser - which set the default precisions to be the same as the default precisions of GLSL ES - */ -#if 0 - if(ver < Version(1,30,10)){ - parseOmitPrecision(); - } else { - parseExtendDefaultPrecision(); - } -#else - //XXX: Until proved otherwise, glsl doesn't know/use those precision macros, so we omit then - parseOmitPrecision(); -#endif - parseLineNumbers(); - parseOriginalSrc(); -} -const GLchar** ShaderParser::parsedLines() { - m_parsedLines = (GLchar*)m_parsedSrc.c_str(); - return const_cast<const GLchar**> (&m_parsedLines); -}; - -const char* ShaderParser::getOriginalSrc(){ - return m_originalSrc; -} - -void ShaderParser::parseLineNumbers() -{ - m_parsedSrc += "#line 1\n"; -} - -void ShaderParser::parseOriginalSrc() { - m_parsedSrc+=m_src; -} - -void ShaderParser::parseGLSLversion() { - - // - // find in shader the #version token if exist. - // That token should be the first non-comment or blank token - // - const char *src = m_src.c_str(); - const int minGLSLVersion = 120; - int glslVersion = minGLSLVersion; - enum { - PARSE_NONE, - PARSE_IN_C_COMMENT, - PARSE_IN_LINE_COMMENT - } parseState = PARSE_NONE; - const char *c = src; - - while( c && *c != '\0') { - if (parseState == PARSE_IN_C_COMMENT) { - if (*c == '*' && *(c+1) == '/') { - parseState = PARSE_NONE; - c += 2; - } - else c++; - } - else if (parseState == PARSE_IN_LINE_COMMENT) { - if (*c == '\n') { - parseState = PARSE_NONE; - } - c++; - } - else if (*c == '/' && *(c+1) == '/') { - parseState = PARSE_IN_LINE_COMMENT; - c += 2; - } - else if (*c == '/' && *(c+1) == '*') { - parseState = PARSE_IN_C_COMMENT; - c += 2; - } - else if (*c == ' ' || *c == '\t' || *c == '\r' || *c == '\n') { - c++; - } - else { - // - // We have reached the first non-blank character outside - // a comment, this must be a #version token or else #version - // token does not exist in this shader source. - // - if (!strncmp(c,"#version",8)) { - int ver; - if (sscanf(c+8,"%d",&ver) == 1) { - // - // parsed version string correctly, blank out the - // version token from the source, we will add it later at - // the begining of the shader. - // - char *cc = (char *)c; - for (int i=0; i<8; i++,cc++) *cc = ' '; - while (*cc < '0' || *cc > '9') { *cc = ' '; cc++; } - while (*cc >= '0' && *cc <= '9') { *cc = ' '; cc++; } - - // Use the version from the source but only if - // it is larger than our minGLSLVersion - if (ver > minGLSLVersion) glslVersion = ver; - } - } - - // - // break the loop, no need to go further on the source. - break; - } - } - - // - // allow to force GLSL version through environment variable - // - const char *forceVersion = getenv("GOOGLE_GLES_FORCE_GLSL_VERSION"); - if (forceVersion) { - int ver; - if (sscanf(forceVersion,"%d",&ver) == 1) { - glslVersion = ver; - } - } - - // - // if glslVersion is defined, add it to the parsed source - // - if (glslVersion > 0) { - char vstr[16]; - sprintf(vstr,"%d",glslVersion); - m_parsedSrc += std::string("#version ") + - std::string(vstr) + - std::string("\n"); - } -} - -void ShaderParser::parseBuiltinConstants() -{ - m_parsedSrc += - "const int _translator_gl_MaxVertexUniformVectors = 256;\n" - "const int _translator_gl_MaxFragmentUniformVectors = 256;\n" - "const int _translator_gl_MaxVaryingVectors = 15;\n" - "#define gl_MaxVertexUniformVectors _translator_gl_MaxVertexUniformVectors\n" - "#define gl_MaxFragmentUniformVectors _translator_gl_MaxFragmentUniformVectors\n" - "#define gl_MaxVaryingVectors _translator_gl_MaxVaryingVectors\n"; - -} - -void ShaderParser::parseOmitPrecision(){ - - //defines we need to add in order to Omit precisions qualifiers - static const GLchar defines[] = { - "#define GLES 1\n" - "#define lowp \n" - "#define mediump \n" - "#define highp \n" - }; - m_parsedSrc+=defines; - - // - // parse the source and blank out precision statements - // which has the following syntax: - // precision {qualifier} {type}; - // where {qualifier} is one of lowp,mediump or hightp - // type is any valid GLES defined type (we do not check that here!) - // NOTE: This is needed in order to workaround driver bug in - // Intel/Linux where the compiler does not get statement like - // "float;", otherwise we could just define a macro named - // precision to be empty. - // - const char *src = m_src.c_str(); - - enum { - PRECISION, - QUALIFIER, - SEMICOLON - } statementState = PRECISION; - const char *precision = NULL; - - enum { - PARSE_NONE, - PARSE_IN_C_COMMENT, - PARSE_IN_LINE_COMMENT - } parseState = PARSE_NONE; - const char *c = src; - const char *t = NULL; - - #define IS_DELIMITER(c) ( (c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n' ) - #define IS_TOKEN_START(c) ( ((c) >= 'a' && (c) <='z') || ((c) >= 'A' && (c) <= 'Z') ) - #define IS_TOKEN_DELIMITER(c) ( IS_DELIMITER(c) || (c) == ';' ) - - while( c && *c != '\0') { - if (parseState == PARSE_IN_C_COMMENT) { - if (*c == '*' && *(c+1) == '/') { - parseState = PARSE_NONE; - c += 2; - } - else c++; - } - else if (parseState == PARSE_IN_LINE_COMMENT) { - if (*c == '\n') { - parseState = PARSE_NONE; - } - c++; - } - else if (*c == '/' && *(c+1) == '/') { - parseState = PARSE_IN_LINE_COMMENT; - c += 2; - } - else if (*c == '/' && *(c+1) == '*') { - parseState = PARSE_IN_C_COMMENT; - c += 2; - } - else if (t && IS_TOKEN_DELIMITER(*c)) { - int tokenLen = c - t; - switch (statementState) { - case PRECISION: - if (tokenLen == 9 && !strncmp(t,"precision",9)) { - statementState = QUALIFIER; - precision = t; - } - break; - case QUALIFIER: - if ((tokenLen == 4 && !strncmp(t,"lowp",4)) || - (tokenLen == 7 && !strncmp(t,"mediump",7)) || - (tokenLen == 5 && !strncmp(t,"highp",5))) { - statementState = SEMICOLON; - } - else { - statementState = PRECISION; - } - break; - case SEMICOLON: - if (*c == ';') { - for (char *r = (char *)precision; r<=c ; ++r) { - *r = ' '; //blank the character - } - } - statementState = PRECISION; //search for the next precision line - break; - default: - break; - } - c++; - t = NULL; - } - else if (IS_DELIMITER(*c)) { - c++; - } - else { - if (!t && IS_TOKEN_START(*c)) { - t = c; - } - c++; - } - } -} - -void ShaderParser::parseExtendDefaultPrecision(){ - - //the precision lines which we need to add to the shader - static const GLchar extend[] = { - "#define GLES 1\n" - "precision lowp sampler2D;\n" - "precision lowp samplerCube;\n" - }; - - m_parsedSrc+=extend; -} - -void ShaderParser::clearParsedSrc(){ - m_parsedSrc.clear(); -} - -GLenum ShaderParser::getType() { - return m_type; -} - -void ShaderParser::setInfoLog(GLchar* infoLog) -{ - delete[] m_infoLog; - m_infoLog = infoLog; -} - -GLchar* ShaderParser::getInfoLog() -{ - return m_infoLog; -} - -ShaderParser::~ShaderParser(){ - clearParsedSrc(); - if (m_originalSrc) - free(m_originalSrc); - delete[] m_infoLog; -} diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h deleted file mode 100644 index 8cd3940..0000000 --- a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -* 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 SHADER_PARSER_H -#define SHADER_PARSER_H - -#include "GLESv2Context.h" -#include <string> -#include <GLES2/gl2.h> -#include <GLcommon/objectNameManager.h> - -class ShaderParser:public ObjectData{ -public: - ShaderParser(); - ShaderParser(GLenum type); - void setSrc(const Version& ver,GLsizei count,const GLchar* const* strings,const GLint* length); - const char* getOriginalSrc(); - const GLchar** parsedLines(); - GLenum getType(); - ~ShaderParser(); - - void setInfoLog(GLchar * infoLog); - GLchar* getInfoLog(); - - void setDeleteStatus(bool val) { m_deleteStatus = val; } - bool getDeleteStatus() const { return m_deleteStatus; } - - void setAttachedProgram(GLuint program) { m_program = program; } - GLuint getAttachedProgram() const { return m_program; } -private: - void parseOriginalSrc(); - void parseGLSLversion(); - void parseBuiltinConstants(); - void parseOmitPrecision(); - void parseExtendDefaultPrecision(); - void parseLineNumbers(); - void clearParsedSrc(); - - GLenum m_type; - char* m_originalSrc; - std::string m_src; - std::string m_parsedSrc; - GLchar* m_parsedLines; - GLchar* m_infoLog; - bool m_deleteStatus; - GLuint m_program; -}; -#endif diff --git a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk b/emulator/opengl/host/libs/Translator/GLcommon/Android.mk deleted file mode 100644 index d1a462d..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk +++ /dev/null @@ -1,58 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -host_common_SRC_FILES := \ - GLDispatch.cpp \ - GLutils.cpp \ - GLEScontext.cpp \ - GLESvalidate.cpp \ - GLESpointer.cpp \ - GLESbuffer.cpp \ - DummyGLfuncs.cpp \ - RangeManip.cpp \ - TextureUtils.cpp \ - PaletteTexture.cpp \ - etc1.cpp \ - objectNameManager.cpp \ - FramebufferData.cpp - -host_GL_COMMON_LINKER_FLAGS := -host_common_LDLIBS := -host_common_LDFLAGS := - -ifeq ($(HOST_OS),linux) -# host_common_LDFLAGS += -Wl,--whole-archive - host_common_LDLIBS += -lGL -ldl - host_common_LDFLAGS += -Wl,-Bsymbolic -endif - -ifeq ($(HOST_OS),windows) - host_common_LDLIBS += -lopengl32 -lgdi32 - host_common_LDFLAGS += -Wl,--add-stdcall-alias -endif - - -### EGL host implementation ######################## - -$(call emugl-begin-host-static-library,libGLcommon) - -translator_path := $(LOCAL_PATH)/.. -LOCAL_SRC_FILES := $(host_common_SRC_FILES) -$(call emugl-export,LDLIBS,$(host_common_LDLIBS)) -$(call emugl-export,LDFLAGS,$(host_common_LDFLAGS)) -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared) -$(call emugl-export,STATIC_LIBRARIES, libemugl_common) - -$(call emugl-end-module) - - -### EGL host implementation, 64-bit ################ -$(call emugl-begin-host64-static-library,lib64GLcommon) - -translator_path := $(LOCAL_PATH)/.. -LOCAL_SRC_FILES := $(host_common_SRC_FILES) -$(call emugl-export,LDLIBS,$(host_common_LDLIBS)) -$(call emugl-export,LDFLAGS,$(host_common_LDFLAGS)) -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared) -$(call emugl-export,STATIC_LIBRARIES, lib64emugl_common) - -$(call emugl-end-module) diff --git a/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp b/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp deleted file mode 100644 index cc0e3ec..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* -* 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 "DummyGLfuncs.h" - - void GLAPIENTRY dummy_glActiveTexture ( GLenum texture ){} - void GLAPIENTRY dummy_glBindBuffer (GLenum target, GLuint buffer){} - void GLAPIENTRY dummy_glBindTexture (GLenum target, GLuint texture){} - void GLAPIENTRY dummy_glBlendFunc (GLenum sfactor, GLenum dfactor){} - void GLAPIENTRY dummy_glBlendEquation( GLenum mode ){} - void GLAPIENTRY dummy_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha){} - void GLAPIENTRY dummy_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha){} - void GLAPIENTRY dummy_glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage){} - void GLAPIENTRY dummy_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data){} - void GLAPIENTRY dummy_glClear(GLbitfield mask){} - void GLAPIENTRY dummy_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){} - void GLAPIENTRY dummy_glClearStencil(GLint s){} - void GLAPIENTRY dummy_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha){} - void GLAPIENTRY dummy_glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ){} - void GLAPIENTRY dummy_glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ){} - void GLAPIENTRY dummy_glCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border){} - void GLAPIENTRY dummy_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height){} - void GLAPIENTRY dummy_glCullFace(GLenum mode){} - void GLAPIENTRY dummy_glDeleteBuffers(GLsizei n, const GLuint *buffers){} - void GLAPIENTRY dummy_glDeleteTextures(GLsizei n, const GLuint *textures){} - void GLAPIENTRY dummy_glDepthFunc(GLenum func){} - void GLAPIENTRY dummy_glDepthMask(GLboolean flag){} - void GLAPIENTRY dummy_glDepthRange(GLclampd zNear, GLclampd zFar){} - void GLAPIENTRY dummy_glDisable(GLenum cap){} - void GLAPIENTRY dummy_glDrawArrays(GLenum mode, GLint first, GLsizei count){} - void GLAPIENTRY dummy_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices){} - void GLAPIENTRY dummy_glEnable(GLenum cap){} - void GLAPIENTRY dummy_glFinish(void){} - void GLAPIENTRY dummy_glFlush(void){} - void GLAPIENTRY dummy_glFrontFace(GLenum mode){} - void GLAPIENTRY dummy_glGenBuffers(GLsizei n, GLuint *buffers){} - void GLAPIENTRY dummy_glGenTextures(GLsizei n, GLuint *textures){} - void GLAPIENTRY dummy_glGetBooleanv(GLenum pname, GLboolean *params){} - void GLAPIENTRY dummy_glGetBufferParameteriv(GLenum, GLenum, GLint *){} - GLenum GLAPIENTRY dummy_glGetError(void){ return 0;} - void GLAPIENTRY dummy_glGetFloatv(GLenum pname, GLfloat *params){} - void GLAPIENTRY dummy_glGetIntegerv(GLenum pname, GLint *params){} - const GLubyte * GLAPIENTRY dummy_glGetString(GLenum name){ return 0;} - void GLAPIENTRY dummy_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params){} - void GLAPIENTRY dummy_glGetTexParameteriv(GLenum target, GLenum pname, GLint *params){} - void GLAPIENTRY dummy_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params){} - void GLAPIENTRY dummy_glHint(GLenum target, GLenum mode){} - GLboolean GLAPIENTRY dummy_glIsBuffer(GLuint){ return false;} - GLboolean GLAPIENTRY dummy_glIsEnabled(GLenum cap){ return false;} - GLboolean GLAPIENTRY dummy_glIsTexture(GLuint texture){return false;} - void GLAPIENTRY dummy_glLineWidth(GLfloat width){} - void GLAPIENTRY dummy_glPolygonOffset(GLfloat factor, GLfloat units){} - void GLAPIENTRY dummy_glPixelStorei(GLenum pname, GLint param){} - void GLAPIENTRY dummy_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels){} - void GLAPIENTRY dummy_glSampleCoverage(GLclampf value, GLboolean invert ){} - void GLAPIENTRY dummy_glScissor(GLint x, GLint y, GLsizei width, GLsizei height){} - void GLAPIENTRY dummy_glStencilFunc(GLenum func, GLint ref, GLuint mask){} - void GLAPIENTRY dummy_glStencilMask(GLuint mask){} - void GLAPIENTRY dummy_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass){} - void GLAPIENTRY dummy_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels){} - void GLAPIENTRY dummy_glTexParameteri(GLenum target, GLenum pname, GLint param){} - void GLAPIENTRY dummy_glTexParameteriv(GLenum target, GLenum pname, const GLint *params){} - void GLAPIENTRY dummy_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels){} - void GLAPIENTRY dummy_glViewport(GLint x, GLint y, GLsizei width, GLsizei height){} - void GLAPIENTRY dummy_glPushAttrib( GLbitfield mask ){} - void GLAPIENTRY dummy_glPopAttrib( void ){} - void GLAPIENTRY dummy_glPushClientAttrib( GLbitfield mask ){} - void GLAPIENTRY dummy_glPopClientAttrib( void ){} - - /* OpenGL functions which are needed ONLY for implementing GLES 1.1*/ - void GLAPIENTRY dummy_glAlphaFunc(GLenum func, GLclampf ref){} - void GLAPIENTRY dummy_glBegin( GLenum mode ){} - void GLAPIENTRY dummy_glClearDepth(GLclampd depth){} - void GLAPIENTRY dummy_glClientActiveTexture( GLenum texture ){} - void GLAPIENTRY dummy_glClipPlane(GLenum plane, const GLdouble *equation){} - void GLAPIENTRY dummy_glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha){} - void GLAPIENTRY dummy_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha){} - void GLAPIENTRY dummy_glColor4fv( const GLfloat *v ){} - void GLAPIENTRY dummy_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha){} - void GLAPIENTRY dummy_glColor4ubv( const GLubyte *v ){} - void GLAPIENTRY dummy_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer){} - void GLAPIENTRY dummy_glDisableClientState(GLenum array){} - void GLAPIENTRY dummy_glEnableClientState(GLenum array){} - void GLAPIENTRY dummy_glEnd(void){} - void GLAPIENTRY dummy_glFogf(GLenum pname, GLfloat param){} - void GLAPIENTRY dummy_glFogfv(GLenum pname, const GLfloat *params){} - void GLAPIENTRY dummy_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){} - void GLAPIENTRY dummy_glGetClipPlane(GLenum plane, GLdouble *equation){} - void GLAPIENTRY dummy_glGetDoublev( GLenum pname, GLdouble *params ){} - void GLAPIENTRY dummy_glGetLightfv(GLenum light, GLenum pname, GLfloat *params){} - void GLAPIENTRY dummy_glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params){} - void GLAPIENTRY dummy_glGetPointerv(GLenum pname, GLvoid* *params){} - void GLAPIENTRY dummy_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params){} - void GLAPIENTRY dummy_glGetTexEnviv(GLenum target, GLenum pname, GLint *params){} - void GLAPIENTRY dummy_glLightf(GLenum light, GLenum pname, GLfloat param){} - void GLAPIENTRY dummy_glLightfv(GLenum light, GLenum pname, const GLfloat *params){} - void GLAPIENTRY dummy_glLightModelf(GLenum pname, GLfloat param){} - void GLAPIENTRY dummy_glLightModelfv(GLenum pname, const GLfloat *params){} - void GLAPIENTRY dummy_glLoadIdentity(void){} - void GLAPIENTRY dummy_glLoadMatrixf(const GLfloat *m){} - void GLAPIENTRY dummy_glLogicOp(GLenum opcode){} - void GLAPIENTRY dummy_glMaterialf(GLenum face, GLenum pname, GLfloat param){} - void GLAPIENTRY dummy_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params){} - void GLAPIENTRY dummy_glMultiTexCoord2fv( GLenum target, const GLfloat *v ){} - void GLAPIENTRY dummy_glMultiTexCoord2sv( GLenum target, const GLshort *v ){} - void GLAPIENTRY dummy_glMultiTexCoord3fv( GLenum target, const GLfloat *v ){} - void GLAPIENTRY dummy_glMultiTexCoord3sv( GLenum target, const GLshort *v ){} - void GLAPIENTRY dummy_glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ){} - void GLAPIENTRY dummy_glMultiTexCoord4fv( GLenum target, const GLfloat *v ){} - void GLAPIENTRY dummy_glMultiTexCoord4sv( GLenum target, const GLshort *v ){} - void GLAPIENTRY dummy_glMultMatrixf(const GLfloat *m){} - void GLAPIENTRY dummy_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz){} - void GLAPIENTRY dummy_glNormal3fv( const GLfloat *v ){} - void GLAPIENTRY dummy_glNormal3sv(const GLshort *v ){} - void GLAPIENTRY dummy_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){} - void GLAPIENTRY dummy_glPointParameterf(GLenum, GLfloat){} - void GLAPIENTRY dummy_glPointParameterfv(GLenum, const GLfloat *){} - void GLAPIENTRY dummy_glPointSize(GLfloat size){} - void GLAPIENTRY dummy_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z){} - void GLAPIENTRY dummy_glScalef(GLfloat x, GLfloat y, GLfloat z){} - void GLAPIENTRY dummy_glTexEnvf(GLenum target, GLenum pname, GLfloat param){} - void GLAPIENTRY dummy_glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params){} - void GLAPIENTRY dummy_glTexParameterf(GLenum target, GLenum pname, GLfloat param){} - void GLAPIENTRY dummy_glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params){} - void GLAPIENTRY dummy_glMatrixMode(GLenum mode){} - void GLAPIENTRY dummy_glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer){} - void GLAPIENTRY dummy_glPopMatrix(void){} - void GLAPIENTRY dummy_glPushMatrix(void){} - void GLAPIENTRY dummy_glShadeModel(GLenum mode){} - void GLAPIENTRY dummy_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer){} - void GLAPIENTRY dummy_glTexEnvi(GLenum target, GLenum pname, GLint param){} - void GLAPIENTRY dummy_glTexEnviv(GLenum target, GLenum pname, const GLint *params){} - void GLAPIENTRY dummy_glTranslatef(GLfloat x, GLfloat y, GLfloat z){} - void GLAPIENTRY dummy_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer){} - - /* OpenGL functions which are needed ONLY for implementing GLES 1.1 EXTENSIONS*/ - GLboolean GLAPIENTRY dummy_glIsRenderbufferEXT(GLuint renderbuffer){ return false;} - void GLAPIENTRY dummy_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer){} - void GLAPIENTRY dummy_glDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers){} - void GLAPIENTRY dummy_glGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers){} - void GLAPIENTRY dummy_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height){} - void GLAPIENTRY dummy_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params){} - GLboolean GLAPIENTRY dummy_glIsFramebufferEXT(GLuint framebuffer){ return false;} - void GLAPIENTRY dummy_glBindFramebufferEXT(GLenum target, GLuint framebuffer){} - void GLAPIENTRY dummy_glDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers){} - void GLAPIENTRY dummy_glGenFramebuffersEXT(GLsizei n, GLuint *framebuffers){} - GLenum GLAPIENTRY dummy_glCheckFramebufferStatusEXT(GLenum target){ return 0;} - void GLAPIENTRY dummy_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level){} - void GLAPIENTRY dummy_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level){} - void GLAPIENTRY dummy_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset){} - void GLAPIENTRY dummy_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer){} - void GLAPIENTRY dummy_glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params){} - void GLAPIENTRY dummy_glGenerateMipmapEXT(GLenum target){} - void GLAPIENTRY dummy_glCurrentPaletteMatrixARB(GLint index){} - void GLAPIENTRY dummy_glMatrixIndexuivARB(GLint size, GLuint * indices){} - void GLAPIENTRY dummy_glMatrixIndexPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer){} - void GLAPIENTRY dummy_glWeightPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer){} - void GLAPIENTRY dummy_glTexGenf(GLenum coord, GLenum pname, GLfloat param ){} - void GLAPIENTRY dummy_glTexGeni(GLenum coord, GLenum pname, GLint param ){} - void GLAPIENTRY dummy_glTexGenf(GLenum coord, GLenum pname, const GLfloat *params ){} - void GLAPIENTRY dummy_glTexGeniv(GLenum coord, GLenum pname, const GLint *params ){} - void GLAPIENTRY dummy_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params ){} - void GLAPIENTRY dummy_glGetTexGeniv(GLenum coord, GLenum pname, GLint *params ){} - - /* Loading OpenGL functions which are needed ONLY for implementing GLES 2.0*/ - void GL_APIENTRY dummy_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){} - void GL_APIENTRY dummy_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask){} - void GL_APIENTRY dummy_glStencilMaskSeparate(GLenum face, GLuint mask){} - void GL_APIENTRY dummy_glGenerateMipmap(GLenum target){} - void GL_APIENTRY dummy_glBindFramebuffer(GLenum target, GLuint framebuffer){} - void GL_APIENTRY dummy_glBindRenderbuffer(GLenum target, GLuint renderbuffer){} - void GL_APIENTRY dummy_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers){} - void GL_APIENTRY dummy_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers){} - GLboolean GL_APIENTRY dummy_glIsProgram(GLuint program){ return false;} - GLboolean GL_APIENTRY dummy_glIsShader(GLuint shader){ return false;} - void GL_APIENTRY dummy_glVertexAttrib1f(GLuint indx, GLfloat x){} - void GL_APIENTRY dummy_glVertexAttrib1fv(GLuint indx, const GLfloat* values){} - void GL_APIENTRY dummy_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y){} - void GL_APIENTRY dummy_glVertexAttrib2fv(GLuint indx, const GLfloat* values){} - void GL_APIENTRY dummy_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z){} - void GL_APIENTRY dummy_glVertexAttrib3fv(GLuint indx, const GLfloat* values){} - void GL_APIENTRY dummy_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w){} - void GL_APIENTRY dummy_glVertexAttrib4fv(GLuint indx, const GLfloat* values){} - void GL_APIENTRY dummy_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr){} - void GL_APIENTRY dummy_glDisableVertexAttribArray(GLuint index){} - void GL_APIENTRY dummy_glEnableVertexAttribArray(GLuint index){} - void GL_APIENTRY dummy_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params){} - void GL_APIENTRY dummy_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params){} - void GL_APIENTRY dummy_glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer){} - void GL_APIENTRY dummy_glUniform1f(GLint location, GLfloat x){} - void GL_APIENTRY dummy_glUniform1fv(GLint location, GLsizei count, const GLfloat* v){} - void GL_APIENTRY dummy_glUniform1i(GLint location, GLint x){} - void GL_APIENTRY dummy_glUniform1iv(GLint location, GLsizei count, const GLint* v){} - void GL_APIENTRY dummy_glUniform2f(GLint location, GLfloat x, GLfloat y){} - void GL_APIENTRY dummy_glUniform2fv(GLint location, GLsizei count, const GLfloat* v){} - void GL_APIENTRY dummy_glUniform2i(GLint location, GLint x, GLint y){} - void GL_APIENTRY dummy_glUniform2iv(GLint location, GLsizei count, const GLint* v){} - void GL_APIENTRY dummy_glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z){} - void GL_APIENTRY dummy_glUniform3fv(GLint location, GLsizei count, const GLfloat* v){} - void GL_APIENTRY dummy_glUniform3i(GLint location, GLint x, GLint y, GLint z){} - void GL_APIENTRY dummy_glUniform3iv(GLint location, GLsizei count, const GLint* v){} - void GL_APIENTRY dummy_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w){} - void GL_APIENTRY dummy_glUniform4fv(GLint location, GLsizei count, const GLfloat* v){} - void GL_APIENTRY dummy_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w){} - void GL_APIENTRY dummy_glUniform4iv(GLint location, GLsizei count, const GLint* v){} - void GL_APIENTRY dummy_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){} - void GL_APIENTRY dummy_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){} - void GL_APIENTRY dummy_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value){} - void GL_APIENTRY dummy_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params){} - void GL_APIENTRY dummy_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params){} - GLboolean GL_APIENTRY dummy_glIsFramebuffer(GLuint framebuffer){ return false;} - GLboolean GL_APIENTRY dummy_glIsRenderbuffer(GLuint renderbuffer){ return false;} - GLenum GL_APIENTRY dummy_glCheckFramebufferStatus(GLenum target){ return 0;} - void GL_APIENTRY dummy_glAttachShader(GLuint program, GLuint shader){} - void GL_APIENTRY dummy_glBindAttribLocation(GLuint program, GLuint index, const GLchar* name){} - void GL_APIENTRY dummy_glCompileShader(GLuint shader){} - GLuint GL_APIENTRY dummy_glCreateProgram(void){ return 0;} - GLuint GL_APIENTRY dummy_glCreateShader(GLenum type){ return 0;} - void GL_APIENTRY dummy_glDeleteProgram(GLuint program){} - void GL_APIENTRY dummy_glDeleteShader(GLuint shader){} - void GL_APIENTRY dummy_glDetachShader(GLuint program, GLuint shader){} - void GL_APIENTRY dummy_glLinkProgram(GLuint program){} - void GL_APIENTRY dummy_glUseProgram(GLuint program){} - void GL_APIENTRY dummy_glValidateProgram(GLuint program){} - void GL_APIENTRY dummy_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){} - void GL_APIENTRY dummy_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name){} - void GL_APIENTRY dummy_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders){} - int GL_APIENTRY dummy_glGetAttribLocation(GLuint program, const GLchar* name){ return 0;} - void GL_APIENTRY dummy_glGetProgramiv(GLuint program, GLenum pname, GLint* params){} - void GL_APIENTRY dummy_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog){} - void GL_APIENTRY dummy_glGetShaderiv(GLuint shader, GLenum pname, GLint* params){} - void GL_APIENTRY dummy_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog){} - void GL_APIENTRY dummy_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision){} - void GL_APIENTRY dummy_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source){} - void GL_APIENTRY dummy_glGetUniformfv(GLuint program, GLint location, GLfloat* params){} - void GL_APIENTRY dummy_glGetUniformiv(GLuint program, GLint location, GLint* params){} - int GL_APIENTRY dummy_glGetUniformLocation(GLuint program, const GLchar* name){ return 0;} - void GL_APIENTRY dummy_glReleaseShaderCompiler(void){} - void GL_APIENTRY dummy_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height){} - void GL_APIENTRY dummy_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length){} - void GL_APIENTRY dummy_glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length){} - void GL_APIENTRY dummy_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer){} - void GL_APIENTRY dummy_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level){} diff --git a/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h b/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h deleted file mode 100644 index dd5379c..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/DummyGLfuncs.h +++ /dev/null @@ -1,265 +0,0 @@ -/* -* 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 DUMMY_GL_FUNCS_H -#define DUMMY_GL_FUNCS_H - -#include <GLES/gl.h> -#include <GLES2/gl2.h> - -#include <GLcommon/gldefs.h> -#define GLAPIENTRY GL_APIENTRY - - void GLAPIENTRY dummy_glActiveTexture ( GLenum texture ); - void GLAPIENTRY dummy_glBindBuffer (GLenum target, GLuint buffer); - void GLAPIENTRY dummy_glBindTexture (GLenum target, GLuint texture); - void GLAPIENTRY dummy_glBlendFunc (GLenum sfactor, GLenum dfactor); - void GLAPIENTRY dummy_glBlendEquation( GLenum mode ); - void GLAPIENTRY dummy_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); - void GLAPIENTRY dummy_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); - void GLAPIENTRY dummy_glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); - void GLAPIENTRY dummy_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); - void GLAPIENTRY dummy_glClear(GLbitfield mask); - void GLAPIENTRY dummy_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void GLAPIENTRY dummy_glClearStencil(GLint s); - void GLAPIENTRY dummy_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); - void GLAPIENTRY dummy_glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); - void GLAPIENTRY dummy_glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); - void GLAPIENTRY dummy_glCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); - void GLAPIENTRY dummy_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); - void GLAPIENTRY dummy_glCullFace(GLenum mode); - void GLAPIENTRY dummy_glDeleteBuffers(GLsizei n, const GLuint *buffers); - void GLAPIENTRY dummy_glDeleteTextures(GLsizei n, const GLuint *textures); - void GLAPIENTRY dummy_glDepthFunc(GLenum func); - void GLAPIENTRY dummy_glDepthMask(GLboolean flag); - void GLAPIENTRY dummy_glDepthRange(GLclampd zNear, GLclampd zFar); - void GLAPIENTRY dummy_glDisable(GLenum cap); - void GLAPIENTRY dummy_glDrawArrays(GLenum mode, GLint first, GLsizei count); - void GLAPIENTRY dummy_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); - void GLAPIENTRY dummy_glEnable(GLenum cap); - void GLAPIENTRY dummy_glFinish(void); - void GLAPIENTRY dummy_glFlush(void); - void GLAPIENTRY dummy_glFrontFace(GLenum mode); - void GLAPIENTRY dummy_glGenBuffers(GLsizei n, GLuint *buffers); - void GLAPIENTRY dummy_glGenTextures(GLsizei n, GLuint *textures); - void GLAPIENTRY dummy_glGetBooleanv(GLenum pname, GLboolean *params); - void GLAPIENTRY dummy_glGetBufferParameteriv(GLenum, GLenum, GLint *); - GLenum GLAPIENTRY dummy_glGetError(void); - void GLAPIENTRY dummy_glGetFloatv(GLenum pname, GLfloat *params); - void GLAPIENTRY dummy_glGetIntegerv(GLenum pname, GLint *params); - const GLubyte * GLAPIENTRY dummy_glGetString(GLenum name); - void GLAPIENTRY dummy_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params); - void GLAPIENTRY dummy_glGetTexParameteriv(GLenum target, GLenum pname, GLint *params); - void GLAPIENTRY dummy_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params); - void GLAPIENTRY dummy_glHint(GLenum target, GLenum mode); - GLboolean GLAPIENTRY dummy_glIsBuffer(GLuint); - GLboolean GLAPIENTRY dummy_glIsEnabled(GLenum cap); - GLboolean GLAPIENTRY dummy_glIsTexture(GLuint texture); - void GLAPIENTRY dummy_glLineWidth(GLfloat width); - void GLAPIENTRY dummy_glPolygonOffset(GLfloat factor, GLfloat units); - void GLAPIENTRY dummy_glPixelStorei(GLenum pname, GLint param); - void GLAPIENTRY dummy_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); - void GLAPIENTRY dummy_glSampleCoverage(GLclampf value, GLboolean invert ); - void GLAPIENTRY dummy_glScissor(GLint x, GLint y, GLsizei width, GLsizei height); - void GLAPIENTRY dummy_glStencilFunc(GLenum func, GLint ref, GLuint mask); - void GLAPIENTRY dummy_glStencilMask(GLuint mask); - void GLAPIENTRY dummy_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass); - void GLAPIENTRY dummy_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); - void GLAPIENTRY dummy_glTexParameteri(GLenum target, GLenum pname, GLint param); - void GLAPIENTRY dummy_glTexParameteriv(GLenum target, GLenum pname, const GLint *params); - void GLAPIENTRY dummy_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); - void GLAPIENTRY dummy_glViewport(GLint x, GLint y, GLsizei width, GLsizei height); - void GLAPIENTRY dummy_glPushAttrib( GLbitfield mask ); - void GLAPIENTRY dummy_glPopAttrib( void ); - void GLAPIENTRY dummy_glPushClientAttrib( GLbitfield mask ); - void GLAPIENTRY dummy_glPopClientAttrib( void ); - - /* OpenGL functions which are needed ONLY for implementing GLES 1.1*/ - void GLAPIENTRY dummy_glAlphaFunc(GLenum func, GLclampf ref); - void GLAPIENTRY dummy_glBegin( GLenum mode ); - void GLAPIENTRY dummy_glClearDepth(GLclampd depth); - void GLAPIENTRY dummy_glClientActiveTexture( GLenum texture ); - void GLAPIENTRY dummy_glClipPlane(GLenum plane, const GLdouble *equation); - void GLAPIENTRY dummy_glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); - void GLAPIENTRY dummy_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); - void GLAPIENTRY dummy_glColor4fv( const GLfloat *v ); - void GLAPIENTRY dummy_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); - void GLAPIENTRY dummy_glColor4ubv( const GLubyte *v ); - void GLAPIENTRY dummy_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - void GLAPIENTRY dummy_glDisableClientState(GLenum array); - void GLAPIENTRY dummy_glEnableClientState(GLenum array); - void GLAPIENTRY dummy_glEnd(void); - void GLAPIENTRY dummy_glFogf(GLenum pname, GLfloat param); - void GLAPIENTRY dummy_glFogfv(GLenum pname, const GLfloat *params); - void GLAPIENTRY dummy_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); - void GLAPIENTRY dummy_glGetClipPlane(GLenum plane, GLdouble *equation); - void GLAPIENTRY dummy_glGetDoublev( GLenum pname, GLdouble *params ); - void GLAPIENTRY dummy_glGetLightfv(GLenum light, GLenum pname, GLfloat *params); - void GLAPIENTRY dummy_glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params); - void GLAPIENTRY dummy_glGetPointerv(GLenum pname, GLvoid* *params); - void GLAPIENTRY dummy_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params); - void GLAPIENTRY dummy_glGetTexEnviv(GLenum target, GLenum pname, GLint *params); - void GLAPIENTRY dummy_glLightf(GLenum light, GLenum pname, GLfloat param); - void GLAPIENTRY dummy_glLightfv(GLenum light, GLenum pname, const GLfloat *params); - void GLAPIENTRY dummy_glLightModelf(GLenum pname, GLfloat param); - void GLAPIENTRY dummy_glLightModelfv(GLenum pname, const GLfloat *params); - void GLAPIENTRY dummy_glLoadIdentity(void); - void GLAPIENTRY dummy_glLoadMatrixf(const GLfloat *m); - void GLAPIENTRY dummy_glLogicOp(GLenum opcode); - void GLAPIENTRY dummy_glMaterialf(GLenum face, GLenum pname, GLfloat param); - void GLAPIENTRY dummy_glMaterialfv(GLenum face, GLenum pname, const GLfloat *params); - void GLAPIENTRY dummy_glMultiTexCoord2fv( GLenum target, const GLfloat *v ); - void GLAPIENTRY dummy_glMultiTexCoord2sv( GLenum target, const GLshort *v ); - void GLAPIENTRY dummy_glMultiTexCoord3fv( GLenum target, const GLfloat *v ); - void GLAPIENTRY dummy_glMultiTexCoord3sv( GLenum target, const GLshort *v ); - void GLAPIENTRY dummy_glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); - void GLAPIENTRY dummy_glMultiTexCoord4fv( GLenum target, const GLfloat *v ); - void GLAPIENTRY dummy_glMultiTexCoord4sv( GLenum target, const GLshort *v ); - void GLAPIENTRY dummy_glMultMatrixf(const GLfloat *m); - void GLAPIENTRY dummy_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); - void GLAPIENTRY dummy_glNormal3fv( const GLfloat *v ); - void GLAPIENTRY dummy_glNormal3sv(const GLshort *v ); - void GLAPIENTRY dummy_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); - void GLAPIENTRY dummy_glPointParameterf(GLenum, GLfloat); - void GLAPIENTRY dummy_glPointParameterfv(GLenum, const GLfloat *); - void GLAPIENTRY dummy_glPointSize(GLfloat size); - void GLAPIENTRY dummy_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); - void GLAPIENTRY dummy_glScalef(GLfloat x, GLfloat y, GLfloat z); - void GLAPIENTRY dummy_glTexEnvf(GLenum target, GLenum pname, GLfloat param); - void GLAPIENTRY dummy_glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params); - void GLAPIENTRY dummy_glTexParameterf(GLenum target, GLenum pname, GLfloat param); - void GLAPIENTRY dummy_glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params); - void GLAPIENTRY dummy_glMatrixMode(GLenum mode); - void GLAPIENTRY dummy_glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer); - void GLAPIENTRY dummy_glPopMatrix(void); - void GLAPIENTRY dummy_glPushMatrix(void); - void GLAPIENTRY dummy_glShadeModel(GLenum mode); - void GLAPIENTRY dummy_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - void GLAPIENTRY dummy_glTexEnvi(GLenum target, GLenum pname, GLint param); - void GLAPIENTRY dummy_glTexEnviv(GLenum target, GLenum pname, const GLint *params); - void GLAPIENTRY dummy_glTranslatef(GLfloat x, GLfloat y, GLfloat z); - void GLAPIENTRY dummy_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - - /* OpenGL functions which are needed ONLY for implementing GLES 1.1 EXTENSIONS*/ - GLboolean GLAPIENTRY dummy_glIsRenderbufferEXT(GLuint renderbuffer); - void GLAPIENTRY dummy_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer); - void GLAPIENTRY dummy_glDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers); - void GLAPIENTRY dummy_glGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers); - void GLAPIENTRY dummy_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - void GLAPIENTRY dummy_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params); - GLboolean GLAPIENTRY dummy_glIsFramebufferEXT(GLuint framebuffer); - void GLAPIENTRY dummy_glBindFramebufferEXT(GLenum target, GLuint framebuffer); - void GLAPIENTRY dummy_glDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers); - void GLAPIENTRY dummy_glGenFramebuffersEXT(GLsizei n, GLuint *framebuffers); - GLenum GLAPIENTRY dummy_glCheckFramebufferStatusEXT(GLenum target); - void GLAPIENTRY dummy_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - void GLAPIENTRY dummy_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - void GLAPIENTRY dummy_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); - void GLAPIENTRY dummy_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); - void GLAPIENTRY dummy_glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params); - void GLAPIENTRY dummy_glGenerateMipmapEXT(GLenum target); - void GLAPIENTRY dummy_glCurrentPaletteMatrixARB(GLint index); - void GLAPIENTRY dummy_glMatrixIndexuivARB(GLint size, GLuint * indices); - void GLAPIENTRY dummy_glMatrixIndexPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); - void GLAPIENTRY dummy_glWeightPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); - void GLAPIENTRY dummy_glTexGenf(GLenum coord, GLenum pname, GLfloat param ); - void GLAPIENTRY dummy_glTexGeni(GLenum coord, GLenum pname, GLint param ); - void GLAPIENTRY dummy_glTexGenf(GLenum coord, GLenum pname, const GLfloat *params ); - void GLAPIENTRY dummy_glTexGeniv(GLenum coord, GLenum pname, const GLint *params ); - void GLAPIENTRY dummy_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params ); - void GLAPIENTRY dummy_glGetTexGeniv(GLenum coord, GLenum pname, GLint *params ); - - /* Loading OpenGL functions which are needed ONLY for implementing GLES 2.0*/ - void GL_APIENTRY dummy_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void GL_APIENTRY dummy_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); - void GL_APIENTRY dummy_glStencilMaskSeparate(GLenum face, GLuint mask); - void GL_APIENTRY dummy_glGenerateMipmap(GLenum target); - void GL_APIENTRY dummy_glBindFramebuffer(GLenum target, GLuint framebuffer); - void GL_APIENTRY dummy_glBindRenderbuffer(GLenum target, GLuint renderbuffer); - void GL_APIENTRY dummy_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers); - void GL_APIENTRY dummy_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers); - GLboolean GL_APIENTRY dummy_glIsProgram(GLuint program); - GLboolean GL_APIENTRY dummy_glIsShader(GLuint shader); - void GL_APIENTRY dummy_glVertexAttrib1f(GLuint indx, GLfloat x); - void GL_APIENTRY dummy_glVertexAttrib1fv(GLuint indx, const GLfloat* values); - void GL_APIENTRY dummy_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); - void GL_APIENTRY dummy_glVertexAttrib2fv(GLuint indx, const GLfloat* values); - void GL_APIENTRY dummy_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); - void GL_APIENTRY dummy_glVertexAttrib3fv(GLuint indx, const GLfloat* values); - void GL_APIENTRY dummy_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void GL_APIENTRY dummy_glVertexAttrib4fv(GLuint indx, const GLfloat* values); - void GL_APIENTRY dummy_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); - void GL_APIENTRY dummy_glDisableVertexAttribArray(GLuint index); - void GL_APIENTRY dummy_glEnableVertexAttribArray(GLuint index); - void GL_APIENTRY dummy_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); - void GL_APIENTRY dummy_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); - void GL_APIENTRY dummy_glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer); - void GL_APIENTRY dummy_glUniform1f(GLint location, GLfloat x); - void GL_APIENTRY dummy_glUniform1fv(GLint location, GLsizei count, const GLfloat* v); - void GL_APIENTRY dummy_glUniform1i(GLint location, GLint x); - void GL_APIENTRY dummy_glUniform1iv(GLint location, GLsizei count, const GLint* v); - void GL_APIENTRY dummy_glUniform2f(GLint location, GLfloat x, GLfloat y); - void GL_APIENTRY dummy_glUniform2fv(GLint location, GLsizei count, const GLfloat* v); - void GL_APIENTRY dummy_glUniform2i(GLint location, GLint x, GLint y); - void GL_APIENTRY dummy_glUniform2iv(GLint location, GLsizei count, const GLint* v); - void GL_APIENTRY dummy_glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z); - void GL_APIENTRY dummy_glUniform3fv(GLint location, GLsizei count, const GLfloat* v); - void GL_APIENTRY dummy_glUniform3i(GLint location, GLint x, GLint y, GLint z); - void GL_APIENTRY dummy_glUniform3iv(GLint location, GLsizei count, const GLint* v); - void GL_APIENTRY dummy_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void GL_APIENTRY dummy_glUniform4fv(GLint location, GLsizei count, const GLfloat* v); - void GL_APIENTRY dummy_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w); - void GL_APIENTRY dummy_glUniform4iv(GLint location, GLsizei count, const GLint* v); - void GL_APIENTRY dummy_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - void GL_APIENTRY dummy_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - void GL_APIENTRY dummy_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - void GL_APIENTRY dummy_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params); - void GL_APIENTRY dummy_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params); - GLboolean GL_APIENTRY dummy_glIsFramebuffer(GLuint framebuffer); - GLboolean GL_APIENTRY dummy_glIsRenderbuffer(GLuint renderbuffer); - GLenum GL_APIENTRY dummy_glCheckFramebufferStatus(GLenum target); - void GL_APIENTRY dummy_glAttachShader(GLuint program, GLuint shader); - void GL_APIENTRY dummy_glBindAttribLocation(GLuint program, GLuint index, const GLchar* name); - void GL_APIENTRY dummy_glCompileShader(GLuint shader); - GLuint GL_APIENTRY dummy_glCreateProgram(void); - GLuint GL_APIENTRY dummy_glCreateShader(GLenum type); - void GL_APIENTRY dummy_glDeleteProgram(GLuint program); - void GL_APIENTRY dummy_glDeleteShader(GLuint shader); - void GL_APIENTRY dummy_glDetachShader(GLuint program, GLuint shader); - void GL_APIENTRY dummy_glLinkProgram(GLuint program); - void GL_APIENTRY dummy_glUseProgram(GLuint program); - void GL_APIENTRY dummy_glValidateProgram(GLuint program); - void GL_APIENTRY dummy_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); - void GL_APIENTRY dummy_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); - void GL_APIENTRY dummy_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); - int GL_APIENTRY dummy_glGetAttribLocation(GLuint program, const GLchar* name); - void GL_APIENTRY dummy_glGetProgramiv(GLuint program, GLenum pname, GLint* params); - void GL_APIENTRY dummy_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); - void GL_APIENTRY dummy_glGetShaderiv(GLuint shader, GLenum pname, GLint* params); - void GL_APIENTRY dummy_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); - void GL_APIENTRY dummy_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); - void GL_APIENTRY dummy_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); - void GL_APIENTRY dummy_glGetUniformfv(GLuint program, GLint location, GLfloat* params); - void GL_APIENTRY dummy_glGetUniformiv(GLuint program, GLint location, GLint* params); - int GL_APIENTRY dummy_glGetUniformLocation(GLuint program, const GLchar* name); - void GL_APIENTRY dummy_glReleaseShaderCompiler(void); - void GL_APIENTRY dummy_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - void GL_APIENTRY dummy_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); - void GL_APIENTRY dummy_glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); - void GL_APIENTRY dummy_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); - void GL_APIENTRY dummy_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - -#endif diff --git a/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp b/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp deleted file mode 100644 index 2e35c8d..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* -* 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. -*/ -#include <GLES/gl.h> -#include <GLES/glext.h> -#include <GLcommon/FramebufferData.h> -#include <GLcommon/GLEScontext.h> - -RenderbufferData::RenderbufferData() : sourceEGLImage(0), - eglImageDetach(NULL), - attachedFB(0), - attachedPoint(0), - eglImageGlobalTexName(0) { -} - -RenderbufferData::~RenderbufferData() { - if (sourceEGLImage && eglImageDetach) (*eglImageDetach)(sourceEGLImage); -} - - -FramebufferData::FramebufferData(GLuint name):m_dirty(false) { - m_fbName = name; - for (int i=0; i<MAX_ATTACH_POINTS; i++) { - m_attachPoints[i].target = 0; - m_attachPoints[i].name = 0; - m_attachPoints[i].obj = ObjectDataPtr(NULL); - m_attachPoints[i].owned = false; - } -} - -FramebufferData::~FramebufferData() { -for (int i=0; i<MAX_ATTACH_POINTS; i++) { - detachObject(i); -} -} - -void FramebufferData::setAttachment(GLenum attachment, - GLenum target, - GLuint name, - ObjectDataPtr obj, - bool takeOwnership) { -int idx = attachmentPointIndex(attachment); - if (!name) { - detachObject(idx); - return; - } - if (m_attachPoints[idx].target != target || - m_attachPoints[idx].name != name || - m_attachPoints[idx].obj.Ptr() != obj.Ptr() || - m_attachPoints[idx].owned != takeOwnership) { - - detachObject(idx); - - m_attachPoints[idx].target = target; - m_attachPoints[idx].name = name; - m_attachPoints[idx].obj = obj; - m_attachPoints[idx].owned = takeOwnership; - - if (target == GL_RENDERBUFFER_OES && obj.Ptr() != NULL) { - RenderbufferData *rbData = (RenderbufferData *)obj.Ptr(); - rbData->attachedFB = m_fbName; - rbData->attachedPoint = attachment; - } - - m_dirty = true; - } -} - -GLuint FramebufferData::getAttachment(GLenum attachment, - GLenum *outTarget, - ObjectDataPtr *outObj) { - int idx = attachmentPointIndex(attachment); - if (outTarget) *outTarget = m_attachPoints[idx].target; - if (outObj) *outObj = m_attachPoints[idx].obj; - return m_attachPoints[idx].name; -} - -int FramebufferData::attachmentPointIndex(GLenum attachment) -{ - switch(attachment) { - case GL_COLOR_ATTACHMENT0_OES: - return 0; - case GL_DEPTH_ATTACHMENT_OES: - return 1; - case GL_STENCIL_ATTACHMENT_OES: - return 2; - default: - return MAX_ATTACH_POINTS; - } -} - -void FramebufferData::detachObject(int idx) { - if (m_attachPoints[idx].target == GL_RENDERBUFFER_OES && m_attachPoints[idx].obj.Ptr() != NULL) { - RenderbufferData *rbData = (RenderbufferData *)m_attachPoints[idx].obj.Ptr(); - rbData->attachedFB = 0; - rbData->attachedPoint = 0; - } - - if(m_attachPoints[idx].owned) - { - switch(m_attachPoints[idx].target) - { - case GL_RENDERBUFFER_OES: - GLEScontext::dispatcher().glDeleteRenderbuffersEXT(1, &(m_attachPoints[idx].name)); - break; - case GL_TEXTURE_2D: - GLEScontext::dispatcher().glDeleteTextures(1, &(m_attachPoints[idx].name)); - break; - } - } - - m_attachPoints[idx].target = 0; - m_attachPoints[idx].name = 0; - m_attachPoints[idx].obj = ObjectDataPtr(NULL); - m_attachPoints[idx].owned = false; -} - -void FramebufferData::validate(GLEScontext* ctx) -{ - if(!getAttachment(GL_COLOR_ATTACHMENT0_OES, NULL, NULL)) - { - // GLES does not require the framebuffer to have a color attachment. - // OpenGL does. Therefore, if no color is attached, create a dummy - // color texture and attach it. - // This dummy color texture will is owned by the FramebufferObject, - // and will be released by it when its object is detached. - - GLint type = GL_NONE; - GLint name = 0; - - ctx->dispatcher().glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT_OES, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); - if(type != GL_NONE) - { - ctx->dispatcher().glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT_OES, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &name); - } - else - { - ctx->dispatcher().glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT_OES, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); - if(type != GL_NONE) - { - ctx->dispatcher().glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT_OES, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &name); - } - else - { - // No color, depth or stencil attachments - do nothing - return; - } - } - - // Find the existing attachment(s) dimensions - GLint width = 0; - GLint height = 0; - - if(type == GL_RENDERBUFFER) - { - GLint prev; - ctx->dispatcher().glGetIntegerv(GL_RENDERBUFFER_BINDING, &prev); - ctx->dispatcher().glBindRenderbufferEXT(GL_RENDERBUFFER, name); - ctx->dispatcher().glGetRenderbufferParameterivEXT(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width); - ctx->dispatcher().glGetRenderbufferParameterivEXT(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height); - ctx->dispatcher().glBindRenderbufferEXT(GL_RENDERBUFFER, prev); - } - else if(type == GL_TEXTURE) - { - GLint prev; - ctx->dispatcher().glGetIntegerv(GL_TEXTURE_BINDING_2D, &prev); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, name); - ctx->dispatcher().glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); - ctx->dispatcher().glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, prev); - } - - // Create the color attachment and attch it - unsigned int tex = ctx->shareGroup()->genGlobalName(TEXTURE); - GLint prev; - ctx->dispatcher().glGetIntegerv(GL_TEXTURE_BINDING_2D, &prev); - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, tex); - - ctx->dispatcher().glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - ctx->dispatcher().glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - ctx->dispatcher().glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - ctx->dispatcher().glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - ctx->dispatcher().glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - - ctx->dispatcher().glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tex, 0); - setAttachment(GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tex, ObjectDataPtr(NULL), true); - - ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, prev); - } - - if(m_dirty) - { - // This is a workaround for a bug found in several OpenGL - // drivers (e.g. ATI's) - after the framebuffer attachments - // have changed, and before the next draw, unbind and rebind - // the framebuffer to sort things out. - ctx->dispatcher().glBindFramebufferEXT(GL_FRAMEBUFFER,0); - ctx->dispatcher().glBindFramebufferEXT(GL_FRAMEBUFFER,ctx->shareGroup()->getGlobalName(FRAMEBUFFER,m_fbName)); - - m_dirty = false; - } -} - diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp deleted file mode 100644 index 3f091d1..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/* -* 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. -*/ - -#include <GLcommon/GLDispatch.h> -#include <stdio.h> -#include "emugl/common/shared_library.h" - -#ifdef __linux__ -#include <GL/glx.h> -#elif defined(WIN32) -#include <windows.h> -#endif - -#include "DummyGLfuncs.h" - -typedef void (*GL_FUNC_PTR)(); - -static GL_FUNC_PTR getGLFuncAddress(const char *funcName) { - GL_FUNC_PTR ret = NULL; -#ifdef __linux__ - static emugl::SharedLibrary* libGL = emugl::SharedLibrary::open("libGL"); - ret = (GL_FUNC_PTR)glXGetProcAddress((const GLubyte*)funcName); -#elif defined(WIN32) - static emugl::SharedLibrary* libGL = emugl::SharedLibrary::open("opengl32"); - ret = (GL_FUNC_PTR)wglGetProcAddress(funcName); -#elif defined(__APPLE__) - static emugl::SharedLibrary* libGL = emugl::SharedLibrary::open("/System/Library/Frameworks/OpenGL.framework/OpenGL"); -#endif - if(!ret && libGL){ - ret = libGL->findSymbol(funcName); - } - return ret; -} - -#define LOAD_GL_FUNC(name) do { \ - if (!name) { \ - void* funcAddress = (void *)getGLFuncAddress(#name); \ - if (funcAddress) { \ - name = (__typeof__(name))(funcAddress); \ - } else { \ - fprintf(stderr, "Could not load func %s\n", #name); \ - name = (__typeof__(name))(dummy_##name); \ - } \ - } \ - } while (0) - -#define LOAD_GLEXT_FUNC(name) do { \ - if (!name) { \ - void* funcAddress = (void *)getGLFuncAddress(#name); \ - if (funcAddress) { \ - name = (__typeof__(name))(funcAddress); \ - } \ - } \ - } while (0) - -/* initializing static GLDispatch members*/ - -emugl::Mutex GLDispatch::s_lock; -void (GLAPIENTRY *GLDispatch::glActiveTexture)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glBindBuffer)(GLenum,GLuint) = NULL; -void (GLAPIENTRY *GLDispatch::glBindTexture)(GLenum, GLuint) = NULL; -void (GLAPIENTRY *GLDispatch::glBlendFunc)(GLenum,GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glBlendEquation)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glBlendEquationSeparate)(GLenum,GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glBlendFuncSeparate)(GLenum,GLenum,GLenum,GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glBufferData)(GLenum,GLsizeiptr,const GLvoid *,GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glBufferSubData)(GLenum,GLintptr,GLsizeiptr,const GLvoid *) = NULL; -void (GLAPIENTRY *GLDispatch::glClear)(GLbitfield) = NULL; -void (GLAPIENTRY *GLDispatch::glClearColor)(GLclampf,GLclampf,GLclampf,GLclampf) = NULL; -void (GLAPIENTRY *GLDispatch::glClearStencil)(GLint) = NULL; -void (GLAPIENTRY *GLDispatch::glColorMask)(GLboolean,GLboolean,GLboolean,GLboolean) = NULL; -void (GLAPIENTRY *GLDispatch::glCompressedTexImage2D)(GLenum,GLint,GLenum,GLsizei,GLsizei,GLint,GLsizei, const GLvoid *) = NULL; -void (GLAPIENTRY *GLDispatch::glCompressedTexSubImage2D)(GLenum,GLint,GLint,GLint,GLsizei,GLsizei,GLenum,GLsizei,const GLvoid *) = NULL; -void (GLAPIENTRY *GLDispatch::glCopyTexImage2D)(GLenum,GLint,GLenum,GLint,GLint,GLsizei,GLsizei,GLint) = NULL; -void (GLAPIENTRY *GLDispatch::glCopyTexSubImage2D)(GLenum,GLint,GLint,GLint,GLint,GLint,GLsizei,GLsizei) = NULL; -void (GLAPIENTRY *GLDispatch::glCullFace)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glDeleteBuffers)(GLsizei,const GLuint *) = NULL; -void (GLAPIENTRY *GLDispatch::glDeleteTextures)(GLsizei,const GLuint *) = NULL; -void (GLAPIENTRY *GLDispatch::glDepthFunc)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glDepthMask)(GLboolean) = NULL; -void (GLAPIENTRY *GLDispatch::glDepthRange)(GLclampd,GLclampd) = NULL; -void (GLAPIENTRY *GLDispatch::glDisable)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glDrawArrays)(GLenum,GLint,GLsizei) = NULL; -void (GLAPIENTRY *GLDispatch::glDrawElements)(GLenum,GLsizei,GLenum,const GLvoid *) = NULL; -void (GLAPIENTRY *GLDispatch::glEnable)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glFinish)() = NULL; -void (GLAPIENTRY *GLDispatch::glFlush)() = NULL; -void (GLAPIENTRY *GLDispatch::glFrontFace)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glGenBuffers)(GLsizei,GLuint *) = NULL; -void (GLAPIENTRY *GLDispatch::glGenTextures)(GLsizei,GLuint *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetBooleanv)(GLenum,GLboolean *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetBufferParameteriv)(GLenum, GLenum, GLint *) = NULL; -GLenum (GLAPIENTRY *GLDispatch::glGetError)() = NULL; -void (GLAPIENTRY *GLDispatch::glGetFloatv)(GLenum,GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetIntegerv)(GLenum,GLint *) = NULL; -const GLubyte * (GLAPIENTRY *GLDispatch::glGetString) (GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glGetTexParameterfv)(GLenum,GLenum,GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetTexParameteriv)(GLenum,GLenum,GLint *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetTexLevelParameteriv) (GLenum target, GLint level, GLenum pname, GLint *params) = NULL; -void (GLAPIENTRY *GLDispatch::glHint)(GLenum,GLenum) = NULL; -GLboolean (GLAPIENTRY *GLDispatch::glIsBuffer)(GLuint) = NULL; -GLboolean (GLAPIENTRY *GLDispatch::glIsEnabled)(GLenum) = NULL; -GLboolean (GLAPIENTRY *GLDispatch::glIsTexture)(GLuint) = NULL; -void (GLAPIENTRY *GLDispatch::glLineWidth)(GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glPolygonOffset)(GLfloat, GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glPixelStorei)(GLenum,GLint) = NULL; -void (GLAPIENTRY *GLDispatch::glReadPixels)(GLint,GLint,GLsizei,GLsizei,GLenum,GLenum,GLvoid *) = NULL; -void (GLAPIENTRY *GLDispatch::glSampleCoverage)(GLclampf,GLboolean) = NULL; -void (GLAPIENTRY *GLDispatch::glScissor)(GLint,GLint,GLsizei,GLsizei) = NULL; -void (GLAPIENTRY *GLDispatch::glStencilFunc)(GLenum,GLint,GLuint) = NULL; -void (GLAPIENTRY *GLDispatch::glStencilMask)(GLuint) = NULL; -void (GLAPIENTRY *GLDispatch::glStencilOp)(GLenum, GLenum,GLenum); -void (GLAPIENTRY *GLDispatch::glTexImage2D)(GLenum,GLint,GLint,GLsizei,GLsizei,GLint,GLenum,GLenum,const GLvoid *) = NULL; -void (GLAPIENTRY *GLDispatch::glTexParameterf)(GLenum,GLenum, GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glTexParameterfv)(GLenum,GLenum,const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glTexParameteri)(GLenum,GLenum,GLint) = NULL; -void (GLAPIENTRY *GLDispatch::glTexParameteriv)(GLenum,GLenum,const GLint *) = NULL; -void (GLAPIENTRY *GLDispatch::glTexSubImage2D)(GLenum,GLint,GLint,GLint,GLsizei,GLsizei,GLenum,GLenum,const GLvoid *) = NULL; -void (GLAPIENTRY *GLDispatch::glViewport)(GLint,GLint,GLsizei,GLsizei) = NULL; -void (GLAPIENTRY *GLDispatch::glPushAttrib) ( GLbitfield mask ) = NULL; -void (GLAPIENTRY *GLDispatch::glPopAttrib) ( void ) = NULL; -void (GLAPIENTRY *GLDispatch::glPushClientAttrib) ( GLbitfield mask ) = NULL; -void (GLAPIENTRY *GLDispatch::glPopClientAttrib) ( void ) = NULL; - -/*GLES 1.1*/ -void (GLAPIENTRY *GLDispatch::glAlphaFunc)(GLenum,GLclampf) = NULL; -void (GLAPIENTRY *GLDispatch::glBegin)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glClearDepth)(GLclampd) = NULL; -void (GLAPIENTRY *GLDispatch::glClientActiveTexture)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glClipPlane)(GLenum,const GLdouble *) = NULL; -void (GLAPIENTRY *GLDispatch::glColor4d)(GLdouble,GLdouble,GLdouble,GLdouble) = NULL; -void (GLAPIENTRY *GLDispatch::glColor4f)(GLfloat,GLfloat,GLfloat,GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glColor4fv)(const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glColor4ub)(GLubyte,GLubyte,GLubyte,GLubyte) = NULL; -void (GLAPIENTRY *GLDispatch::glColor4ubv)(const GLubyte *) = NULL; -void (GLAPIENTRY *GLDispatch::glColorPointer)(GLint,GLenum,GLsizei,const GLvoid *) = NULL; -void (GLAPIENTRY *GLDispatch::glDisableClientState)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glEnableClientState)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glEnd)() = NULL; -void (GLAPIENTRY *GLDispatch::glFogf)(GLenum, GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glFogfv)(GLenum,const GLfloat *); -void (GLAPIENTRY *GLDispatch::glFrustum)(GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble) = NULL; -void (GLAPIENTRY *GLDispatch::glGetClipPlane)(GLenum,GLdouble *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetDoublev)(GLenum,GLdouble *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetLightfv)(GLenum,GLenum,GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetMaterialfv)(GLenum,GLenum,GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetPointerv)(GLenum,GLvoid**) = NULL; -void (GLAPIENTRY *GLDispatch::glGetTexEnvfv)(GLenum,GLenum,GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glGetTexEnviv)(GLenum,GLenum,GLint *)= NULL; -void (GLAPIENTRY *GLDispatch::glLightf)(GLenum,GLenum,GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glLightfv)(GLenum,GLenum,const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glLightModelf)(GLenum,GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glLightModelfv)(GLenum,const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glLoadIdentity)() = NULL; -void (GLAPIENTRY *GLDispatch::glLoadMatrixf)(const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glLogicOp)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glMaterialf)(GLenum,GLenum,GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glMaterialfv)(GLenum,GLenum,const GLfloat *); -void (GLAPIENTRY *GLDispatch::glMultiTexCoord2fv)(GLenum, const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glMultiTexCoord2sv)(GLenum, const GLshort *) = NULL; -void (GLAPIENTRY *GLDispatch::glMultiTexCoord3fv)(GLenum, const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glMultiTexCoord3sv)(GLenum,const GLshort *) = NULL; -void (GLAPIENTRY *GLDispatch::glMultiTexCoord4f)(GLenum,GLfloat,GLfloat,GLfloat,GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glMultiTexCoord4fv)(GLenum,const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glMultiTexCoord4sv)(GLenum,const GLshort *) = NULL; -void (GLAPIENTRY *GLDispatch::glMultMatrixf)(const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glNormal3f)(GLfloat,GLfloat,GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glNormal3fv)(const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glNormal3sv)(const GLshort *) = NULL; -void (GLAPIENTRY *GLDispatch::glOrtho)(GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble) = NULL; -void (GLAPIENTRY *GLDispatch::glPointParameterf)(GLenum, GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glPointParameterfv)(GLenum, const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glPointSize)(GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glRotatef)(GLfloat,GLfloat,GLfloat,GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glScalef)(GLfloat,GLfloat,GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glTexEnvf)(GLenum,GLenum,GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glTexEnvfv)(GLenum,GLenum,const GLfloat *) = NULL; -void (GLAPIENTRY *GLDispatch::glMatrixMode)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glNormalPointer)(GLenum,GLsizei,const GLvoid *) = NULL; -void (GLAPIENTRY *GLDispatch::glPopMatrix)() = NULL; -void (GLAPIENTRY *GLDispatch::glPushMatrix)() = NULL; -void (GLAPIENTRY *GLDispatch::glShadeModel)(GLenum) = NULL; -void (GLAPIENTRY *GLDispatch::glTexCoordPointer)(GLint,GLenum, GLsizei, const GLvoid*) = NULL; -void (GLAPIENTRY *GLDispatch::glTexEnvi)(GLenum ,GLenum,GLint) = NULL; -void (GLAPIENTRY *GLDispatch::glTexEnviv)(GLenum, GLenum, const GLint *) = NULL; -void (GLAPIENTRY *GLDispatch::glTranslatef)(GLfloat,GLfloat, GLfloat) = NULL; -void (GLAPIENTRY *GLDispatch::glVertexPointer)(GLint,GLenum,GLsizei, const GLvoid *) = NULL; - -/* GLES 1.1 EXTENSIONS*/ -GLboolean (GLAPIENTRY *GLDispatch::glIsRenderbufferEXT) (GLuint renderbuffer) = NULL; -void (GLAPIENTRY *GLDispatch::glBindRenderbufferEXT) (GLenum target, GLuint renderbuffer) = NULL; -void (GLAPIENTRY *GLDispatch::glDeleteRenderbuffersEXT) (GLsizei n, const GLuint *renderbuffers) = NULL; -void (GLAPIENTRY *GLDispatch::glGenRenderbuffersEXT) (GLsizei n, GLuint *renderbuffers) = NULL; -void (GLAPIENTRY *GLDispatch::glRenderbufferStorageEXT) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL; -void (GLAPIENTRY *GLDispatch::glGetRenderbufferParameterivEXT) (GLenum target, GLenum pname, GLint *params) = NULL; -GLboolean (GLAPIENTRY *GLDispatch::glIsFramebufferEXT) (GLuint framebuffer) = NULL; -void (GLAPIENTRY *GLDispatch::glBindFramebufferEXT) (GLenum target, GLuint framebuffer) = NULL; -void (GLAPIENTRY *GLDispatch::glDeleteFramebuffersEXT) (GLsizei n, const GLuint *framebuffers) = NULL; -void (GLAPIENTRY *GLDispatch::glGenFramebuffersEXT) (GLsizei n, GLuint *framebuffers) = NULL; -GLenum (GLAPIENTRY *GLDispatch::glCheckFramebufferStatusEXT) (GLenum target) = NULL; -void (GLAPIENTRY *GLDispatch::glFramebufferTexture1DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; -void (GLAPIENTRY *GLDispatch::glFramebufferTexture2DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; -void (GLAPIENTRY *GLDispatch::glFramebufferTexture3DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = NULL; -void (GLAPIENTRY *GLDispatch::glFramebufferRenderbufferEXT) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL; -void (GLAPIENTRY *GLDispatch::glGetFramebufferAttachmentParameterivEXT) (GLenum target, GLenum attachment, GLenum pname, GLint *params) = NULL; -void (GLAPIENTRY *GLDispatch::glGenerateMipmapEXT) (GLenum target) = NULL; -void (GLAPIENTRY *GLDispatch::glCurrentPaletteMatrixARB) (GLint index) = NULL; -void (GLAPIENTRY *GLDispatch::glMatrixIndexuivARB) (GLint size, GLuint * indices) = NULL; -void (GLAPIENTRY *GLDispatch::glMatrixIndexPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) = NULL; -void (GLAPIENTRY *GLDispatch::glWeightPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) = NULL; -void (GLAPIENTRY *GLDispatch::glTexGenf) (GLenum coord, GLenum pname, GLfloat param ) = NULL; -void (GLAPIENTRY *GLDispatch::glTexGeni) (GLenum coord, GLenum pname, GLint param ) = NULL; -void (GLAPIENTRY *GLDispatch::glTexGenfv) (GLenum coord, GLenum pname, const GLfloat *params ) = NULL; -void (GLAPIENTRY *GLDispatch::glTexGeniv) (GLenum coord, GLenum pname, const GLint *params ) = NULL; -void (GLAPIENTRY *GLDispatch::glGetTexGenfv) (GLenum coord, GLenum pname, GLfloat *params ) = NULL; -void (GLAPIENTRY *GLDispatch::glGetTexGeniv) (GLenum coord, GLenum pname, GLint *params ) = NULL; - -/* GLES 2.0*/ -void (GL_APIENTRY *GLDispatch::glBlendColor)(GLclampf,GLclampf,GLclampf,GLclampf) = NULL; -void (GL_APIENTRY *GLDispatch::glStencilFuncSeparate)(GLenum,GLenum,GLint,GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glStencilMaskSeparate)(GLenum,GLuint) = NULL; -GLboolean (GL_APIENTRY *GLDispatch::glIsProgram)(GLuint program) = NULL; -GLboolean (GL_APIENTRY *GLDispatch::glIsShader)(GLuint shader) = NULL; -void (GL_APIENTRY *GLDispatch::glVertexAttrib1f)(GLuint,GLfloat) = NULL; -void (GL_APIENTRY *GLDispatch::glVertexAttrib1fv)(GLuint,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glVertexAttrib2f)(GLuint,GLfloat, GLfloat) = NULL; -void (GL_APIENTRY *GLDispatch::glVertexAttrib2fv)(GLuint,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glVertexAttrib3f)(GLuint,GLfloat, GLfloat,GLfloat) = NULL; -void (GL_APIENTRY *GLDispatch::glVertexAttrib3fv)(GLuint,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glVertexAttrib4f)(GLuint,GLfloat,GLfloat,GLfloat,GLfloat ) = NULL; -void (GL_APIENTRY *GLDispatch::glVertexAttrib4fv)(GLuint,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glVertexAttribPointer)(GLuint,GLint,GLenum,GLboolean,GLsizei,const GLvoid*) = NULL; -void (GL_APIENTRY *GLDispatch::glDisableVertexAttribArray)(GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glEnableVertexAttribArray)(GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glGetVertexAttribfv)(GLuint,GLenum,GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetVertexAttribiv)(GLuint,GLenum,GLint*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetVertexAttribPointerv)(GLuint,GLenum,GLvoid**) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform1f)(GLint,GLfloat) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform1fv)(GLint,GLsizei,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform1i)(GLint,GLint) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform1iv)(GLint,GLsizei,const GLint*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform2f)(GLint,GLfloat,GLfloat) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform2fv)(GLint,GLsizei,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform2i)(GLint,GLint,GLint) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform2iv)(GLint ,GLsizei,const GLint*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform3f)(GLint,GLfloat,GLfloat,GLfloat) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform3fv)(GLint,GLsizei,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform3i)(GLint,GLint,GLint,GLint) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform3iv)(GLint,GLsizei,const GLint*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform4f)(GLint,GLfloat,GLfloat,GLfloat,GLfloat) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform4fv)(GLint,GLsizei,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform4i)(GLint,GLint,GLint,GLint,GLint) = NULL; -void (GL_APIENTRY *GLDispatch::glUniform4iv)(GLint,GLsizei,const GLint*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniformMatrix2fv)(GLint,GLsizei,GLboolean,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniformMatrix3fv)(GLint,GLsizei,GLboolean,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glUniformMatrix4fv)(GLint,GLsizei,GLboolean,const GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glAttachShader)(GLuint,GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glBindAttribLocation)(GLuint,GLuint,const GLchar*) = NULL; -void (GL_APIENTRY *GLDispatch::glCompileShader)(GLuint) = NULL; -GLuint (GL_APIENTRY *GLDispatch::glCreateProgram)() = NULL; -GLuint (GL_APIENTRY *GLDispatch::glCreateShader)(GLenum) = NULL; -void (GL_APIENTRY *GLDispatch::glDeleteProgram)(GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glDeleteShader)(GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glDetachShader)(GLuint,GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glLinkProgram)(GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glUseProgram)(GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glValidateProgram)(GLuint) = NULL; -void (GL_APIENTRY *GLDispatch::glGetActiveAttrib)(GLuint,GLuint,GLsizei,GLsizei*,GLint*,GLenum*,GLchar*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetActiveUniform)(GLuint,GLuint,GLsizei,GLsizei*,GLint*,GLenum*,GLchar*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetAttachedShaders)(GLuint,GLsizei,GLsizei*,GLuint*) = NULL; -int (GL_APIENTRY *GLDispatch::glGetAttribLocation)(GLuint,const GLchar*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetProgramiv)(GLuint,GLenum,GLint*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetProgramInfoLog)(GLuint,GLsizei,GLsizei*,GLchar*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetShaderiv)(GLuint,GLenum,GLint*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetShaderInfoLog)(GLuint,GLsizei,GLsizei*,GLchar*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetShaderPrecisionFormat)(GLenum,GLenum,GLint*,GLint*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetShaderSource)(GLuint,GLsizei,GLsizei*,GLchar*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetUniformfv)(GLuint,GLint,GLfloat*) = NULL; -void (GL_APIENTRY *GLDispatch::glGetUniformiv)(GLuint,GLint,GLint*) = NULL; -int (GL_APIENTRY *GLDispatch::glGetUniformLocation)(GLuint,const GLchar*) = NULL; -void (GL_APIENTRY *GLDispatch::glReleaseShaderCompiler)() = NULL; -void (GL_APIENTRY *GLDispatch::glShaderBinary)(GLsizei,const GLuint*,GLenum,const GLvoid*,GLsizei) = NULL; -void (GL_APIENTRY *GLDispatch::glShaderSource)(GLuint,GLsizei,const GLchar* const*,const GLint*) = NULL; - -GLDispatch::GLDispatch():m_isLoaded(false){}; - - -void GLDispatch::dispatchFuncs(GLESVersion version){ - emugl::Mutex::AutoLock mutex(s_lock); - if(m_isLoaded) - return; - - /* Loading OpenGL functions which are needed for implementing BOTH GLES 1.1 & GLES 2.0*/ - LOAD_GL_FUNC(glActiveTexture); - LOAD_GL_FUNC(glBindBuffer); - LOAD_GL_FUNC(glBindTexture); - LOAD_GL_FUNC(glBlendFunc); - LOAD_GL_FUNC(glBlendEquation); - LOAD_GL_FUNC(glBlendEquationSeparate); - LOAD_GL_FUNC(glBlendFuncSeparate); - LOAD_GL_FUNC(glBufferData); - LOAD_GL_FUNC(glBufferSubData); - LOAD_GL_FUNC(glClear); - LOAD_GL_FUNC(glClearColor); - LOAD_GL_FUNC(glClearDepth); - LOAD_GL_FUNC(glClearStencil); - LOAD_GL_FUNC(glColorMask); - LOAD_GL_FUNC(glCompressedTexImage2D); - LOAD_GL_FUNC(glCompressedTexSubImage2D); - LOAD_GL_FUNC(glCopyTexImage2D); - LOAD_GL_FUNC(glCopyTexSubImage2D); - LOAD_GL_FUNC(glCullFace); - LOAD_GL_FUNC(glDeleteBuffers); - LOAD_GL_FUNC(glDeleteTextures); - LOAD_GL_FUNC(glDepthFunc); - LOAD_GL_FUNC(glDepthMask); - LOAD_GL_FUNC(glDepthRange); - LOAD_GL_FUNC(glDisable); - LOAD_GL_FUNC(glDrawArrays); - LOAD_GL_FUNC(glDrawElements); - LOAD_GL_FUNC(glEnable); - LOAD_GL_FUNC(glFinish); - LOAD_GL_FUNC(glFlush); - LOAD_GL_FUNC(glFrontFace); - LOAD_GL_FUNC(glGenBuffers); - LOAD_GL_FUNC(glGenTextures); - LOAD_GL_FUNC(glGetBooleanv); - LOAD_GL_FUNC(glGetBufferParameteriv); - LOAD_GL_FUNC(glGetError); - LOAD_GL_FUNC(glGetFloatv); - LOAD_GL_FUNC(glGetIntegerv); - LOAD_GL_FUNC(glGetString); - LOAD_GL_FUNC(glTexParameterf); - LOAD_GL_FUNC(glTexParameterfv); - LOAD_GL_FUNC(glGetTexParameterfv); - LOAD_GL_FUNC(glGetTexParameteriv); - LOAD_GL_FUNC(glGetTexLevelParameteriv); - LOAD_GL_FUNC(glHint); - LOAD_GL_FUNC(glIsBuffer); - LOAD_GL_FUNC(glIsEnabled); - LOAD_GL_FUNC(glIsTexture); - LOAD_GL_FUNC(glLineWidth); - LOAD_GL_FUNC(glPolygonOffset); - LOAD_GL_FUNC(glPixelStorei); - LOAD_GL_FUNC(glReadPixels); - LOAD_GL_FUNC(glSampleCoverage); - LOAD_GL_FUNC(glScissor); - LOAD_GL_FUNC(glStencilFunc); - LOAD_GL_FUNC(glStencilMask); - LOAD_GL_FUNC(glStencilOp); - LOAD_GL_FUNC(glTexImage2D); - LOAD_GL_FUNC(glTexParameteri); - LOAD_GL_FUNC(glTexParameteriv); - LOAD_GL_FUNC(glTexSubImage2D); - LOAD_GL_FUNC(glViewport); - LOAD_GL_FUNC(glPushAttrib); - LOAD_GL_FUNC(glPushClientAttrib); - LOAD_GL_FUNC(glPopAttrib); - LOAD_GL_FUNC(glPopClientAttrib); - LOAD_GLEXT_FUNC(glIsRenderbufferEXT); - LOAD_GLEXT_FUNC(glBindRenderbufferEXT); - LOAD_GLEXT_FUNC(glDeleteRenderbuffersEXT); - LOAD_GLEXT_FUNC(glGenRenderbuffersEXT); - LOAD_GLEXT_FUNC(glRenderbufferStorageEXT); - LOAD_GLEXT_FUNC(glGetRenderbufferParameterivEXT); - LOAD_GLEXT_FUNC(glIsFramebufferEXT); - LOAD_GLEXT_FUNC(glBindFramebufferEXT); - LOAD_GLEXT_FUNC(glDeleteFramebuffersEXT); - LOAD_GLEXT_FUNC(glGenFramebuffersEXT); - LOAD_GLEXT_FUNC(glCheckFramebufferStatusEXT); - LOAD_GLEXT_FUNC(glFramebufferTexture1DEXT); - LOAD_GLEXT_FUNC(glFramebufferTexture2DEXT); - LOAD_GLEXT_FUNC(glFramebufferTexture3DEXT); - LOAD_GLEXT_FUNC(glFramebufferRenderbufferEXT); - LOAD_GLEXT_FUNC(glGetFramebufferAttachmentParameterivEXT); - LOAD_GLEXT_FUNC(glGenerateMipmapEXT); - - /* Loading OpenGL functions which are needed ONLY for implementing GLES 1.1*/ - if(version == GLES_1_1){ - LOAD_GL_FUNC(glAlphaFunc); - LOAD_GL_FUNC(glBegin); - LOAD_GL_FUNC(glClientActiveTexture); - LOAD_GL_FUNC(glClipPlane); - LOAD_GL_FUNC(glColor4d); - LOAD_GL_FUNC(glColor4f); - LOAD_GL_FUNC(glColor4fv); - LOAD_GL_FUNC(glColor4ub); - LOAD_GL_FUNC(glColor4ubv); - LOAD_GL_FUNC(glColorPointer); - LOAD_GL_FUNC(glDisableClientState); - LOAD_GL_FUNC(glEnableClientState); - LOAD_GL_FUNC(glEnd); - LOAD_GL_FUNC(glFogf); - LOAD_GL_FUNC(glFogfv); - LOAD_GL_FUNC(glFrustum); - LOAD_GL_FUNC(glGetClipPlane); - LOAD_GL_FUNC(glGetDoublev); - LOAD_GL_FUNC(glGetLightfv); - LOAD_GL_FUNC(glGetMaterialfv); - LOAD_GL_FUNC(glGetPointerv); - LOAD_GL_FUNC(glGetTexEnvfv); - LOAD_GL_FUNC(glGetTexEnviv); - LOAD_GL_FUNC(glLightf); - LOAD_GL_FUNC(glLightfv); - LOAD_GL_FUNC(glLightModelf); - LOAD_GL_FUNC(glLightModelfv); - LOAD_GL_FUNC(glLoadIdentity); - LOAD_GL_FUNC(glLoadMatrixf); - LOAD_GL_FUNC(glLogicOp); - LOAD_GL_FUNC(glMaterialf); - LOAD_GL_FUNC(glMaterialfv); - LOAD_GL_FUNC(glMultiTexCoord2fv); - LOAD_GL_FUNC(glMultiTexCoord2sv); - LOAD_GL_FUNC(glMultiTexCoord3fv); - LOAD_GL_FUNC(glMultiTexCoord3sv); - LOAD_GL_FUNC(glMultiTexCoord4fv); - LOAD_GL_FUNC(glMultiTexCoord4sv); - LOAD_GL_FUNC(glMultiTexCoord4f); - LOAD_GL_FUNC(glMultMatrixf); - LOAD_GL_FUNC(glNormal3f); - LOAD_GL_FUNC(glNormal3fv); - LOAD_GL_FUNC(glNormal3sv); - LOAD_GL_FUNC(glOrtho); - LOAD_GL_FUNC(glPointParameterf); - LOAD_GL_FUNC(glPointParameterfv); - LOAD_GL_FUNC(glPointSize); - LOAD_GL_FUNC(glRotatef); - LOAD_GL_FUNC(glScalef); - LOAD_GL_FUNC(glTexEnvf); - LOAD_GL_FUNC(glTexEnvfv); - LOAD_GL_FUNC(glMatrixMode); - LOAD_GL_FUNC(glNormalPointer); - LOAD_GL_FUNC(glPopMatrix); - LOAD_GL_FUNC(glPushMatrix); - LOAD_GL_FUNC(glShadeModel); - LOAD_GL_FUNC(glTexCoordPointer); - LOAD_GL_FUNC(glTexEnvi); - LOAD_GL_FUNC(glTexEnviv); - LOAD_GL_FUNC(glTranslatef); - LOAD_GL_FUNC(glVertexPointer); - - LOAD_GLEXT_FUNC(glCurrentPaletteMatrixARB); - LOAD_GLEXT_FUNC(glMatrixIndexuivARB); - LOAD_GLEXT_FUNC(glMatrixIndexPointerARB); - LOAD_GLEXT_FUNC(glWeightPointerARB); - LOAD_GLEXT_FUNC(glTexGenf); - LOAD_GLEXT_FUNC(glTexGeni); - LOAD_GLEXT_FUNC(glTexGenfv); - LOAD_GLEXT_FUNC(glTexGeniv); - LOAD_GLEXT_FUNC(glGetTexGenfv); - LOAD_GLEXT_FUNC(glGetTexGeniv); - - } else if (version == GLES_2_0){ - - /* Loading OpenGL functions which are needed ONLY for implementing GLES 2.0*/ - - LOAD_GL_FUNC(glBlendColor); - LOAD_GL_FUNC(glBlendFuncSeparate); - LOAD_GL_FUNC(glStencilFuncSeparate); - LOAD_GL_FUNC(glIsProgram); - LOAD_GL_FUNC(glIsShader); - LOAD_GL_FUNC(glVertexAttrib1f); - LOAD_GL_FUNC(glVertexAttrib1fv); - LOAD_GL_FUNC(glVertexAttrib2f); - LOAD_GL_FUNC(glVertexAttrib2fv); - LOAD_GL_FUNC(glVertexAttrib3f); - LOAD_GL_FUNC(glVertexAttrib3fv); - LOAD_GL_FUNC(glVertexAttrib4f); - LOAD_GL_FUNC(glVertexAttrib4fv); - LOAD_GL_FUNC(glVertexAttribPointer); - LOAD_GL_FUNC(glDisableVertexAttribArray); - LOAD_GL_FUNC(glEnableVertexAttribArray); - LOAD_GL_FUNC(glGetVertexAttribfv); - LOAD_GL_FUNC(glGetVertexAttribiv); - LOAD_GL_FUNC(glGetVertexAttribPointerv); - LOAD_GL_FUNC(glUniform1f); - LOAD_GL_FUNC(glUniform1fv); - LOAD_GL_FUNC(glUniform1i); - LOAD_GL_FUNC(glUniform1iv); - LOAD_GL_FUNC(glUniform2f); - LOAD_GL_FUNC(glUniform2fv); - LOAD_GL_FUNC(glUniform2i); - LOAD_GL_FUNC(glUniform2iv); - LOAD_GL_FUNC(glUniform3f); - LOAD_GL_FUNC(glUniform3fv); - LOAD_GL_FUNC(glUniform3i); - LOAD_GL_FUNC(glUniform3iv); - LOAD_GL_FUNC(glUniform4f); - LOAD_GL_FUNC(glUniform4fv); - LOAD_GL_FUNC(glUniform4i); - LOAD_GL_FUNC(glUniform4iv); - LOAD_GL_FUNC(glUniformMatrix2fv); - LOAD_GL_FUNC(glUniformMatrix3fv); - LOAD_GL_FUNC(glUniformMatrix4fv); - LOAD_GL_FUNC(glAttachShader); - LOAD_GL_FUNC(glBindAttribLocation); - LOAD_GL_FUNC(glCompileShader); - LOAD_GL_FUNC(glCreateProgram); - LOAD_GL_FUNC(glCreateShader); - LOAD_GL_FUNC(glDeleteProgram); - LOAD_GL_FUNC(glDeleteShader); - LOAD_GL_FUNC(glDetachShader); - LOAD_GL_FUNC(glLinkProgram); - LOAD_GL_FUNC(glUseProgram); - LOAD_GL_FUNC(glValidateProgram); - LOAD_GL_FUNC(glGetActiveAttrib); - LOAD_GL_FUNC(glGetActiveUniform); - LOAD_GL_FUNC(glGetAttachedShaders); - LOAD_GL_FUNC(glGetAttribLocation); - LOAD_GL_FUNC(glGetProgramiv); - LOAD_GL_FUNC(glGetProgramInfoLog); - LOAD_GL_FUNC(glGetShaderiv); - LOAD_GL_FUNC(glGetShaderInfoLog); - LOAD_GLEXT_FUNC(glGetShaderPrecisionFormat); - LOAD_GL_FUNC(glGetShaderSource); - LOAD_GL_FUNC(glGetUniformfv); - LOAD_GL_FUNC(glGetUniformiv); - LOAD_GL_FUNC(glGetUniformLocation); - LOAD_GLEXT_FUNC(glReleaseShaderCompiler); - LOAD_GLEXT_FUNC(glShaderBinary); - LOAD_GL_FUNC(glShaderSource); - LOAD_GL_FUNC(glStencilMaskSeparate); - } - m_isLoaded = true; -} diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLESbuffer.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLESbuffer.cpp deleted file mode 100644 index 5dcdd65..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/GLESbuffer.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* -* 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. -*/ -#include <GLcommon/GLESbuffer.h> -#include <string.h> - -bool GLESbuffer::setBuffer(GLuint size,GLuint usage,const GLvoid* data) { - m_size = size; - m_usage = usage; - if(m_data) { - delete [] m_data; - m_data = NULL; - } - m_data = new unsigned char[size]; - if(m_data) { - if(data) { - memcpy(m_data,data,size); - } - m_conversionManager.clear(); - m_conversionManager.addRange(Range(0,m_size)); - return true; - } - return false; -} - -bool GLESbuffer::setSubBuffer(GLint offset,GLuint size,const GLvoid* data) { - if(offset + size > m_size) return false; - memcpy(m_data+offset,data,size); - m_conversionManager.addRange(Range(offset,size)); - m_conversionManager.merge(); - return true; -} - -void GLESbuffer::getConversions(const RangeList& rIn,RangeList& rOut) { - m_conversionManager.delRanges(rIn,rOut); - rOut.merge(); -} - -GLESbuffer::~GLESbuffer() { - if(m_data) { - delete [] m_data; - } -} diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp deleted file mode 100644 index ba3edbe..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp +++ /dev/null @@ -1,760 +0,0 @@ -/* -* 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 <GLcommon/GLEScontext.h> -#include <GLcommon/GLconversion_macros.h> -#include <GLcommon/GLESmacros.h> -#include <GLES/gl.h> -#include <GLES/glext.h> -#include <GLcommon/GLESvalidate.h> -#include <GLcommon/TextureUtils.h> -#include <GLcommon/FramebufferData.h> -#include <strings.h> -#include <string.h> - -//decleration -static void convertFixedDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize); -static void convertFixedIndirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,GLsizei count,GLenum indices_type,const GLvoid* indices,unsigned int strideOut,int attribSize); -static void convertByteDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize); -static void convertByteIndirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,GLsizei count,GLenum indices_type,const GLvoid* indices,unsigned int strideOut,int attribSize); - -GLESConversionArrays::~GLESConversionArrays() { - for(std::map<GLenum,ArrayData>::iterator it = m_arrays.begin(); it != m_arrays.end();it++) { - if((*it).second.allocated){ - if((*it).second.type == GL_FLOAT){ - GLfloat* p = (GLfloat *)((*it).second.data); - if(p) delete[] p; - } else if((*it).second.type == GL_SHORT){ - GLshort* p = (GLshort *)((*it).second.data); - if(p) delete[] p; - } - } - } -} - -void GLESConversionArrays::allocArr(unsigned int size,GLenum type){ - if(type == GL_FIXED){ - m_arrays[m_current].data = new GLfloat[size]; - m_arrays[m_current].type = GL_FLOAT; - } else if(type == GL_BYTE){ - m_arrays[m_current].data = new GLshort[size]; - m_arrays[m_current].type = GL_SHORT; - } - m_arrays[m_current].stride = 0; - m_arrays[m_current].allocated = true; -} - -void GLESConversionArrays::setArr(void* data,unsigned int stride,GLenum type){ - m_arrays[m_current].type = type; - m_arrays[m_current].data = data; - m_arrays[m_current].stride = stride; - m_arrays[m_current].allocated = false; -} - -void* GLESConversionArrays::getCurrentData(){ - return m_arrays[m_current].data; -} - -ArrayData& GLESConversionArrays::getCurrentArray(){ - return m_arrays[m_current]; -} - -unsigned int GLESConversionArrays::getCurrentIndex(){ - return m_current; -} - -ArrayData& GLESConversionArrays::operator[](int i){ - return m_arrays[i]; -} - -void GLESConversionArrays::operator++(){ - m_current++; -} - -GLDispatch GLEScontext::s_glDispatch; -emugl::Mutex GLEScontext::s_lock; -std::string* GLEScontext::s_glExtensions= NULL; -std::string GLEScontext::s_glVendor; -std::string GLEScontext::s_glRenderer; -std::string GLEScontext::s_glVersion; -GLSupport GLEScontext::s_glSupport; - -Version::Version():m_major(0), - m_minor(0), - m_release(0){}; - -Version::Version(int major,int minor,int release):m_major(major), - m_minor(minor), - m_release(release){}; - -Version::Version(const Version& ver):m_major(ver.m_major), - m_minor(ver.m_minor), - m_release(ver.m_release){} - -Version::Version(const char* versionString){ - m_release = 0; - if((!versionString) || - ((!(sscanf(versionString,"%d.%d" ,&m_major,&m_minor) == 2)) && - (!(sscanf(versionString,"%d.%d.%d",&m_major,&m_minor,&m_release) == 3)))){ - m_major = m_minor = 0; // the version is not in the right format - } -} - -Version& Version::operator=(const Version& ver){ - m_major = ver.m_major; - m_minor = ver.m_minor; - m_release = ver.m_release; - return *this; -} - -bool Version::operator<(const Version& ver) const{ - if(m_major < ver.m_major) return true; - if(m_major == ver.m_major){ - if(m_minor < ver.m_minor) return true; - if(m_minor == ver.m_minor){ - return m_release < ver.m_release; - } - } - return false; -} - -void GLEScontext::init() { - - if (!s_glExtensions) { - initCapsLocked(s_glDispatch.glGetString(GL_EXTENSIONS)); - s_glExtensions = new std::string(""); - } - - if (!m_initialized) { - initExtensionString(); - - int maxTexUnits = getMaxTexUnits(); - m_texState = new textureUnitState[maxTexUnits]; - for (int i=0;i<maxTexUnits;++i) { - for (int j=0;j<NUM_TEXTURE_TARGETS;++j) - { - m_texState[i][j].texture = 0; - m_texState[i][j].enabled = GL_FALSE; - } - } - } -} - -GLEScontext::GLEScontext(): - m_initialized(false) , - m_activeTexture(0) , - m_unpackAlignment(4) , - m_glError(GL_NO_ERROR) , - m_texState(0) , - m_arrayBuffer(0) , - m_elementBuffer(0), - m_renderbuffer(0), - m_framebuffer(0) -{ -}; - -GLenum GLEScontext::getGLerror() { - return m_glError; -} - -void GLEScontext::setGLerror(GLenum err) { - m_glError = err; -} - -void GLEScontext::setActiveTexture(GLenum tex) { - m_activeTexture = tex - GL_TEXTURE0; -} - -GLEScontext::~GLEScontext() { - for(ArraysMap::iterator it = m_map.begin(); it != m_map.end();it++) { - GLESpointer* p = (*it).second; - if(p) { - delete p; - } - } - delete[] m_texState; - m_texState = NULL; -} - -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 = SafeUIntFromPointer(data); - 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; - } - m_map[arrType]->setArray(size,type,stride,data,normalize); - return data; -} - -void GLEScontext::enableArr(GLenum arr,bool enable) { - m_map[arr]->enable(enable); -} - -bool GLEScontext::isArrEnabled(GLenum arr) { - return m_map[arr]->isEnable(); -} - -const GLESpointer* GLEScontext::getPointer(GLenum arrType) { - if (m_map.find(arrType) != m_map.end()) return m_map[arrType]; - return NULL; -} - -static void convertFixedDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize) { - - for(unsigned int i = 0; i < nBytes;i+=strideOut) { - const GLfixed* fixed_data = (const GLfixed *)dataIn; - //filling attrib - for(int j=0;j<attribSize;j++) { - reinterpret_cast<GLfloat*>(&static_cast<unsigned char*>(dataOut)[i])[j] = X2F(fixed_data[j]); - } - dataIn += strideIn; - } -} - -static void convertFixedIndirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,GLsizei count,GLenum indices_type,const GLvoid* indices,unsigned int strideOut,int attribSize) { - for(int i = 0 ;i < count ;i++) { - unsigned short index = indices_type == GL_UNSIGNED_BYTE? ((GLubyte *)indices)[i]: - ((GLushort *)indices)[i]; - const GLfixed* fixed_data = (GLfixed *)(dataIn + index*strideIn); - GLfloat* float_data = reinterpret_cast<GLfloat*>(static_cast<unsigned char*>(dataOut) + index*strideOut); - - for(int j=0;j<attribSize;j++) { - float_data[j] = X2F(fixed_data[j]); - } - } -} - -static void convertByteDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize) { - - for(unsigned int i = 0; i < nBytes;i+=strideOut) { - const GLbyte* byte_data = (const GLbyte *)dataIn; - //filling attrib - for(int j=0;j<attribSize;j++) { - reinterpret_cast<GLshort*>(&static_cast<unsigned char*>(dataOut)[i])[j] = B2S(byte_data[j]); - } - dataIn += strideIn; - } -} - -static void convertByteIndirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,GLsizei count,GLenum indices_type,const GLvoid* indices,unsigned int strideOut,int attribSize) { - for(int i = 0 ;i < count ;i++) { - unsigned short index = indices_type == GL_UNSIGNED_BYTE? ((GLubyte *)indices)[i]: - ((GLushort *)indices)[i]; - const GLbyte* bytes_data = (GLbyte *)(dataIn + index*strideIn); - GLshort* short_data = reinterpret_cast<GLshort*>(static_cast<unsigned char*>(dataOut) + index*strideOut); - - for(int j=0;j<attribSize;j++) { - short_data[j] = B2S(bytes_data[j]); - } - } -} -static void directToBytesRanges(GLint first,GLsizei count,GLESpointer* p,RangeList& list) { - - int attribSize = p->getSize()*4; //4 is the sizeof GLfixed or GLfloat in bytes - int stride = p->getStride()?p->getStride():attribSize; - int start = p->getBufferOffset()+first*attribSize; - if(!p->getStride()) { - list.addRange(Range(start,count*attribSize)); - } else { - for(int i = 0 ;i < count; i++,start+=stride) { - list.addRange(Range(start,attribSize)); - } - } -} - -static void indirectToBytesRanges(const GLvoid* indices,GLenum indices_type,GLsizei count,GLESpointer* p,RangeList& list) { - - int attribSize = p->getSize() * 4; //4 is the sizeof GLfixed or GLfloat in bytes - int stride = p->getStride()?p->getStride():attribSize; - int start = p->getBufferOffset(); - for(int i=0 ; i < count; i++) { - GLushort index = (indices_type == GL_UNSIGNED_SHORT? - static_cast<const GLushort*>(indices)[i]: - static_cast<const GLubyte*>(indices)[i]); - list.addRange(Range(start+index*stride,attribSize)); - - } -} - -int bytesRangesToIndices(RangeList& ranges,GLESpointer* p,GLushort* indices) { - - int attribSize = p->getSize() * 4; //4 is the sizeof GLfixed or GLfloat in bytes - int stride = p->getStride()?p->getStride():attribSize; - int offset = p->getBufferOffset(); - - int n = 0; - for(int i=0;i<ranges.size();i++) { - int startIndex = (ranges[i].getStart() - offset) / stride; - int nElements = ranges[i].getSize()/attribSize; - for(int j=0;j<nElements;j++) { - indices[n++] = startIndex+j; - } - } - return n; -} - -void GLEScontext::convertDirect(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p) { - - GLenum type = p->getType(); - int attribSize = p->getSize(); - unsigned int size = attribSize*count + first; - unsigned int bytes = type == GL_FIXED ? sizeof(GLfixed):sizeof(GLbyte); - cArrs.allocArr(size,type); - int stride = p->getStride()?p->getStride():bytes*attribSize; - const char* data = (const char*)p->getArrayData() + (first*stride); - - if(type == GL_FIXED) { - convertFixedDirectLoop(data,stride,cArrs.getCurrentData(),size*sizeof(GLfloat),attribSize*sizeof(GLfloat),attribSize); - } else if(type == GL_BYTE) { - convertByteDirectLoop(data,stride,cArrs.getCurrentData(),size*sizeof(GLshort),attribSize*sizeof(GLshort),attribSize); - } -} - -void GLEScontext::convertDirectVBO(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p) { - - RangeList ranges; - RangeList conversions; - GLushort* indices = NULL; - int attribSize = p->getSize(); - int stride = p->getStride()?p->getStride():sizeof(GLfixed)*attribSize; - char* data = (char*)p->getBufferData() + (first*stride); - - if(p->bufferNeedConversion()) { - directToBytesRanges(first,count,p,ranges); //converting indices range to buffer bytes ranges by offset - p->getBufferConversions(ranges,conversions); // getting from the buffer the relevant ranges that still needs to be converted - - if(conversions.size()) { // there are some elements to convert - indices = new GLushort[count]; - int nIndices = bytesRangesToIndices(conversions,p,indices); //converting bytes ranges by offset to indices in this array - convertFixedIndirectLoop(data,stride,data,nIndices,GL_UNSIGNED_SHORT,indices,stride,attribSize); - } - } - if(indices) delete[] indices; - cArrs.setArr(data,p->getStride(),GL_FLOAT); -} - -int GLEScontext::findMaxIndex(GLsizei count,GLenum type,const GLvoid* indices) { - //finding max index - int max = 0; - if(type == GL_UNSIGNED_BYTE) { - GLubyte* b_indices =(GLubyte *)indices; - for(int i=0;i<count;i++) { - if(b_indices[i] > max) max = b_indices[i]; - } - } else { - GLushort* us_indices =(GLushort *)indices; - for(int i=0;i<count;i++) { - if(us_indices[i] > max) max = us_indices[i]; - } - } - return max; -} - -void GLEScontext::convertIndirect(GLESConversionArrays& cArrs,GLsizei count,GLenum indices_type,const GLvoid* indices,GLenum array_id,GLESpointer* p) { - GLenum type = p->getType(); - int maxElements = findMaxIndex(count,type,indices) + 1; - - int attribSize = p->getSize(); - int size = attribSize * maxElements; - unsigned int bytes = type == GL_FIXED ? sizeof(GLfixed):sizeof(GLbyte); - cArrs.allocArr(size,type); - int stride = p->getStride()?p->getStride():bytes*attribSize; - - const char* data = (const char*)p->getArrayData(); - if(type == GL_FIXED) { - convertFixedIndirectLoop(data,stride,cArrs.getCurrentData(),count,indices_type,indices,attribSize*sizeof(GLfloat),attribSize); - } else if(type == GL_BYTE){ - convertByteIndirectLoop(data,stride,cArrs.getCurrentData(),count,indices_type,indices,attribSize*sizeof(GLshort),attribSize); - } -} - -void GLEScontext::convertIndirectVBO(GLESConversionArrays& cArrs,GLsizei count,GLenum indices_type,const GLvoid* indices,GLenum array_id,GLESpointer* p) { - RangeList ranges; - RangeList conversions; - GLushort* conversionIndices = NULL; - int attribSize = p->getSize(); - int stride = p->getStride()?p->getStride():sizeof(GLfixed)*attribSize; - char* data = static_cast<char*>(p->getBufferData()); - if(p->bufferNeedConversion()) { - indirectToBytesRanges(indices,indices_type,count,p,ranges); //converting indices range to buffer bytes ranges by offset - p->getBufferConversions(ranges,conversions); // getting from the buffer the relevant ranges that still needs to be converted - if(conversions.size()) { // there are some elements to convert - conversionIndices = new GLushort[count]; - int nIndices = bytesRangesToIndices(conversions,p,conversionIndices); //converting bytes ranges by offset to indices in this array - convertFixedIndirectLoop(data,stride,data,nIndices,GL_UNSIGNED_SHORT,conversionIndices,stride,attribSize); - } - } - if(conversionIndices) delete[] conversionIndices; - cArrs.setArr(data,p->getStride(),GL_FLOAT); -} - - - -void GLEScontext::bindBuffer(GLenum target,GLuint buffer) { - if(target == GL_ARRAY_BUFFER) { - m_arrayBuffer = buffer; - } else { - m_elementBuffer = buffer; - } -} - -void GLEScontext::unbindBuffer(GLuint buffer) { - if(m_arrayBuffer == buffer) - { - m_arrayBuffer = 0; - } - if(m_elementBuffer == buffer) - { - m_elementBuffer = 0; - } -} - -//checks if any buffer is binded to target -bool GLEScontext::isBindedBuffer(GLenum target) { - if(target == GL_ARRAY_BUFFER) { - return m_arrayBuffer != 0; - } else { - return m_elementBuffer != 0; - } -} - -GLuint GLEScontext::getBuffer(GLenum target) { - return target == GL_ARRAY_BUFFER ? m_arrayBuffer:m_elementBuffer; -} - -GLvoid* GLEScontext::getBindedBuffer(GLenum target) { - GLuint bufferName = getBuffer(target); - if(!bufferName) return NULL; - - GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr()); - return vbo->getData(); -} - -void GLEScontext::getBufferSize(GLenum target,GLint* param) { - GLuint bufferName = getBuffer(target); - GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr()); - *param = vbo->getSize(); -} - -void GLEScontext::getBufferUsage(GLenum target,GLint* param) { - GLuint bufferName = getBuffer(target); - GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr()); - *param = vbo->getUsage(); -} - -bool GLEScontext::setBufferData(GLenum target,GLsizeiptr size,const GLvoid* data,GLenum usage) { - GLuint bufferName = getBuffer(target); - if(!bufferName) return false; - GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr()); - return vbo->setBuffer(size,usage,data); -} - -bool GLEScontext::setBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const GLvoid* data) { - - GLuint bufferName = getBuffer(target); - if(!bufferName) return false; - GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr()); - return vbo->setSubBuffer(offset,size,data); -} - -const char * GLEScontext::getExtensionString() { - const char * ret; - s_lock.lock(); - if (s_glExtensions) - ret = s_glExtensions->c_str(); - else - ret=""; - s_lock.unlock(); - return ret; -} - -const char * GLEScontext::getVendorString() const { - return s_glVendor.c_str(); -} - -const char * GLEScontext::getRendererString() const { - return s_glRenderer.c_str(); -} - -const char * GLEScontext::getVersionString() const { - return s_glVersion.c_str(); -} - -void GLEScontext::getGlobalLock() { - s_lock.lock(); -} - -void GLEScontext::releaseGlobalLock() { - s_lock.unlock(); -} - - -void GLEScontext::initCapsLocked(const GLubyte * extensionString) -{ - const char* cstring = (const char*)extensionString; - - s_glDispatch.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS,&s_glSupport.maxVertexAttribs); - s_glDispatch.glGetIntegerv(GL_MAX_CLIP_PLANES,&s_glSupport.maxClipPlane); - s_glDispatch.glGetIntegerv(GL_MAX_LIGHTS,&s_glSupport.maxLights); - s_glDispatch.glGetIntegerv(GL_MAX_TEXTURE_SIZE,&s_glSupport.maxTexSize); - s_glDispatch.glGetIntegerv(GL_MAX_TEXTURE_UNITS,&s_glSupport.maxTexUnits); - s_glDispatch.glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&s_glSupport.maxTexImageUnits); - const GLubyte* glslVersion = s_glDispatch.glGetString(GL_SHADING_LANGUAGE_VERSION); - s_glSupport.glslVersion = Version((const char*)(glslVersion)); - - if (strstr(cstring,"GL_EXT_bgra ")!=NULL) - s_glSupport.GL_EXT_TEXTURE_FORMAT_BGRA8888 = true; - - if (strstr(cstring,"GL_EXT_framebuffer_object ")!=NULL) - s_glSupport.GL_EXT_FRAMEBUFFER_OBJECT = true; - - if (strstr(cstring,"GL_ARB_vertex_blend ")!=NULL) - s_glSupport.GL_ARB_VERTEX_BLEND = true; - - if (strstr(cstring,"GL_ARB_matrix_palette ")!=NULL) - s_glSupport.GL_ARB_MATRIX_PALETTE = true; - - if (strstr(cstring,"GL_EXT_packed_depth_stencil ")!=NULL ) - s_glSupport.GL_EXT_PACKED_DEPTH_STENCIL = true; - - if (strstr(cstring,"GL_OES_read_format ")!=NULL) - s_glSupport.GL_OES_READ_FORMAT = true; - - if (strstr(cstring,"GL_ARB_half_float_pixel ")!=NULL) - s_glSupport.GL_ARB_HALF_FLOAT_PIXEL = true; - - if (strstr(cstring,"GL_NV_half_float ")!=NULL) - s_glSupport.GL_NV_HALF_FLOAT = true; - - if (strstr(cstring,"GL_ARB_half_float_vertex ")!=NULL) - s_glSupport.GL_ARB_HALF_FLOAT_VERTEX = true; - - if (strstr(cstring,"GL_SGIS_generate_mipmap ")!=NULL) - s_glSupport.GL_SGIS_GENERATE_MIPMAP = true; - - if (strstr(cstring,"GL_ARB_ES2_compatibility ")!=NULL) - s_glSupport.GL_ARB_ES2_COMPATIBILITY = true; - - if (strstr(cstring,"GL_OES_standard_derivatives ")!=NULL) - s_glSupport.GL_OES_STANDARD_DERIVATIVES = true; - -} - -void GLEScontext::buildStrings(const char* baseVendor, - const char* baseRenderer, const char* baseVersion, const char* version) -{ - static const char VENDOR[] = {"Google ("}; - static const char RENDERER[] = {"Android Emulator OpenGL ES Translator ("}; - const size_t VENDOR_LEN = sizeof(VENDOR) - 1; - const size_t RENDERER_LEN = sizeof(RENDERER) - 1; - - size_t baseVendorLen = strlen(baseVendor); - s_glVendor.clear(); - s_glVendor.reserve(baseVendorLen + VENDOR_LEN + 1); - s_glVendor.append(VENDOR, VENDOR_LEN); - s_glVendor.append(baseVendor, baseVendorLen); - s_glVendor.append(")", 1); - - size_t baseRendererLen = strlen(baseRenderer); - s_glRenderer.clear(); - s_glRenderer.reserve(baseRendererLen + RENDERER_LEN + 1); - s_glRenderer.append(RENDERER, RENDERER_LEN); - s_glRenderer.append(baseRenderer, baseRendererLen); - s_glRenderer.append(")", 1); - - size_t baseVersionLen = strlen(baseVersion); - size_t versionLen = strlen(version); - s_glVersion.clear(); - s_glVersion.reserve(baseVersionLen + versionLen + 3); - s_glVersion.append(version, versionLen); - s_glVersion.append(" (", 2); - s_glVersion.append(baseVersion, baseVersionLen); - s_glVersion.append(")", 1); -} - -bool GLEScontext::isTextureUnitEnabled(GLenum unit) { - for (int i=0;i<NUM_TEXTURE_TARGETS;++i) { - if (m_texState[unit-GL_TEXTURE0][i].enabled) - return true; - } - return false; -} - -bool GLEScontext::glGetBooleanv(GLenum pname, GLboolean *params) -{ - GLint iParam; - - if(glGetIntegerv(pname, &iParam)) - { - *params = (iParam != 0); - return true; - } - - return false; -} - -bool GLEScontext::glGetFixedv(GLenum pname, GLfixed *params) -{ - bool result = false; - GLint numParams = 1; - - GLint* iParams = new GLint[numParams]; - if (numParams>0 && glGetIntegerv(pname,iParams)) { - while(numParams >= 0) - { - params[numParams] = I2X(iParams[numParams]); - numParams--; - } - result = true; - } - delete [] iParams; - - return result; -} - -bool GLEScontext::glGetFloatv(GLenum pname, GLfloat *params) -{ - bool result = false; - GLint numParams = 1; - - GLint* iParams = new GLint[numParams]; - if (numParams>0 && glGetIntegerv(pname,iParams)) { - while(numParams >= 0) - { - params[numParams] = (GLfloat)iParams[numParams]; - numParams--; - } - result = true; - } - delete [] iParams; - - return result; -} - -bool GLEScontext::glGetIntegerv(GLenum pname, GLint *params) -{ - switch(pname) - { - case GL_ARRAY_BUFFER_BINDING: - *params = m_arrayBuffer; - break; - - case GL_ELEMENT_ARRAY_BUFFER_BINDING: - *params = m_elementBuffer; - break; - - case GL_TEXTURE_BINDING_CUBE_MAP: - *params = m_texState[m_activeTexture][TEXTURE_CUBE_MAP].texture; - break; - - case GL_TEXTURE_BINDING_2D: - *params = m_texState[m_activeTexture][TEXTURE_2D].texture; - break; - - case GL_ACTIVE_TEXTURE: - *params = m_activeTexture+GL_TEXTURE0; - break; - - case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: - *params = GL_UNSIGNED_BYTE; - break; - - case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: - *params = GL_RGBA; - break; - - case GL_MAX_TEXTURE_SIZE: - *params = getMaxTexSize(); - break; - default: - return false; - } - - return true; -} - -TextureTarget GLEScontext::GLTextureTargetToLocal(GLenum target) { - TextureTarget value=TEXTURE_2D; - switch (target) { - case GL_TEXTURE_CUBE_MAP: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - value = TEXTURE_CUBE_MAP; - break; - case GL_TEXTURE_2D: - value = TEXTURE_2D; - break; - } - return value; -} - -unsigned int GLEScontext::getBindedTexture(GLenum target) { - TextureTarget pos = GLTextureTargetToLocal(target); - return m_texState[m_activeTexture][pos].texture; -} - -unsigned int GLEScontext::getBindedTexture(GLenum unit, GLenum target) { - TextureTarget pos = GLTextureTargetToLocal(target); - return m_texState[unit-GL_TEXTURE0][pos].texture; -} - -void GLEScontext::setBindedTexture(GLenum target, unsigned int tex) { - TextureTarget pos = GLTextureTargetToLocal(target); - m_texState[m_activeTexture][pos].texture = tex; -} - -void GLEScontext::setTextureEnabled(GLenum target, GLenum enable) { - TextureTarget pos = GLTextureTargetToLocal(target); - m_texState[m_activeTexture][pos].enabled = enable; -} - -#define INTERNAL_NAME(x) (x +0x100000000ll); - -ObjectLocalName GLEScontext::getDefaultTextureName(GLenum target) { - ObjectLocalName name = 0; - switch (GLTextureTargetToLocal(target)) { - case TEXTURE_2D: - name = INTERNAL_NAME(0); - break; - case TEXTURE_CUBE_MAP: - name = INTERNAL_NAME(1); - break; - default: - name = 0; - break; - } - return name; -} - -void GLEScontext::drawValidate(void) -{ - if(m_framebuffer == 0) - return; - - ObjectDataPtr fbObj = m_shareGroup->getObjectData(FRAMEBUFFER,m_framebuffer); - if (fbObj.Ptr() == NULL) - return; - - FramebufferData *fbData = (FramebufferData *)fbObj.Ptr(); - - fbData->validate(this); -} diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp deleted file mode 100644 index 372257e..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -#include <GLcommon/GLESpointer.h> -#include <stdlib.h> - -GLESpointer::GLESpointer():m_size(4), - m_type(GL_FLOAT), - m_stride(0), - m_enabled(false), - m_normalize(false), - m_data(NULL), - m_buffer(NULL), - m_bufferName(0), - m_buffOffset(0), - m_isVBO(false){}; - - -GLenum GLESpointer:: getType() const { - return m_type; -} - -GLint GLESpointer::getSize() const { - return m_size; -} - -GLsizei GLESpointer::getStride() const { - return m_stride; -} - -const GLvoid* GLESpointer::getArrayData() const { - return m_data; -} - -GLvoid* GLESpointer::getBufferData() const { - return m_buffer ? static_cast<unsigned char*>(m_buffer->getData()) + m_buffOffset : NULL; -} - -const GLvoid* GLESpointer::getData() const{ - return m_isVBO ? getBufferData():getArrayData(); -} - -void GLESpointer::redirectPointerData(){ - m_data = getBufferData(); -} - -GLuint GLESpointer::getBufferName() const { - return m_bufferName; -} - -unsigned int GLESpointer::getBufferOffset() const { - - return m_buffOffset; -} - -bool GLESpointer::isEnable() const { - return m_enabled; -} - -bool GLESpointer::isNormalize() const { - return m_normalize; -} - -bool GLESpointer::isVBO() const { - return m_isVBO; -} - -void GLESpointer::enable(bool b) { - m_enabled = b; -} - -void GLESpointer::setArray(GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) { - m_size = size; - m_type = type; - m_stride = stride; - m_data = data; - m_buffer = NULL; - m_bufferName = 0; - m_normalize = normalize; - m_isVBO = false; -} - -void GLESpointer::setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,GLuint bufferName,int offset,bool normalize) { - m_size = size; - m_type = type; - m_stride = stride; - m_data = NULL; - m_buffer = buf; - m_bufferName = bufferName; - m_buffOffset = offset; - m_normalize = normalize; - m_isVBO = true; -} - -void GLESpointer::getBufferConversions(const RangeList& rl,RangeList& rlOut) { - m_buffer->getConversions(rl,rlOut); -} diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp deleted file mode 100644 index 8e35978..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* -* 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 <GLcommon/GLESvalidate.h> -#include <GLES/gl.h> -#include <GLES/glext.h> -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> -#include <OpenglCodecCommon/ErrorLog.h> - - -bool GLESvalidate::textureEnum(GLenum e,unsigned int maxTex) { - return e >= GL_TEXTURE0 && e <= (GL_TEXTURE0 + maxTex); -} - -bool GLESvalidate::pixelType(GLEScontext * ctx, GLenum type) { - if ((ctx && ctx->getCaps()->GL_EXT_PACKED_DEPTH_STENCIL) && - (type == GL_UNSIGNED_INT_24_8_OES) ) - return true; - - if (ctx && - (ctx->getCaps()->GL_ARB_HALF_FLOAT_PIXEL || ctx->getCaps()->GL_NV_HALF_FLOAT) && - (type == GL_HALF_FLOAT_OES)) - return true; - - switch(type) { - case GL_UNSIGNED_BYTE: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_FLOAT: - return true; - } - return false; -} - -bool GLESvalidate::pixelOp(GLenum format,GLenum type) { - switch(type) { - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_5_5_5_1: - return format == GL_RGBA; - case GL_UNSIGNED_SHORT_5_6_5: - return format == GL_RGB; - } - return true; -} - -bool GLESvalidate::pixelFrmt(GLEScontext* ctx ,GLenum format) { - if (ctx && ctx->getCaps()->GL_EXT_TEXTURE_FORMAT_BGRA8888 && format == GL_BGRA_EXT) - return true; - if (ctx && ctx->getCaps()->GL_EXT_PACKED_DEPTH_STENCIL && format == GL_DEPTH_STENCIL_OES) - return true; - switch(format) { - case GL_ALPHA: - case GL_RGB: - case GL_RGBA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - return true; - } - return false; -} - -bool GLESvalidate::bufferTarget(GLenum target) { - return target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER; -} - -bool GLESvalidate::bufferUsage(GLenum usage) { - switch(usage) { - case GL_STREAM_DRAW: - case GL_STATIC_DRAW: - case GL_DYNAMIC_DRAW: - return true; - } - return false; -} - -bool GLESvalidate::bufferParam(GLenum param) { - return (param == GL_BUFFER_SIZE) || (param == GL_BUFFER_USAGE); -} - -bool GLESvalidate::drawMode(GLenum mode) { - switch(mode) { - case GL_POINTS: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - case GL_LINES: - case GL_TRIANGLE_STRIP: - case GL_TRIANGLE_FAN: - case GL_TRIANGLES: - return true; - } - return false; -} - -bool GLESvalidate::drawType(GLenum mode) { - return mode == GL_UNSIGNED_BYTE || - mode == GL_UNSIGNED_SHORT || - mode == GL_UNSIGNED_INT; -} - -bool GLESvalidate::textureTarget(GLenum target) { - return target==GL_TEXTURE_2D || target==GL_TEXTURE_CUBE_MAP; -} - -bool GLESvalidate::textureTargetLimited(GLenum target) { - return target==GL_TEXTURE_2D; -} - -bool GLESvalidate::textureTargetEx(GLenum target) { - switch(target) { - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: - case GL_TEXTURE_2D: - return true; - } - return false; -} - -bool GLESvalidate::blendEquationMode(GLenum mode){ - return mode == GL_FUNC_ADD || - mode == GL_FUNC_SUBTRACT || - mode == GL_FUNC_REVERSE_SUBTRACT; -} - -bool GLESvalidate::framebufferTarget(GLenum target){ - return target == GL_FRAMEBUFFER; -} - -bool GLESvalidate::framebufferAttachment(GLenum attachment){ - switch(attachment){ - case GL_COLOR_ATTACHMENT0: - case GL_DEPTH_ATTACHMENT: - case GL_STENCIL_ATTACHMENT: - return true; - } - return false; -} - -bool GLESvalidate::framebufferAttachmentParams(GLenum pname){ - switch(pname){ - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: - return true; - } - return false; -} - -bool GLESvalidate::renderbufferTarget(GLenum target){ - return target == GL_RENDERBUFFER; -} - -bool GLESvalidate::renderbufferParams(GLenum pname){ - switch(pname){ - case GL_RENDERBUFFER_WIDTH: - case GL_RENDERBUFFER_HEIGHT: - case GL_RENDERBUFFER_INTERNAL_FORMAT: - case GL_RENDERBUFFER_RED_SIZE: - case GL_RENDERBUFFER_GREEN_SIZE: - case GL_RENDERBUFFER_BLUE_SIZE: - case GL_RENDERBUFFER_ALPHA_SIZE: - case GL_RENDERBUFFER_DEPTH_SIZE: - case GL_RENDERBUFFER_STENCIL_SIZE: - return true; - } - return false; -} - -bool GLESvalidate::texImgDim(GLsizei width,GLsizei height,int maxTexSize) { - - if( width < 0 || height < 0 || width > maxTexSize || height > maxTexSize) - return false; - return isPowerOf2(width) && isPowerOf2(height); -} - diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLutils.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLutils.cpp deleted file mode 100644 index 46e292c..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/GLutils.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -* 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. -*/ -#include <GLcommon/GLutils.h> - -bool isPowerOf2(int num) { - return (num & (num -1)) == 0; -} diff --git a/emulator/opengl/host/libs/Translator/GLcommon/PaletteTexture.cpp b/emulator/opengl/host/libs/Translator/GLcommon/PaletteTexture.cpp deleted file mode 100644 index c99ed07..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/PaletteTexture.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* -* 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. -*/ -#include "GLcommon/PaletteTexture.h" -#include <stdio.h> - - - -struct Color -{ - Color(unsigned char r, unsigned char g,unsigned char b, unsigned char a):red(r),green(g),blue(b),alpha(a){}; - unsigned char red; - unsigned char green; - unsigned char blue; - unsigned char alpha; -}; - -void getPaletteInfo(GLenum internalFormat,unsigned int& indexSizeBits,unsigned int& colorSizeBytes,GLenum& colorFrmt) { - - colorFrmt = GL_RGB; - switch(internalFormat) - { - case GL_PALETTE4_RGB8_OES: - indexSizeBits = 4; - colorSizeBytes = 3; - break; - - case GL_PALETTE4_RGBA8_OES: - indexSizeBits = 4; - colorSizeBytes = 4; - colorFrmt = GL_RGBA; - break; - - case GL_PALETTE4_RGBA4_OES: - case GL_PALETTE4_RGB5_A1_OES: - colorFrmt = GL_RGBA; - /* fall-through */ - case GL_PALETTE4_R5_G6_B5_OES: - indexSizeBits = 4; - colorSizeBytes = 2; - break; - - case GL_PALETTE8_RGB8_OES: - indexSizeBits = 8; - colorSizeBytes = 3; - break; - - case GL_PALETTE8_RGBA8_OES: - indexSizeBits = 8; - colorSizeBytes = 4; - colorFrmt = GL_RGBA; - break; - - case GL_PALETTE8_RGBA4_OES: - case GL_PALETTE8_RGB5_A1_OES: - colorFrmt = GL_RGBA; - /* fall-through */ - case GL_PALETTE8_R5_G6_B5_OES: - indexSizeBits = 8; - colorSizeBytes = 2; - break; - } -} - - -Color paletteColor(const unsigned char* pallete,unsigned int index,GLenum format) -{ - short s; - switch(format) { - //RGB - case GL_PALETTE4_RGB8_OES: - case GL_PALETTE8_RGB8_OES: - return Color(pallete[index],pallete[index+1],pallete[index+2],0); - case GL_PALETTE8_R5_G6_B5_OES: - case GL_PALETTE4_R5_G6_B5_OES: - s = *((short *)(pallete+index)); - return Color((s >> 11)*255/31,((s >> 5) & 0x3f)*255/63 ,(s & 0x1f)*255/31,0); - - //RGBA - case GL_PALETTE4_RGBA8_OES: - case GL_PALETTE8_RGBA8_OES: - return Color(pallete[index],pallete[index+1],pallete[index+2],pallete[index+3]); - case GL_PALETTE4_RGBA4_OES: - case GL_PALETTE8_RGBA4_OES: - s = *((short *)(pallete+index)); - return Color(((s >> 12) & 0xf)*255/15,((s >> 8) & 0xf)*255/15,((s >> 4) & 0xf)*255/15 ,(s & 0xf)*255/15); - case GL_PALETTE4_RGB5_A1_OES: - case GL_PALETTE8_RGB5_A1_OES: - s = *((short *)(pallete+index)); - return Color(((s >> 11) & 0x1f)*255/31,((s >> 6) & 0x1f)*255/31,((s >> 1) & 0x1f)*255/31 ,(s & 0x1) * 255); - default: - return Color(255,255,255,255); - } -} - -unsigned char* uncompressTexture(GLenum internalformat,GLenum& formatOut,GLsizei width,GLsizei height,GLsizei imageSize, const GLvoid* data,GLint level) { - - unsigned int indexSizeBits; //the size of the color index in the pallete - unsigned int colorSizeBytes; //the size of each color cell in the pallete - - getPaletteInfo(internalformat,indexSizeBits,colorSizeBytes,formatOut); - if(!data) - { - return NULL; - } - - const unsigned char* palette = static_cast<const unsigned char *>(data); - - //the pallete positioned in the begininng of the data - // so we jump over it to get to the colos indices in the palette - - int nColors = 2 << (indexSizeBits -1); //2^indexSizeBits - int paletteSizeBytes = nColors*colorSizeBytes; - const unsigned char* imageIndices = palette + paletteSizeBytes; - - //jumping to the the correct mipmap level - for(int i=0;i<level;i++) { - imageIndices+= (width*height*indexSizeBits)/8; - width = width >> 1; - height = height >> 1; - } - - int colorSizeOut = (formatOut == GL_RGB? 3:4); - int nPixels = width*height; - unsigned char* pixelsOut = new unsigned char[nPixels*colorSizeOut]; - if(!pixelsOut) return NULL; - - int leftBytes = ((palette + imageSize) /* the end of data pointer*/ - - imageIndices); - int leftPixels = (leftBytes * 8 )/indexSizeBits; - - int maxIndices = (leftPixels < nPixels) ? leftPixels:nPixels; - - //filling the pixels array - for(int i =0 ; i < maxIndices ; i++) { - int paletteIndex = 0; - int indexOut = i*colorSizeOut; - if(indexSizeBits == 4) { - paletteIndex = (i%2) == 0 ? - imageIndices[i/2] >> 4: //upper bits - imageIndices[i/2] & 0xf; //lower bits - } else { - paletteIndex = imageIndices[i]; - } - - paletteIndex*=colorSizeBytes; - Color c = paletteColor(palette,paletteIndex,internalformat); - - pixelsOut[indexOut] = c.red; - pixelsOut[indexOut+1] = c.green; - pixelsOut[indexOut+2] = c.blue; - if(formatOut == GL_RGBA) { - pixelsOut[indexOut+3] = c.alpha; - } - } - return pixelsOut; -} - diff --git a/emulator/opengl/host/libs/Translator/GLcommon/RangeManip.cpp b/emulator/opengl/host/libs/Translator/GLcommon/RangeManip.cpp deleted file mode 100644 index 2d6f119..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/RangeManip.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* -* 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. -*/ -#include <GLcommon/RangeManip.h> - - -bool Range::rangeIntersection(const Range& r,Range& rOut) const { - if(m_start > r.getEnd() || r.getStart() > m_end) return false; - int max_start = (m_start > r.getStart())? m_start:r.getStart(); - int min_end = (m_end < r.getEnd())?m_end:r.getEnd(); - int size = min_end - max_start; - if(size) { - rOut.setRange(max_start,min_end-max_start); - return true; - } - return false; -} - -bool Range::rangeUnion(const Range& r,Range& rOut) const { - if(m_start > r.getEnd() || r.getStart() > m_end) return false; - int min_start = (m_start < r.getStart())?m_start:r.getStart(); - int max_end = (m_end > r.getEnd())?m_end:r.getEnd(); - int size = max_end - min_start; - if(size) { - rOut.setRange(min_start,max_end-min_start); - return true; - } - return false; -} - -void RangeList::addRange(const Range& r) { - if(r.getSize()) - list.push_back(r); -} - -void RangeList::addRanges(const RangeList& rl) { - for(int i =0; i< rl.size();i++) { - addRange(rl.list[i]); - } -} - -void RangeList::delRanges(const RangeList& rl,RangeList& deleted) { - for(int i =0; i< rl.size();i++) { - delRange(rl.list[i],deleted); - } -} - -bool RangeList::empty() const{ - return list.empty(); -} - -int RangeList::size() const{ - return list.size(); -} -void RangeList::clear() { - return list.clear(); -} - -void RangeList::erase(unsigned int i) { - if(i > list.size()) return; - list.erase(list.begin() +i); -} - -void RangeList::delRange(const Range& r,RangeList& deleted) { - if(r.getSize() == 0) return; - - Range intersection; - Range temp; - // compare new rect to each and any of the rects on the list - for (int i=0;i<(int)list.size();i++) { // i must be signed for i-- below - // if there is intersection - if (r.rangeIntersection(list[i],intersection)) { - Range old=list[i]; - // remove old as it is about to be split - erase(i); - i--; - if (intersection!=old) { // otherwise split: - //intersection on right side - if(old.getStart() != intersection.getStart()) { - list.insert(list.begin(),Range(old.getStart(),intersection.getStart() - old.getStart())); - } - - //intersection on left side - if(old.getEnd() != intersection.getEnd()) { - list.insert(list.begin(),Range(intersection.getEnd(),old.getEnd() - intersection.getEnd())); - } - } - deleted.addRange(intersection); - } - } -} - -void RangeList::merge() { - if(list.empty()) return; - - Range temp; - bool changed; - - do { // re-run if changed in last run - changed=0; - // run for each combinations of two rects in the list - for (int i=0;i<(((int)list.size())-1) && !changed ;i++) - { - for (int j=i+1;j<(int)list.size() && !changed ;j++) - { - if (list[i].rangeUnion(list[j],temp)) { - // are them exactly one on left of the other - list[i] = temp; - erase(j); - changed=1; - } - } - } - } while (changed); -} diff --git a/emulator/opengl/host/libs/Translator/GLcommon/TextureUtils.cpp b/emulator/opengl/host/libs/Translator/GLcommon/TextureUtils.cpp deleted file mode 100644 index 81152f6..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/TextureUtils.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* -* 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. -*/ -#include <GLcommon/TextureUtils.h> -#include <GLcommon/GLESmacros.h> -#include <GLcommon/GLDispatch.h> -#include <GLcommon/GLESvalidate.h> -#include <stdio.h> -#include <cmath> - -int getCompressedFormats(int* formats){ - if(formats){ - //Palette - formats[0] = GL_PALETTE4_RGBA8_OES; - formats[1] = GL_PALETTE4_RGBA4_OES; - formats[2] = GL_PALETTE8_RGBA8_OES; - formats[3] = GL_PALETTE8_RGBA4_OES; - formats[4] = GL_PALETTE4_RGB8_OES; - formats[5] = GL_PALETTE8_RGB8_OES; - formats[6] = GL_PALETTE4_RGB5_A1_OES; - formats[7] = GL_PALETTE8_RGB5_A1_OES; - formats[8] = GL_PALETTE4_R5_G6_B5_OES; - formats[9] = GL_PALETTE8_R5_G6_B5_OES; - //ETC - formats[MAX_SUPPORTED_PALETTE] = GL_ETC1_RGB8_OES; - } - return MAX_SUPPORTED_PALETTE + MAX_ETC_SUPPORTED; -} - -void doCompressedTexImage2D(GLEScontext * ctx, GLenum target, GLint level, - GLenum internalformat, GLsizei width, - GLsizei height, GLint border, - GLsizei imageSize, const GLvoid* data, void * funcPtr) -{ - /* XXX: This is just a hack to fix the resolve of glTexImage2D problem - It will be removed when we'll no longer link against ligGL */ - typedef void (GLAPIENTRY *glTexImage2DPtr_t ) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); - glTexImage2DPtr_t glTexImage2DPtr; - glTexImage2DPtr = (glTexImage2DPtr_t)funcPtr; - - switch (internalformat) { - case GL_ETC1_RGB8_OES: - { - GLint format = GL_RGB; - GLint type = GL_UNSIGNED_BYTE; - - GLsizei compressedSize = etc1_get_encoded_data_size(width, height); - SET_ERROR_IF((compressedSize > imageSize), GL_INVALID_VALUE); - - const int32_t align = ctx->getUnpackAlignment()-1; - const int32_t bpr = ((width * 3) + align) & ~align; - const size_t size = bpr * height; - - etc1_byte* pOut = new etc1_byte[size]; - int res = etc1_decode_image((const etc1_byte*)data, pOut, width, height, 3, bpr); - SET_ERROR_IF(res!=0, GL_INVALID_VALUE); - glTexImage2DPtr(target,level,format,width,height,border,format,type,pOut); - delete [] pOut; - } - break; - - case GL_PALETTE4_RGB8_OES: - case GL_PALETTE4_RGBA8_OES: - case GL_PALETTE4_R5_G6_B5_OES: - case GL_PALETTE4_RGBA4_OES: - case GL_PALETTE4_RGB5_A1_OES: - case GL_PALETTE8_RGB8_OES: - case GL_PALETTE8_RGBA8_OES: - case GL_PALETTE8_R5_G6_B5_OES: - case GL_PALETTE8_RGBA4_OES: - case GL_PALETTE8_RGB5_A1_OES: - { - SET_ERROR_IF(level > log2(ctx->getMaxTexSize()) || - border !=0 || level > 0 || - !GLESvalidate::texImgDim(width,height,ctx->getMaxTexSize()+2),GL_INVALID_VALUE) - - int nMipmaps = -level + 1; - GLsizei tmpWidth = width; - GLsizei tmpHeight = height; - - for(int i = 0; i < nMipmaps ; i++) - { - GLenum uncompressedFrmt; - unsigned char* uncompressed = uncompressTexture(internalformat,uncompressedFrmt,width,height,imageSize,data,i); - glTexImage2DPtr(target,i,uncompressedFrmt,tmpWidth,tmpHeight,border,uncompressedFrmt,GL_UNSIGNED_BYTE,uncompressed); - tmpWidth/=2; - tmpHeight/=2; - delete[] uncompressed; - } - } - break; - - default: - SET_ERROR_IF(1, GL_INVALID_ENUM); - break; - } -} diff --git a/emulator/opengl/host/libs/Translator/GLcommon/etc1.cpp b/emulator/opengl/host/libs/Translator/GLcommon/etc1.cpp deleted file mode 100644 index 97d1085..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/etc1.cpp +++ /dev/null @@ -1,670 +0,0 @@ -// 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. - -#include <ETC1/etc1.h> - -#include <string.h> - -/* From http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt - - The number of bits that represent a 4x4 texel block is 64 bits if - <internalformat> is given by ETC1_RGB8_OES. - - The data for a block is a number of bytes, - - {q0, q1, q2, q3, q4, q5, q6, q7} - - where byte q0 is located at the lowest memory address and q7 at - the highest. The 64 bits specifying the block is then represented - by the following 64 bit integer: - - int64bit = 256*(256*(256*(256*(256*(256*(256*q0+q1)+q2)+q3)+q4)+q5)+q6)+q7; - - ETC1_RGB8_OES: - - a) bit layout in bits 63 through 32 if diffbit = 0 - - 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 - ----------------------------------------------- - | base col1 | base col2 | base col1 | base col2 | - | R1 (4bits)| R2 (4bits)| G1 (4bits)| G2 (4bits)| - ----------------------------------------------- - - 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 - --------------------------------------------------- - | base col1 | base col2 | table | table |diff|flip| - | B1 (4bits)| B2 (4bits)| cw 1 | cw 2 |bit |bit | - --------------------------------------------------- - - - b) bit layout in bits 63 through 32 if diffbit = 1 - - 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 - ----------------------------------------------- - | base col1 | dcol 2 | base col1 | dcol 2 | - | R1' (5 bits) | dR2 | G1' (5 bits) | dG2 | - ----------------------------------------------- - - 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 - --------------------------------------------------- - | base col 1 | dcol 2 | table | table |diff|flip| - | B1' (5 bits) | dB2 | cw 1 | cw 2 |bit |bit | - --------------------------------------------------- - - - c) bit layout in bits 31 through 0 (in both cases) - - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 - ----------------------------------------------- - | most significant pixel index bits | - | p| o| n| m| l| k| j| i| h| g| f| e| d| c| b| a| - ----------------------------------------------- - - 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - -------------------------------------------------- - | least significant pixel index bits | - | p| o| n| m| l| k| j| i| h| g| f| e| d| c | b | a | - -------------------------------------------------- - - - Add table 3.17.2: Intensity modifier sets for ETC1 compressed textures: - - table codeword modifier table - ------------------ ---------------------- - 0 -8 -2 2 8 - 1 -17 -5 5 17 - 2 -29 -9 9 29 - 3 -42 -13 13 42 - 4 -60 -18 18 60 - 5 -80 -24 24 80 - 6 -106 -33 33 106 - 7 -183 -47 47 183 - - - Add table 3.17.3 Mapping from pixel index values to modifier values for - ETC1 compressed textures: - - pixel index value - --------------- - msb lsb resulting modifier value - ----- ----- ------------------------- - 1 1 -b (large negative value) - 1 0 -a (small negative value) - 0 0 a (small positive value) - 0 1 b (large positive value) - - - */ - -static const int kModifierTable[] = { -/* 0 */2, 8, -2, -8, -/* 1 */5, 17, -5, -17, -/* 2 */9, 29, -9, -29, -/* 3 */13, 42, -13, -42, -/* 4 */18, 60, -18, -60, -/* 5 */24, 80, -24, -80, -/* 6 */33, 106, -33, -106, -/* 7 */47, 183, -47, -183 }; - -static const int kLookup[8] = { 0, 1, 2, 3, -4, -3, -2, -1 }; - -static inline etc1_byte clamp(int x) { - return (etc1_byte) (x >= 0 ? (x < 255 ? x : 255) : 0); -} - -static -inline int convert4To8(int b) { - int c = b & 0xf; - return (c << 4) | c; -} - -static -inline int convert5To8(int b) { - int c = b & 0x1f; - return (c << 3) | (c >> 2); -} - -static -inline int convert6To8(int b) { - int c = b & 0x3f; - return (c << 2) | (c >> 4); -} - -static -inline int divideBy255(int d) { - return (d + 128 + (d >> 8)) >> 8; -} - -static -inline int convert8To4(int b) { - int c = b & 0xff; - return divideBy255(c * 15); -} - -static -inline int convert8To5(int b) { - int c = b & 0xff; - return divideBy255(c * 31); -} - -static -inline int convertDiff(int base, int diff) { - return convert5To8((0x1f & base) + kLookup[0x7 & diff]); -} - -static -void decode_subblock(etc1_byte* pOut, int r, int g, int b, const int* table, - etc1_uint32 low, bool second, bool flipped) { - int baseX = 0; - int baseY = 0; - if (second) { - if (flipped) { - baseY = 2; - } else { - baseX = 2; - } - } - for (int i = 0; i < 8; i++) { - int x, y; - if (flipped) { - x = baseX + (i >> 1); - y = baseY + (i & 1); - } else { - x = baseX + (i >> 2); - y = baseY + (i & 3); - } - int k = y + (x * 4); - int offset = ((low >> k) & 1) | ((low >> (k + 15)) & 2); - int delta = table[offset]; - etc1_byte* q = pOut + 3 * (x + 4 * y); - *q++ = clamp(r + delta); - *q++ = clamp(g + delta); - *q++ = clamp(b + delta); - } -} - -// Input is an ETC1 compressed version of the data. -// Output is a 4 x 4 square of 3-byte pixels in form R, G, B - -void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut) { - etc1_uint32 high = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; - etc1_uint32 low = (pIn[4] << 24) | (pIn[5] << 16) | (pIn[6] << 8) | pIn[7]; - int r1, r2, g1, g2, b1, b2; - if (high & 2) { - // differential - int rBase = high >> 27; - int gBase = high >> 19; - int bBase = high >> 11; - r1 = convert5To8(rBase); - r2 = convertDiff(rBase, high >> 24); - g1 = convert5To8(gBase); - g2 = convertDiff(gBase, high >> 16); - b1 = convert5To8(bBase); - b2 = convertDiff(bBase, high >> 8); - } else { - // not differential - r1 = convert4To8(high >> 28); - r2 = convert4To8(high >> 24); - g1 = convert4To8(high >> 20); - g2 = convert4To8(high >> 16); - b1 = convert4To8(high >> 12); - b2 = convert4To8(high >> 8); - } - int tableIndexA = 7 & (high >> 5); - int tableIndexB = 7 & (high >> 2); - const int* tableA = kModifierTable + tableIndexA * 4; - const int* tableB = kModifierTable + tableIndexB * 4; - bool flipped = (high & 1) != 0; - decode_subblock(pOut, r1, g1, b1, tableA, low, false, flipped); - decode_subblock(pOut, r2, g2, b2, tableB, low, true, flipped); -} - -typedef struct { - etc1_uint32 high; - etc1_uint32 low; - etc1_uint32 score; // Lower is more accurate -} etc_compressed; - -static -inline void take_best(etc_compressed* a, const etc_compressed* b) { - if (a->score > b->score) { - *a = *b; - } -} - -static -void etc_average_colors_subblock(const etc1_byte* pIn, etc1_uint32 inMask, - etc1_byte* pColors, bool flipped, bool second) { - int r = 0; - int g = 0; - int b = 0; - - if (flipped) { - int by = 0; - if (second) { - by = 2; - } - for (int y = 0; y < 2; y++) { - int yy = by + y; - for (int x = 0; x < 4; x++) { - int i = x + 4 * yy; - if (inMask & (1 << i)) { - const etc1_byte* p = pIn + i * 3; - r += *(p++); - g += *(p++); - b += *(p++); - } - } - } - } else { - int bx = 0; - if (second) { - bx = 2; - } - for (int y = 0; y < 4; y++) { - for (int x = 0; x < 2; x++) { - int xx = bx + x; - int i = xx + 4 * y; - if (inMask & (1 << i)) { - const etc1_byte* p = pIn + i * 3; - r += *(p++); - g += *(p++); - b += *(p++); - } - } - } - } - pColors[0] = (etc1_byte)((r + 4) >> 3); - pColors[1] = (etc1_byte)((g + 4) >> 3); - pColors[2] = (etc1_byte)((b + 4) >> 3); -} - -static -inline int square(int x) { - return x * x; -} - -static etc1_uint32 chooseModifier(const etc1_byte* pBaseColors, - const etc1_byte* pIn, etc1_uint32 *pLow, int bitIndex, - const int* pModifierTable) { - etc1_uint32 bestScore = ~0; - int bestIndex = 0; - int pixelR = pIn[0]; - int pixelG = pIn[1]; - int pixelB = pIn[2]; - int r = pBaseColors[0]; - int g = pBaseColors[1]; - int b = pBaseColors[2]; - for (int i = 0; i < 4; i++) { - int modifier = pModifierTable[i]; - int decodedG = clamp(g + modifier); - etc1_uint32 score = (etc1_uint32) (6 * square(decodedG - pixelG)); - if (score >= bestScore) { - continue; - } - int decodedR = clamp(r + modifier); - score += (etc1_uint32) (3 * square(decodedR - pixelR)); - if (score >= bestScore) { - continue; - } - int decodedB = clamp(b + modifier); - score += (etc1_uint32) square(decodedB - pixelB); - if (score < bestScore) { - bestScore = score; - bestIndex = i; - } - } - etc1_uint32 lowMask = (((bestIndex >> 1) << 16) | (bestIndex & 1)) - << bitIndex; - *pLow |= lowMask; - return bestScore; -} - -static -void etc_encode_subblock_helper(const etc1_byte* pIn, etc1_uint32 inMask, - etc_compressed* pCompressed, bool flipped, bool second, - const etc1_byte* pBaseColors, const int* pModifierTable) { - int score = pCompressed->score; - if (flipped) { - int by = 0; - if (second) { - by = 2; - } - for (int y = 0; y < 2; y++) { - int yy = by + y; - for (int x = 0; x < 4; x++) { - int i = x + 4 * yy; - if (inMask & (1 << i)) { - score += chooseModifier(pBaseColors, pIn + i * 3, - &pCompressed->low, yy + x * 4, pModifierTable); - } - } - } - } else { - int bx = 0; - if (second) { - bx = 2; - } - for (int y = 0; y < 4; y++) { - for (int x = 0; x < 2; x++) { - int xx = bx + x; - int i = xx + 4 * y; - if (inMask & (1 << i)) { - score += chooseModifier(pBaseColors, pIn + i * 3, - &pCompressed->low, y + xx * 4, pModifierTable); - } - } - } - } - pCompressed->score = score; -} - -static bool inRange4bitSigned(int color) { - return color >= -4 && color <= 3; -} - -static void etc_encodeBaseColors(etc1_byte* pBaseColors, - const etc1_byte* pColors, etc_compressed* pCompressed) { - int r1, g1, b1, r2, g2, b2; // 8 bit base colors for sub-blocks - bool differential; - { - int r51 = convert8To5(pColors[0]); - int g51 = convert8To5(pColors[1]); - int b51 = convert8To5(pColors[2]); - int r52 = convert8To5(pColors[3]); - int g52 = convert8To5(pColors[4]); - int b52 = convert8To5(pColors[5]); - - r1 = convert5To8(r51); - g1 = convert5To8(g51); - b1 = convert5To8(b51); - - int dr = r52 - r51; - int dg = g52 - g51; - int db = b52 - b51; - - differential = inRange4bitSigned(dr) && inRange4bitSigned(dg) - && inRange4bitSigned(db); - if (differential) { - r2 = convert5To8(r51 + dr); - g2 = convert5To8(g51 + dg); - b2 = convert5To8(b51 + db); - pCompressed->high |= (r51 << 27) | ((7 & dr) << 24) | (g51 << 19) - | ((7 & dg) << 16) | (b51 << 11) | ((7 & db) << 8) | 2; - } - } - - if (!differential) { - int r41 = convert8To4(pColors[0]); - int g41 = convert8To4(pColors[1]); - int b41 = convert8To4(pColors[2]); - int r42 = convert8To4(pColors[3]); - int g42 = convert8To4(pColors[4]); - int b42 = convert8To4(pColors[5]); - r1 = convert4To8(r41); - g1 = convert4To8(g41); - b1 = convert4To8(b41); - r2 = convert4To8(r42); - g2 = convert4To8(g42); - b2 = convert4To8(b42); - pCompressed->high |= (r41 << 28) | (r42 << 24) | (g41 << 20) | (g42 - << 16) | (b41 << 12) | (b42 << 8); - } - pBaseColors[0] = r1; - pBaseColors[1] = g1; - pBaseColors[2] = b1; - pBaseColors[3] = r2; - pBaseColors[4] = g2; - pBaseColors[5] = b2; -} - -static -void etc_encode_block_helper(const etc1_byte* pIn, etc1_uint32 inMask, - const etc1_byte* pColors, etc_compressed* pCompressed, bool flipped) { - pCompressed->score = ~0; - pCompressed->high = (flipped ? 1 : 0); - pCompressed->low = 0; - - etc1_byte pBaseColors[6]; - - etc_encodeBaseColors(pBaseColors, pColors, pCompressed); - - int originalHigh = pCompressed->high; - - const int* pModifierTable = kModifierTable; - for (int i = 0; i < 8; i++, pModifierTable += 4) { - etc_compressed temp; - temp.score = 0; - temp.high = originalHigh | (i << 5); - temp.low = 0; - etc_encode_subblock_helper(pIn, inMask, &temp, flipped, false, - pBaseColors, pModifierTable); - take_best(pCompressed, &temp); - } - pModifierTable = kModifierTable; - etc_compressed firstHalf = *pCompressed; - for (int i = 0; i < 8; i++, pModifierTable += 4) { - etc_compressed temp; - temp.score = firstHalf.score; - temp.high = firstHalf.high | (i << 2); - temp.low = firstHalf.low; - etc_encode_subblock_helper(pIn, inMask, &temp, flipped, true, - pBaseColors + 3, pModifierTable); - if (i == 0) { - *pCompressed = temp; - } else { - take_best(pCompressed, &temp); - } - } -} - -static void writeBigEndian(etc1_byte* pOut, etc1_uint32 d) { - pOut[0] = (etc1_byte)(d >> 24); - pOut[1] = (etc1_byte)(d >> 16); - pOut[2] = (etc1_byte)(d >> 8); - pOut[3] = (etc1_byte) d; -} - -// Input is a 4 x 4 square of 3-byte pixels in form R, G, B -// inmask is a 16-bit mask where bit (1 << (x + y * 4)) tells whether the corresponding (x,y) -// pixel is valid or not. Invalid pixel color values are ignored when compressing. -// Output is an ETC1 compressed version of the data. - -void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 inMask, - etc1_byte* pOut) { - etc1_byte colors[6]; - etc1_byte flippedColors[6]; - etc_average_colors_subblock(pIn, inMask, colors, false, false); - etc_average_colors_subblock(pIn, inMask, colors + 3, false, true); - etc_average_colors_subblock(pIn, inMask, flippedColors, true, false); - etc_average_colors_subblock(pIn, inMask, flippedColors + 3, true, true); - - etc_compressed a, b; - etc_encode_block_helper(pIn, inMask, colors, &a, false); - etc_encode_block_helper(pIn, inMask, flippedColors, &b, true); - take_best(&a, &b); - writeBigEndian(pOut, a.high); - writeBigEndian(pOut + 4, a.low); -} - -// 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) { - return (((width + 3) & ~3) * ((height + 3) & ~3)) >> 1; -} - -// Encode an entire image. -// pIn - pointer to the image data. Formatted such that the Red component of -// pixel (x,y) is at pIn + pixelSize * x + stride * y + redOffset; -// pOut - pointer to encoded data. Must be large enough to store entire encoded image. - -int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height, - etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut) { - if (pixelSize < 2 || pixelSize > 3) { - return -1; - } - static const unsigned short kYMask[] = { 0x0, 0xf, 0xff, 0xfff, 0xffff }; - static const unsigned short kXMask[] = { 0x0, 0x1111, 0x3333, 0x7777, - 0xffff }; - etc1_byte block[ETC1_DECODED_BLOCK_SIZE]; - etc1_byte encoded[ETC1_ENCODED_BLOCK_SIZE]; - - etc1_uint32 encodedWidth = (width + 3) & ~3; - etc1_uint32 encodedHeight = (height + 3) & ~3; - - for (etc1_uint32 y = 0; y < encodedHeight; y += 4) { - etc1_uint32 yEnd = height - y; - if (yEnd > 4) { - yEnd = 4; - } - int ymask = kYMask[yEnd]; - for (etc1_uint32 x = 0; x < encodedWidth; x += 4) { - etc1_uint32 xEnd = width - x; - if (xEnd > 4) { - xEnd = 4; - } - int mask = ymask & kXMask[xEnd]; - for (etc1_uint32 cy = 0; cy < yEnd; cy++) { - etc1_byte* q = block + (cy * 4) * 3; - const etc1_byte* p = pIn + pixelSize * x + stride * (y + cy); - if (pixelSize == 3) { - memcpy(q, p, xEnd * 3); - } else { - for (etc1_uint32 cx = 0; cx < xEnd; cx++) { - int pixel = (p[1] << 8) | p[0]; - *q++ = convert5To8(pixel >> 11); - *q++ = convert6To8(pixel >> 5); - *q++ = convert5To8(pixel); - p += pixelSize; - } - } - } - etc1_encode_block(block, mask, encoded); - memcpy(pOut, encoded, sizeof(encoded)); - pOut += sizeof(encoded); - } - } - return 0; -} - -// Decode an entire image. -// pIn - pointer to encoded data. -// pOut - pointer to the image data. Will be written such that the Red component of -// pixel (x,y) is at pIn + pixelSize * x + stride * y + redOffset. Must be -// large enough to store entire image. - - -int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut, - etc1_uint32 width, etc1_uint32 height, - etc1_uint32 pixelSize, etc1_uint32 stride) { - if (pixelSize < 2 || pixelSize > 3) { - return -1; - } - etc1_byte block[ETC1_DECODED_BLOCK_SIZE]; - - etc1_uint32 encodedWidth = (width + 3) & ~3; - etc1_uint32 encodedHeight = (height + 3) & ~3; - - for (etc1_uint32 y = 0; y < encodedHeight; y += 4) { - etc1_uint32 yEnd = height - y; - if (yEnd > 4) { - yEnd = 4; - } - for (etc1_uint32 x = 0; x < encodedWidth; x += 4) { - etc1_uint32 xEnd = width - x; - if (xEnd > 4) { - xEnd = 4; - } - etc1_decode_block(pIn, block); - pIn += ETC1_ENCODED_BLOCK_SIZE; - for (etc1_uint32 cy = 0; cy < yEnd; cy++) { - const etc1_byte* q = block + (cy * 4) * 3; - etc1_byte* p = pOut + pixelSize * x + stride * (y + cy); - if (pixelSize == 3) { - memcpy(p, q, xEnd * 3); - } else { - for (etc1_uint32 cx = 0; cx < xEnd; cx++) { - etc1_byte r = *q++; - etc1_byte g = *q++; - etc1_byte b = *q++; - etc1_uint32 pixel = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); - *p++ = (etc1_byte) pixel; - *p++ = (etc1_byte) (pixel >> 8); - } - } - } - } - } - return 0; -} - -static const char kMagic[] = { 'P', 'K', 'M', ' ', '1', '0' }; - -static const etc1_uint32 ETC1_PKM_FORMAT_OFFSET = 6; -static const etc1_uint32 ETC1_PKM_ENCODED_WIDTH_OFFSET = 8; -static const etc1_uint32 ETC1_PKM_ENCODED_HEIGHT_OFFSET = 10; -static const etc1_uint32 ETC1_PKM_WIDTH_OFFSET = 12; -static const etc1_uint32 ETC1_PKM_HEIGHT_OFFSET = 14; - -static const etc1_uint32 ETC1_RGB_NO_MIPMAPS = 0; - -static void writeBEUint16(etc1_byte* pOut, etc1_uint32 data) { - pOut[0] = (etc1_byte) (data >> 8); - pOut[1] = (etc1_byte) data; -} - -static etc1_uint32 readBEUint16(const etc1_byte* pIn) { - return (pIn[0] << 8) | pIn[1]; -} - -// Format a PKM header - -void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height) { - memcpy(pHeader, kMagic, sizeof(kMagic)); - etc1_uint32 encodedWidth = (width + 3) & ~3; - etc1_uint32 encodedHeight = (height + 3) & ~3; - writeBEUint16(pHeader + ETC1_PKM_FORMAT_OFFSET, ETC1_RGB_NO_MIPMAPS); - writeBEUint16(pHeader + ETC1_PKM_ENCODED_WIDTH_OFFSET, encodedWidth); - writeBEUint16(pHeader + ETC1_PKM_ENCODED_HEIGHT_OFFSET, encodedHeight); - writeBEUint16(pHeader + ETC1_PKM_WIDTH_OFFSET, width); - writeBEUint16(pHeader + ETC1_PKM_HEIGHT_OFFSET, height); -} - -// Check if a PKM header is correctly formatted. - -etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader) { - if (memcmp(pHeader, kMagic, sizeof(kMagic))) { - return false; - } - etc1_uint32 format = readBEUint16(pHeader + ETC1_PKM_FORMAT_OFFSET); - etc1_uint32 encodedWidth = readBEUint16(pHeader + ETC1_PKM_ENCODED_WIDTH_OFFSET); - etc1_uint32 encodedHeight = readBEUint16(pHeader + ETC1_PKM_ENCODED_HEIGHT_OFFSET); - etc1_uint32 width = readBEUint16(pHeader + ETC1_PKM_WIDTH_OFFSET); - etc1_uint32 height = readBEUint16(pHeader + ETC1_PKM_HEIGHT_OFFSET); - return format == ETC1_RGB_NO_MIPMAPS && - encodedWidth >= width && encodedWidth - width < 4 && - encodedHeight >= height && encodedHeight - height < 4; -} - -// Read the image width from a PKM header - -etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader) { - return readBEUint16(pHeader + ETC1_PKM_WIDTH_OFFSET); -} - -// Read the image height from a PKM header - -etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader){ - return readBEUint16(pHeader + ETC1_PKM_HEIGHT_OFFSET); -} diff --git a/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp b/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp deleted file mode 100644 index 3612211..0000000 --- a/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* -* 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. -*/ -#include <map> -#include <GLcommon/objectNameManager.h> -#include <GLcommon/GLEScontext.h> - - -NameSpace::NameSpace(NamedObjectType p_type, - GlobalNameSpace *globalNameSpace) : - m_nextName(0), - m_type(p_type), - m_globalNameSpace(globalNameSpace) {} - -NameSpace::~NameSpace() -{ - for (NamesMap::iterator n = m_localToGlobalMap.begin(); - n != m_localToGlobalMap.end(); - n++) { - m_globalNameSpace->deleteName(m_type, (*n).second); - } -} - -ObjectLocalName -NameSpace::genName(ObjectLocalName p_localName, - bool genGlobal, bool genLocal) -{ - ObjectLocalName localName = p_localName; - if (genLocal) { - do { - localName = ++m_nextName; - } while(localName == 0 || - m_localToGlobalMap.find(localName) != - m_localToGlobalMap.end() ); - } - - if (genGlobal) { - unsigned int globalName = m_globalNameSpace->genName(m_type); - m_localToGlobalMap[localName] = globalName; - } - - return localName; -} - - -unsigned int -NameSpace::genGlobalName(void) -{ - return m_globalNameSpace->genName(m_type); -} - -unsigned int -NameSpace::getGlobalName(ObjectLocalName p_localName) -{ - NamesMap::iterator n( m_localToGlobalMap.find(p_localName) ); - if (n != m_localToGlobalMap.end()) { - // object found - return its global name map - return (*n).second; - } - - // object does not exist; - return 0; -} - -ObjectLocalName -NameSpace::getLocalName(unsigned int p_globalName) -{ - for(NamesMap::iterator it = m_localToGlobalMap.begin(); it != m_localToGlobalMap.end();it++){ - if((*it).second == p_globalName){ - // object found - return its local name - return (*it).first; - } - } - - // object does not exist; - return 0; -} - -void -NameSpace::deleteName(ObjectLocalName p_localName) -{ - NamesMap::iterator n( m_localToGlobalMap.find(p_localName) ); - if (n != m_localToGlobalMap.end()) { - m_globalNameSpace->deleteName(m_type, (*n).second); - m_localToGlobalMap.erase(p_localName); - } -} - -bool -NameSpace::isObject(ObjectLocalName p_localName) -{ - return (m_localToGlobalMap.find(p_localName) != m_localToGlobalMap.end() ); -} - -void -NameSpace::replaceGlobalName(ObjectLocalName p_localName, unsigned int p_globalName) -{ - NamesMap::iterator n( m_localToGlobalMap.find(p_localName) ); - if (n != m_localToGlobalMap.end()) { - m_globalNameSpace->deleteName(m_type, (*n).second); - (*n).second = p_globalName; - } -} - - -GlobalNameSpace::GlobalNameSpace() : m_lock() {} - -GlobalNameSpace::~GlobalNameSpace() {} - -unsigned int -GlobalNameSpace::genName(NamedObjectType p_type) -{ - if ( p_type >= NUM_OBJECT_TYPES ) return 0; - unsigned int name = 0; - - emugl::Mutex::AutoLock _lock(m_lock); - switch (p_type) { - case VERTEXBUFFER: - GLEScontext::dispatcher().glGenBuffers(1,&name); - break; - case TEXTURE: - GLEScontext::dispatcher().glGenTextures(1,&name); - break; - case RENDERBUFFER: - GLEScontext::dispatcher().glGenRenderbuffersEXT(1,&name); - break; - case FRAMEBUFFER: - GLEScontext::dispatcher().glGenFramebuffersEXT(1,&name); - break; - case SHADER: //objects in shader namepace are not handled - default: - name = 0; - } - return name; -} - -void -GlobalNameSpace::deleteName(NamedObjectType p_type, unsigned int p_name) -{ -} - -typedef std::pair<NamedObjectType, ObjectLocalName> ObjectIDPair; -typedef std::map<ObjectIDPair, ObjectDataPtr> ObjectDataMap; - -ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace) : m_lock() { - for (int i=0; i < NUM_OBJECT_TYPES; i++) { - m_nameSpace[i] = new NameSpace((NamedObjectType)i, globalNameSpace); - } - - m_objectsData = NULL; -} - -ShareGroup::~ShareGroup() -{ - emugl::Mutex::AutoLock _lock(m_lock); - for (int t = 0; t < NUM_OBJECT_TYPES; t++) { - delete m_nameSpace[t]; - } - - delete (ObjectDataMap *)m_objectsData; -} - -ObjectLocalName -ShareGroup::genName(NamedObjectType p_type, - ObjectLocalName p_localName, - bool genLocal) -{ - if (p_type >= NUM_OBJECT_TYPES) return 0; - - emugl::Mutex::AutoLock _lock(m_lock); - ObjectLocalName localName = - m_nameSpace[p_type]->genName(p_localName, true, genLocal); - return localName; -} - -unsigned int -ShareGroup::genGlobalName(NamedObjectType p_type) -{ - if (p_type >= NUM_OBJECT_TYPES) return 0; - - emugl::Mutex::AutoLock _lock(m_lock); - return m_nameSpace[p_type]->genGlobalName(); -} - -unsigned int -ShareGroup::getGlobalName(NamedObjectType p_type, - ObjectLocalName p_localName) -{ - if (p_type >= NUM_OBJECT_TYPES) return 0; - - emugl::Mutex::AutoLock _lock(m_lock); - return m_nameSpace[p_type]->getGlobalName(p_localName); -} - -ObjectLocalName -ShareGroup::getLocalName(NamedObjectType p_type, - unsigned int p_globalName) -{ - if (p_type >= NUM_OBJECT_TYPES) return 0; - - emugl::Mutex::AutoLock _lock(m_lock); - return m_nameSpace[p_type]->getLocalName(p_globalName); -} - -void -ShareGroup::deleteName(NamedObjectType p_type, ObjectLocalName p_localName) -{ - if (p_type >= NUM_OBJECT_TYPES) return; - - emugl::Mutex::AutoLock _lock(m_lock); - m_nameSpace[p_type]->deleteName(p_localName); - ObjectDataMap *map = (ObjectDataMap *)m_objectsData; - if (map) { - map->erase( ObjectIDPair(p_type, p_localName) ); - } -} - -bool -ShareGroup::isObject(NamedObjectType p_type, ObjectLocalName p_localName) -{ - if (p_type >= NUM_OBJECT_TYPES) return 0; - - emugl::Mutex::AutoLock _lock(m_lock); - return m_nameSpace[p_type]->isObject(p_localName); -} - -void -ShareGroup::replaceGlobalName(NamedObjectType p_type, - ObjectLocalName p_localName, - unsigned int p_globalName) -{ - if (p_type >= NUM_OBJECT_TYPES) return; - - emugl::Mutex::AutoLock _lock(m_lock); - m_nameSpace[p_type]->replaceGlobalName(p_localName, p_globalName); -} - -void -ShareGroup::setObjectData(NamedObjectType p_type, - ObjectLocalName p_localName, - ObjectDataPtr data) -{ - if (p_type >= NUM_OBJECT_TYPES) return; - - emugl::Mutex::AutoLock _lock(m_lock); - - ObjectDataMap *map = (ObjectDataMap *)m_objectsData; - if (!map) { - map = new ObjectDataMap(); - m_objectsData = map; - } - - ObjectIDPair id( p_type, p_localName ); - map->insert( std::pair<ObjectIDPair, ObjectDataPtr>(id, data) ); -} - -ObjectDataPtr -ShareGroup::getObjectData(NamedObjectType p_type, - ObjectLocalName p_localName) -{ - ObjectDataPtr ret; - - if (p_type >= NUM_OBJECT_TYPES) return ret; - - emugl::Mutex::AutoLock _lock(m_lock); - - ObjectDataMap *map = (ObjectDataMap *)m_objectsData; - if (map) { - ObjectDataMap::iterator i = - map->find( ObjectIDPair(p_type, p_localName) ); - if (i != map->end()) ret = (*i).second; - } - return ret; -} - -ObjectNameManager::ObjectNameManager(GlobalNameSpace *globalNameSpace) : - m_lock(), m_globalNameSpace(globalNameSpace) {} - -ObjectNameManager::~ObjectNameManager() {} - -ShareGroupPtr -ObjectNameManager::createShareGroup(void *p_groupName) -{ - emugl::Mutex::AutoLock _lock(m_lock); - - ShareGroupPtr shareGroupReturn; - - ShareGroupsMap::iterator s( m_groups.find(p_groupName) ); - if (s != m_groups.end()) { - shareGroupReturn = (*s).second; - } - else { - // - // Group does not exist, create new group - // - shareGroupReturn = ShareGroupPtr(new ShareGroup(m_globalNameSpace)); - m_groups.insert( - std::pair<void*, ShareGroupPtr>( - p_groupName, shareGroupReturn)); - } - - return shareGroupReturn; -} - -ShareGroupPtr -ObjectNameManager::getShareGroup(void *p_groupName) -{ - emugl::Mutex::AutoLock _lock(m_lock); - - ShareGroupPtr shareGroupReturn(NULL); - - ShareGroupsMap::iterator s( m_groups.find(p_groupName) ); - if (s != m_groups.end()) { - shareGroupReturn = (*s).second; - } - - return shareGroupReturn; -} - -ShareGroupPtr -ObjectNameManager::attachShareGroup(void *p_groupName, - void *p_existingGroupName) -{ - emugl::Mutex::AutoLock _lock(m_lock); - - ShareGroupsMap::iterator s( m_groups.find(p_existingGroupName) ); - if (s == m_groups.end()) { - // ShareGroup did not found !!! - return ShareGroupPtr(NULL); - } - - ShareGroupPtr shareGroupReturn((*s).second); - if (m_groups.find(p_groupName) == m_groups.end()) { - m_groups.insert( - std::pair<void*, ShareGroupPtr>( - p_groupName, shareGroupReturn)); - } - return shareGroupReturn; -} - -void -ObjectNameManager::deleteShareGroup(void *p_groupName) -{ - emugl::Mutex::AutoLock _lock(m_lock); - - ShareGroupsMap::iterator s( m_groups.find(p_groupName) ); - if (s != m_groups.end()) { - m_groups.erase(s); - } -} - -void *ObjectNameManager::getGlobalContext() -{ - emugl::Mutex::AutoLock _lock(m_lock); - return (m_groups.size() > 0) ? (*m_groups.begin()).first : NULL; -} - diff --git a/emulator/opengl/host/libs/Translator/include/EGL/egl.h b/emulator/opengl/host/libs/Translator/include/EGL/egl.h deleted file mode 100644 index 99ea342..0000000 --- a/emulator/opengl/host/libs/Translator/include/EGL/egl.h +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- mode: c; tab-width: 8; -*- */ -/* vi: set sw=4 ts=8: */ -/* Reference version of egl.h for EGL 1.4. - * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $ - */ - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __egl_h_ -#define __egl_h_ - -/* All platform-dependent types and macro boilerplate (such as EGLAPI - * and EGLAPIENTRY) should go in eglplatform.h. - */ -#include <EGL/eglplatform.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* EGL Types */ -/* EGLint is defined in eglplatform.h */ -typedef unsigned int EGLBoolean; -typedef unsigned int EGLenum; -typedef void *EGLConfig; -typedef void *EGLContext; -typedef void *EGLDisplay; -typedef void *EGLSurface; -typedef void *EGLClientBuffer; - -/* EGL Versioning */ -#define EGL_VERSION_1_0 1 -#define EGL_VERSION_1_1 1 -#define EGL_VERSION_1_2 1 -#define EGL_VERSION_1_3 1 -#define EGL_VERSION_1_4 1 - -/* EGL Enumerants. Bitmasks and other exceptional cases aside, most - * enums are assigned unique values starting at 0x3000. - */ - -/* EGL aliases */ -#define EGL_FALSE 0 -#define EGL_TRUE 1 - -/* Out-of-band handle values */ -#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) -#define EGL_NO_CONTEXT ((EGLContext)0) -#define EGL_NO_DISPLAY ((EGLDisplay)0) -#define EGL_NO_SURFACE ((EGLSurface)0) - -/* Out-of-band attribute value */ -#define EGL_DONT_CARE ((EGLint)-1) - -/* Errors / GetError return values */ -#define EGL_SUCCESS 0x3000 -#define EGL_NOT_INITIALIZED 0x3001 -#define EGL_BAD_ACCESS 0x3002 -#define EGL_BAD_ALLOC 0x3003 -#define EGL_BAD_ATTRIBUTE 0x3004 -#define EGL_BAD_CONFIG 0x3005 -#define EGL_BAD_CONTEXT 0x3006 -#define EGL_BAD_CURRENT_SURFACE 0x3007 -#define EGL_BAD_DISPLAY 0x3008 -#define EGL_BAD_MATCH 0x3009 -#define EGL_BAD_NATIVE_PIXMAP 0x300A -#define EGL_BAD_NATIVE_WINDOW 0x300B -#define EGL_BAD_PARAMETER 0x300C -#define EGL_BAD_SURFACE 0x300D -#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */ - -/* Reserved 0x300F-0x301F for additional errors */ - -/* Config attributes */ -#define EGL_BUFFER_SIZE 0x3020 -#define EGL_ALPHA_SIZE 0x3021 -#define EGL_BLUE_SIZE 0x3022 -#define EGL_GREEN_SIZE 0x3023 -#define EGL_RED_SIZE 0x3024 -#define EGL_DEPTH_SIZE 0x3025 -#define EGL_STENCIL_SIZE 0x3026 -#define EGL_CONFIG_CAVEAT 0x3027 -#define EGL_CONFIG_ID 0x3028 -#define EGL_LEVEL 0x3029 -#define EGL_MAX_PBUFFER_HEIGHT 0x302A -#define EGL_MAX_PBUFFER_PIXELS 0x302B -#define EGL_MAX_PBUFFER_WIDTH 0x302C -#define EGL_NATIVE_RENDERABLE 0x302D -#define EGL_NATIVE_VISUAL_ID 0x302E -#define EGL_NATIVE_VISUAL_TYPE 0x302F -#define EGL_SAMPLES 0x3031 -#define EGL_SAMPLE_BUFFERS 0x3032 -#define EGL_SURFACE_TYPE 0x3033 -#define EGL_TRANSPARENT_TYPE 0x3034 -#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 -#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 -#define EGL_TRANSPARENT_RED_VALUE 0x3037 -#define EGL_NONE 0x3038 /* Attrib list terminator */ -#define EGL_BIND_TO_TEXTURE_RGB 0x3039 -#define EGL_BIND_TO_TEXTURE_RGBA 0x303A -#define EGL_MIN_SWAP_INTERVAL 0x303B -#define EGL_MAX_SWAP_INTERVAL 0x303C -#define EGL_LUMINANCE_SIZE 0x303D -#define EGL_ALPHA_MASK_SIZE 0x303E -#define EGL_COLOR_BUFFER_TYPE 0x303F -#define EGL_RENDERABLE_TYPE 0x3040 -#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */ -#define EGL_CONFORMANT 0x3042 - -/* Reserved 0x3041-0x304F for additional config attributes */ - -/* Config attribute values */ -#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */ -#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */ -#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */ -#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */ -#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */ - -/* More config attribute values, for EGL_TEXTURE_FORMAT */ -#define EGL_NO_TEXTURE 0x305C -#define EGL_TEXTURE_RGB 0x305D -#define EGL_TEXTURE_RGBA 0x305E -#define EGL_TEXTURE_2D 0x305F - -/* Config attribute mask bits */ -#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */ - -#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */ -#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */ -#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */ -#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */ - -/* QueryString targets */ -#define EGL_VENDOR 0x3053 -#define EGL_VERSION 0x3054 -#define EGL_EXTENSIONS 0x3055 -#define EGL_CLIENT_APIS 0x308D - -/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */ -#define EGL_HEIGHT 0x3056 -#define EGL_WIDTH 0x3057 -#define EGL_LARGEST_PBUFFER 0x3058 -#define EGL_TEXTURE_FORMAT 0x3080 -#define EGL_TEXTURE_TARGET 0x3081 -#define EGL_MIPMAP_TEXTURE 0x3082 -#define EGL_MIPMAP_LEVEL 0x3083 -#define EGL_RENDER_BUFFER 0x3086 -#define EGL_VG_COLORSPACE 0x3087 -#define EGL_VG_ALPHA_FORMAT 0x3088 -#define EGL_HORIZONTAL_RESOLUTION 0x3090 -#define EGL_VERTICAL_RESOLUTION 0x3091 -#define EGL_PIXEL_ASPECT_RATIO 0x3092 -#define EGL_SWAP_BEHAVIOR 0x3093 -#define EGL_MULTISAMPLE_RESOLVE 0x3099 - -/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */ -#define EGL_BACK_BUFFER 0x3084 -#define EGL_SINGLE_BUFFER 0x3085 - -/* OpenVG color spaces */ -#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */ -#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */ - -/* OpenVG alpha formats */ -#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */ -#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */ - -/* Constant scale factor by which fractional display resolutions & - * aspect ratio are scaled when queried as integer values. - */ -#define EGL_DISPLAY_SCALING 10000 - -/* Unknown display resolution/aspect ratio */ -#define EGL_UNKNOWN ((EGLint)-1) - -/* Back buffer swap behaviors */ -#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */ -#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */ - -/* CreatePbufferFromClientBuffer buffer types */ -#define EGL_OPENVG_IMAGE 0x3096 - -/* QueryContext targets */ -#define EGL_CONTEXT_CLIENT_TYPE 0x3097 - -/* CreateContext attributes */ -#define EGL_CONTEXT_CLIENT_VERSION 0x3098 - -/* Multisample resolution behaviors */ -#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */ -#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */ - -/* BindAPI/QueryAPI targets */ -#define EGL_OPENGL_ES_API 0x30A0 -#define EGL_OPENVG_API 0x30A1 -#define EGL_OPENGL_API 0x30A2 - -/* GetCurrentSurface targets */ -#define EGL_DRAW 0x3059 -#define EGL_READ 0x305A - -/* WaitNative engines */ -#define EGL_CORE_NATIVE_ENGINE 0x305B - -/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */ -#define EGL_COLORSPACE EGL_VG_COLORSPACE -#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT -#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB -#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR -#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE -#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE - -/* EGL extensions must request enum blocks from the Khronos - * API Registrar, who maintains the enumerant registry. Submit - * a bug in Khronos Bugzilla against task "Registry". - */ - - - -/* EGL Functions */ - -EGLAPI EGLint EGLAPIENTRY eglGetError(void); - -EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id); -EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor); -EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy); - -EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name); - -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, - EGLint config_size, EGLint *num_config); -EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, - EGLConfig *configs, EGLint config_size, - EGLint *num_config); -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, - EGLint attribute, EGLint *value); - -EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, - EGLNativeWindowType win, - const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, - const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, - EGLint attribute, EGLint *value); - -EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api); -EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void); - -EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void); - -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void); - -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer( - EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, - EGLConfig config, const EGLint *attrib_list); - -EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, - EGLint attribute, EGLint value); -EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); - - -EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval); - - -EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, - EGLContext share_context, - const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx); -EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, - EGLSurface read, EGLContext ctx); - -EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void); -EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw); -EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, - EGLint attribute, EGLint *value); - -EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine); -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, - EGLNativePixmapType target); - -/* 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 (*__eglMustCastToProperFunctionPointerType)(void); - -/* Now, define eglGetProcAddress using the generic function ptr. type */ -EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY - eglGetProcAddress(const char *procname); - -#ifdef __cplusplus -} -#endif - -#endif /* __egl_h_ */ diff --git a/emulator/opengl/host/libs/Translator/include/EGL/eglext.h b/emulator/opengl/host/libs/Translator/include/EGL/eglext.h deleted file mode 100644 index 1ffcd56..0000000 --- a/emulator/opengl/host/libs/Translator/include/EGL/eglext.h +++ /dev/null @@ -1,244 +0,0 @@ -#ifndef __eglext_h_ -#define __eglext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2010 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#include <EGL/eglplatform.h> - -/*************************************************************/ - -/* Header file version number */ -/* Current version at http://www.khronos.org/registry/egl/ */ -/* $Revision: 11249 $ on $Date: 2010-05-05 09:54:28 -0700 (Wed, 05 May 2010) $ */ -#define EGL_EGLEXT_VERSION 5 - -#ifndef EGL_KHR_config_attribs -#define EGL_KHR_config_attribs 1 -#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */ -#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */ -#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */ -#endif - -#ifndef EGL_KHR_lock_surface -#define EGL_KHR_lock_surface 1 -#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ -#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ -#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */ -#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */ -#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */ -#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */ -#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */ -#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */ -#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */ -#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */ -#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */ -#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */ -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface); -#endif - -#ifndef EGL_KHR_image -#define EGL_KHR_image 1 -#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */ -typedef void *EGLImageKHR; -#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); -#endif - -#ifndef EGL_KHR_vg_parent_image -#define EGL_KHR_vg_parent_image 1 -#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_KHR_gl_texture_2D_image -#define EGL_KHR_gl_texture_2D_image 1 -#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */ -#endif - -#ifndef EGL_KHR_gl_texture_cubemap_image -#define EGL_KHR_gl_texture_cubemap_image 1 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_KHR_gl_texture_3D_image -#define EGL_KHR_gl_texture_3D_image 1 -#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */ -#endif - -#ifndef EGL_KHR_gl_renderbuffer_image -#define EGL_KHR_gl_renderbuffer_image 1 -#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_KHR_reusable_sync -#define EGL_KHR_reusable_sync 1 - -typedef void* EGLSyncKHR; -typedef khronos_utime_nanoseconds_t EGLTimeKHR; - -#define EGL_SYNC_STATUS_KHR 0x30F1 -#define EGL_SIGNALED_KHR 0x30F2 -#define EGL_UNSIGNALED_KHR 0x30F3 -#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 -#define EGL_CONDITION_SATISFIED_KHR 0x30F6 -#define EGL_SYNC_TYPE_KHR 0x30F7 -#define EGL_SYNC_REUSABLE_KHR 0x30FA -#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR <flags> bitfield */ -#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull -#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); -typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); -#endif - -#ifndef EGL_KHR_image_base -#define EGL_KHR_image_base 1 -/* Most interfaces defined by EGL_KHR_image_pixmap above */ -#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */ -#endif - -#ifndef EGL_KHR_image_pixmap -#define EGL_KHR_image_pixmap 1 -/* Interfaces defined by EGL_KHR_image above */ -#endif - -#ifndef EGL_IMG_context_priority -#define EGL_IMG_context_priority 1 -#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 -#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 -#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 -#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 -#endif - -#ifndef EGL_NV_coverage_sample -#define EGL_NV_coverage_sample 1 -#define EGL_COVERAGE_BUFFERS_NV 0x30E0 -#define EGL_COVERAGE_SAMPLES_NV 0x30E1 -#endif - -#ifndef EGL_NV_depth_nonlinear -#define EGL_NV_depth_nonlinear 1 -#define EGL_DEPTH_ENCODING_NV 0x30E2 -#define EGL_DEPTH_ENCODING_NONE_NV 0 -#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 -#endif - -#ifndef EGL_NV_sync -#define EGL_NV_sync 1 -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 -#define EGL_SYNC_STATUS_NV 0x30E7 -#define EGL_SIGNALED_NV 0x30E8 -#define EGL_UNSIGNALED_NV 0x30E9 -#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 -#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull -#define EGL_ALREADY_SIGNALED_NV 0x30EA -#define EGL_TIMEOUT_EXPIRED_NV 0x30EB -#define EGL_CONDITION_SATISFIED_NV 0x30EC -#define EGL_SYNC_TYPE_NV 0x30ED -#define EGL_SYNC_CONDITION_NV 0x30EE -#define EGL_SYNC_FENCE_NV 0x30EF -#define EGL_NO_SYNC_NV ((EGLSyncNV)0) -typedef void* EGLSyncNV; -typedef unsigned long long EGLTimeNV; -#ifdef EGL_EGLEXT_PROTOTYPES -EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); -EGLBoolean eglDestroySyncNV (EGLSyncNV sync); -EGLBoolean eglFenceNV (EGLSyncNV sync); -EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); -EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); -EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); -typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); -#endif - -#ifndef EGL_KHR_fence_sync -#define EGL_KHR_fence_sync 1 -/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */ -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 -#define EGL_SYNC_CONDITION_KHR 0x30F8 -#define EGL_SYNC_FENCE_KHR 0x30F9 -#endif - -#ifndef EGL_ANDROID_image_native_buffer -#define EGL_ANDROID_image_native_buffer 1 -struct android_native_buffer_t; -#define EGL_NATIVE_BUFFER_ANDROID 0x3140 /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_ANDROID_swap_rectangle -#define EGL_ANDROID_swap_rectangle 1 -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSetSwapRectangleANDROID (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSWAPRECTANGLEANDROIDPROC) (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h b/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h deleted file mode 100644 index 953284a..0000000 --- a/emulator/opengl/host/libs/Translator/include/EGL/eglinternalplatform.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -* 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 EGL_INTERNAL_PLATFORM_H -#define EGL_INTERNAL_PLATFORM_H - -class SrfcInfo; //defined in Egl{$platform}Api.cpp -typedef SrfcInfo* SURFACE; -typedef SURFACE EGLNativeSurfaceType; - -#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif - -#include <GL/gl.h> -#define WGL_WGLEXT_PROTOTYPES -#include <GL/wglext.h> - -class WinDisplay; //defined in EglWindows.cpp -typedef WinDisplay* DISPLAY; - -typedef PIXELFORMATDESCRIPTOR EGLNativePixelFormatType; -#define PIXEL_FORMAT_INITIALIZER {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; -typedef HGLRC EGLNativeContextType; -typedef HPBUFFERARB EGLNativePbufferType; -typedef DISPLAY EGLNativeInternalDisplayType; - -#elif defined(__APPLE__) - -typedef void* EGLNativePixelFormatType; -#define PIXEL_FORMAT_INITIALIZER NULL -typedef void* EGLNativeContextType; -typedef void* EGLNativePbufferType; -typedef EGLNativeDisplayType EGLNativeInternalDisplayType; - - -#elif defined(__unix__) - -/* X11 (tentative) */ -#include <GL/glx.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -typedef GLXFBConfig EGLNativePixelFormatType; -#define PIXEL_FORMAT_INITIALIZER 0; -typedef GLXContext EGLNativeContextType; -typedef GLXPbuffer EGLNativePbufferType; -typedef EGLNativeDisplayType EGLNativeInternalDisplayType; - -#else -#error "Platform not recognized" -#endif - - -#endif diff --git a/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h b/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h deleted file mode 100644 index b159cd7..0000000 --- a/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef __eglplatform_h_ -#define __eglplatform_h_ -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Platform-specific types and definitions for egl.h - * $Revision: 9724 $ on $Date: 2009-12-02 02:05:33 -0800 (Wed, 02 Dec 2009) $ - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "EGL" component "Registry". - */ -#include <KHR/khrplatform.h> - -/* Macros used in EGL function prototype declarations. - * - * EGL functions should be prototyped as: - * - * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); - * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); - * - * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h - */ - -#ifndef EGLAPI -#define EGLAPI KHRONOS_APICALL -#endif - -#ifndef EGLAPIENTRY -#define EGLAPIENTRY KHRONOS_APIENTRY -#endif -#define EGLAPIENTRYP EGLAPIENTRY* - -/* The types NativeDisplayType, NativeWindowType, and NativePixmapType - * are aliases of window-system-dependent types, such as X Display * or - * Windows Device Context. They must be defined in platform-specific - * code below. The EGL-prefixed versions of Native*Type are the same - * types, renamed in EGL 1.3 so all types in the API start with "EGL". - */ - -#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#include <windows.h> - - - -typedef HDC EGLNativeDisplayType; -typedef HBITMAP EGLNativePixmapType; -typedef HWND EGLNativeWindowType; - -#elif defined(__APPLE__) - -typedef unsigned int EGLNativeDisplayType; -typedef void* EGLNativePixmapType; -typedef void* EGLNativeWindowType; - - -#elif defined(__unix__) - -/* X11 (tentative) */ -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -typedef Display * EGLNativeDisplayType; -typedef Pixmap EGLNativePixmapType; -typedef Window EGLNativeWindowType; - -#else -#error "Platform not recognized" -#endif - -/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ -typedef EGLNativeDisplayType NativeDisplayType; -typedef EGLNativePixmapType NativePixmapType; -typedef EGLNativeWindowType NativeWindowType; - - -/* Define EGLint. This must be a signed integral type large enough to contain - * all legal attribute names and values passed into and out of EGL, whether - * their type is boolean, bitmask, enumerant (symbolic constant), integer, - * handle, or other. While in general a 32-bit integer will suffice, if - * handles are 64 bit types, then EGLint should be defined as a signed 64-bit - * integer type. - */ -typedef khronos_int32_t EGLint; - -#endif /* __eglplatform_h */ diff --git a/emulator/opengl/host/libs/Translator/include/ETC1/etc1.h b/emulator/opengl/host/libs/Translator/include/ETC1/etc1.h deleted file mode 100644 index 0d38905..0000000 --- a/emulator/opengl/host/libs/Translator/include/ETC1/etc1.h +++ /dev/null @@ -1,106 +0,0 @@ -// 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 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 diff --git a/emulator/opengl/host/libs/Translator/include/GL/wglext.h b/emulator/opengl/host/libs/Translator/include/GL/wglext.h deleted file mode 100644 index 8e06d93..0000000 --- a/emulator/opengl/host/libs/Translator/include/GL/wglext.h +++ /dev/null @@ -1,901 +0,0 @@ -#ifndef __wglext_h_ -#define __wglext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2010 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Function declaration macros - to move into glplatform.h */ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include <windows.h> -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number */ -/* wglext.h last updated 2010/08/06 */ -/* Current version at http://www.opengl.org/registry/ */ -#define WGL_WGLEXT_VERSION 22 - -#ifndef WGL_ARB_buffer_region -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 -#endif - -#ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 -#endif - -#ifndef WGL_ARB_extensions_string -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif - -#ifndef WGL_ARB_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 -#endif - -#ifndef WGL_ARB_framebuffer_sRGB -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#endif - -#ifndef WGL_ARB_create_context_profile -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define ERROR_INVALID_PROFILE_ARB 0x2096 -#endif - -#ifndef WGL_ARB_create_context_robustness -#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 -#endif - -#ifndef WGL_EXT_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_DEPTH_FLOAT_EXT 0x2040 -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 -#endif - -#ifndef WGL_I3D_gamma -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F -#endif - -#ifndef WGL_I3D_genlock -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 -#endif - -#ifndef WGL_I3D_swap_frame_lock -#endif - -#ifndef WGL_NV_render_depth_texture -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 -#endif - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 -#endif - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 -#endif - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 -#endif - -#ifndef WGL_NV_present_video -#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 -#endif - -#ifndef WGL_NV_video_out -#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 -#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 -#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 -#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 -#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 -#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 -#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define WGL_VIDEO_OUT_FRAME 0x20C8 -#define WGL_VIDEO_OUT_FIELD_1 0x20C9 -#define WGL_VIDEO_OUT_FIELD_2 0x20CA -#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB -#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC -#endif - -#ifndef WGL_NV_swap_group -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 -#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 -#endif - -#ifndef WGL_AMD_gpu_association -#define WGL_GPU_VENDOR_AMD 0x1F00 -#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 -#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 -#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 -#define WGL_GPU_RAM_AMD 0x21A3 -#define WGL_GPU_CLOCK_AMD 0x21A4 -#define WGL_GPU_NUM_PIPES_AMD 0x21A5 -#define WGL_GPU_NUM_SIMD_AMD 0x21A6 -#define WGL_GPU_NUM_RB_AMD 0x21A7 -#define WGL_GPU_NUM_SPI_AMD 0x21A8 -#endif - -#ifndef WGL_NV_video_capture -#define WGL_UNIQUE_ID_NV 0x20CE -#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF -#endif - -#ifndef WGL_NV_copy_image -#endif - -#ifndef WGL_NV_multisample_coverage -#define WGL_COVERAGE_SAMPLES_NV 0x2042 -#define WGL_COLOR_SAMPLES_NV 0x20B9 -#endif - -#ifndef WGL_EXT_create_context_es2_profile -#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#endif - - -/*************************************************************/ - -#ifndef WGL_ARB_pbuffer -DECLARE_HANDLE(HPBUFFERARB); -#endif -#ifndef WGL_EXT_pbuffer -DECLARE_HANDLE(HPBUFFEREXT); -#endif -#ifndef WGL_NV_present_video -DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); -#endif -#ifndef WGL_NV_video_output -DECLARE_HANDLE(HPVIDEODEV); -#endif -#ifndef WGL_NV_gpu_affinity -DECLARE_HANDLE(HPGPUNV); -DECLARE_HANDLE(HGPUNV); - -typedef struct _GPU_DEVICE { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD Flags; - RECT rcVirtualScreen; -} GPU_DEVICE, *PGPU_DEVICE; -#endif -#ifndef WGL_NV_video_capture -DECLARE_HANDLE(HVIDEOINPUTDEVICENV); -#endif - -#ifndef WGL_ARB_buffer_region -#define WGL_ARB_buffer_region 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); -extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); -extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); -extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); -typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); -typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); -typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -#endif - -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 -#endif - -#ifndef WGL_ARB_extensions_string -#define WGL_ARB_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_ARB_make_current_read -#define WGL_ARB_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -extern HDC WINAPI wglGetCurrentReadDCARB (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_ARB_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); -extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); -extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); -extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_ARB_render_texture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); -extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); -extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 -#endif - -#ifndef WGL_ARB_framebuffer_sRGB -#define WGL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_ARB_create_context 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); -#endif - -#ifndef WGL_ARB_create_context_profile -#define WGL_ARB_create_context_profile 1 -#endif - -#ifndef WGL_ARB_create_context_robustness -#define WGL_ARB_create_context_robustness 1 -#endif - -#ifndef WGL_EXT_display_color_table -#define WGL_EXT_display_color_table 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); -extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); -extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); -extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); -typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); -#endif - -#ifndef WGL_EXT_extensions_string -#define WGL_EXT_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); -#endif - -#ifndef WGL_EXT_make_current_read -#define WGL_EXT_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -extern HDC WINAPI wglGetCurrentReadDCEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_EXT_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); -extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); -extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); -extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_EXT_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); -extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); -extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_EXT_swap_control -#define WGL_EXT_swap_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSwapIntervalEXT (int interval); -extern int WINAPI wglGetSwapIntervalEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); -typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 -#endif - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -extern void WINAPI wglFreeMemoryNV (void *pointer); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 -#endif - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); -extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_I3D_digital_video_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); -extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -#endif - -#ifndef WGL_I3D_gamma -#define WGL_I3D_gamma 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); -extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); -extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); -extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); -#endif - -#ifndef WGL_I3D_genlock -#define WGL_I3D_genlock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC); -extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC); -extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); -extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); -extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); -extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); -extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); -extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); -extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); -extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); -extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); -extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); -typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); -typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_I3D_image_buffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); -extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); -extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); -extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); -typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); -typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); -typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); -#endif - -#ifndef WGL_I3D_swap_frame_lock -#define WGL_I3D_swap_frame_lock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableFrameLockI3D (void); -extern BOOL WINAPI wglDisableFrameLockI3D (void); -extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); -extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); -#endif - -#ifndef WGL_I3D_swap_frame_usage -#define WGL_I3D_swap_frame_usage 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); -extern BOOL WINAPI wglBeginFrameTrackingI3D (void); -extern BOOL WINAPI wglEndFrameTrackingI3D (void); -extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); -typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_NV_float_buffer 1 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_3DL_stereo_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); -#endif - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_EXT_pixel_format_packed_float 1 -#endif - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef WGL_NV_present_video -#define WGL_NV_present_video 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); -extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); -extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); -typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); -typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); -#endif - -#ifndef WGL_NV_video_output -#define WGL_NV_video_output 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); -extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); -extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); -extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); -extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); -typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); -typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -#endif - -#ifndef WGL_NV_swap_group -#define WGL_NV_swap_group 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); -extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); -extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); -extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); -extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); -extern BOOL WINAPI wglResetFrameCountNV (HDC hDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); -typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); -typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); -typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); -typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_NV_gpu_affinity 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); -extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); -extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -extern BOOL WINAPI wglDeleteDCNV (HDC hdc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); -typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); -typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); -#endif - -#ifndef WGL_AMD_gpu_association -#define WGL_AMD_gpu_association 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); -extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); -extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); -extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); -extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); -extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); -extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); -extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); -extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); -typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); -typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); -typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); -typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); -typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -#ifndef WGL_NV_video_capture -#define WGL_NV_video_capture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); -extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); -extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); -extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); -typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); -typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -#endif - -#ifndef WGL_NV_copy_image -#define WGL_NV_copy_image 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef WGL_NV_multisample_coverage -#define WGL_NV_multisample_coverage 1 -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/emulator/opengl/host/libs/Translator/include/GLES/gl.h b/emulator/opengl/host/libs/Translator/include/GLES/gl.h deleted file mode 100644 index 5b8d85a..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLES/gl.h +++ /dev/null @@ -1,770 +0,0 @@ -#ifndef __gl_h_ -#define __gl_h_ - -/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */ - -#include <GLES/glplatform.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -typedef void GLvoid; -typedef char GLchar; -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef khronos_int8_t GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef khronos_float_t GLfloat; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; -typedef khronos_int32_t GLclampx; - -typedef khronos_intptr_t GLintptr; -typedef khronos_ssize_t GLsizeiptr; - - -/*************************************************************/ - -/* OpenGL ES core versions */ -#define GL_VERSION_ES_CM_1_0 1 -#define GL_VERSION_ES_CL_1_0 1 -#define GL_VERSION_ES_CM_1_1 1 -#define GL_VERSION_ES_CL_1_1 1 - -/* ClearBufferMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 - -/* AlphaFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* ClipPlaneName */ -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 - -/* ColorMaterialFace */ -/* GL_FRONT_AND_BACK */ - -/* ColorMaterialParameter */ -/* GL_AMBIENT_AND_DIFFUSE */ - -/* ColorPointerType */ -/* GL_UNSIGNED_BYTE */ -/* GL_FLOAT */ -/* GL_FIXED */ - -/* CullFaceMode */ -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* EnableCap */ -#define GL_FOG 0x0B60 -#define GL_LIGHTING 0x0B50 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_BLEND 0x0BE2 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -/* GL_LIGHT0 */ -/* GL_LIGHT1 */ -/* GL_LIGHT2 */ -/* GL_LIGHT3 */ -/* GL_LIGHT4 */ -/* GL_LIGHT5 */ -/* GL_LIGHT6 */ -/* GL_LIGHT7 */ -#define GL_POINT_SMOOTH 0x0B10 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_NORMALIZE 0x0BA1 -#define GL_RESCALE_NORMAL 0x803A -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FogMode */ -/* GL_LINEAR */ -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 - -/* FogParameter */ -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetPName */ -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_LINE_WIDTH 0x0B21 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_SHADE_MODEL 0x0B54 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_MATRIX_MODE 0x0BA0 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_ALPHA_TEST_FUNC 0x0BC1 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ - -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_FOG_HINT 0x0C54 -#define GL_GENERATE_MIPMAP_HINT 0x8192 - -/* LightModelParameter */ -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 - -/* LightParameter */ -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C - -/* LogicOp */ -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F - -/* MaterialFace */ -/* GL_FRONT_AND_BACK */ - -/* MaterialParameter */ -#define GL_EMISSION 0x1600 -#define GL_SHININESS 0x1601 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ - -/* MatrixMode */ -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 - -/* NormalPointerType */ -/* GL_BYTE */ -/* GL_SHORT */ -/* GL_FLOAT */ -/* GL_FIXED */ - -/* PixelFormat */ -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelStoreParameter */ -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 - -/* PixelType */ -/* GL_UNSIGNED_BYTE */ -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 - -/* ShadingModel */ -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 - -/* StencilFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -/* GL_INVERT */ - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TexCoordPointerType */ -/* GL_SHORT */ -/* GL_FLOAT */ -/* GL_FIXED */ -/* GL_BYTE */ - -/* TextureEnvMode */ -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -/* GL_BLEND */ -#define GL_ADD 0x0104 -/* GL_REPLACE */ - -/* TextureEnvParameter */ -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 - -/* TextureEnvTarget */ -#define GL_TEXTURE_ENV 0x2300 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_GENERATE_MIPMAP 0x8191 - -/* TextureTarget */ -/* GL_TEXTURE_2D */ - -/* TextureUnit */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 - -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F - -/* VertexPointerType */ -/* GL_SHORT */ -/* GL_FLOAT */ -/* GL_FIXED */ -/* GL_BYTE */ - -/* LightName */ -#define GL_LIGHT0 0x4000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 - -/* Buffer Objects */ -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 - -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A - -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 - -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 - -/* Texture combine + dot3 */ -#define GL_SUBTRACT 0x84E7 -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A - -#define GL_ALPHA_SCALE 0x0D1C - -#define GL_SRC0_RGB 0x8580 -#define GL_SRC1_RGB 0x8581 -#define GL_SRC2_RGB 0x8582 -#define GL_SRC0_ALPHA 0x8588 -#define GL_SRC1_ALPHA 0x8589 -#define GL_SRC2_ALPHA 0x858A - -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF - -/*------------------------------------------------------------------------* - * required OES extension tokens - *------------------------------------------------------------------------*/ - -/* OES_read_format */ -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -/* OES_point_size_array */ -#ifndef GL_OES_point_size_array -#define GL_POINT_SIZE_ARRAY_OES 0x8B9C -#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A -#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B -#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C -#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F -#endif - -/* GL_OES_point_sprite */ -#ifndef GL_OES_point_sprite -#define GL_POINT_SPRITE_OES 0x8861 -#define GL_COORD_REPLACE_OES 0x8862 -#endif - -/*************************************************************/ - -/* Available only in Common profile */ -GL_API void GL_APIENTRY glAlphaFunc (GLenum func, GLclampf ref); -GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_API void GL_APIENTRY glClearDepthf (GLclampf depth); -GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation); -GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GL_API void GL_APIENTRY glFogf (GLenum pname, GLfloat param); -GL_API void GL_APIENTRY glFogfv (GLenum pname, const GLfloat *params); -GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); -GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat eqn[4]); -GL_API void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params); -GL_API void GL_APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); -GL_API void GL_APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); -GL_API void GL_APIENTRY glGetTexEnvfv (GLenum env, GLenum pname, GLfloat *params); -GL_API void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); -GL_API void GL_APIENTRY glLightModelf (GLenum pname, GLfloat param); -GL_API void GL_APIENTRY glLightModelfv (GLenum pname, const GLfloat *params); -GL_API void GL_APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); -GL_API void GL_APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); -GL_API void GL_APIENTRY glLineWidth (GLfloat width); -GL_API void GL_APIENTRY glLoadMatrixf (const GLfloat *m); -GL_API void GL_APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); -GL_API void GL_APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); -GL_API void GL_APIENTRY glMultMatrixf (const GLfloat *m); -GL_API void GL_APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GL_API void GL_APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); -GL_API void GL_APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); -GL_API void GL_APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GL_API void GL_APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GL_API void GL_APIENTRY glPointSize (GLfloat size); -GL_API void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GL_API void GL_APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GL_API void GL_APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); -GL_API void GL_APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); -GL_API void GL_APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); -GL_API void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GL_API void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GL_API void GL_APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); - -/* Available in both Common and Common-Lite profiles */ -GL_API void GL_APIENTRY glActiveTexture (GLenum texture); -GL_API void GL_APIENTRY glAlphaFuncx (GLenum func, GLclampx ref); -GL_API void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GL_API void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); -GL_API void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GL_API void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -GL_API void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GL_API void GL_APIENTRY glClear (GLbitfield mask); -GL_API void GL_APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); -GL_API void GL_APIENTRY glClearDepthx (GLclampx depth); -GL_API void GL_APIENTRY glClearStencil (GLint s); -GL_API void GL_APIENTRY glClientActiveTexture (GLenum texture); -GL_API void GL_APIENTRY glClipPlanex (GLenum plane, const GLfixed *equation); -GL_API void GL_APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -GL_API void GL_APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GL_API void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GL_API void GL_APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GL_API void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GL_API void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GL_API void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GL_API void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GL_API void GL_APIENTRY glCullFace (GLenum mode); -GL_API void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GL_API void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); -GL_API void GL_APIENTRY glDepthFunc (GLenum func); -GL_API void GL_APIENTRY glDepthMask (GLboolean flag); -GL_API void GL_APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar); -GL_API void GL_APIENTRY glDisable (GLenum cap); -GL_API void GL_APIENTRY glDisableClientState (GLenum array); -GL_API void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GL_API void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -GL_API void GL_APIENTRY glEnable (GLenum cap); -GL_API void GL_APIENTRY glEnableClientState (GLenum array); -GL_API void GL_APIENTRY glFinish (void); -GL_API void GL_APIENTRY glFlush (void); -GL_API void GL_APIENTRY glFogx (GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glFogxv (GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glFrontFace (GLenum mode); -GL_API void GL_APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); -GL_API void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *params); -GL_API void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GL_API void GL_APIENTRY glGetClipPlanex (GLenum pname, GLfixed eqn[4]); -GL_API void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GL_API void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); -GL_API GLenum GL_APIENTRY glGetError (void); -GL_API void GL_APIENTRY glGetFixedv (GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *params); -GL_API void GL_APIENTRY glGetLightxv (GLenum light, GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glGetPointerv (GLenum pname, GLvoid **params); -GL_API const GLubyte * GL_APIENTRY glGetString (GLenum name); -GL_API void GL_APIENTRY glGetTexEnviv (GLenum env, GLenum pname, GLint *params); -GL_API void GL_APIENTRY glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); -GL_API void GL_APIENTRY glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glHint (GLenum target, GLenum mode); -GL_API GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); -GL_API GLboolean GL_APIENTRY glIsEnabled (GLenum cap); -GL_API GLboolean GL_APIENTRY glIsTexture (GLuint texture); -GL_API void GL_APIENTRY glLightModelx (GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glLightModelxv (GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glLineWidthx (GLfixed width); -GL_API void GL_APIENTRY glLoadIdentity (void); -GL_API void GL_APIENTRY glLoadMatrixx (const GLfixed *m); -GL_API void GL_APIENTRY glLogicOp (GLenum opcode); -GL_API void GL_APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glMatrixMode (GLenum mode); -GL_API void GL_APIENTRY glMultMatrixx (const GLfixed *m); -GL_API void GL_APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -GL_API void GL_APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz); -GL_API void GL_APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -GL_API void GL_APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); -GL_API void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); -GL_API void GL_APIENTRY glPointParameterx (GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glPointParameterxv (GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glPointSizex (GLfixed size); -GL_API void GL_APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units); -GL_API void GL_APIENTRY glPopMatrix (void); -GL_API void GL_APIENTRY glPushMatrix (void); -GL_API void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); -GL_API void GL_APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -GL_API void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); -GL_API void GL_APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert); -GL_API void GL_APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z); -GL_API void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GL_API void GL_APIENTRY glShadeModel (GLenum mode); -GL_API void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GL_API void GL_APIENTRY glStencilMask (GLuint mask); -GL_API void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GL_API void GL_APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GL_API void GL_APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); -GL_API void GL_APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); -GL_API void GL_APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GL_API void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GL_API void GL_APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); -GL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z); -GL_API void GL_APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GL_API void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); - -/*------------------------------------------------------------------------* - * Required OES extension functions - *------------------------------------------------------------------------*/ - -/* GL_OES_read_format */ -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#endif - -/* GL_OES_point_size_array */ -#ifndef GL_OES_point_size_array -#define GL_OES_point_size_array 1 -GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -/* GL_OES_point_sprite */ -#ifndef GL_OES_point_sprite -#define GL_OES_point_sprite 1 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gl_h_ */ - diff --git a/emulator/opengl/host/libs/Translator/include/GLES/glext.h b/emulator/opengl/host/libs/Translator/include/GLES/glext.h deleted file mode 100644 index 130e4b0..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLES/glext.h +++ /dev/null @@ -1,1073 +0,0 @@ -#ifndef __glext_h_ -#define __glext_h_ - -/* $Revision: 13240 $ on $Date:: 2010-12-17 15:16:00 -0800 #$ */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -#ifndef GL_APIENTRYP -# define GL_APIENTRYP GL_APIENTRY* -#endif - -/*------------------------------------------------------------------------* - * OES extension tokens - *------------------------------------------------------------------------*/ - -/* GL_OES_blend_equation_separate */ -#ifndef GL_OES_blend_equation_separate -/* BLEND_EQUATION_RGB_OES same as BLEND_EQUATION_OES */ -#define GL_BLEND_EQUATION_RGB_OES 0x8009 -#define GL_BLEND_EQUATION_ALPHA_OES 0x883D -#endif - -/* GL_OES_blend_func_separate */ -#ifndef GL_OES_blend_func_separate -#define GL_BLEND_DST_RGB_OES 0x80C8 -#define GL_BLEND_SRC_RGB_OES 0x80C9 -#define GL_BLEND_DST_ALPHA_OES 0x80CA -#define GL_BLEND_SRC_ALPHA_OES 0x80CB -#endif - -/* GL_OES_blend_subtract */ -#ifndef GL_OES_blend_subtract -#define GL_BLEND_EQUATION_OES 0x8009 -#define GL_FUNC_ADD_OES 0x8006 -#define GL_FUNC_SUBTRACT_OES 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_OES 0x800B -#endif - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_ETC1_RGB8_OES 0x8D64 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_DEPTH_COMPONENT24_OES 0x81A6 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_DEPTH_COMPONENT32_OES 0x81A7 -#endif - -/* GL_OES_draw_texture */ -#ifndef GL_OES_draw_texture -#define GL_TEXTURE_CROP_RECT_OES 0x8B9D -#endif - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -typedef void* GLeglImageOES; -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -/* GLeglImageOES defined in GL_OES_EGL_image already. */ -#define GL_TEXTURE_EXTERNAL_OES 0x8D65 -#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 -#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_UNSIGNED_INT 0x1405 -#endif - -/* GL_OES_fixed_point */ -#ifndef GL_OES_fixed_point -#define GL_FIXED_OES 0x140C -#endif - -/* GL_OES_framebuffer_object */ -#ifndef GL_OES_framebuffer_object -#define GL_NONE_OES 0 -#define GL_FRAMEBUFFER_OES 0x8D40 -#define GL_RENDERBUFFER_OES 0x8D41 -#define GL_RGBA4_OES 0x8056 -#define GL_RGB5_A1_OES 0x8057 -#define GL_RGB565_OES 0x8D62 -#define GL_DEPTH_COMPONENT16_OES 0x81A5 -#define GL_RENDERBUFFER_WIDTH_OES 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_OES 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_OES 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE_OES 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_OES 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_OES 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_OES 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_OES 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_OES 0x8D55 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES 0x8CD3 -#define GL_COLOR_ATTACHMENT0_OES 0x8CE0 -#define GL_DEPTH_ATTACHMENT_OES 0x8D00 -#define GL_STENCIL_ATTACHMENT_OES 0x8D20 -#define GL_FRAMEBUFFER_COMPLETE_OES 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES 0x8CDA -#define GL_FRAMEBUFFER_UNSUPPORTED_OES 0x8CDD -#define GL_FRAMEBUFFER_BINDING_OES 0x8CA6 -#define GL_RENDERBUFFER_BINDING_OES 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE_OES 0x84E8 -#define GL_INVALID_FRAMEBUFFER_OPERATION_OES 0x0506 -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_WRITE_ONLY_OES 0x88B9 -#define GL_BUFFER_ACCESS_OES 0x88BB -#define GL_BUFFER_MAPPED_OES 0x88BC -#define GL_BUFFER_MAP_POINTER_OES 0x88BD -#endif - -/* GL_OES_matrix_get */ -#ifndef GL_OES_matrix_get -#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D -#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E -#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F -#endif - -/* GL_OES_matrix_palette */ -#ifndef GL_OES_matrix_palette -#define GL_MAX_VERTEX_UNITS_OES 0x86A4 -#define GL_MAX_PALETTE_MATRICES_OES 0x8842 -#define GL_MATRIX_PALETTE_OES 0x8840 -#define GL_MATRIX_INDEX_ARRAY_OES 0x8844 -#define GL_WEIGHT_ARRAY_OES 0x86AD -#define GL_CURRENT_PALETTE_MATRIX_OES 0x8843 -#define GL_MATRIX_INDEX_ARRAY_SIZE_OES 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_OES 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_OES 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_OES 0x8849 -#define GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES 0x8B9E -#define GL_WEIGHT_ARRAY_SIZE_OES 0x86AB -#define GL_WEIGHT_ARRAY_TYPE_OES 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_OES 0x86AA -#define GL_WEIGHT_ARRAY_POINTER_OES 0x86AC -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_OES 0x889E -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_DEPTH_STENCIL_OES 0x84F9 -#define GL_UNSIGNED_INT_24_8_OES 0x84FA -#define GL_DEPTH24_STENCIL8_OES 0x88F0 -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_RGB8_OES 0x8051 -#define GL_RGBA8_OES 0x8058 -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_STENCIL_INDEX1_OES 0x8D46 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_STENCIL_INDEX4_OES 0x8D47 -#endif - -/* GL_OES_stencil8 */ -#ifndef GL_OES_stencil8 -#define GL_STENCIL_INDEX8_OES 0x8D48 -#endif - -/* GL_OES_stencil_wrap */ -#ifndef GL_OES_stencil_wrap -#define GL_INCR_WRAP_OES 0x8507 -#define GL_DECR_WRAP_OES 0x8508 -#endif - -/* GL_OES_texture_cube_map */ -#ifndef GL_OES_texture_cube_map -#define GL_NORMAL_MAP_OES 0x8511 -#define GL_REFLECTION_MAP_OES 0x8512 -#define GL_TEXTURE_CUBE_MAP_OES 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_OES 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES 0x851A -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES 0x851C -#define GL_TEXTURE_GEN_MODE_OES 0x2500 -#define GL_TEXTURE_GEN_STR_OES 0x8D60 -#endif - -/* GL_OES_texture_mirrored_repeat */ -#ifndef GL_OES_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_OES 0x8370 -#endif - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 -#endif - -/*------------------------------------------------------------------------* - * AMD extension tokens - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_3DC_X_AMD 0x87F9 -#define GL_3DC_XY_AMD 0x87FA -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_ATC_RGB_AMD 0x8C92 -#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE -#endif - -/*------------------------------------------------------------------------* - * APPLE extension tokens - *------------------------------------------------------------------------*/ - -/* GL_APPLE_texture_2D_limited_npot */ -/* No new tokens introduced by this extension. */ - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 -#define GL_MAX_SAMPLES_APPLE 0x8D57 -#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D -#endif - -/*------------------------------------------------------------------------* - * ARM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_ARM_rgba8 */ -/* No new tokens introduced by this extension. */ - -/*------------------------------------------------------------------------* - * EXT extension tokens - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_COLOR_EXT 0x1800 -#define GL_DEPTH_EXT 0x1801 -#define GL_STENCIL_EXT 0x1802 -#endif - -/* GL_EXT_multi_draw_arrays */ -/* No new tokens introduced by this extension. */ - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_BGRA_EXT 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_EXT_texture_lod_bias */ -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -/*------------------------------------------------------------------------* - * IMG extension tokens - *------------------------------------------------------------------------*/ - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_BGRA_IMG 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#endif - -/* GL_IMG_texture_env_enhanced_fixed_function */ -#ifndef GL_IMG_texture_env_enhanced_fixed_function -#define GL_MODULATE_COLOR_IMG 0x8C04 -#define GL_RECIP_ADD_SIGNED_ALPHA_IMG 0x8C05 -#define GL_TEXTURE_ALPHA_MODULATE_IMG 0x8C06 -#define GL_FACTOR_ALPHA_MODULATE_IMG 0x8C07 -#define GL_FRAGMENT_ALPHA_MODULATE_IMG 0x8C08 -#define GL_ADD_BLEND_IMG 0x8C09 -#define GL_DOT3_RGBA_IMG 0x86AF -#endif - -/* GL_IMG_user_clip_plane */ -#ifndef GL_IMG_user_clip_plane -#define GL_CLIP_PLANE0_IMG 0x3000 -#define GL_CLIP_PLANE1_IMG 0x3001 -#define GL_CLIP_PLANE2_IMG 0x3002 -#define GL_CLIP_PLANE3_IMG 0x3003 -#define GL_CLIP_PLANE4_IMG 0x3004 -#define GL_CLIP_PLANE5_IMG 0x3005 -#define GL_MAX_CLIP_PLANES_IMG 0x0D32 -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 -#define GL_MAX_SAMPLES_IMG 0x9135 -#define GL_TEXTURE_SAMPLES_IMG 0x9136 -#endif - -/*------------------------------------------------------------------------* - * NV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -/*------------------------------------------------------------------------* - * QCOM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_QCOM_driver_control */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 -#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 -#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 -#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 -#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 -#define GL_TEXTURE_TYPE_QCOM 0x8BD7 -#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 -#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 -#define GL_TEXTURE_TARGET_QCOM 0x8BDA -#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB -#define GL_STATE_RESTORE 0x8BDC -#endif - -/* GL_QCOM_extended_get2 */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_WRITEONLY_RENDERING_QCOM 0x8823 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 -#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 -#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 -#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 -#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 -#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 -#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 -#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 -#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 -#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 -#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 -#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 -#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 -#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 -#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 -#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 -#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 -#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 -#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 -#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 -#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 -#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 -#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 -#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 -#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 -#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 -#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 -#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 -#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 -#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 -#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 -#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 -#endif - -/*------------------------------------------------------------------------* - * End of extension tokens, start of corresponding extension functions - *------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------* - * OES extension functions - *------------------------------------------------------------------------*/ - -/* GL_OES_blend_equation_separate */ -#ifndef GL_OES_blend_equation_separate -#define GL_OES_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glBlendEquationSeparateOES (GLenum modeRGB, GLenum modeAlpha); -#endif -typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEOESPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -/* GL_OES_blend_func_separate */ -#ifndef GL_OES_blend_func_separate -#define GL_OES_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glBlendFuncSeparateOES (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif -typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEOESPROC) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -/* GL_OES_blend_subtract */ -#ifndef GL_OES_blend_subtract -#define GL_OES_blend_subtract 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glBlendEquationOES (GLenum mode); -#endif -typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONOESPROC) (GLenum mode); -#endif - -/* GL_OES_byte_coordinates */ -#ifndef GL_OES_byte_coordinates -#define GL_OES_byte_coordinates 1 -#endif - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_OES_compressed_ETC1_RGB8_texture 1 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_OES_depth24 1 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_OES_depth32 1 -#endif - -/* GL_OES_draw_texture */ -#ifndef GL_OES_draw_texture -#define GL_OES_draw_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); -GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height); -GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); -GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort *coords); -GL_API void GL_APIENTRY glDrawTexivOES (const GLint *coords); -GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed *coords); -GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); -GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat *coords); -#endif -typedef void (GL_APIENTRYP PFNGLDRAWTEXSOESPROC) (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); -typedef void (GL_APIENTRYP PFNGLDRAWTEXIOESPROC) (GLint x, GLint y, GLint z, GLint width, GLint height); -typedef void (GL_APIENTRYP PFNGLDRAWTEXXOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); -typedef void (GL_APIENTRYP PFNGLDRAWTEXSVOESPROC) (const GLshort *coords); -typedef void (GL_APIENTRYP PFNGLDRAWTEXIVOESPROC) (const GLint *coords); -typedef void (GL_APIENTRYP PFNGLDRAWTEXXVOESPROC) (const GLfixed *coords); -typedef void (GL_APIENTRYP PFNGLDRAWTEXFOESPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); -typedef void (GL_APIENTRYP PFNGLDRAWTEXFVOESPROC) (const GLfloat *coords); -#endif - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -#define GL_OES_EGL_image 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); -GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); -#endif -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -#define GL_OES_EGL_image_external 1 -/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_OES_element_index_uint 1 -#endif - -/* GL_OES_extended_matrix_palette */ -#ifndef GL_OES_extended_matrix_palette -#define GL_OES_extended_matrix_palette 1 -#endif - -/* GL_OES_fbo_render_mipmap */ -#ifndef GL_OES_fbo_render_mipmap -#define GL_OES_fbo_render_mipmap 1 -#endif - -/* GL_OES_fixed_point */ -#ifndef GL_OES_fixed_point -#define GL_OES_fixed_point 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glAlphaFuncxOES (GLenum func, GLclampx ref); -GL_API void GL_APIENTRY glClearColorxOES (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); -GL_API void GL_APIENTRY glClearDepthxOES (GLclampx depth); -GL_API void GL_APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); -GL_API void GL_APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GL_API void GL_APIENTRY glDepthRangexOES (GLclampx zNear, GLclampx zFar); -GL_API void GL_APIENTRY glFogxOES (GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glFogxvOES (GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glFrustumxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); -GL_API void GL_APIENTRY glGetClipPlanexOES (GLenum pname, GLfixed eqn[4]); -GL_API void GL_APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glGetLightxvOES (GLenum light, GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glGetMaterialxvOES (GLenum face, GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glGetTexEnvxvOES (GLenum env, GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GL_API void GL_APIENTRY glLightModelxOES (GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glLineWidthxOES (GLfixed width); -GL_API void GL_APIENTRY glLoadMatrixxOES (const GLfixed *m); -GL_API void GL_APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glMultMatrixxOES (const GLfixed *m); -GL_API void GL_APIENTRY glMultiTexCoord4xOES (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -GL_API void GL_APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); -GL_API void GL_APIENTRY glOrthoxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); -GL_API void GL_APIENTRY glPointParameterxOES (GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glPointSizexOES (GLfixed size); -GL_API void GL_APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); -GL_API void GL_APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -GL_API void GL_APIENTRY glSampleCoveragexOES (GLclampx value, GLboolean invert); -GL_API void GL_APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); -GL_API void GL_APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); -#endif -typedef void (GL_APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLclampx ref); -typedef void (GL_APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); -typedef void (GL_APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLclampx depth); -typedef void (GL_APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); -typedef void (GL_APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (GL_APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLclampx zNear, GLclampx zFar); -typedef void (GL_APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); -typedef void (GL_APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *params); -typedef void (GL_APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); -typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum pname, GLfixed eqn[4]); -typedef void (GL_APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); -typedef void (GL_APIENTRYP PFNGLGETLIGHTXVOESPROC) (GLenum light, GLenum pname, GLfixed *params); -typedef void (GL_APIENTRYP PFNGLGETMATERIALXVOESPROC) (GLenum face, GLenum pname, GLfixed *params); -typedef void (GL_APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum env, GLenum pname, GLfixed *params); -typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (GL_APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); -typedef void (GL_APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *params); -typedef void (GL_APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); -typedef void (GL_APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); -typedef void (GL_APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); -typedef void (GL_APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); -typedef void (GL_APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (GL_APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *params); -typedef void (GL_APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); -typedef void (GL_APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (GL_APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); -typedef void (GL_APIENTRYP PFNGLORTHOXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); -typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXOESPROC) (GLenum pname, GLfixed param); -typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); -typedef void (GL_APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); -typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); -typedef void (GL_APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEXOESPROC) (GLclampx value, GLboolean invert); -typedef void (GL_APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (GL_APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (GL_APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (GL_APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -#endif - -/* GL_OES_framebuffer_object */ -#ifndef GL_OES_framebuffer_object -#define GL_OES_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API GLboolean GL_APIENTRY glIsRenderbufferOES (GLuint renderbuffer); -GL_API void GL_APIENTRY glBindRenderbufferOES (GLenum target, GLuint renderbuffer); -GL_API void GL_APIENTRY glDeleteRenderbuffersOES (GLsizei n, const GLuint* renderbuffers); -GL_API void GL_APIENTRY glGenRenderbuffersOES (GLsizei n, GLuint* renderbuffers); -GL_API void GL_APIENTRY glRenderbufferStorageOES (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GL_API void GL_APIENTRY glGetRenderbufferParameterivOES (GLenum target, GLenum pname, GLint* params); -GL_API GLboolean GL_APIENTRY glIsFramebufferOES (GLuint framebuffer); -GL_API void GL_APIENTRY glBindFramebufferOES (GLenum target, GLuint framebuffer); -GL_API void GL_APIENTRY glDeleteFramebuffersOES (GLsizei n, const GLuint* framebuffers); -GL_API void GL_APIENTRY glGenFramebuffersOES (GLsizei n, GLuint* framebuffers); -GL_API GLenum GL_APIENTRY glCheckFramebufferStatusOES (GLenum target); -GL_API void GL_APIENTRY glFramebufferRenderbufferOES (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GL_API void GL_APIENTRY glFramebufferTexture2DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GL_API void GL_APIENTRY glGetFramebufferAttachmentParameterivOES (GLenum target, GLenum attachment, GLenum pname, GLint* params); -GL_API void GL_APIENTRY glGenerateMipmapOES (GLenum target); -#endif -typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFEROESPROC) (GLuint renderbuffer); -typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFEROESPROC) (GLenum target, GLuint renderbuffer); -typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSOESPROC) (GLsizei n, const GLuint* renderbuffers); -typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSOESPROC) (GLsizei n, GLuint* renderbuffers); -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVOESPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFEROESPROC) (GLuint framebuffer); -typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFEROESPROC) (GLenum target, GLuint framebuffer); -typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSOESPROC) (GLsizei n, const GLuint* framebuffers); -typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSOESPROC) (GLsizei n, GLuint* framebuffers); -typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) (GLenum target); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); -typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPOESPROC) (GLenum target); -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_OES_mapbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); -GL_API GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); -GL_API void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid ** params); -#endif -typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); -typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); -typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid ** params); -#endif - -/* GL_OES_matrix_get */ -#ifndef GL_OES_matrix_get -#define GL_OES_matrix_get 1 -#endif - -/* GL_OES_matrix_palette */ -#ifndef GL_OES_matrix_palette -#define GL_OES_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glCurrentPaletteMatrixOES (GLuint matrixpaletteindex); -GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES (void); -GL_API void GL_APIENTRY glMatrixIndexPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GL_API void GL_APIENTRY glWeightPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif -typedef void (GL_APIENTRYP PFNGLCURRENTPALETTEMATRIXOESPROC) (GLuint matrixpaletteindex); -typedef void (GL_APIENTRYP PFNGLLOADPALETTEFROMMODELVIEWMATRIXOESPROC) (void); -typedef void (GL_APIENTRYP PFNGLMATRIXINDEXPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_OES_packed_depth_stencil 1 -#endif - -/* GL_OES_query_matrix */ -#ifndef GL_OES_query_matrix -#define GL_OES_query_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES (GLfixed mantissa[16], GLint exponent[16]); -#endif -typedef GLbitfield (GL_APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed mantissa[16], GLint exponent[16]); -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_OES_rgb8_rgba8 1 -#endif - -/* GL_OES_single_precision */ -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar); -GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); -GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); -GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); -GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]); -GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth); -#endif -typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf zNear, GLclampf zFar); -typedef void (GL_APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); -typedef void (GL_APIENTRYP PFNGLORTHOFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); -typedef void (GL_APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); -typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum pname, GLfloat eqn[4]); -typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_OES_stencil1 1 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_OES_stencil4 1 -#endif - -/* GL_OES_stencil8 */ -#ifndef GL_OES_stencil8 -#define GL_OES_stencil8 1 -#endif - -/* GL_OES_stencil_wrap */ -#ifndef GL_OES_stencil_wrap -#define GL_OES_stencil_wrap 1 -#endif - -/* GL_OES_texture_cube_map */ -#ifndef GL_OES_texture_cube_map -#define GL_OES_texture_cube_map 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glTexGenfOES (GLenum coord, GLenum pname, GLfloat param); -GL_API void GL_APIENTRY glTexGenfvOES (GLenum coord, GLenum pname, const GLfloat *params); -GL_API void GL_APIENTRY glTexGeniOES (GLenum coord, GLenum pname, GLint param); -GL_API void GL_APIENTRY glTexGenivOES (GLenum coord, GLenum pname, const GLint *params); -GL_API void GL_APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); -GL_API void GL_APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); -GL_API void GL_APIENTRY glGetTexGenfvOES (GLenum coord, GLenum pname, GLfloat *params); -GL_API void GL_APIENTRY glGetTexGenivOES (GLenum coord, GLenum pname, GLint *params); -GL_API void GL_APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); -#endif -typedef void (GL_APIENTRYP PFNGLTEXGENFOESPROC) (GLenum coord, GLenum pname, GLfloat param); -typedef void (GL_APIENTRYP PFNGLTEXGENFVOESPROC) (GLenum coord, GLenum pname, const GLfloat *params); -typedef void (GL_APIENTRYP PFNGLTEXGENIOESPROC) (GLenum coord, GLenum pname, GLint param); -typedef void (GL_APIENTRYP PFNGLTEXGENIVOESPROC) (GLenum coord, GLenum pname, const GLint *params); -typedef void (GL_APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); -typedef void (GL_APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); -typedef void (GL_APIENTRYP PFNGLGETTEXGENFVOESPROC) (GLenum coord, GLenum pname, GLfloat *params); -typedef void (GL_APIENTRYP PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); -#endif - -/* GL_OES_texture_env_crossbar */ -#ifndef GL_OES_texture_env_crossbar -#define GL_OES_texture_env_crossbar 1 -#endif - -/* GL_OES_texture_mirrored_repeat */ -#ifndef GL_OES_texture_mirrored_repeat -#define GL_OES_texture_mirrored_repeat 1 -#endif - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_OES_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glBindVertexArrayOES (GLuint array); -GL_API void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); -GL_API void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); -GL_API GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); -#endif -typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); -typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); -typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); -#endif - -/*------------------------------------------------------------------------* - * AMD extension functions - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_AMD_compressed_3DC_texture 1 -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_AMD_compressed_ATC_texture 1 -#endif - -/*------------------------------------------------------------------------* - * APPLE extension functions - *------------------------------------------------------------------------*/ - -/* GL_APPLE_texture_2D_limited_npot */ -#ifndef GL_APPLE_texture_2D_limited_npot -#define GL_APPLE_texture_2D_limited_npot 1 -#endif - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_APPLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GL_API void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_APPLE_texture_format_BGRA8888 1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_APPLE_texture_max_level 1 -#endif - -/*------------------------------------------------------------------------* - * ARM extension functions - *------------------------------------------------------------------------*/ - -/* GL_ARM_rgba8 */ -#ifndef GL_ARM_rgba8 -#define GL_ARM_rgba8 1 -#endif - -/*------------------------------------------------------------------------* - * EXT extension functions - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_EXT_discard_framebuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif -typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif - -/* GL_EXT_multi_draw_arrays */ -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_EXT_read_format_bgra 1 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_EXT_texture_format_BGRA8888 1 -#endif - -/* GL_EXT_texture_lod_bias */ -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif - -/*------------------------------------------------------------------------* - * IMG extension functions - *------------------------------------------------------------------------*/ - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_IMG_read_format 1 -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_IMG_texture_compression_pvrtc 1 -#endif - -/* GL_IMG_texture_env_enhanced_fixed_function */ -#ifndef GL_IMG_texture_env_enhanced_fixed_function -#define GL_IMG_texture_env_enhanced_fixed_function 1 -#endif - -/* GL_IMG_user_clip_plane */ -#ifndef GL_IMG_user_clip_plane -#define GL_IMG_user_clip_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glClipPlanefIMG (GLenum, const GLfloat *); -GL_API void GL_APIENTRY glClipPlanexIMG (GLenum, const GLfixed *); -#endif -typedef void (GL_APIENTRYP PFNGLCLIPPLANEFIMGPROC) (GLenum p, const GLfloat *eqn); -typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMGPROC) (GLenum p, const GLfixed *eqn); -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_IMG_multisampled_render_to_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); -#endif - -/*------------------------------------------------------------------------* - * NV extension functions - *------------------------------------------------------------------------*/ - -/* NV_fence */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GL_API void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *); -GL_API GLboolean GL_APIENTRY glIsFenceNV (GLuint); -GL_API GLboolean GL_APIENTRY glTestFenceNV (GLuint); -GL_API void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GL_API void GL_APIENTRY glFinishFenceNV (GLuint); -GL_API void GL_APIENTRY glSetFenceNV (GLuint, GLenum); -#endif -typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -/*------------------------------------------------------------------------* - * QCOM extension functions - *------------------------------------------------------------------------*/ - -/* GL_QCOM_driver_control */ -#ifndef GL_QCOM_driver_control -#define GL_QCOM_driver_control 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); -GL_API void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); -GL_API void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); -GL_API void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); -#endif -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); -typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -#endif - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_QCOM_extended_get 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); -GL_API void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -GL_API void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -GL_API void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -GL_API void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -GL_API void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); -GL_API void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -GL_API void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params); -#endif - -/* GL_QCOM_extended_get2 */ -#ifndef GL_QCOM_extended_get2 -#define GL_QCOM_extended_get2 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); -GL_API void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -GL_API GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); -GL_API void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); -#endif - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_QCOM_perfmon_global_mode 1 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_QCOM_writeonly_rendering 1 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_QCOM_tiled_rendering 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -GL_API void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); -#endif -typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __glext_h_ */ - diff --git a/emulator/opengl/host/libs/Translator/include/GLES/glplatform.h b/emulator/opengl/host/libs/Translator/include/GLES/glplatform.h deleted file mode 100644 index 2db6ee2..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLES/glplatform.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __glplatform_h_ -#define __glplatform_h_ - -/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */ - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/* Platform-specific types and definitions for OpenGL ES 1.X gl.h - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "OpenGL-ES" component "Registry". - */ - -#include <KHR/khrplatform.h> - -#ifndef GL_API -#define GL_API KHRONOS_APICALL -#endif - -#ifndef GL_APIENTRY -#define GL_APIENTRY KHRONOS_APIENTRY -#endif - -#endif /* __glplatform_h_ */ diff --git a/emulator/opengl/host/libs/Translator/include/GLES2/gl2.h b/emulator/opengl/host/libs/Translator/include/GLES2/gl2.h deleted file mode 100644 index eae81f4..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLES2/gl2.h +++ /dev/null @@ -1,621 +0,0 @@ -#ifndef __gl2_h_ -#define __gl2_h_ - -/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ - -#include <GLES2/gl2platform.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/*------------------------------------------------------------------------- - * Data type definitions - *-----------------------------------------------------------------------*/ - -typedef void GLvoid; -typedef char GLchar; -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef khronos_int8_t GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef khronos_float_t GLfloat; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; - -/* GL types for handling large vertex buffer objects */ -typedef khronos_intptr_t GLintptr; -typedef khronos_ssize_t GLsizeiptr; - -/* OpenGL ES core versions */ -#define GL_ES_VERSION_2_0 1 - -/* ClearBufferMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 - -/* AlphaFunction (not supported in ES20) */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* BlendEquationSeparate */ -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ -#define GL_BLEND_EQUATION_ALPHA 0x883D - -/* BlendSubtract */ -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B - -/* Separate Blend Functions */ -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 - -/* Buffer Objects */ -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 - -#define GL_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 - -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 - -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 - -/* CullFaceMode */ -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* EnableCap */ -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetPName */ -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -/* GL_SCISSOR_TEST */ -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -/* GL_POLYGON_OFFSET_FILL */ -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ - -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -#define GL_GENERATE_MIPMAP_HINT 0x8192 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C - -/* PixelFormat */ -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelType */ -/* GL_UNSIGNED_BYTE */ -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 - -/* Shaders */ -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D - -/* StencilFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 - -/* TextureTarget */ -/* GL_TEXTURE_2D */ -#define GL_TEXTURE 0x1702 - -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C - -/* TextureUnit */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 - -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 - -/* Uniform Types */ -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 - -/* Vertex Arrays */ -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F - -/* Read Format */ -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B - -/* Shader Source */ -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_SHADER_COMPILER 0x8DFA - -/* Shader Binary */ -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 - -/* Shader Precision-Specified Types */ -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 - -/* Framebuffer Object. */ -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 - -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_STENCIL_INDEX 0x1901 -#define GL_STENCIL_INDEX8 0x8D48 - -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 - -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 - -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 - -#define GL_NONE 0 - -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD - -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 - -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 - -/*------------------------------------------------------------------------- - * GL core functions. - *-----------------------------------------------------------------------*/ - -GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); -GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); -GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); -GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ); -GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); -GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); -GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); -GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); -GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); -GL_APICALL void GL_APIENTRY glClearStencil (GLint s); -GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); -GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); -GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); -GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); -GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); -GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); -GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); -GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); -GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); -GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); -GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glDisable (GLenum cap); -GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); -GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); -GL_APICALL void GL_APIENTRY glEnable (GLenum cap); -GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); -GL_APICALL void GL_APIENTRY glFinish (void); -GL_APICALL void GL_APIENTRY glFlush (void); -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); -GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); -GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); -GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); -GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); -GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); -GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); -GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL GLenum GL_APIENTRY glGetError (void); -GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); -GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); -GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); -GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); -GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); -GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); -GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); -GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); -GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); -GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); -GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); -GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); -GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); -GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); -GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); -GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); -GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); -GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); -GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); -GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); -GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); -GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); -GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); -GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); -GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); -GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); -GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); -GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); -GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); -GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); -GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); -GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); -GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); -GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); -GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2_h_ */ diff --git a/emulator/opengl/host/libs/Translator/include/GLES2/gl2ext.h b/emulator/opengl/host/libs/Translator/include/GLES2/gl2ext.h deleted file mode 100644 index 46f6093..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLES2/gl2ext.h +++ /dev/null @@ -1,973 +0,0 @@ -#ifndef __gl2ext_h_ -#define __gl2ext_h_ - -/* $Revision: 13239 $ on $Date:: 2010-12-17 15:13:56 -0800 #$ */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -#ifndef GL_APIENTRYP -# define GL_APIENTRYP GL_APIENTRY* -#endif - -/*------------------------------------------------------------------------* - * OES extension tokens - *------------------------------------------------------------------------*/ - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_ETC1_RGB8_OES 0x8D64 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_DEPTH_COMPONENT24_OES 0x81A6 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_DEPTH_COMPONENT32_OES 0x81A7 -#endif - -/* GL_OES_depth_texture */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -typedef void* GLeglImageOES; -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -/* GLeglImageOES defined in GL_OES_EGL_image already. */ -#define GL_TEXTURE_EXTERNAL_OES 0x8D65 -#define GL_SAMPLER_EXTERNAL_OES 0x8D66 -#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 -#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_UNSIGNED_INT 0x1405 -#endif - -/* GL_OES_get_program_binary */ -#ifndef GL_OES_get_program_binary -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE -#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_WRITE_ONLY_OES 0x88B9 -#define GL_BUFFER_ACCESS_OES 0x88BB -#define GL_BUFFER_MAPPED_OES 0x88BC -#define GL_BUFFER_MAP_POINTER_OES 0x88BD -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_DEPTH_STENCIL_OES 0x84F9 -#define GL_UNSIGNED_INT_24_8_OES 0x84FA -#define GL_DEPTH24_STENCIL8_OES 0x88F0 -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_RGB8_OES 0x8051 -#define GL_RGBA8_OES 0x8058 -#endif - -/* GL_OES_standard_derivatives */ -#ifndef GL_OES_standard_derivatives -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_STENCIL_INDEX1_OES 0x8D46 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_STENCIL_INDEX4_OES 0x8D47 -#endif - -/* GL_OES_texture_3D */ -#ifndef GL_OES_texture_3D -#define GL_TEXTURE_WRAP_R_OES 0x8072 -#define GL_TEXTURE_3D_OES 0x806F -#define GL_TEXTURE_BINDING_3D_OES 0x806A -#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 -#define GL_SAMPLER_3D_OES 0x8B5F -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 -#endif - -/* GL_OES_texture_float */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_float_linear */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_half_float */ -#ifndef GL_OES_texture_half_float -#define GL_HALF_FLOAT_OES 0x8D61 -#endif - -/* GL_OES_texture_half_float_linear */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_npot */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 -#endif - -/* GL_OES_vertex_half_float */ -/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */ - -/* GL_OES_vertex_type_10_10_10_2 */ -#ifndef GL_OES_vertex_type_10_10_10_2 -#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 -#define GL_INT_10_10_10_2_OES 0x8DF7 -#endif - -/*------------------------------------------------------------------------* - * AMD extension tokens - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_3DC_X_AMD 0x87F9 -#define GL_3DC_XY_AMD 0x87FA -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_ATC_RGB_AMD 0x8C92 -#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE -#endif - -/* GL_AMD_performance_monitor */ -#ifndef GL_AMD_performance_monitor -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -#endif - -/* GL_AMD_program_binary_Z400 */ -#ifndef GL_AMD_program_binary_Z400 -#define GL_Z400_BINARY_AMD 0x8740 -#endif - -/*------------------------------------------------------------------------* - * ANGLE extension tokens - *------------------------------------------------------------------------*/ - -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 -#define GL_MAX_SAMPLES_ANGLE 0x8D57 -#endif - -/*------------------------------------------------------------------------* - * APPLE extension tokens - *------------------------------------------------------------------------*/ - -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 -#define GL_MAX_SAMPLES_APPLE 0x8D57 -#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D -#endif - -/*------------------------------------------------------------------------* - * ARM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_ARM_mali_shader_binary */ -#ifndef GL_ARM_mali_shader_binary -#define GL_MALI_SHADER_BINARY_ARM 0x8F60 -#endif - -/* GL_ARM_rgba8 */ -/* No new tokens introduced by this extension. */ - -/*------------------------------------------------------------------------* - * EXT extension tokens - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_COLOR_EXT 0x1800 -#define GL_DEPTH_EXT 0x1801 -#define GL_STENCIL_EXT 0x1802 -#endif - -/* GL_EXT_multi_draw_arrays */ -/* No new tokens introduced by this extension. */ - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_BGRA_EXT 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_EXT_texture_type_2_10_10_10_REV */ -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 -#endif - -/* GL_EXT_texture_compression_dxt1 */ -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#endif - -/* GL_EXT_shader_texture_lod */ -/* No new tokens introduced by this extension. */ - -/*------------------------------------------------------------------------* - * IMG extension tokens - *------------------------------------------------------------------------*/ - -/* GL_IMG_program_binary */ -#ifndef GL_IMG_program_binary -#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 -#endif - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_BGRA_IMG 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 -#endif - -/* GL_IMG_shader_binary */ -#ifndef GL_IMG_shader_binary -#define GL_SGX_BINARY_IMG 0x8C0A -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 -#define GL_MAX_SAMPLES_IMG 0x9135 -#define GL_TEXTURE_SAMPLES_IMG 0x9136 -#endif - -/*------------------------------------------------------------------------* - * NV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -/* GL_NV_coverage_sample */ -#ifndef GL_NV_coverage_sample -#define GL_COVERAGE_COMPONENT_NV 0x8ED0 -#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 -#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 -#define GL_COVERAGE_BUFFERS_NV 0x8ED3 -#define GL_COVERAGE_SAMPLES_NV 0x8ED4 -#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 -#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 -#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 -#define GL_COVERAGE_BUFFER_BIT_NV 0x8000 -#endif - -/* GL_NV_depth_nonlinear */ -#ifndef GL_NV_depth_nonlinear -#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C -#endif - -/*------------------------------------------------------------------------* - * QCOM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_QCOM_driver_control */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 -#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 -#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 -#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 -#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 -#define GL_TEXTURE_TYPE_QCOM 0x8BD7 -#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 -#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 -#define GL_TEXTURE_TARGET_QCOM 0x8BDA -#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB -#define GL_STATE_RESTORE 0x8BDC -#endif - -/* GL_QCOM_extended_get2 */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_WRITEONLY_RENDERING_QCOM 0x8823 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 -#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 -#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 -#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 -#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 -#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 -#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 -#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 -#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 -#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 -#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 -#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 -#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 -#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 -#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 -#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 -#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 -#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 -#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 -#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 -#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 -#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 -#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 -#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 -#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 -#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 -#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 -#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 -#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 -#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 -#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 -#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 -#endif - -/*------------------------------------------------------------------------* - * VIV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_VIV_shader_binary */ -#ifndef GL_VIV_shader_binary -#define GL_SHADER_BINARY_VIV 0x8FC4 -#endif - -/*------------------------------------------------------------------------* - * End of extension tokens, start of corresponding extension functions - *------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------* - * OES extension functions - *------------------------------------------------------------------------*/ - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_OES_compressed_ETC1_RGB8_texture 1 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_OES_depth24 1 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_OES_depth32 1 -#endif - -/* GL_OES_depth_texture */ -#ifndef GL_OES_depth_texture -#define GL_OES_depth_texture 1 -#endif - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -#define GL_OES_EGL_image 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); -GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); -#endif -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -#define GL_OES_EGL_image_external 1 -/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_OES_element_index_uint 1 -#endif - -/* GL_OES_fbo_render_mipmap */ -#ifndef GL_OES_fbo_render_mipmap -#define GL_OES_fbo_render_mipmap 1 -#endif - -/* GL_OES_fragment_precision_high */ -#ifndef GL_OES_fragment_precision_high -#define GL_OES_fragment_precision_high 1 -#endif - -/* GL_OES_get_program_binary */ -#ifndef GL_OES_get_program_binary -#define GL_OES_get_program_binary 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); -#endif -typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_OES_mapbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); -GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); -GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params); -#endif -typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); -typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); -typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params); -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_OES_packed_depth_stencil 1 -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_OES_rgb8_rgba8 1 -#endif - -/* GL_OES_standard_derivatives */ -#ifndef GL_OES_standard_derivatives -#define GL_OES_standard_derivatives 1 -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_OES_stencil1 1 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_OES_stencil4 1 -#endif - -/* GL_OES_texture_3D */ -#ifndef GL_OES_texture_3D -#define GL_OES_texture_3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -#endif -typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); -typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); -typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -#endif - -/* GL_OES_texture_float */ -#ifndef GL_OES_texture_float -#define GL_OES_texture_float 1 -#endif - -/* GL_OES_texture_float_linear */ -#ifndef GL_OES_texture_float_linear -#define GL_OES_texture_float_linear 1 -#endif - -/* GL_OES_texture_half_float */ -#ifndef GL_OES_texture_half_float -#define GL_OES_texture_half_float 1 -#endif - -/* GL_OES_texture_half_float_linear */ -#ifndef GL_OES_texture_half_float_linear -#define GL_OES_texture_half_float_linear 1 -#endif - -/* GL_OES_texture_npot */ -#ifndef GL_OES_texture_npot -#define GL_OES_texture_npot 1 -#endif - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_OES_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); -GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); -GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); -GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); -#endif -typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); -typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); -typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); -#endif - -/* GL_OES_vertex_half_float */ -#ifndef GL_OES_vertex_half_float -#define GL_OES_vertex_half_float 1 -#endif - -/* GL_OES_vertex_type_10_10_10_2 */ -#ifndef GL_OES_vertex_type_10_10_10_2 -#define GL_OES_vertex_type_10_10_10_2 1 -#endif - -/*------------------------------------------------------------------------* - * AMD extension functions - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_AMD_compressed_3DC_texture 1 -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_AMD_compressed_ATC_texture 1 -#endif - -/* AMD_performance_monitor */ -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); -GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); -typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif - -/* GL_AMD_program_binary_Z400 */ -#ifndef GL_AMD_program_binary_Z400 -#define GL_AMD_program_binary_Z400 1 -#endif - -/*------------------------------------------------------------------------* - * ANGLE extension functions - *------------------------------------------------------------------------*/ - -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_ANGLE_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif -typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_ANGLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -/*------------------------------------------------------------------------* - * APPLE extension functions - *------------------------------------------------------------------------*/ - -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#endif - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_APPLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_APPLE_texture_format_BGRA8888 1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_APPLE_texture_max_level 1 -#endif - -/*------------------------------------------------------------------------* - * ARM extension functions - *------------------------------------------------------------------------*/ - -/* GL_ARM_mali_shader_binary */ -#ifndef GL_ARM_mali_shader_binary -#define GL_ARM_mali_shader_binary 1 -#endif - -/* GL_ARM_rgba8 */ -#ifndef GL_ARM_rgba8 -#define GL_ARM_rgba8 1 -#endif - -/*------------------------------------------------------------------------* - * EXT extension functions - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_EXT_discard_framebuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif -typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_EXT_read_format_bgra 1 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_EXT_texture_format_BGRA8888 1 -#endif - -/* GL_EXT_texture_type_2_10_10_10_REV */ -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_EXT_texture_type_2_10_10_10_REV 1 -#endif - -/* GL_EXT_texture_compression_dxt1 */ -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_EXT_texture_compression_dxt1 1 -#endif - -/* GL_EXT_shader_texture_lod */ -#ifndef GL_EXT_shader_texture_lod -#define GL_EXT_shader_texture_lod 1 -#endif - -/*------------------------------------------------------------------------* - * IMG extension functions - *------------------------------------------------------------------------*/ - -/* GL_IMG_program_binary */ -#ifndef GL_IMG_program_binary -#define GL_IMG_program_binary 1 -#endif - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_IMG_read_format 1 -#endif - -/* GL_IMG_shader_binary */ -#ifndef GL_IMG_shader_binary -#define GL_IMG_shader_binary 1 -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_IMG_texture_compression_pvrtc 1 -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_IMG_multisampled_render_to_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); -#endif - -/*------------------------------------------------------------------------* - * NV extension functions - *------------------------------------------------------------------------*/ - -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *); -GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint); -GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint); -GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint); -GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum); -#endif -typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -/* GL_NV_coverage_sample */ -#ifndef GL_NV_coverage_sample -#define GL_NV_coverage_sample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); -GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); -#endif -typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); -typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); -#endif - -/* GL_NV_depth_nonlinear */ -#ifndef GL_NV_depth_nonlinear -#define GL_NV_depth_nonlinear 1 -#endif - -/*------------------------------------------------------------------------* - * QCOM extension functions - *------------------------------------------------------------------------*/ - -/* GL_QCOM_driver_control */ -#ifndef GL_QCOM_driver_control -#define GL_QCOM_driver_control 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); -GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); -GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); -GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); -#endif -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); -typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -#endif - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_QCOM_extended_get 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); -GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params); -#endif - -/* GL_QCOM_extended_get2 */ -#ifndef GL_QCOM_extended_get2 -#define GL_QCOM_extended_get2 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); -GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); -GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); -#endif - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_QCOM_perfmon_global_mode 1 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_QCOM_writeonly_rendering 1 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_QCOM_tiled_rendering 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); -#endif -typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); -#endif - -/*------------------------------------------------------------------------* - * VIV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_VIV_shader_binary */ -#ifndef GL_VIV_shader_binary -#define GL_VIV_shader_binary 1 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2ext_h_ */ diff --git a/emulator/opengl/host/libs/Translator/include/GLES2/gl2platform.h b/emulator/opengl/host/libs/Translator/include/GLES2/gl2platform.h deleted file mode 100644 index c9fa3c4..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLES2/gl2platform.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __gl2platform_h_ -#define __gl2platform_h_ - -/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "OpenGL-ES" component "Registry". - */ - -#include <KHR/khrplatform.h> - -#ifndef GL_APICALL -#define GL_APICALL KHRONOS_APICALL -#endif - -#ifndef GL_APIENTRY -#define GL_APIENTRY KHRONOS_APIENTRY -#endif - -#endif /* __gl2platform_h_ */ diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/FramebufferData.h b/emulator/opengl/host/libs/Translator/include/GLcommon/FramebufferData.h deleted file mode 100644 index 46cb651..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/FramebufferData.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h deleted file mode 100644 index 6eda55b..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h +++ /dev/null @@ -1,267 +0,0 @@ -/* -* 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 GLDISPATCHH -#define GLDISPATCHH - -#include <GLES/gl.h> -#include <GLES2/gl2.h> -#include "emugl/common/mutex.h" -#include "gldefs.h" -#include "GLutils.h" - -#define GLAPIENTRY GL_APIENTRY -typedef void(*FUNCPTR)(); - -class GLDispatch -{ -public: - - GLDispatch(); - void dispatchFuncs(GLESVersion version); - - /* OpenGL functions which are needed for implementing BOTH GLES 1.1 & GLES 2.0*/ - static void (GLAPIENTRY *glActiveTexture) ( GLenum texture ); - static void (GLAPIENTRY *glBindBuffer) (GLenum target, GLuint buffer); - static void (GLAPIENTRY *glBindTexture) (GLenum target, GLuint texture); - static void (GLAPIENTRY *glBlendFunc) (GLenum sfactor, GLenum dfactor); - static void (GLAPIENTRY *glBlendEquation)( GLenum mode ); - static void (GLAPIENTRY *glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); - static void (GLAPIENTRY *glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); - static void (GLAPIENTRY *glBufferData) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); - static void (GLAPIENTRY *glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); - static void (GLAPIENTRY *glClear) (GLbitfield mask); - static void (GLAPIENTRY *glClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - static void (GLAPIENTRY *glClearStencil) (GLint s); - static void (GLAPIENTRY *glColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); - static void (GLAPIENTRY *glCompressedTexImage2D) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); - static void (GLAPIENTRY *glCompressedTexSubImage2D) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); - static void (GLAPIENTRY *glCopyTexImage2D) (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); - static void (GLAPIENTRY *glCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); - static void (GLAPIENTRY *glCullFace) (GLenum mode); - static void (GLAPIENTRY *glDeleteBuffers) (GLsizei n, const GLuint *buffers); - static void (GLAPIENTRY *glDeleteTextures) (GLsizei n, const GLuint *textures); - static void (GLAPIENTRY *glDepthFunc) (GLenum func); - static void (GLAPIENTRY *glDepthMask) (GLboolean flag); - static void (GLAPIENTRY *glDepthRange) (GLclampd zNear, GLclampd zFar); - static void (GLAPIENTRY *glDisable) (GLenum cap); - static void (GLAPIENTRY *glDrawArrays) (GLenum mode, GLint first, GLsizei count); - static void (GLAPIENTRY *glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); - static void (GLAPIENTRY *glEnable) (GLenum cap); - static void (GLAPIENTRY *glFinish) (void); - static void (GLAPIENTRY *glFlush) (void); - static void (GLAPIENTRY *glFrontFace) (GLenum mode); - static void (GLAPIENTRY *glGenBuffers) (GLsizei n, GLuint *buffers); - static void (GLAPIENTRY *glGenTextures) (GLsizei n, GLuint *textures); - static void (GLAPIENTRY *glGetBooleanv) (GLenum pname, GLboolean *params); - static void (GLAPIENTRY *glGetBufferParameteriv) (GLenum, GLenum, GLint *); - static GLenum (GLAPIENTRY *glGetError) (void); - static void (GLAPIENTRY *glGetFloatv) (GLenum pname, GLfloat *params); - static void (GLAPIENTRY *glGetIntegerv) (GLenum pname, GLint *params); - static const GLubyte * (GLAPIENTRY *glGetString) (GLenum name); - static void (GLAPIENTRY *glGetTexParameterfv) (GLenum target, GLenum pname, GLfloat *params); - static void (GLAPIENTRY *glGetTexParameteriv) (GLenum target, GLenum pname, GLint *params); - static void (GLAPIENTRY *glGetTexLevelParameteriv) (GLenum target, GLint level, GLenum pname, GLint *params); - static void (GLAPIENTRY *glHint) (GLenum target, GLenum mode); - static GLboolean (GLAPIENTRY *glIsBuffer) (GLuint); - static GLboolean (GLAPIENTRY *glIsEnabled) (GLenum cap); - static GLboolean (GLAPIENTRY *glIsTexture) (GLuint texture); - static void (GLAPIENTRY *glLineWidth) (GLfloat width); - static void (GLAPIENTRY *glPolygonOffset) (GLfloat factor, GLfloat units); - static void (GLAPIENTRY *glPixelStorei) (GLenum pname, GLint param); - static void (GLAPIENTRY *glReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); - static void (GLAPIENTRY *glSampleCoverage) ( GLclampf value, GLboolean invert ); - static void (GLAPIENTRY *glScissor) (GLint x, GLint y, GLsizei width, GLsizei height); - static void (GLAPIENTRY *glStencilFunc) (GLenum func, GLint ref, GLuint mask); - static void (GLAPIENTRY *glStencilMask) (GLuint mask); - static void (GLAPIENTRY *glStencilOp) (GLenum fail, GLenum zfail, GLenum zpass); - static void (GLAPIENTRY *glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); - static void (GLAPIENTRY *glTexParameteri) (GLenum target, GLenum pname, GLint param); - static void (GLAPIENTRY *glTexParameteriv) (GLenum target, GLenum pname, const GLint *params); - static void (GLAPIENTRY *glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); - static void (GLAPIENTRY *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height); - static void (GLAPIENTRY *glPushAttrib) ( GLbitfield mask ); - static void (GLAPIENTRY *glPopAttrib) ( void ); - static void (GLAPIENTRY *glPushClientAttrib) ( GLbitfield mask ); - static void (GLAPIENTRY *glPopClientAttrib) ( void ); - static GLboolean (GLAPIENTRY *glIsRenderbufferEXT) (GLuint renderbuffer); - static void (GLAPIENTRY *glBindRenderbufferEXT) (GLenum target, GLuint renderbuffer); - static void (GLAPIENTRY *glDeleteRenderbuffersEXT) (GLsizei n, const GLuint *renderbuffers); - static void (GLAPIENTRY *glGenRenderbuffersEXT) (GLsizei n, GLuint *renderbuffers); - static void (GLAPIENTRY *glRenderbufferStorageEXT) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - static void (GLAPIENTRY *glGetRenderbufferParameterivEXT) (GLenum target, GLenum pname, GLint *params); - static GLboolean (GLAPIENTRY *glIsFramebufferEXT) (GLuint framebuffer); - static void (GLAPIENTRY *glBindFramebufferEXT) (GLenum target, GLuint framebuffer); - static void (GLAPIENTRY *glDeleteFramebuffersEXT) (GLsizei n, const GLuint *framebuffers); - static void (GLAPIENTRY *glGenFramebuffersEXT) (GLsizei n, GLuint *framebuffers); - static GLenum (GLAPIENTRY *glCheckFramebufferStatusEXT) (GLenum target); - static void (GLAPIENTRY *glFramebufferTexture1DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - static void (GLAPIENTRY *glFramebufferTexture2DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - static void (GLAPIENTRY *glFramebufferTexture3DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); - static void (GLAPIENTRY *glFramebufferRenderbufferEXT) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); - static void (GLAPIENTRY *glGetFramebufferAttachmentParameterivEXT) (GLenum target, GLenum attachment, GLenum pname, GLint *params); - static void (GLAPIENTRY *glGenerateMipmapEXT) (GLenum target); - - /* OpenGL functions which are needed ONLY for implementing GLES 1.1*/ - static void (GLAPIENTRY *glAlphaFunc) (GLenum func, GLclampf ref); - static void (GLAPIENTRY *glBegin)( GLenum mode ); - static void (GLAPIENTRY *glClearDepth) (GLclampd depth); - static void (GLAPIENTRY *glClientActiveTexture) ( GLenum texture ); - static void (GLAPIENTRY *glClipPlane) (GLenum plane, const GLdouble *equation); - static void (GLAPIENTRY *glColor4d) (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); - static void (GLAPIENTRY *glColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); - static void (GLAPIENTRY *glColor4fv) ( const GLfloat *v ); - static void (GLAPIENTRY *glColor4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); - static void (GLAPIENTRY *glColor4ubv) ( const GLubyte *v ); - static void (GLAPIENTRY *glColorPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - static void (GLAPIENTRY *glDisableClientState) (GLenum array); - static void (GLAPIENTRY *glEnableClientState) (GLenum array); - static void (GLAPIENTRY *glEnd) (void); - static void (GLAPIENTRY *glFogf) (GLenum pname, GLfloat param); - static void (GLAPIENTRY *glFogfv) (GLenum pname, const GLfloat *params); - static void (GLAPIENTRY *glFrustum) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); - static void (GLAPIENTRY *glGetClipPlane) (GLenum plane, GLdouble *equation); - static void (GLAPIENTRY *glGetDoublev) ( GLenum pname, GLdouble *params ); - static void (GLAPIENTRY *glGetLightfv) (GLenum light, GLenum pname, GLfloat *params); - static void (GLAPIENTRY *glGetMaterialfv) (GLenum face, GLenum pname, GLfloat *params); - static void (GLAPIENTRY *glGetPointerv) (GLenum pname, GLvoid* *params); - static void (GLAPIENTRY *glGetTexEnvfv) (GLenum target, GLenum pname, GLfloat *params); - static void (GLAPIENTRY *glGetTexEnviv) (GLenum target, GLenum pname, GLint *params); - static void (GLAPIENTRY *glLightf) (GLenum light, GLenum pname, GLfloat param); - static void (GLAPIENTRY *glLightfv) (GLenum light, GLenum pname, const GLfloat *params); - static void (GLAPIENTRY *glLightModelf) (GLenum pname, GLfloat param); - static void (GLAPIENTRY *glLightModelfv) (GLenum pname, const GLfloat *params); - static void (GLAPIENTRY *glLoadIdentity) (void); - static void (GLAPIENTRY *glLoadMatrixf) (const GLfloat *m); - static void (GLAPIENTRY *glLogicOp) (GLenum opcode); - static void (GLAPIENTRY *glMaterialf) (GLenum face, GLenum pname, GLfloat param); - static void (GLAPIENTRY *glMaterialfv) (GLenum face, GLenum pname, const GLfloat *params); - static void (GLAPIENTRY *glMultiTexCoord2fv) ( GLenum target, const GLfloat *v ); - static void (GLAPIENTRY *glMultiTexCoord2sv) ( GLenum target, const GLshort *v ); - static void (GLAPIENTRY *glMultiTexCoord3fv) ( GLenum target, const GLfloat *v ); - static void (GLAPIENTRY *glMultiTexCoord3sv) ( GLenum target, const GLshort *v ); - static void (GLAPIENTRY *glMultiTexCoord4f) ( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); - static void (GLAPIENTRY *glMultiTexCoord4fv) ( GLenum target, const GLfloat *v ); - static void (GLAPIENTRY *glMultiTexCoord4sv) ( GLenum target, const GLshort *v ); - static void (GLAPIENTRY *glMultMatrixf) (const GLfloat *m); - static void (GLAPIENTRY *glNormal3f) (GLfloat nx, GLfloat ny, GLfloat nz); - static void (GLAPIENTRY *glNormal3fv) ( const GLfloat *v ); - static void (GLAPIENTRY *glNormal3sv) ( const GLshort *v ); - static void (GLAPIENTRY *glOrtho) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); - static void (GLAPIENTRY *glPointParameterf) (GLenum, GLfloat); - static void (GLAPIENTRY *glPointParameterfv) (GLenum, const GLfloat *); - static void (GLAPIENTRY *glPointSize) (GLfloat size); - static void (GLAPIENTRY *glRotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); - static void (GLAPIENTRY *glScalef) (GLfloat x, GLfloat y, GLfloat z); - static void (GLAPIENTRY *glTexEnvf) (GLenum target, GLenum pname, GLfloat param); - static void (GLAPIENTRY *glTexEnvfv) (GLenum target, GLenum pname, const GLfloat *params); - static void (GLAPIENTRY *glTexParameterf) (GLenum target, GLenum pname, GLfloat param); - static void (GLAPIENTRY *glTexParameterfv) (GLenum target, GLenum pname, const GLfloat *params); - static void (GLAPIENTRY *glMatrixMode) (GLenum mode); - static void (GLAPIENTRY *glNormalPointer) (GLenum type, GLsizei stride, const GLvoid *pointer); - static void (GLAPIENTRY *glPopMatrix) (void); - static void (GLAPIENTRY *glPushMatrix) (void); - static void (GLAPIENTRY *glShadeModel) (GLenum mode); - static void (GLAPIENTRY *glTexCoordPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - static void (GLAPIENTRY *glTexEnvi) (GLenum target, GLenum pname, GLint param); - static void (GLAPIENTRY *glTexEnviv) (GLenum target, GLenum pname, const GLint *params); - static void (GLAPIENTRY *glTranslatef) (GLfloat x, GLfloat y, GLfloat z); - static void (GLAPIENTRY *glVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - - /* OpenGL functions which are needed ONLY for implementing GLES 1.1 EXTENSIONS*/ - static void (GLAPIENTRY *glCurrentPaletteMatrixARB) (GLint index); - static void (GLAPIENTRY *glMatrixIndexuivARB) (GLint size, GLuint * indices); - static void (GLAPIENTRY *glMatrixIndexPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); - static void (GLAPIENTRY *glWeightPointerARB) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); - static void (GLAPIENTRY *glTexGenf) (GLenum coord, GLenum pname, GLfloat param ); - static void (GLAPIENTRY *glTexGeni) (GLenum coord, GLenum pname, GLint param ); - static void (GLAPIENTRY *glTexGenfv) (GLenum coord, GLenum pname, const GLfloat *params ); - static void (GLAPIENTRY *glTexGeniv) (GLenum coord, GLenum pname, const GLint *params ); - static void (GLAPIENTRY *glGetTexGenfv) (GLenum coord, GLenum pname, GLfloat *params ); - static void (GLAPIENTRY *glGetTexGeniv) (GLenum coord, GLenum pname, GLint *params ); - - /* Loading OpenGL functions which are needed ONLY for implementing GLES 2.0*/ - static void (GL_APIENTRY *glBlendColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - static void (GL_APIENTRY *glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask); - static void (GL_APIENTRY *glStencilMaskSeparate)(GLenum face, GLuint mask); - static GLboolean (GL_APIENTRY *glIsProgram)(GLuint program); - static GLboolean (GL_APIENTRY *glIsShader)(GLuint shader); - static void (GL_APIENTRY *glVertexAttrib1f)(GLuint indx, GLfloat x); - static void (GL_APIENTRY *glVertexAttrib1fv)(GLuint indx, const GLfloat* values); - static void (GL_APIENTRY *glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y); - static void (GL_APIENTRY *glVertexAttrib2fv)(GLuint indx, const GLfloat* values); - static void (GL_APIENTRY *glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z); - static void (GL_APIENTRY *glVertexAttrib3fv)(GLuint indx, const GLfloat* values); - static void (GL_APIENTRY *glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - static void (GL_APIENTRY *glVertexAttrib4fv)(GLuint indx, const GLfloat* values); - static void (GL_APIENTRY *glVertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); - static void (GL_APIENTRY *glDisableVertexAttribArray)(GLuint index); - static void (GL_APIENTRY *glEnableVertexAttribArray)(GLuint index); - static void (GL_APIENTRY *glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params); - static void (GL_APIENTRY *glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* params); - static void (GL_APIENTRY *glGetVertexAttribPointerv)(GLuint index, GLenum pname, GLvoid** pointer); - static void (GL_APIENTRY *glUniform1f)(GLint location, GLfloat x); - static void (GL_APIENTRY *glUniform1fv)(GLint location, GLsizei count, const GLfloat* v); - static void (GL_APIENTRY *glUniform1i)(GLint location, GLint x); - static void (GL_APIENTRY *glUniform1iv)(GLint location, GLsizei count, const GLint* v); - static void (GL_APIENTRY *glUniform2f)(GLint location, GLfloat x, GLfloat y); - static void (GL_APIENTRY *glUniform2fv)(GLint location, GLsizei count, const GLfloat* v); - static void (GL_APIENTRY *glUniform2i)(GLint location, GLint x, GLint y); - static void (GL_APIENTRY *glUniform2iv)(GLint location, GLsizei count, const GLint* v); - static void (GL_APIENTRY *glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z); - static void (GL_APIENTRY *glUniform3fv)(GLint location, GLsizei count, const GLfloat* v); - static void (GL_APIENTRY *glUniform3i)(GLint location, GLint x, GLint y, GLint z); - static void (GL_APIENTRY *glUniform3iv)(GLint location, GLsizei count, const GLint* v); - static void (GL_APIENTRY *glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - static void (GL_APIENTRY *glUniform4fv)(GLint location, GLsizei count, const GLfloat* v); - static void (GL_APIENTRY *glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w); - static void (GL_APIENTRY *glUniform4iv)(GLint location, GLsizei count, const GLint* v); - static void (GL_APIENTRY *glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - static void (GL_APIENTRY *glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - static void (GL_APIENTRY *glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - static void (GL_APIENTRY *glAttachShader)(GLuint program, GLuint shader); - static void (GL_APIENTRY *glBindAttribLocation)(GLuint program, GLuint index, const GLchar* name); - static void (GL_APIENTRY *glCompileShader)(GLuint shader); - static GLuint (GL_APIENTRY *glCreateProgram)(void); - static GLuint (GL_APIENTRY *glCreateShader)(GLenum type); - static void (GL_APIENTRY *glDeleteProgram)(GLuint program); - static void (GL_APIENTRY *glDeleteShader)(GLuint shader); - static void (GL_APIENTRY *glDetachShader)(GLuint program, GLuint shader); - static void (GL_APIENTRY *glLinkProgram)(GLuint program); - static void (GL_APIENTRY *glUseProgram)(GLuint program); - static void (GL_APIENTRY *glValidateProgram)(GLuint program); - static void (GL_APIENTRY *glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); - static void (GL_APIENTRY *glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); - static void (GL_APIENTRY *glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); - static int (GL_APIENTRY *glGetAttribLocation)(GLuint program, const GLchar* name); - static void (GL_APIENTRY *glGetProgramiv)(GLuint program, GLenum pname, GLint* params); - static void (GL_APIENTRY *glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); - static void (GL_APIENTRY *glGetShaderiv)(GLuint shader, GLenum pname, GLint* params); - static void (GL_APIENTRY *glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); - static void (GL_APIENTRY *glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); - static void (GL_APIENTRY *glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); - static void (GL_APIENTRY *glGetUniformfv)(GLuint program, GLint location, GLfloat* params); - static void (GL_APIENTRY *glGetUniformiv)(GLuint program, GLint location, GLint* params); - static int (GL_APIENTRY *glGetUniformLocation)(GLuint program, const GLchar* name); - static void (GL_APIENTRY *glReleaseShaderCompiler)(void); - static void (GL_APIENTRY *glShaderBinary)(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); - static void (GL_APIENTRY *glShaderSource)(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); - -private: - bool m_isLoaded; - static emugl::Mutex s_lock; -}; - -#endif diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h deleted file mode 100644 index 38429d1..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h deleted file mode 100644 index 5aed0ad..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h +++ /dev/null @@ -1,218 +0,0 @@ -/* -* 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) , \ - 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) {} ; - int maxLights; - int maxVertexAttribs; - int maxClipPlane; - int maxTexUnits; - int maxTexImageUnits; - int maxTexSize; - 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; - -}; - -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(); - 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 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 - diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h deleted file mode 100644 index 95ffadb..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef GLES_MACROS_H -#define GLES_MACROS_H - -#define GET_CTX() \ - if(!s_eglIface) return; \ - GLEScontext *ctx = s_eglIface->getGLESContext(); \ - -#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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h deleted file mode 100644 index 851fe45..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESpointer.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h deleted file mode 100644 index 92c1f33..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLconversion_macros.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLconversion_macros.h deleted file mode 100644 index 83e99b4..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLconversion_macros.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h deleted file mode 100644 index 974b9be..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* 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> - -typedef enum { - GLES_1_1 = 1, - GLES_2_0 = 2, - MAX_GLES_VERSION //Must be last -} GLESVersion; - -template <class T> -void swap(T& x,T& y) { - T temp; - temp = x; - x = y; - y = temp; -} - -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) { - // 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)); - return (unsigned int)(uintptr_t)(ptr); -} - -#endif diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/PaletteTexture.h b/emulator/opengl/host/libs/Translator/include/GLcommon/PaletteTexture.h deleted file mode 100644 index 90b206d..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/PaletteTexture.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/RangeManip.h b/emulator/opengl/host/libs/Translator/include/GLcommon/RangeManip.h deleted file mode 100644 index e3162b8..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/RangeManip.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/TextureUtils.h b/emulator/opengl/host/libs/Translator/include/GLcommon/TextureUtils.h deleted file mode 100644 index 9b0c4ea..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/TextureUtils.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h b/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h deleted file mode 100644 index e0d1bfb..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -* 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 <GLES/gl.h> -#include <string.h> -#include "objectNameManager.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 { - GLEScontext* (*createGLESContext)(); - void (*initContext)(GLEScontext*,ShareGroupPtr); - void (*deleteGLESContext)(GLEScontext*); - void (*flush)(); - void (*finish)(); - void (*setShareGroup)(GLEScontext*,ShareGroupPtr); - __translatorMustCastToProperFunctionPointerType (*getProcAddress)(const char*); -}GLESiface; - - -typedef struct { - GLEScontext* (*getGLESContext)(); - EglImage* (*eglAttachEGLImage)(unsigned int imageId); - void (*eglDetachEGLImage)(unsigned int imageId); -}EGLiface; - -typedef GLESiface* (*__translator_getGLESIfaceFunc)(EGLiface*); - -} -#endif diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/etc1.h b/emulator/opengl/host/libs/Translator/include/GLcommon/etc1.h deleted file mode 100644 index 15ee9ac..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/etc1.h +++ /dev/null @@ -1,108 +0,0 @@ -// 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 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h b/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h deleted file mode 100644 index 1f0c7ef..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/gldefs.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* 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. -*/ - -typedef double GLclampd; /* double precision float in [0,1] */ -typedef double GLdouble; /* double precision float */ - -#define GL_S 0x2000 -#define GL_T 0x2001 -#define GL_R 0x2002 -#define GL_Q 0x2003 -#define GL_TEXTURE_GEN_S 0x0C60 -#define GL_TEXTURE_GEN_T 0x0C61 -#define GL_TEXTURE_GEN_R 0x0C62 -#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 -#define GL_TRANSFORM_BIT 0x00001000 -#define GL_INT 0x1404 -#define GL_HALF_FLOAT_NV 0x140B -#define GL_HALF_FLOAT 0x140B -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_POINT_SPRITE 0x8861 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h b/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h deleted file mode 100644 index 4d4d038..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h +++ /dev/null @@ -1,269 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h b/emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h deleted file mode 100644 index c9e6f17..0000000 --- a/emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h +++ /dev/null @@ -1,282 +0,0 @@ -#ifndef __khrplatform_h_ -#define __khrplatform_h_ - -/* -** Copyright (c) 2008-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Khronos platform-specific types and definitions. - * - * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ - * - * Adopters may modify this file to suit their platform. Adopters are - * encouraged to submit platform specific modifications to the Khronos - * group so that they can be included in future versions of this file. - * Please submit changes by sending them to the public Khronos Bugzilla - * (http://khronos.org/bugzilla) by filing a bug against product - * "Khronos (general)" component "Registry". - * - * A predefined template which fills in some of the bug fields can be - * reached using http://tinyurl.com/khrplatform-h-bugreport, but you - * must create a Bugzilla login first. - * - * - * See the Implementer's Guidelines for information about where this file - * should be located on your system and for more details of its use: - * http://www.khronos.org/registry/implementers_guide.pdf - * - * This file should be included as - * #include <KHR/khrplatform.h> - * by Khronos client API header files that use its types and defines. - * - * The types in khrplatform.h should only be used to define API-specific types. - * - * Types defined in khrplatform.h: - * khronos_int8_t signed 8 bit - * khronos_uint8_t unsigned 8 bit - * khronos_int16_t signed 16 bit - * khronos_uint16_t unsigned 16 bit - * khronos_int32_t signed 32 bit - * khronos_uint32_t unsigned 32 bit - * khronos_int64_t signed 64 bit - * khronos_uint64_t unsigned 64 bit - * khronos_intptr_t signed same number of bits as a pointer - * khronos_uintptr_t unsigned same number of bits as a pointer - * khronos_ssize_t signed size - * khronos_usize_t unsigned size - * khronos_float_t signed 32 bit floating point - * khronos_time_ns_t unsigned 64 bit time in nanoseconds - * khronos_utime_nanoseconds_t unsigned time interval or absolute time in - * nanoseconds - * khronos_stime_nanoseconds_t signed time interval in nanoseconds - * khronos_boolean_enum_t enumerated boolean type. This should - * only be used as a base type when a client API's boolean type is - * an enum. Client APIs which use an integer or other type for - * booleans cannot use this as the base type for their boolean. - * - * Tokens defined in khrplatform.h: - * - * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. - * - * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. - * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. - * - * Calling convention macros defined in this file: - * KHRONOS_APICALL - * KHRONOS_APIENTRY - * KHRONOS_APIATTRIBUTES - * - * These may be used in function prototypes as: - * - * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( - * int arg1, - * int arg2) KHRONOS_APIATTRIBUTES; - */ - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APICALL - *------------------------------------------------------------------------- - * This precedes the return type of the function in the function prototype. - */ -#if defined(_WIN32) && !defined(__SCITECH_SNAP__) -# define KHRONOS_APICALL __declspec(dllimport) -#elif defined (__SYMBIAN32__) -# define KHRONOS_APICALL IMPORT_C -#else -# define KHRONOS_APICALL -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIENTRY - *------------------------------------------------------------------------- - * This follows the return type of the function and precedes the function - * name in the function prototype. - */ -#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) - /* Win32 but not WinCE */ -# define KHRONOS_APIENTRY __stdcall -#else -# define KHRONOS_APIENTRY -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIATTRIBUTES - *------------------------------------------------------------------------- - * This follows the closing parenthesis of the function prototype arguments. - */ -#if defined (__ARMCC_2__) -#define KHRONOS_APIATTRIBUTES __softfp -#else -#define KHRONOS_APIATTRIBUTES -#endif - -/*------------------------------------------------------------------------- - * basic type definitions - *-----------------------------------------------------------------------*/ -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) - - -/* - * Using <stdint.h> - */ -#include <stdint.h> -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__VMS ) || defined(__sgi) - -/* - * Using <inttypes.h> - */ -#include <inttypes.h> -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) - -/* - * Win32 - */ -typedef __int32 khronos_int32_t; -typedef unsigned __int32 khronos_uint32_t; -typedef __int64 khronos_int64_t; -typedef unsigned __int64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__sun__) || defined(__digital__) - -/* - * Sun or Digital - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; -#else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; -#endif /* __arch64__ */ -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif 0 - -/* - * Hypothetical platform with no float or int64 support - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#define KHRONOS_SUPPORT_INT64 0 -#define KHRONOS_SUPPORT_FLOAT 0 - -#else - -/* - * Generic fallback - */ -#include <stdint.h> -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#endif - - -/* - * Types that are (so far) the same on all platforms - */ -typedef signed char khronos_int8_t; -typedef unsigned char khronos_uint8_t; -typedef signed short int khronos_int16_t; -typedef unsigned short int khronos_uint16_t; - -/* - * Types that differ between LLP64 and LP64 architectures - in LLP64, - * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears - * to be the only LLP64 architecture in current use. - */ -#ifdef _WIN64 -typedef signed long long int khronos_intptr_t; -typedef unsigned long long int khronos_uintptr_t; -typedef signed long long int khronos_ssize_t; -typedef unsigned long long int khronos_usize_t; -#else -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; -#endif - -#if KHRONOS_SUPPORT_FLOAT -/* - * Float type - */ -typedef float khronos_float_t; -#endif - -#if KHRONOS_SUPPORT_INT64 -/* Time types - * - * These types can be used to represent a time interval in nanoseconds or - * an absolute Unadjusted System Time. Unadjusted System Time is the number - * of nanoseconds since some arbitrary system event (e.g. since the last - * time the system booted). The Unadjusted System Time is an unsigned - * 64 bit value that wraps back to 0 every 584 years. Time intervals - * may be either signed or unsigned. - */ -typedef khronos_uint64_t khronos_utime_nanoseconds_t; -typedef khronos_int64_t khronos_stime_nanoseconds_t; -#endif - -/* - * Dummy value used to pad enum types to 32 bits. - */ -#ifndef KHRONOS_MAX_ENUM -#define KHRONOS_MAX_ENUM 0x7FFFFFFF -#endif - -/* - * Enumerated boolean type - * - * Values other than zero should be considered to be true. Therefore - * comparisons should not be made against KHRONOS_TRUE. - */ -typedef enum { - KHRONOS_FALSE = 0, - KHRONOS_TRUE = 1, - KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM -} khronos_boolean_enum_t; - -#endif /* __khrplatform_h_ */ diff --git a/emulator/opengl/host/libs/libOpenglRender/Android.mk b/emulator/opengl/host/libs/libOpenglRender/Android.mk deleted file mode 100644 index 20567f0..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/Android.mk +++ /dev/null @@ -1,82 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -host_OS_SRCS := -host_common_LDLIBS := - -ifeq ($(HOST_OS),linux) - host_OS_SRCS = NativeLinuxSubWindow.cpp - host_common_LDLIBS += -lX11 -lrt -endif - -ifeq ($(HOST_OS),darwin) - host_OS_SRCS = NativeMacSubWindow.m - host_common_LDLIBS += -Wl,-framework,AppKit -endif - -ifeq ($(HOST_OS),windows) - host_OS_SRCS = NativeWindowsSubWindow.cpp -endif - -host_common_SRC_FILES := \ - $(host_OS_SRCS) \ - render_api.cpp \ - ColorBuffer.cpp \ - EGLDispatch.cpp \ - FBConfig.cpp \ - FrameBuffer.cpp \ - GLDispatch.cpp \ - GL2Dispatch.cpp \ - RenderContext.cpp \ - WindowSurface.cpp \ - RenderControl.cpp \ - ThreadInfo.cpp \ - RenderThread.cpp \ - ReadBuffer.cpp \ - RenderServer.cpp - -host_common_CFLAGS := - -#For gl debbuging -#host_common_CFLAGS += -DCHECK_GL_ERROR - - -### host libOpenglRender ################################################# -$(call emugl-begin-host-shared-library,libOpenglRender) - -$(call emugl-import,libGLESv1_dec libGLESv2_dec lib_renderControl_dec libOpenglCodecCommon) - -LOCAL_LDLIBS += $(host_common_LDLIBS) - -LOCAL_SRC_FILES := $(host_common_SRC_FILES) -$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include) -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) - -# use Translator's egl/gles headers -LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include - -LOCAL_STATIC_LIBRARIES += libemugl_common - -$(call emugl-export,CFLAGS,$(host_common_CFLAGS)) - -$(call emugl-end-module) - - -### host libOpenglRender, 64-bit ######################################### -$(call emugl-begin-host64-shared-library,lib64OpenglRender) - -$(call emugl-import,lib64GLESv1_dec lib64GLESv2_dec lib64_renderControl_dec lib64OpenglCodecCommon) - -LOCAL_LDLIBS += $(host_common_LDLIBS) - -LOCAL_SRC_FILES := $(host_common_SRC_FILES) -$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include) -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) - -# use Translator's egl/gles headers -LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include - -LOCAL_STATIC_LIBRARIES += lib64emugl_common - -$(call emugl-export,CFLAGS,$(host_common_CFLAGS)) - -$(call emugl-end-module) diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp deleted file mode 100644 index e612294..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/* -* 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. -*/ -#include "ColorBuffer.h" -#include "FrameBuffer.h" -#include "EGLDispatch.h" -#include "GLDispatch.h" -#include "ThreadInfo.h" -#include "GLcommon/GLutils.h" -#ifdef WITH_GLES2 -#include "GL2Dispatch.h" -#endif -#include <stdio.h> - -ColorBuffer *ColorBuffer::create(int p_width, int p_height, - GLenum p_internalFormat) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - - GLenum texInternalFormat = 0; - - switch(p_internalFormat) { - case GL_RGB: - case GL_RGB565_OES: - texInternalFormat = GL_RGB; - break; - - case GL_RGBA: - case GL_RGB5_A1_OES: - case GL_RGBA4_OES: - texInternalFormat = GL_RGBA; - break; - - default: - return NULL; - break; - } - - if (!fb->bind_locked()) { - return NULL; - } - - ColorBuffer *cb = new ColorBuffer(); - - - s_gl.glGenTextures(1, &cb->m_tex); - s_gl.glBindTexture(GL_TEXTURE_2D, cb->m_tex); - int nComp = (texInternalFormat == GL_RGB ? 3 : 4); - char *zBuff = new char[nComp*p_width*p_height]; - if (zBuff) { - memset(zBuff, 0, nComp*p_width*p_height); - } - s_gl.glTexImage2D(GL_TEXTURE_2D, 0, texInternalFormat, - p_width, p_height, 0, - texInternalFormat, - GL_UNSIGNED_BYTE, zBuff); - delete [] zBuff; - s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - s_gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - // - // create another texture for that colorbuffer for blit - // - s_gl.glGenTextures(1, &cb->m_blitTex); - s_gl.glBindTexture(GL_TEXTURE_2D, cb->m_blitTex); - s_gl.glTexImage2D(GL_TEXTURE_2D, 0, texInternalFormat, - p_width, p_height, 0, - texInternalFormat, - GL_UNSIGNED_BYTE, NULL); - s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - s_gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - cb->m_width = p_width; - cb->m_height = p_height; - cb->m_internalFormat = texInternalFormat; - - if (fb->getCaps().has_eglimage_texture_2d) { - cb->m_eglImage = s_egl.eglCreateImageKHR( - fb->getDisplay(), - s_egl.eglGetCurrentContext(), - EGL_GL_TEXTURE_2D_KHR, - (EGLClientBuffer)SafePointerFromUInt(cb->m_tex), - NULL); - - cb->m_blitEGLImage = s_egl.eglCreateImageKHR( - fb->getDisplay(), - s_egl.eglGetCurrentContext(), - EGL_GL_TEXTURE_2D_KHR, - (EGLClientBuffer)SafePointerFromUInt(cb->m_blitTex), - NULL); - } - - fb->unbind_locked(); - return cb; -} - -ColorBuffer::ColorBuffer() : - m_tex(0), - m_blitTex(0), - m_eglImage(NULL), - m_blitEGLImage(NULL), - m_fbo(0), - m_internalFormat(0) -{ -} - -ColorBuffer::~ColorBuffer() -{ - FrameBuffer *fb = FrameBuffer::getFB(); - fb->bind_locked(); - - if (m_blitEGLImage) { - s_egl.eglDestroyImageKHR(fb->getDisplay(), m_blitEGLImage); - } - if (m_eglImage) { - s_egl.eglDestroyImageKHR(fb->getDisplay(), m_eglImage); - } - - if (m_fbo) { - s_gl.glDeleteFramebuffersOES(1, &m_fbo); - } - - GLuint tex[2] = {m_tex, m_blitTex}; - s_gl.glDeleteTextures(2, tex); - - fb->unbind_locked(); -} - -void ColorBuffer::subUpdate(int x, int y, int width, int height, GLenum p_format, GLenum p_type, void *pixels) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb->bind_locked()) return; - s_gl.glBindTexture(GL_TEXTURE_2D, m_tex); - s_gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - s_gl.glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, - width, height, p_format, p_type, pixels); - fb->unbind_locked(); -} - -bool ColorBuffer::blitFromCurrentReadBuffer() -{ - RenderThreadInfo *tInfo = RenderThreadInfo::get(); - if (!tInfo->currContext.Ptr()) { - // no Current context - return false; - } - - // - // Create a temporary texture inside the current context - // from the blit_texture EGLImage and copy the pixels - // from the current read buffer to that texture - // - GLuint tmpTex; - GLint currTexBind; - if (tInfo->currContext->isGL2()) { - s_gl2.glGetIntegerv(GL_TEXTURE_BINDING_2D, &currTexBind); - s_gl2.glGenTextures(1,&tmpTex); - s_gl2.glBindTexture(GL_TEXTURE_2D, tmpTex); - s_gl2.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_blitEGLImage); - s_gl2.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, - m_width, m_height); - } - else { - s_gl.glGetIntegerv(GL_TEXTURE_BINDING_2D, &currTexBind); - s_gl.glGenTextures(1,&tmpTex); - s_gl.glBindTexture(GL_TEXTURE_2D, tmpTex); - s_gl.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_blitEGLImage); - s_gl.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, - m_width, m_height); - } - - - // - // Now bind the frame buffer context and blit from - // m_blitTex into m_tex - // - FrameBuffer *fb = FrameBuffer::getFB(); - if (fb->bind_locked()) { - - // - // bind FBO object which has this colorbuffer as render target - // - if (bind_fbo()) { - - // - // save current viewport and match it to the current - // colorbuffer size - // - GLint vport[4] = {}; - s_gl.glGetIntegerv(GL_VIEWPORT, vport); - s_gl.glViewport(0, 0, m_width, m_height); - - // render m_blitTex - s_gl.glBindTexture(GL_TEXTURE_2D, m_blitTex); - s_gl.glEnable(GL_TEXTURE_2D); - s_gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - drawTexQuad(); // this will render the texture flipped - - // unbind the fbo - s_gl.glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); - - // restrore previous viewport - s_gl.glViewport(vport[0], vport[1], vport[2], vport[3]); - } - - // unbind from the FrameBuffer context - fb->unbind_locked(); - } - - // - // delete the temporary texture and restore the texture binding - // inside the current context - // - if (tInfo->currContext->isGL2()) { - s_gl2.glDeleteTextures(1, &tmpTex); - s_gl2.glBindTexture(GL_TEXTURE_2D, currTexBind); - } - else { - s_gl.glDeleteTextures(1, &tmpTex); - s_gl.glBindTexture(GL_TEXTURE_2D, currTexBind); - } - - return true; -} - -bool ColorBuffer::bindToTexture() -{ - if (m_eglImage) { - RenderThreadInfo *tInfo = RenderThreadInfo::get(); - if (tInfo->currContext.Ptr()) { -#ifdef WITH_GLES2 - if (tInfo->currContext->isGL2()) { - s_gl2.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_eglImage); - } - else { - s_gl.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_eglImage); - } -#else - s_gl.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_eglImage); -#endif - return true; - } - } - return false; -} - -bool ColorBuffer::bindToRenderbuffer() -{ - if (m_eglImage) { - RenderThreadInfo *tInfo = RenderThreadInfo::get(); - if (tInfo->currContext.Ptr()) { -#ifdef WITH_GLES2 - if (tInfo->currContext->isGL2()) { - s_gl2.glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER_OES, m_eglImage); - } - else { - s_gl.glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER_OES, m_eglImage); - } -#else - s_gl.glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER_OES, m_eglImage); -#endif - return true; - } - } - return false; -} - -bool ColorBuffer::bind_fbo() -{ - if (m_fbo) { - // fbo already exist - just bind - s_gl.glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_fbo); - return true; - } - - s_gl.glGenFramebuffersOES(1, &m_fbo); - s_gl.glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_fbo); - s_gl.glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, - GL_COLOR_ATTACHMENT0_OES, - GL_TEXTURE_2D, m_tex, 0); - GLenum status = s_gl.glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES); - if (status != GL_FRAMEBUFFER_COMPLETE_OES) { - ERR("ColorBuffer::bind_fbo: FBO not complete: %#x\n", status); - s_gl.glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); - s_gl.glDeleteFramebuffersOES(1, &m_fbo); - m_fbo = 0; - return false; - } - - return true; -} - -bool ColorBuffer::post() -{ - s_gl.glBindTexture(GL_TEXTURE_2D, m_tex); - s_gl.glEnable(GL_TEXTURE_2D); - s_gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - drawTexQuad(); - - return true; -} - -void ColorBuffer::drawTexQuad() -{ - GLfloat verts[] = { -1.0f, -1.0f, 0.0f, - -1.0f, +1.0f, 0.0f, - +1.0f, -1.0f, 0.0f, - +1.0f, +1.0f, 0.0f }; - - GLfloat tcoords[] = { 0.0f, 1.0f, - 0.0f, 0.0f, - 1.0f, 1.0f, - 1.0f, 0.0f }; - - s_gl.glClientActiveTexture(GL_TEXTURE0); - s_gl.glEnableClientState(GL_TEXTURE_COORD_ARRAY); - s_gl.glTexCoordPointer(2, GL_FLOAT, 0, tcoords); - - s_gl.glEnableClientState(GL_VERTEX_ARRAY); - s_gl.glVertexPointer(3, GL_FLOAT, 0, verts); - s_gl.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); -} - -void ColorBuffer::readback(unsigned char* img) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (fb->bind_locked()) { - if (bind_fbo()) { - s_gl.glReadPixels(0, 0, m_width, m_height, - GL_RGBA, GL_UNSIGNED_BYTE, img); - } - fb->unbind_locked(); - } -} diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h deleted file mode 100644 index 9a919c3..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* 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 _LIBRENDER_COLORBUFFER_H -#define _LIBRENDER_COLORBUFFER_H - -#include <EGL/egl.h> -#include <EGL/eglext.h> -#include <GLES/gl.h> -#include "emugl/common/smart_ptr.h" - -class ColorBuffer -{ -public: - static ColorBuffer *create(int p_width, int p_height, - GLenum p_internalFormat); - ~ColorBuffer(); - - GLuint getGLTextureName() const { return m_tex; } - GLuint getWidth() const { return m_width; } - GLuint getHeight() const { return m_height; } - - void subUpdate(int x, int y, int width, int height, GLenum p_format, GLenum p_type, void *pixels); - bool post(); - bool bindToTexture(); - bool bindToRenderbuffer(); - bool blitFromCurrentReadBuffer(); - void readback(unsigned char* img); - -private: - ColorBuffer(); - void drawTexQuad(); - bool bind_fbo(); // binds a fbo which have this texture as render target - -private: - GLuint m_tex; - GLuint m_blitTex; - EGLImageKHR m_eglImage; - EGLImageKHR m_blitEGLImage; - GLuint m_width; - GLuint m_height; - GLuint m_fbo; - GLenum m_internalFormat; -}; - -typedef emugl::SmartPtr<ColorBuffer> ColorBufferPtr; - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/EGLDispatch.cpp b/emulator/opengl/host/libs/libOpenglRender/EGLDispatch.cpp deleted file mode 100644 index 7d514e8..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/EGLDispatch.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -* 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. -*/ -#include "EGLDispatch.h" -#include <stdio.h> -#include <stdlib.h> - -#include "emugl/common/shared_library.h" - -EGLDispatch s_egl; - -#define DEFAULT_EGL_LIB EMUGL_LIBNAME("EGL_translator") - -bool init_egl_dispatch() -{ - - const char *libName = getenv("ANDROID_EGL_LIB"); - if (!libName) libName = DEFAULT_EGL_LIB; - - emugl::SharedLibrary *lib = emugl::SharedLibrary::open(libName); - if (!lib) { - printf("Failed to open %s\n", libName); - return NULL; - } - s_egl.eglGetError = (eglGetError_t) lib->findSymbol("eglGetError"); - s_egl.eglGetDisplay = (eglGetDisplay_t) lib->findSymbol("eglGetDisplay"); - s_egl.eglInitialize = (eglInitialize_t) lib->findSymbol("eglInitialize"); - s_egl.eglTerminate = (eglTerminate_t) lib->findSymbol("eglTerminate"); - s_egl.eglQueryString = (eglQueryString_t) lib->findSymbol("eglQueryString"); - s_egl.eglGetConfigs = (eglGetConfigs_t) lib->findSymbol("eglGetConfigs"); - s_egl.eglChooseConfig = (eglChooseConfig_t) lib->findSymbol("eglChooseConfig"); - s_egl.eglGetConfigAttrib = (eglGetConfigAttrib_t) lib->findSymbol("eglGetConfigAttrib"); - s_egl.eglCreateWindowSurface = (eglCreateWindowSurface_t) lib->findSymbol("eglCreateWindowSurface"); - s_egl.eglCreatePbufferSurface = (eglCreatePbufferSurface_t) lib->findSymbol("eglCreatePbufferSurface"); - s_egl.eglCreatePixmapSurface = (eglCreatePixmapSurface_t) lib->findSymbol("eglCreatePixmapSurface"); - s_egl.eglDestroySurface = (eglDestroySurface_t) lib->findSymbol("eglDestroySurface"); - s_egl.eglQuerySurface = (eglQuerySurface_t) lib->findSymbol("eglQuerySurface"); - s_egl.eglBindAPI = (eglBindAPI_t) lib->findSymbol("eglBindAPI"); - s_egl.eglQueryAPI = (eglQueryAPI_t) lib->findSymbol("eglQueryAPI"); - s_egl.eglWaitClient = (eglWaitClient_t) lib->findSymbol("eglWaitClient"); - s_egl.eglReleaseThread = (eglReleaseThread_t) lib->findSymbol("eglReleaseThread"); - s_egl.eglCreatePbufferFromClientBuffer = (eglCreatePbufferFromClientBuffer_t) lib->findSymbol("eglCreatePbufferFromClientBuffer"); - s_egl.eglSurfaceAttrib = (eglSurfaceAttrib_t) lib->findSymbol("eglSurfaceAttrib"); - s_egl.eglBindTexImage = (eglBindTexImage_t) lib->findSymbol("eglBindTexImage"); - s_egl.eglReleaseTexImage = (eglReleaseTexImage_t) lib->findSymbol("eglReleaseTexImage"); - s_egl.eglSwapInterval = (eglSwapInterval_t) lib->findSymbol("eglSwapInterval"); - s_egl.eglCreateContext = (eglCreateContext_t) lib->findSymbol("eglCreateContext"); - s_egl.eglDestroyContext = (eglDestroyContext_t) lib->findSymbol("eglDestroyContext"); - s_egl.eglMakeCurrent = (eglMakeCurrent_t) lib->findSymbol("eglMakeCurrent"); - s_egl.eglGetCurrentContext = (eglGetCurrentContext_t) lib->findSymbol("eglGetCurrentContext"); - s_egl.eglGetCurrentSurface = (eglGetCurrentSurface_t) lib->findSymbol("eglGetCurrentSurface"); - s_egl.eglGetCurrentDisplay = (eglGetCurrentDisplay_t) lib->findSymbol("eglGetCurrentDisplay"); - s_egl.eglQueryContext = (eglQueryContext_t) lib->findSymbol("eglQueryContext"); - s_egl.eglWaitGL = (eglWaitGL_t) lib->findSymbol("eglWaitGL"); - s_egl.eglWaitNative = (eglWaitNative_t) lib->findSymbol("eglWaitNative"); - s_egl.eglSwapBuffers = (eglSwapBuffers_t) lib->findSymbol("eglSwapBuffers"); - s_egl.eglCopyBuffers = (eglCopyBuffers_t) lib->findSymbol("eglCopyBuffers"); - s_egl.eglGetProcAddress = (eglGetProcAddress_t) lib->findSymbol("eglGetProcAddress"); - -#define INIT_EGL_EXT_FUNC(name) \ - if (s_egl.eglGetProcAddress) s_egl.name = (name ## _t) s_egl.eglGetProcAddress(#name); \ - if (!s_egl.name || !s_egl.eglGetProcAddress) s_egl.name = (name ## _t) lib->findSymbol(#name) - - INIT_EGL_EXT_FUNC(eglLockSurfaceKHR); - INIT_EGL_EXT_FUNC(eglUnlockSurfaceKHR); - INIT_EGL_EXT_FUNC(eglCreateImageKHR); - INIT_EGL_EXT_FUNC(eglDestroyImageKHR); - INIT_EGL_EXT_FUNC(eglCreateSyncKHR); - INIT_EGL_EXT_FUNC(eglDestroySyncKHR); - INIT_EGL_EXT_FUNC(eglClientWaitSyncKHR); - INIT_EGL_EXT_FUNC(eglSignalSyncKHR); - INIT_EGL_EXT_FUNC(eglGetSyncAttribKHR); - INIT_EGL_EXT_FUNC(eglSetSwapRectangleANDROID); - - return true; -} diff --git a/emulator/opengl/host/libs/libOpenglRender/EGLDispatch.h b/emulator/opengl/host/libs/libOpenglRender/EGLDispatch.h deleted file mode 100644 index f74acba..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/EGLDispatch.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -* 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 _EGL_DISPATCH_H -#define _EGL_DISPATCH_H - -#include "egl_proc.h" - -struct EGLDispatch { - eglGetError_t eglGetError; - eglGetDisplay_t eglGetDisplay; - eglInitialize_t eglInitialize; - eglTerminate_t eglTerminate; - eglQueryString_t eglQueryString; - eglGetConfigs_t eglGetConfigs; - eglChooseConfig_t eglChooseConfig; - eglGetConfigAttrib_t eglGetConfigAttrib; - eglCreateWindowSurface_t eglCreateWindowSurface; - eglCreatePbufferSurface_t eglCreatePbufferSurface; - eglCreatePixmapSurface_t eglCreatePixmapSurface; - eglDestroySurface_t eglDestroySurface; - eglQuerySurface_t eglQuerySurface; - eglBindAPI_t eglBindAPI; - eglQueryAPI_t eglQueryAPI; - eglWaitClient_t eglWaitClient; - eglReleaseThread_t eglReleaseThread; - eglCreatePbufferFromClientBuffer_t eglCreatePbufferFromClientBuffer; - eglSurfaceAttrib_t eglSurfaceAttrib; - eglBindTexImage_t eglBindTexImage; - eglReleaseTexImage_t eglReleaseTexImage; - eglSwapInterval_t eglSwapInterval; - eglCreateContext_t eglCreateContext; - eglDestroyContext_t eglDestroyContext; - eglMakeCurrent_t eglMakeCurrent; - eglGetCurrentContext_t eglGetCurrentContext; - eglGetCurrentSurface_t eglGetCurrentSurface; - eglGetCurrentDisplay_t eglGetCurrentDisplay; - eglQueryContext_t eglQueryContext; - eglWaitGL_t eglWaitGL; - eglWaitNative_t eglWaitNative; - eglSwapBuffers_t eglSwapBuffers; - eglCopyBuffers_t eglCopyBuffers; - eglGetProcAddress_t eglGetProcAddress; - eglLockSurfaceKHR_t eglLockSurfaceKHR; - eglUnlockSurfaceKHR_t eglUnlockSurfaceKHR; - eglCreateImageKHR_t eglCreateImageKHR; - eglDestroyImageKHR_t eglDestroyImageKHR; - eglCreateSyncKHR_t eglCreateSyncKHR; - eglDestroySyncKHR_t eglDestroySyncKHR; - eglClientWaitSyncKHR_t eglClientWaitSyncKHR; - eglSignalSyncKHR_t eglSignalSyncKHR; - eglGetSyncAttribKHR_t eglGetSyncAttribKHR; - eglSetSwapRectangleANDROID_t eglSetSwapRectangleANDROID; -}; - -bool init_egl_dispatch(); - -extern EGLDispatch s_egl; - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp b/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp deleted file mode 100644 index 08c71e8..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* -* 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. -*/ -#include "FBConfig.h" -#include "FrameBuffer.h" -#include "EGLDispatch.h" -#include <stdio.h> - -FBConfig **FBConfig::s_fbConfigs = NULL; -int FBConfig::s_numConfigs = 0; - -const GLuint FBConfig::s_configAttribs[] = { - EGL_DEPTH_SIZE, // must be first - see getDepthSize() - EGL_STENCIL_SIZE, // must be second - see getStencilSize() - EGL_RENDERABLE_TYPE,// must be third - see getRenderableType() - EGL_SURFACE_TYPE, // must be fourth - see getSurfaceType() - EGL_CONFIG_ID, // must be fifth - see chooseConfig() - EGL_BUFFER_SIZE, - EGL_ALPHA_SIZE, - EGL_BLUE_SIZE, - EGL_GREEN_SIZE, - EGL_RED_SIZE, - EGL_CONFIG_CAVEAT, - EGL_LEVEL, - EGL_MAX_PBUFFER_HEIGHT, - EGL_MAX_PBUFFER_PIXELS, - EGL_MAX_PBUFFER_WIDTH, - EGL_NATIVE_RENDERABLE, - EGL_NATIVE_VISUAL_ID, - EGL_NATIVE_VISUAL_TYPE, - EGL_SAMPLES, - EGL_SAMPLE_BUFFERS, - EGL_TRANSPARENT_TYPE, - EGL_TRANSPARENT_BLUE_VALUE, - EGL_TRANSPARENT_GREEN_VALUE, - EGL_TRANSPARENT_RED_VALUE, - EGL_BIND_TO_TEXTURE_RGB, - EGL_BIND_TO_TEXTURE_RGBA, - EGL_MIN_SWAP_INTERVAL, - EGL_MAX_SWAP_INTERVAL, - EGL_LUMINANCE_SIZE, - EGL_ALPHA_MASK_SIZE, - EGL_COLOR_BUFFER_TYPE, - //EGL_MATCH_NATIVE_PIXMAP, - EGL_CONFORMANT -}; - -const int FBConfig::s_numConfigAttribs = sizeof(FBConfig::s_configAttribs) / sizeof(GLuint); - -InitConfigStatus FBConfig::initConfigList(FrameBuffer *fb) -{ - InitConfigStatus ret = INIT_CONFIG_FAILED; - - if (!fb) { - return ret; - } - - EGLDisplay dpy = fb->getDisplay(); - - if (dpy == EGL_NO_DISPLAY) { - fprintf(stderr,"Could not get EGL Display\n"); - return ret; - } - - // - // Query the set of configs in the EGL backend - // - EGLint nConfigs; - if (!s_egl.eglGetConfigs(dpy, NULL, 0, &nConfigs)) { - fprintf(stderr, "Could not get number of available configs\n"); - return ret; - } - EGLConfig *configs = new EGLConfig[nConfigs]; - s_egl.eglGetConfigs(dpy, configs, nConfigs, &nConfigs); - - // - // copy the config attributes, filter out - // configs we do not want to support. - // - int j = 0; - s_fbConfigs = new FBConfig*[nConfigs]; - for (int i=0; i<nConfigs; i++) { - - // - // filter out configs which does not support pbuffers. - // we only support pbuffer configs since we use a pbuffer - // handle to bind a guest created window object. - // - EGLint surfaceType; - s_egl.eglGetConfigAttrib(dpy, configs[i], - EGL_SURFACE_TYPE, &surfaceType); - if (!(surfaceType & EGL_PBUFFER_BIT)) continue; - - // - // Filter out not RGB configs - // - EGLint redSize, greenSize, blueSize; - s_egl.eglGetConfigAttrib(dpy, configs[i], EGL_RED_SIZE, &redSize); - s_egl.eglGetConfigAttrib(dpy, configs[i], EGL_BLUE_SIZE, &blueSize); - s_egl.eglGetConfigAttrib(dpy, configs[i], EGL_GREEN_SIZE, &greenSize); - if (redSize==0 || greenSize==0 || blueSize==0) continue; - - s_fbConfigs[j++] = new FBConfig(dpy, configs[i]); - } - s_numConfigs = j; - - delete[] configs; - - return s_numConfigs > 0 ? INIT_CONFIG_PASSED : INIT_CONFIG_FAILED; -} - -const FBConfig *FBConfig::get(int p_config) -{ - if (p_config >= 0 && p_config < s_numConfigs) { - return s_fbConfigs[p_config]; - } - return NULL; -} - -int FBConfig::getNumConfigs() -{ - return s_numConfigs; -} - -void FBConfig::packConfigsInfo(GLuint *buffer) -{ - memcpy(buffer, s_configAttribs, s_numConfigAttribs * sizeof(GLuint)); - for (int i=0; i<s_numConfigs; i++) { - memcpy(buffer+(i+1)*s_numConfigAttribs, - s_fbConfigs[i]->m_attribValues, - s_numConfigAttribs * sizeof(GLuint)); - } -} - -int FBConfig::chooseConfig(FrameBuffer *fb, EGLint * attribs, uint32_t * configs, uint32_t configs_size) -{ - EGLDisplay dpy = fb->getDisplay(); - int ret = 0; - - if (dpy == EGL_NO_DISPLAY) { - fprintf(stderr,"Could not get EGL Display\n"); - return ret; - } - // - // Query the num of configs in the EGL backend - // - EGLint nConfigs; - if (!s_egl.eglGetConfigs(dpy, NULL, 0, &nConfigs)) { - fprintf(stderr, "Could not get number of available configs\n"); - return ret; - } - // - // Query the max matching configs in the backend - // - EGLConfig *matchedConfigs = new EGLConfig[nConfigs]; - - // - //Until we have EGLImage implementation, we force pbuf configs - // - bool needToAddPbufAttr = true; - int attribCnt = 0; - EGLint * attrib_p = attribs; - if (attribs) { - while (attrib_p[0] != EGL_NONE) { - if (attrib_p[0] == EGL_SURFACE_TYPE) { - attrib_p[1] = EGL_PBUFFER_BIT; //replace whatever was there before - needToAddPbufAttr = false; - } - attrib_p += 2; - attribCnt += 2; - } - } - EGLint * newAttribs = new EGLint[attribCnt + 1 + ((needToAddPbufAttr) ? 2 : 0)]; - attrib_p = newAttribs; - if (needToAddPbufAttr) { - *(attrib_p++) = EGL_SURFACE_TYPE; - *(attrib_p++) = EGL_PBUFFER_BIT; - } - memcpy(attrib_p, attribs, attribCnt*sizeof(EGLint)); - attrib_p += attribCnt; - *attrib_p = EGL_NONE; - -#if 0 - if (newAttribs) { - EGLint * attrib_p = newAttribs; - while (attrib_p[0] != EGL_NONE) { - DBG("attr: 0x%x %d, ", attrib_p[0], attrib_p[1]); - attrib_p += 2; - } - } -#endif - - if (!s_egl.eglChooseConfig(dpy, newAttribs, matchedConfigs, nConfigs, &nConfigs)) { - nConfigs = 0; - } - - delete[] newAttribs; - - // - // From all matchedConfigs we need only config_size FBConfigs, so we intersect both lists compating the CONFIG_ID attribute - // - uint32_t nVerifiedCfgs = 0; - for (int matchedIdx=0; matchedIdx<nConfigs; matchedIdx++) { - if ((configs != NULL) && (configs_size > 0) && (nVerifiedCfgs >= configs_size)) break; //We have enouhgt configs - int sCfgId; - s_egl.eglGetConfigAttrib(dpy, matchedConfigs[matchedIdx], EGL_CONFIG_ID, &sCfgId); - for (int fbIdx=0; fbIdx<s_numConfigs; fbIdx++) { - int dCfgId = s_fbConfigs[fbIdx]->m_attribValues[4]; //CONFIG_ID - if (sCfgId == dCfgId) { - //This config matches the requested attributes and filtered into fbConfigs, so we're happy with it - if (configs && nVerifiedCfgs < configs_size) { - configs[nVerifiedCfgs] = fbIdx; - } - nVerifiedCfgs++; - break; - } - } - } - - delete[] matchedConfigs; - - return nVerifiedCfgs; -} - -FBConfig::FBConfig(EGLDisplay p_eglDpy, EGLConfig p_eglCfg) -{ - m_eglConfig = p_eglCfg; - m_attribValues = new GLint[s_numConfigAttribs]; - for (int i=0; i<s_numConfigAttribs; i++) { - m_attribValues[i] = 0; - s_egl.eglGetConfigAttrib(p_eglDpy, p_eglCfg, s_configAttribs[i], &m_attribValues[i]); - - // - // All exported configs supports android native window rendering - // - if (s_configAttribs[i] == EGL_SURFACE_TYPE) { - m_attribValues[i] |= EGL_WINDOW_BIT; - } - } -} - -FBConfig::~FBConfig() -{ - if (m_attribValues) { - delete[] m_attribValues; - } -} diff --git a/emulator/opengl/host/libs/libOpenglRender/FBConfig.h b/emulator/opengl/host/libs/libOpenglRender/FBConfig.h deleted file mode 100644 index 6388549..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/FBConfig.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* 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 _LIBRENDER_FBCONFIG_H -#define _LIBRENDER_FBCONFIG_H - -#include <EGL/egl.h> -#include <GLES/gl.h> - -class FrameBuffer; - -enum InitConfigStatus { - INIT_CONFIG_FAILED = 0, - INIT_CONFIG_PASSED = 1 -}; - -class FBConfig -{ -public: - static InitConfigStatus initConfigList(FrameBuffer *fb); - static const FBConfig *get(int p_config); - static int getNumConfigs(); - static int getNumAttribs() { return s_numConfigAttribs; } - static void packConfigsInfo(GLuint *buffer); - static int chooseConfig(FrameBuffer *fb, EGLint * attribs, uint32_t * configs, uint32_t configs_size); - ~FBConfig(); - - EGLConfig getEGLConfig() const { return m_eglConfig; } - GLuint getDepthSize() const { return (m_attribValues ? m_attribValues[0] : 0); } - GLuint getStencilSize() const { return (m_attribValues ? m_attribValues[1] : 0); } - GLuint getRenderableType() const { return (m_attribValues ? m_attribValues[2] : 0); } - GLuint getSurfaceType() const { return (m_attribValues ? m_attribValues[3] : 0); } - -private: - FBConfig(EGLDisplay p_eglDpy, EGLConfig p_eglCfg); - -private: - static FBConfig **s_fbConfigs; - static int s_numConfigs; - static const int s_numConfigAttribs; - static const GLuint s_configAttribs[]; - -private: - EGLConfig m_eglConfig; - GLint *m_attribValues; -}; - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp deleted file mode 100644 index e7a7960..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp +++ /dev/null @@ -1,897 +0,0 @@ -/* -* 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. -*/ - -#include "FrameBuffer.h" -#include "NativeSubWindow.h" -#include "FBConfig.h" -#include "EGLDispatch.h" -#include "GLDispatch.h" -#include "GL2Dispatch.h" -#include "ThreadInfo.h" -#include "TimeUtils.h" -#include <stdio.h> - -FrameBuffer *FrameBuffer::s_theFrameBuffer = NULL; -HandleType FrameBuffer::s_nextHandle = 0; - -#ifdef WITH_GLES2 -static char* getGLES2ExtensionString(EGLDisplay p_dpy) -{ - EGLConfig config; - EGLSurface surface; - - GLint configAttribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_NONE - }; - - int n; - if (!s_egl.eglChooseConfig(p_dpy, configAttribs, - &config, 1, &n)) { - return NULL; - } - - EGLint pbufAttribs[] = { - EGL_WIDTH, 1, - EGL_HEIGHT, 1, - EGL_NONE - }; - - surface = s_egl.eglCreatePbufferSurface(p_dpy, config, pbufAttribs); - if (surface == EGL_NO_SURFACE) { - return NULL; - } - - GLint gl2ContextAttribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - - EGLContext ctx = s_egl.eglCreateContext(p_dpy, config, - EGL_NO_CONTEXT, - gl2ContextAttribs); - if (ctx == EGL_NO_CONTEXT) { - s_egl.eglDestroySurface(p_dpy, surface); - return NULL; - } - - if (!s_egl.eglMakeCurrent(p_dpy, surface, surface, ctx)) { - s_egl.eglDestroySurface(p_dpy, surface); - s_egl.eglDestroyContext(p_dpy, ctx); - return NULL; - } - - // the string pointer may become invalid when the context is destroyed - const char* s = (const char*)s_gl2.glGetString(GL_EXTENSIONS); - char* extString = strdup(s ? s : ""); - - s_egl.eglMakeCurrent(p_dpy, NULL, NULL, NULL); - s_egl.eglDestroyContext(p_dpy, ctx); - s_egl.eglDestroySurface(p_dpy, surface); - - return extString; -} -#endif - -void FrameBuffer::finalize(){ - if(s_theFrameBuffer){ - s_theFrameBuffer->removeSubWindow(); - s_theFrameBuffer->m_colorbuffers.clear(); - s_theFrameBuffer->m_windows.clear(); - s_theFrameBuffer->m_contexts.clear(); - s_egl.eglMakeCurrent(s_theFrameBuffer->m_eglDisplay, NULL, NULL, NULL); - s_egl.eglDestroyContext(s_theFrameBuffer->m_eglDisplay,s_theFrameBuffer->m_eglContext); - s_egl.eglDestroyContext(s_theFrameBuffer->m_eglDisplay,s_theFrameBuffer->m_pbufContext); - s_egl.eglDestroySurface(s_theFrameBuffer->m_eglDisplay,s_theFrameBuffer->m_pbufSurface); - s_theFrameBuffer = NULL; - } -} - -bool FrameBuffer::initialize(int width, int height) -{ - if (s_theFrameBuffer != NULL) { - return true; - } - - // - // allocate space for the FrameBuffer object - // - FrameBuffer *fb = new FrameBuffer(width, height); - if (!fb) { - ERR("Failed to create fb\n"); - return false; - } - -#ifdef WITH_GLES2 - // - // Try to load GLES2 Plugin, not mandatory - // - if (getenv("ANDROID_NO_GLES2")) { - fb->m_caps.hasGL2 = false; - } - else { - fb->m_caps.hasGL2 = s_gl2_enabled; - } -#else - fb->m_caps.hasGL2 = false; -#endif - - // - // Initialize backend EGL display - // - fb->m_eglDisplay = s_egl.eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (fb->m_eglDisplay == EGL_NO_DISPLAY) { - ERR("Failed to Initialize backend EGL display\n"); - delete fb; - return false; - } - - if (!s_egl.eglInitialize(fb->m_eglDisplay, &fb->m_caps.eglMajor, &fb->m_caps.eglMinor)) { - ERR("Failed to eglInitialize\n"); - delete fb; - return false; - } - - DBG("egl: %d %d\n", fb->m_caps.eglMajor, fb->m_caps.eglMinor); - s_egl.eglBindAPI(EGL_OPENGL_ES_API); - - // - // if GLES2 plugin has loaded - try to make GLES2 context and - // get GLES2 extension string - // - char* gl2Extensions = NULL; -#ifdef WITH_GLES2 - if (fb->m_caps.hasGL2) { - gl2Extensions = getGLES2ExtensionString(fb->m_eglDisplay); - if (!gl2Extensions) { - // Could not create GLES2 context - drop GL2 capability - fb->m_caps.hasGL2 = false; - } - } -#endif - - // - // Create EGL context for framebuffer post rendering. - // -#if 0 - GLint configAttribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, - EGL_NONE - }; -#else - GLint configAttribs[] = { - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, - EGL_NONE - }; -#endif - - int n; - if (!s_egl.eglChooseConfig(fb->m_eglDisplay, configAttribs, - &fb->m_eglConfig, 1, &n)) { - ERR("Failed on eglChooseConfig\n"); - free(gl2Extensions); - delete fb; - return false; - } - - GLint glContextAttribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 1, - EGL_NONE - }; - - fb->m_eglContext = s_egl.eglCreateContext(fb->m_eglDisplay, fb->m_eglConfig, - EGL_NO_CONTEXT, - glContextAttribs); - if (fb->m_eglContext == EGL_NO_CONTEXT) { - printf("Failed to create Context 0x%x\n", s_egl.eglGetError()); - free(gl2Extensions); - delete fb; - return false; - } - - // - // Create another context which shares with the eglContext to be used - // when we bind the pbuffer. That prevent switching drawable binding - // back and forth on framebuffer context. - // The main purpose of it is to solve a "blanking" behaviour we see on - // on Mac platform when switching binded drawable for a context however - // it is more efficient on other platforms as well. - // - fb->m_pbufContext = s_egl.eglCreateContext(fb->m_eglDisplay, fb->m_eglConfig, - fb->m_eglContext, - glContextAttribs); - if (fb->m_pbufContext == EGL_NO_CONTEXT) { - printf("Failed to create Pbuffer Context 0x%x\n", s_egl.eglGetError()); - free(gl2Extensions); - delete fb; - return false; - } - - // - // create a 1x1 pbuffer surface which will be used for binding - // the FB context. - // The FB output will go to a subwindow, if one exist. - // - EGLint pbufAttribs[] = { - EGL_WIDTH, 1, - EGL_HEIGHT, 1, - EGL_NONE - }; - - fb->m_pbufSurface = s_egl.eglCreatePbufferSurface(fb->m_eglDisplay, - fb->m_eglConfig, - pbufAttribs); - if (fb->m_pbufSurface == EGL_NO_SURFACE) { - printf("Failed to create pbuf surface for FB 0x%x\n", s_egl.eglGetError()); - free(gl2Extensions); - delete fb; - return false; - } - - // Make the context current - if (!fb->bind_locked()) { - ERR("Failed to make current\n"); - free(gl2Extensions); - delete fb; - return false; - } - - // - // Initilize framebuffer capabilities - // - const char *glExtensions = (const char *)s_gl.glGetString(GL_EXTENSIONS); - bool has_gl_oes_image = false; - if (glExtensions) { - has_gl_oes_image = strstr(glExtensions, "GL_OES_EGL_image") != NULL; - } - - if (fb->m_caps.hasGL2 && has_gl_oes_image) { - has_gl_oes_image &= strstr(gl2Extensions, "GL_OES_EGL_image") != NULL; - } - free(gl2Extensions); - gl2Extensions = NULL; - - const char *eglExtensions = s_egl.eglQueryString(fb->m_eglDisplay, - EGL_EXTENSIONS); - - if (eglExtensions && has_gl_oes_image) { - fb->m_caps.has_eglimage_texture_2d = - strstr(eglExtensions, "EGL_KHR_gl_texture_2D_image") != NULL; - fb->m_caps.has_eglimage_renderbuffer = - strstr(eglExtensions, "EGL_KHR_gl_renderbuffer_image") != NULL; - } - else { - fb->m_caps.has_eglimage_texture_2d = false; - fb->m_caps.has_eglimage_renderbuffer = false; - } - - // - // Fail initialization if not all of the following extensions - // exist: - // EGL_KHR_gl_texture_2d_image - // GL_OES_EGL_IMAGE (by both GLES implementations [1 and 2]) - // - if (!fb->m_caps.has_eglimage_texture_2d) { - ERR("Failed: Missing egl_image related extension(s)\n"); - delete fb; - return false; - } - - // - // Initialize set of configs - // - InitConfigStatus configStatus = FBConfig::initConfigList(fb); - if (configStatus == INIT_CONFIG_FAILED) { - ERR("Failed: Initialize set of configs\n"); - delete fb; - return false; - } - - // - // Check that we have config for each GLES and GLES2 - // - int nConfigs = FBConfig::getNumConfigs(); - int nGLConfigs = 0; - int nGL2Configs = 0; - for (int i=0; i<nConfigs; i++) { - GLint rtype = FBConfig::get(i)->getRenderableType(); - if (0 != (rtype & EGL_OPENGL_ES_BIT)) { - nGLConfigs++; - } - if (0 != (rtype & EGL_OPENGL_ES2_BIT)) { - nGL2Configs++; - } - } - - // - // Fail initialization if no GLES configs exist - // - if (nGLConfigs == 0) { - delete fb; - return false; - } - - // - // If no GLES2 configs exist - not GLES2 capability - // - if (nGL2Configs == 0) { - fb->m_caps.hasGL2 = false; - } - - // - // Initialize some GL state in the pbuffer context - // - fb->initGLState(); - - // - // Cache the GL strings so we don't have to think about threading or - // current-context when asked for them. - // - fb->m_glVendor = (const char*)s_gl.glGetString(GL_VENDOR); - fb->m_glRenderer = (const char*)s_gl.glGetString(GL_RENDERER); - fb->m_glVersion = (const char*)s_gl.glGetString(GL_VERSION); - - // release the FB context - fb->unbind_locked(); - - // - // Keep the singleton framebuffer pointer - // - s_theFrameBuffer = fb; - return true; -} - -FrameBuffer::FrameBuffer(int p_width, int p_height) : - m_width(p_width), - m_height(p_height), - m_eglDisplay(EGL_NO_DISPLAY), - m_eglSurface(EGL_NO_SURFACE), - m_eglContext(EGL_NO_CONTEXT), - m_pbufContext(EGL_NO_CONTEXT), - m_prevContext(EGL_NO_CONTEXT), - m_prevReadSurf(EGL_NO_SURFACE), - m_prevDrawSurf(EGL_NO_SURFACE), - m_subWin((EGLNativeWindowType)0), - m_subWinDisplay(NULL), - m_lastPostedColorBuffer(0), - m_zRot(0.0f), - m_eglContextInitialized(false), - m_statsNumFrames(0), - m_statsStartTime(0LL), - m_onPost(NULL), - m_onPostContext(NULL), - m_fbImage(NULL), - m_glVendor(NULL), - m_glRenderer(NULL), - m_glVersion(NULL) -{ - m_fpsStats = getenv("SHOW_FPS_STATS") != NULL; -} - -FrameBuffer::~FrameBuffer() -{ - free(m_fbImage); -} - -void FrameBuffer::setPostCallback(OnPostFn onPost, void* onPostContext) -{ - emugl::Mutex::AutoLock mutex(m_lock); - m_onPost = onPost; - m_onPostContext = onPostContext; - if (m_onPost && !m_fbImage) { - m_fbImage = (unsigned char*)malloc(4 * m_width * m_height); - if (!m_fbImage) { - ERR("out of memory, cancelling OnPost callback"); - m_onPost = NULL; - m_onPostContext = NULL; - return; - } - } -} - -bool FrameBuffer::setupSubWindow(FBNativeWindowType p_window, - int p_x, int p_y, - int p_width, int p_height, float zRot) -{ - bool success = false; - - if (s_theFrameBuffer) { - s_theFrameBuffer->m_lock.lock(); - FrameBuffer *fb = s_theFrameBuffer; - if (!fb->m_subWin) { - - // create native subwindow for FB display output - fb->m_subWin = createSubWindow(p_window, - &fb->m_subWinDisplay, - p_x,p_y,p_width,p_height); - if (fb->m_subWin) { - fb->m_nativeWindow = p_window; - - // create EGLSurface from the generated subwindow - fb->m_eglSurface = s_egl.eglCreateWindowSurface(fb->m_eglDisplay, - fb->m_eglConfig, - fb->m_subWin, - NULL); - - if (fb->m_eglSurface == EGL_NO_SURFACE) { - ERR("Failed to create surface\n"); - destroySubWindow(fb->m_subWinDisplay, fb->m_subWin); - fb->m_subWin = (EGLNativeWindowType)0; - } - else if (fb->bindSubwin_locked()) { - // Subwin creation was successfull, - // update viewport and z rotation and draw - // the last posted color buffer. - s_gl.glViewport(0, 0, p_width, p_height); - fb->m_zRot = zRot; - fb->post( fb->m_lastPostedColorBuffer, false ); - fb->unbind_locked(); - success = true; - } - } - } - s_theFrameBuffer->m_lock.unlock(); - } - - return success; -} - -bool FrameBuffer::removeSubWindow() -{ - bool removed = false; - if (s_theFrameBuffer) { - s_theFrameBuffer->m_lock.lock(); - if (s_theFrameBuffer->m_subWin) { - s_egl.eglMakeCurrent(s_theFrameBuffer->m_eglDisplay, NULL, NULL, NULL); - s_egl.eglDestroySurface(s_theFrameBuffer->m_eglDisplay, - s_theFrameBuffer->m_eglSurface); - destroySubWindow(s_theFrameBuffer->m_subWinDisplay, - s_theFrameBuffer->m_subWin); - - s_theFrameBuffer->m_eglSurface = EGL_NO_SURFACE; - s_theFrameBuffer->m_subWin = (EGLNativeWindowType)0; - removed = true; - } - s_theFrameBuffer->m_lock.unlock(); - } - return removed; -} - -HandleType FrameBuffer::genHandle() -{ - HandleType id; - do { - id = ++s_nextHandle; - } while( id == 0 || - m_contexts.find(id) != m_contexts.end() || - m_windows.find(id) != m_windows.end() ); - - return id; -} - -HandleType FrameBuffer::createColorBuffer(int p_width, int p_height, - GLenum p_internalFormat) -{ - emugl::Mutex::AutoLock mutex(m_lock); - HandleType ret = 0; - - ColorBufferPtr cb( ColorBuffer::create(p_width, p_height, p_internalFormat) ); - if (cb.Ptr() != NULL) { - ret = genHandle(); - m_colorbuffers[ret].cb = cb; - m_colorbuffers[ret].refcount = 1; - } - return ret; -} - -HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share, - bool p_isGL2) -{ - emugl::Mutex::AutoLock mutex(m_lock); - HandleType ret = 0; - - RenderContextPtr share(NULL); - if (p_share != 0) { - RenderContextMap::iterator s( m_contexts.find(p_share) ); - if (s == m_contexts.end()) { - return 0; - } - share = (*s).second; - } - - RenderContextPtr rctx( RenderContext::create(p_config, share, p_isGL2) ); - if (rctx.Ptr() != NULL) { - ret = genHandle(); - m_contexts[ret] = rctx; - } - return ret; -} - -HandleType FrameBuffer::createWindowSurface(int p_config, int p_width, int p_height) -{ - emugl::Mutex::AutoLock mutex(m_lock); - - HandleType ret = 0; - WindowSurfacePtr win( WindowSurface::create(p_config, p_width, p_height) ); - if (win.Ptr() != NULL) { - ret = genHandle(); - m_windows[ret] = win; - } - - return ret; -} - -void FrameBuffer::DestroyRenderContext(HandleType p_context) -{ - emugl::Mutex::AutoLock mutex(m_lock); - m_contexts.erase(p_context); -} - -void FrameBuffer::DestroyWindowSurface(HandleType p_surface) -{ - emugl::Mutex::AutoLock mutex(m_lock); - m_windows.erase(p_surface); -} - -int FrameBuffer::openColorBuffer(HandleType p_colorbuffer) -{ - emugl::Mutex::AutoLock mutex(m_lock); - ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); - if (c == m_colorbuffers.end()) { - // bad colorbuffer handle - ERR("FB: openColorBuffer cb handle %#x not found\n", p_colorbuffer); - return -1; - } - (*c).second.refcount++; - return 0; -} - -void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer) -{ - emugl::Mutex::AutoLock mutex(m_lock); - ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); - if (c == m_colorbuffers.end()) { - ERR("FB: closeColorBuffer cb handle %#x not found\n", p_colorbuffer); - // bad colorbuffer handle - return; - } - if (--(*c).second.refcount == 0) { - m_colorbuffers.erase(c); - } -} - -bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface) -{ - emugl::Mutex::AutoLock mutex(m_lock); - - WindowSurfaceMap::iterator w( m_windows.find(p_surface) ); - if (w == m_windows.end()) { - ERR("FB::flushWindowSurfaceColorBuffer: window handle %#x not found\n", p_surface); - // bad surface handle - return false; - } - - return (*w).second->flushColorBuffer(); -} - -bool FrameBuffer::setWindowSurfaceColorBuffer(HandleType p_surface, - HandleType p_colorbuffer) -{ - emugl::Mutex::AutoLock mutex(m_lock); - - WindowSurfaceMap::iterator w( m_windows.find(p_surface) ); - if (w == m_windows.end()) { - // bad surface handle - ERR("%s: bad window surface handle %#x\n", __FUNCTION__, p_surface); - return false; - } - - ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) ); - if (c == m_colorbuffers.end()) { - ERR("%s: bad color buffer handle %#x\n", __FUNCTION__, p_colorbuffer); - // bad colorbuffer handle - return false; - } - - (*w).second->setColorBuffer( (*c).second.cb ); - - return true; -} - -bool FrameBuffer::updateColorBuffer(HandleType p_colorbuffer, - int x, int y, int width, int height, - GLenum format, GLenum type, void *pixels) -{ - emugl::Mutex::AutoLock mutex(m_lock); - - ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) ); - if (c == m_colorbuffers.end()) { - // bad colorbuffer handle - return false; - } - - (*c).second.cb->subUpdate(x, y, width, height, format, type, pixels); - - return true; -} - -bool FrameBuffer::bindColorBufferToTexture(HandleType p_colorbuffer) -{ - emugl::Mutex::AutoLock mutex(m_lock); - - ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) ); - if (c == m_colorbuffers.end()) { - // bad colorbuffer handle - return false; - } - - return (*c).second.cb->bindToTexture(); -} - -bool FrameBuffer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer) -{ - emugl::Mutex::AutoLock mutex(m_lock); - - ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) ); - if (c == m_colorbuffers.end()) { - // bad colorbuffer handle - return false; - } - - return (*c).second.cb->bindToRenderbuffer(); -} - -bool FrameBuffer::bindContext(HandleType p_context, - HandleType p_drawSurface, - HandleType p_readSurface) -{ - emugl::Mutex::AutoLock mutex(m_lock); - - WindowSurfacePtr draw(NULL), read(NULL); - RenderContextPtr ctx(NULL); - - // - // if this is not an unbind operation - make sure all handles are good - // - if (p_context || p_drawSurface || p_readSurface) { - RenderContextMap::iterator r( m_contexts.find(p_context) ); - if (r == m_contexts.end()) { - // bad context handle - return false; - } - - ctx = (*r).second; - WindowSurfaceMap::iterator w( m_windows.find(p_drawSurface) ); - if (w == m_windows.end()) { - // bad surface handle - return false; - } - draw = (*w).second; - - if (p_readSurface != p_drawSurface) { - WindowSurfaceMap::iterator w( m_windows.find(p_readSurface) ); - if (w == m_windows.end()) { - // bad surface handle - return false; - } - read = (*w).second; - } - else { - read = draw; - } - } - - if (!s_egl.eglMakeCurrent(m_eglDisplay, - draw ? draw->getEGLSurface() : EGL_NO_SURFACE, - read ? read->getEGLSurface() : EGL_NO_SURFACE, - ctx ? ctx->getEGLContext() : EGL_NO_CONTEXT)) { - ERR("eglMakeCurrent failed\n"); - return false; - } - - // - // Bind the surface(s) to the context - // - RenderThreadInfo *tinfo = RenderThreadInfo::get(); - WindowSurfacePtr bindDraw, bindRead; - if (draw.Ptr() == NULL && read.Ptr() == NULL) { - // Unbind the current read and draw surfaces from the context - bindDraw = tinfo->currDrawSurf; - bindRead = tinfo->currReadSurf; - } else { - bindDraw = draw; - bindRead = read; - } - - if (bindDraw.Ptr() != NULL && bindRead.Ptr() != NULL) { - if (bindDraw.Ptr() != bindRead.Ptr()) { - bindDraw->bind(ctx, SURFACE_BIND_DRAW); - bindRead->bind(ctx, SURFACE_BIND_READ); - } - else { - bindDraw->bind(ctx, SURFACE_BIND_READDRAW); - } - } - - // - // update thread info with current bound context - // - tinfo->currContext = ctx; - tinfo->currDrawSurf = draw; - tinfo->currReadSurf = read; - if (ctx) { - if (ctx->isGL2()) tinfo->m_gl2Dec.setContextData(&ctx->decoderContextData()); - else tinfo->m_glDec.setContextData(&ctx->decoderContextData()); - } - else { - tinfo->m_glDec.setContextData(NULL); - tinfo->m_gl2Dec.setContextData(NULL); - } - return true; -} - -// -// The framebuffer lock should be held when calling this function ! -// -bool FrameBuffer::bind_locked() -{ - EGLContext prevContext = s_egl.eglGetCurrentContext(); - EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ); - EGLSurface prevDrawSurf = s_egl.eglGetCurrentSurface(EGL_DRAW); - - if (!s_egl.eglMakeCurrent(m_eglDisplay, m_pbufSurface, - m_pbufSurface, m_pbufContext)) { - ERR("eglMakeCurrent failed\n"); - return false; - } - - m_prevContext = prevContext; - m_prevReadSurf = prevReadSurf; - m_prevDrawSurf = prevDrawSurf; - return true; -} - -bool FrameBuffer::bindSubwin_locked() -{ - EGLContext prevContext = s_egl.eglGetCurrentContext(); - EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ); - EGLSurface prevDrawSurf = s_egl.eglGetCurrentSurface(EGL_DRAW); - - if (!s_egl.eglMakeCurrent(m_eglDisplay, m_eglSurface, - m_eglSurface, m_eglContext)) { - ERR("eglMakeCurrent failed\n"); - return false; - } - - // - // initialize GL state in eglContext if not yet initilaized - // - if (!m_eglContextInitialized) { - initGLState(); - m_eglContextInitialized = true; - } - - m_prevContext = prevContext; - m_prevReadSurf = prevReadSurf; - m_prevDrawSurf = prevDrawSurf; - return true; -} - -bool FrameBuffer::unbind_locked() -{ - if (!s_egl.eglMakeCurrent(m_eglDisplay, m_prevDrawSurf, - m_prevReadSurf, m_prevContext)) { - return false; - } - - m_prevContext = EGL_NO_CONTEXT; - m_prevReadSurf = EGL_NO_SURFACE; - m_prevDrawSurf = EGL_NO_SURFACE; - return true; -} - -bool FrameBuffer::post(HandleType p_colorbuffer, bool needLock) -{ - if (needLock) m_lock.lock(); - bool ret = false; - - ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) ); - if (c != m_colorbuffers.end()) { - - m_lastPostedColorBuffer = p_colorbuffer; - if (!m_subWin) { - // no subwindow created for the FB output - // cannot post the colorbuffer - if (needLock) m_lock.unlock(); - return ret; - } - - - // bind the subwindow eglSurface - if (!bindSubwin_locked()) { - ERR("FrameBuffer::post eglMakeCurrent failed\n"); - if (needLock) m_lock.unlock(); - return false; - } - - // - // render the color buffer to the window - // - s_gl.glPushMatrix(); - s_gl.glRotatef(m_zRot, 0.0f, 0.0f, 1.0f); - if (m_zRot != 0.0f) { - s_gl.glClear(GL_COLOR_BUFFER_BIT); - } - ret = (*c).second.cb->post(); - s_gl.glPopMatrix(); - - if (ret) { - // - // output FPS statistics - // - if (m_fpsStats) { - long long currTime = GetCurrentTimeMS(); - m_statsNumFrames++; - if (currTime - m_statsStartTime >= 1000) { - float dt = (float)(currTime - m_statsStartTime) / 1000.0f; - printf("FPS: %5.3f\n", (float)m_statsNumFrames / dt); - m_statsStartTime = currTime; - m_statsNumFrames = 0; - } - } - - s_egl.eglSwapBuffers(m_eglDisplay, m_eglSurface); - } - - // restore previous binding - unbind_locked(); - - // - // Send framebuffer (without FPS overlay) to callback - // - if (m_onPost) { - (*c).second.cb->readback(m_fbImage); - m_onPost(m_onPostContext, m_width, m_height, -1, - GL_RGBA, GL_UNSIGNED_BYTE, m_fbImage); - } - - } - - if (needLock) m_lock.unlock(); - return ret; -} - -bool FrameBuffer::repost() -{ - if (m_lastPostedColorBuffer) { - return post( m_lastPostedColorBuffer ); - } - return false; -} - -void FrameBuffer::initGLState() -{ - s_gl.glMatrixMode(GL_PROJECTION); - s_gl.glLoadIdentity(); - s_gl.glOrthof(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); - s_gl.glMatrixMode(GL_MODELVIEW); - s_gl.glLoadIdentity(); -} diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h deleted file mode 100644 index f8683b2..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -* 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 _LIBRENDER_FRAMEBUFFER_H -#define _LIBRENDER_FRAMEBUFFER_H - -#include "libOpenglRender/render_api.h" -#include "ColorBuffer.h" -#include "RenderContext.h" -#include "WindowSurface.h" -#include "emugl/common/mutex.h" - -#include <map> -#include <EGL/egl.h> -#include <stdint.h> - -typedef uint32_t HandleType; -struct ColorBufferRef { - ColorBufferPtr cb; - uint32_t refcount; // number of client-side references -}; -typedef std::map<HandleType, RenderContextPtr> RenderContextMap; -typedef std::map<HandleType, WindowSurfacePtr> WindowSurfaceMap; -typedef std::map<HandleType, ColorBufferRef> ColorBufferMap; - -struct FrameBufferCaps -{ - bool hasGL2; - bool has_eglimage_texture_2d; - bool has_eglimage_renderbuffer; - EGLint eglMajor; - EGLint eglMinor; -}; - -class FrameBuffer -{ -public: - static bool initialize(int width, int height); - static bool setupSubWindow(FBNativeWindowType p_window, - int x, int y, - int width, int height, float zRot); - static bool removeSubWindow(); - static void finalize(); - static FrameBuffer *getFB() { return s_theFrameBuffer; } - - const FrameBufferCaps &getCaps() const { return m_caps; } - - int getWidth() const { return m_width; } - int getHeight() const { return m_height; } - - void setPostCallback(OnPostFn onPost, void* onPostContext); - - void getGLStrings(const char** vendor, const char** renderer, const char** version) const { - *vendor = m_glVendor; - *renderer = m_glRenderer; - *version = m_glVersion; - } - - HandleType createRenderContext(int p_config, HandleType p_share, bool p_isGL2 = false); - HandleType createWindowSurface(int p_config, int p_width, int p_height); - HandleType createColorBuffer(int p_width, int p_height, GLenum p_internalFormat); - void DestroyRenderContext(HandleType p_context); - void DestroyWindowSurface(HandleType p_surface); - int openColorBuffer(HandleType p_colorbuffer); - void closeColorBuffer(HandleType p_colorbuffer); - - bool bindContext(HandleType p_context, HandleType p_drawSurface, HandleType p_readSurface); - bool setWindowSurfaceColorBuffer(HandleType p_surface, HandleType p_colorbuffer); - bool flushWindowSurfaceColorBuffer(HandleType p_surface); - bool bindColorBufferToTexture(HandleType p_colorbuffer); - bool bindColorBufferToRenderbuffer(HandleType p_colorbuffer); - bool updateColorBuffer(HandleType p_colorbuffer, - int x, int y, int width, int height, - GLenum format, GLenum type, void *pixels); - - bool post(HandleType p_colorbuffer, bool needLock = true); - bool repost(); - - EGLDisplay getDisplay() const { return m_eglDisplay; } - EGLNativeWindowType getSubWindow() const { return m_subWin; } - bool bind_locked(); - bool unbind_locked(); - - void setDisplayRotation(float zRot) { - m_zRot = zRot; - repost(); - } - -private: - FrameBuffer(int p_width, int p_height); - ~FrameBuffer(); - HandleType genHandle(); - bool bindSubwin_locked(); - void initGLState(); - -private: - static FrameBuffer *s_theFrameBuffer; - static HandleType s_nextHandle; - int m_x; - int m_y; - int m_width; - int m_height; - emugl::Mutex m_lock; - FBNativeWindowType m_nativeWindow; - FrameBufferCaps m_caps; - EGLDisplay m_eglDisplay; - RenderContextMap m_contexts; - WindowSurfaceMap m_windows; - ColorBufferMap m_colorbuffers; - - EGLSurface m_eglSurface; - EGLContext m_eglContext; - EGLSurface m_pbufSurface; - EGLContext m_pbufContext; - - EGLContext m_prevContext; - EGLSurface m_prevReadSurf; - EGLSurface m_prevDrawSurf; - EGLNativeWindowType m_subWin; - EGLNativeDisplayType m_subWinDisplay; - EGLConfig m_eglConfig; - HandleType m_lastPostedColorBuffer; - float m_zRot; - bool m_eglContextInitialized; - - int m_statsNumFrames; - long long m_statsStartTime; - bool m_fpsStats; - - OnPostFn m_onPost; - void* m_onPostContext; - unsigned char* m_fbImage; - - const char* m_glVendor; - const char* m_glRenderer; - const char* m_glVersion; -}; -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.cpp b/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.cpp deleted file mode 100644 index 8c51a4e..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* -* 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. -*/ -#ifdef WITH_GLES2 -#include "GL2Dispatch.h" -#include <stdio.h> -#include <stdlib.h> - -#include "emugl/common/shared_library.h" - -gl2_decoder_context_t s_gl2; -int s_gl2_enabled; - -static emugl::SharedLibrary *s_gles2_lib = NULL; - -#define DEFAULT_GLES_V2_LIB EMUGL_LIBNAME("GLES_V2_translator") - -// -// This function is called only once during initialiation before -// any thread has been created - hence it should NOT be thread safe. -// -bool init_gl2_dispatch() -{ - const char *libName = getenv("ANDROID_GLESv2_LIB"); - if (!libName) libName = DEFAULT_GLES_V2_LIB; - - // - // Load the GLES library - // - s_gles2_lib = emugl::SharedLibrary::open(libName); - if (!s_gles2_lib) return false; - - // - // init the GLES dispatch table - // - s_gl2.initDispatchByName( gl2_dispatch_get_proc_func, NULL ); - s_gl2_enabled = true; - return true; -} - -// -// This function is called only during initialiation before -// any thread has been created - hence it should NOT be thread safe. -// -void *gl2_dispatch_get_proc_func(const char *name, void *userData) -{ - if (!s_gles2_lib) { - return NULL; - } - return (void *)s_gles2_lib->findSymbol(name); -} - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.h b/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.h deleted file mode 100644 index 89f3651..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/GL2Dispatch.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -* 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 _GLES2_DISPATCH_H -#define _GLES2_DISPATCH_H - -#ifdef WITH_GLES2 - -#include "gl2_dec.h" - -bool init_gl2_dispatch(); -void *gl2_dispatch_get_proc_func(const char *name, void *userData); - -extern gl2_decoder_context_t s_gl2; -extern int s_gl2_enabled; - -#endif -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/GLDispatch.cpp b/emulator/opengl/host/libs/libOpenglRender/GLDispatch.cpp deleted file mode 100644 index c127dc3..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/GLDispatch.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/* -* 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. -*/ -#include "GLDispatch.h" -#include <stdio.h> -#include <stdlib.h> - -#include "emugl/common/shared_library.h" - -GLDispatch s_gl; - -static emugl::SharedLibrary *s_gles_lib = NULL; - -// -// This function is called only once during initialiation before -// any thread has been created - hence it should NOT be thread safe. -// - -#define DEFAULT_GLES_CM_LIB EMUGL_LIBNAME("GLES_CM_translator") - -bool init_gl_dispatch() -{ - const char *libName = getenv("ANDROID_GLESv1_LIB"); - if (!libName) libName = DEFAULT_GLES_CM_LIB; - - s_gles_lib = emugl::SharedLibrary::open(libName); - if (!s_gles_lib) return false; - - s_gl.glAlphaFunc = (glAlphaFunc_t) s_gles_lib->findSymbol("glAlphaFunc"); - s_gl.glClearColor = (glClearColor_t) s_gles_lib->findSymbol("glClearColor"); - s_gl.glClearDepthf = (glClearDepthf_t) s_gles_lib->findSymbol("glClearDepthf"); - s_gl.glClipPlanef = (glClipPlanef_t) s_gles_lib->findSymbol("glClipPlanef"); - s_gl.glColor4f = (glColor4f_t) s_gles_lib->findSymbol("glColor4f"); - s_gl.glDepthRangef = (glDepthRangef_t) s_gles_lib->findSymbol("glDepthRangef"); - s_gl.glFogf = (glFogf_t) s_gles_lib->findSymbol("glFogf"); - s_gl.glFogfv = (glFogfv_t) s_gles_lib->findSymbol("glFogfv"); - s_gl.glFrustumf = (glFrustumf_t) s_gles_lib->findSymbol("glFrustumf"); - s_gl.glGetClipPlanef = (glGetClipPlanef_t) s_gles_lib->findSymbol("glGetClipPlanef"); - s_gl.glGetFloatv = (glGetFloatv_t) s_gles_lib->findSymbol("glGetFloatv"); - s_gl.glGetLightfv = (glGetLightfv_t) s_gles_lib->findSymbol("glGetLightfv"); - s_gl.glGetMaterialfv = (glGetMaterialfv_t) s_gles_lib->findSymbol("glGetMaterialfv"); - s_gl.glGetTexEnvfv = (glGetTexEnvfv_t) s_gles_lib->findSymbol("glGetTexEnvfv"); - s_gl.glGetTexParameterfv = (glGetTexParameterfv_t) s_gles_lib->findSymbol("glGetTexParameterfv"); - s_gl.glLightModelf = (glLightModelf_t) s_gles_lib->findSymbol("glLightModelf"); - s_gl.glLightModelfv = (glLightModelfv_t) s_gles_lib->findSymbol("glLightModelfv"); - s_gl.glLightf = (glLightf_t) s_gles_lib->findSymbol("glLightf"); - s_gl.glLightfv = (glLightfv_t) s_gles_lib->findSymbol("glLightfv"); - s_gl.glLineWidth = (glLineWidth_t) s_gles_lib->findSymbol("glLineWidth"); - s_gl.glLoadMatrixf = (glLoadMatrixf_t) s_gles_lib->findSymbol("glLoadMatrixf"); - s_gl.glMaterialf = (glMaterialf_t) s_gles_lib->findSymbol("glMaterialf"); - s_gl.glMaterialfv = (glMaterialfv_t) s_gles_lib->findSymbol("glMaterialfv"); - s_gl.glMultMatrixf = (glMultMatrixf_t) s_gles_lib->findSymbol("glMultMatrixf"); - s_gl.glMultiTexCoord4f = (glMultiTexCoord4f_t) s_gles_lib->findSymbol("glMultiTexCoord4f"); - s_gl.glNormal3f = (glNormal3f_t) s_gles_lib->findSymbol("glNormal3f"); - s_gl.glOrthof = (glOrthof_t) s_gles_lib->findSymbol("glOrthof"); - s_gl.glPointParameterf = (glPointParameterf_t) s_gles_lib->findSymbol("glPointParameterf"); - s_gl.glPointParameterfv = (glPointParameterfv_t) s_gles_lib->findSymbol("glPointParameterfv"); - s_gl.glPointSize = (glPointSize_t) s_gles_lib->findSymbol("glPointSize"); - s_gl.glPolygonOffset = (glPolygonOffset_t) s_gles_lib->findSymbol("glPolygonOffset"); - s_gl.glRotatef = (glRotatef_t) s_gles_lib->findSymbol("glRotatef"); - s_gl.glScalef = (glScalef_t) s_gles_lib->findSymbol("glScalef"); - s_gl.glTexEnvf = (glTexEnvf_t) s_gles_lib->findSymbol("glTexEnvf"); - s_gl.glTexEnvfv = (glTexEnvfv_t) s_gles_lib->findSymbol("glTexEnvfv"); - s_gl.glTexParameterf = (glTexParameterf_t) s_gles_lib->findSymbol("glTexParameterf"); - s_gl.glTexParameterfv = (glTexParameterfv_t) s_gles_lib->findSymbol("glTexParameterfv"); - s_gl.glTranslatef = (glTranslatef_t) s_gles_lib->findSymbol("glTranslatef"); - s_gl.glActiveTexture = (glActiveTexture_t) s_gles_lib->findSymbol("glActiveTexture"); - s_gl.glAlphaFuncx = (glAlphaFuncx_t) s_gles_lib->findSymbol("glAlphaFuncx"); - s_gl.glBindBuffer = (glBindBuffer_t) s_gles_lib->findSymbol("glBindBuffer"); - s_gl.glBindTexture = (glBindTexture_t) s_gles_lib->findSymbol("glBindTexture"); - s_gl.glBlendFunc = (glBlendFunc_t) s_gles_lib->findSymbol("glBlendFunc"); - s_gl.glBufferData = (glBufferData_t) s_gles_lib->findSymbol("glBufferData"); - s_gl.glBufferSubData = (glBufferSubData_t) s_gles_lib->findSymbol("glBufferSubData"); - s_gl.glClear = (glClear_t) s_gles_lib->findSymbol("glClear"); - s_gl.glClearColorx = (glClearColorx_t) s_gles_lib->findSymbol("glClearColorx"); - s_gl.glClearDepthx = (glClearDepthx_t) s_gles_lib->findSymbol("glClearDepthx"); - s_gl.glClearStencil = (glClearStencil_t) s_gles_lib->findSymbol("glClearStencil"); - s_gl.glClientActiveTexture = (glClientActiveTexture_t) s_gles_lib->findSymbol("glClientActiveTexture"); - s_gl.glClipPlanex = (glClipPlanex_t) s_gles_lib->findSymbol("glClipPlanex"); - s_gl.glColor4ub = (glColor4ub_t) s_gles_lib->findSymbol("glColor4ub"); - s_gl.glColor4x = (glColor4x_t) s_gles_lib->findSymbol("glColor4x"); - s_gl.glColorMask = (glColorMask_t) s_gles_lib->findSymbol("glColorMask"); - s_gl.glColorPointer = (glColorPointer_t) s_gles_lib->findSymbol("glColorPointer"); - s_gl.glCompressedTexImage2D = (glCompressedTexImage2D_t) s_gles_lib->findSymbol("glCompressedTexImage2D"); - s_gl.glCompressedTexSubImage2D = (glCompressedTexSubImage2D_t) s_gles_lib->findSymbol("glCompressedTexSubImage2D"); - s_gl.glCopyTexImage2D = (glCopyTexImage2D_t) s_gles_lib->findSymbol("glCopyTexImage2D"); - s_gl.glCopyTexSubImage2D = (glCopyTexSubImage2D_t) s_gles_lib->findSymbol("glCopyTexSubImage2D"); - s_gl.glCullFace = (glCullFace_t) s_gles_lib->findSymbol("glCullFace"); - s_gl.glDeleteBuffers = (glDeleteBuffers_t) s_gles_lib->findSymbol("glDeleteBuffers"); - s_gl.glDeleteTextures = (glDeleteTextures_t) s_gles_lib->findSymbol("glDeleteTextures"); - s_gl.glDepthFunc = (glDepthFunc_t) s_gles_lib->findSymbol("glDepthFunc"); - s_gl.glDepthMask = (glDepthMask_t) s_gles_lib->findSymbol("glDepthMask"); - s_gl.glDepthRangex = (glDepthRangex_t) s_gles_lib->findSymbol("glDepthRangex"); - s_gl.glDisable = (glDisable_t) s_gles_lib->findSymbol("glDisable"); - s_gl.glDisableClientState = (glDisableClientState_t) s_gles_lib->findSymbol("glDisableClientState"); - s_gl.glDrawArrays = (glDrawArrays_t) s_gles_lib->findSymbol("glDrawArrays"); - s_gl.glDrawElements = (glDrawElements_t) s_gles_lib->findSymbol("glDrawElements"); - s_gl.glEnable = (glEnable_t) s_gles_lib->findSymbol("glEnable"); - s_gl.glEnableClientState = (glEnableClientState_t) s_gles_lib->findSymbol("glEnableClientState"); - s_gl.glFinish = (glFinish_t) s_gles_lib->findSymbol("glFinish"); - s_gl.glFlush = (glFlush_t) s_gles_lib->findSymbol("glFlush"); - s_gl.glFogx = (glFogx_t) s_gles_lib->findSymbol("glFogx"); - s_gl.glFogxv = (glFogxv_t) s_gles_lib->findSymbol("glFogxv"); - s_gl.glFrontFace = (glFrontFace_t) s_gles_lib->findSymbol("glFrontFace"); - s_gl.glFrustumx = (glFrustumx_t) s_gles_lib->findSymbol("glFrustumx"); - s_gl.glGetBooleanv = (glGetBooleanv_t) s_gles_lib->findSymbol("glGetBooleanv"); - s_gl.glGetBufferParameteriv = (glGetBufferParameteriv_t) s_gles_lib->findSymbol("glGetBufferParameteriv"); - s_gl.glGetClipPlanex = (glGetClipPlanex_t) s_gles_lib->findSymbol("glGetClipPlanex"); - s_gl.glGenBuffers = (glGenBuffers_t) s_gles_lib->findSymbol("glGenBuffers"); - s_gl.glGenTextures = (glGenTextures_t) s_gles_lib->findSymbol("glGenTextures"); - s_gl.glGetError = (glGetError_t) s_gles_lib->findSymbol("glGetError"); - s_gl.glGetFixedv = (glGetFixedv_t) s_gles_lib->findSymbol("glGetFixedv"); - s_gl.glGetIntegerv = (glGetIntegerv_t) s_gles_lib->findSymbol("glGetIntegerv"); - s_gl.glGetLightxv = (glGetLightxv_t) s_gles_lib->findSymbol("glGetLightxv"); - s_gl.glGetMaterialxv = (glGetMaterialxv_t) s_gles_lib->findSymbol("glGetMaterialxv"); - s_gl.glGetPointerv = (glGetPointerv_t) s_gles_lib->findSymbol("glGetPointerv"); - s_gl.glGetString = (glGetString_t) s_gles_lib->findSymbol("glGetString"); - s_gl.glGetTexEnviv = (glGetTexEnviv_t) s_gles_lib->findSymbol("glGetTexEnviv"); - s_gl.glGetTexEnvxv = (glGetTexEnvxv_t) s_gles_lib->findSymbol("glGetTexEnvxv"); - s_gl.glGetTexParameteriv = (glGetTexParameteriv_t) s_gles_lib->findSymbol("glGetTexParameteriv"); - s_gl.glGetTexParameterxv = (glGetTexParameterxv_t) s_gles_lib->findSymbol("glGetTexParameterxv"); - s_gl.glHint = (glHint_t) s_gles_lib->findSymbol("glHint"); - s_gl.glIsBuffer = (glIsBuffer_t) s_gles_lib->findSymbol("glIsBuffer"); - s_gl.glIsEnabled = (glIsEnabled_t) s_gles_lib->findSymbol("glIsEnabled"); - s_gl.glIsTexture = (glIsTexture_t) s_gles_lib->findSymbol("glIsTexture"); - s_gl.glLightModelx = (glLightModelx_t) s_gles_lib->findSymbol("glLightModelx"); - s_gl.glLightModelxv = (glLightModelxv_t) s_gles_lib->findSymbol("glLightModelxv"); - s_gl.glLightx = (glLightx_t) s_gles_lib->findSymbol("glLightx"); - s_gl.glLightxv = (glLightxv_t) s_gles_lib->findSymbol("glLightxv"); - s_gl.glLineWidthx = (glLineWidthx_t) s_gles_lib->findSymbol("glLineWidthx"); - s_gl.glLoadIdentity = (glLoadIdentity_t) s_gles_lib->findSymbol("glLoadIdentity"); - s_gl.glLoadMatrixx = (glLoadMatrixx_t) s_gles_lib->findSymbol("glLoadMatrixx"); - s_gl.glLogicOp = (glLogicOp_t) s_gles_lib->findSymbol("glLogicOp"); - s_gl.glMaterialx = (glMaterialx_t) s_gles_lib->findSymbol("glMaterialx"); - s_gl.glMaterialxv = (glMaterialxv_t) s_gles_lib->findSymbol("glMaterialxv"); - s_gl.glMatrixMode = (glMatrixMode_t) s_gles_lib->findSymbol("glMatrixMode"); - s_gl.glMultMatrixx = (glMultMatrixx_t) s_gles_lib->findSymbol("glMultMatrixx"); - s_gl.glMultiTexCoord4x = (glMultiTexCoord4x_t) s_gles_lib->findSymbol("glMultiTexCoord4x"); - s_gl.glNormal3x = (glNormal3x_t) s_gles_lib->findSymbol("glNormal3x"); - s_gl.glNormalPointer = (glNormalPointer_t) s_gles_lib->findSymbol("glNormalPointer"); - s_gl.glOrthox = (glOrthox_t) s_gles_lib->findSymbol("glOrthox"); - s_gl.glPixelStorei = (glPixelStorei_t) s_gles_lib->findSymbol("glPixelStorei"); - s_gl.glPointParameterx = (glPointParameterx_t) s_gles_lib->findSymbol("glPointParameterx"); - s_gl.glPointParameterxv = (glPointParameterxv_t) s_gles_lib->findSymbol("glPointParameterxv"); - s_gl.glPointSizex = (glPointSizex_t) s_gles_lib->findSymbol("glPointSizex"); - s_gl.glPolygonOffsetx = (glPolygonOffsetx_t) s_gles_lib->findSymbol("glPolygonOffsetx"); - s_gl.glPopMatrix = (glPopMatrix_t) s_gles_lib->findSymbol("glPopMatrix"); - s_gl.glPushMatrix = (glPushMatrix_t) s_gles_lib->findSymbol("glPushMatrix"); - s_gl.glReadPixels = (glReadPixels_t) s_gles_lib->findSymbol("glReadPixels"); - s_gl.glRotatex = (glRotatex_t) s_gles_lib->findSymbol("glRotatex"); - s_gl.glSampleCoverage = (glSampleCoverage_t) s_gles_lib->findSymbol("glSampleCoverage"); - s_gl.glSampleCoveragex = (glSampleCoveragex_t) s_gles_lib->findSymbol("glSampleCoveragex"); - s_gl.glScalex = (glScalex_t) s_gles_lib->findSymbol("glScalex"); - s_gl.glScissor = (glScissor_t) s_gles_lib->findSymbol("glScissor"); - s_gl.glShadeModel = (glShadeModel_t) s_gles_lib->findSymbol("glShadeModel"); - s_gl.glStencilFunc = (glStencilFunc_t) s_gles_lib->findSymbol("glStencilFunc"); - s_gl.glStencilMask = (glStencilMask_t) s_gles_lib->findSymbol("glStencilMask"); - s_gl.glStencilOp = (glStencilOp_t) s_gles_lib->findSymbol("glStencilOp"); - s_gl.glTexCoordPointer = (glTexCoordPointer_t) s_gles_lib->findSymbol("glTexCoordPointer"); - s_gl.glTexEnvi = (glTexEnvi_t) s_gles_lib->findSymbol("glTexEnvi"); - s_gl.glTexEnvx = (glTexEnvx_t) s_gles_lib->findSymbol("glTexEnvx"); - s_gl.glTexEnviv = (glTexEnviv_t) s_gles_lib->findSymbol("glTexEnviv"); - s_gl.glTexEnvxv = (glTexEnvxv_t) s_gles_lib->findSymbol("glTexEnvxv"); - s_gl.glTexImage2D = (glTexImage2D_t) s_gles_lib->findSymbol("glTexImage2D"); - s_gl.glTexParameteri = (glTexParameteri_t) s_gles_lib->findSymbol("glTexParameteri"); - s_gl.glTexParameterx = (glTexParameterx_t) s_gles_lib->findSymbol("glTexParameterx"); - s_gl.glTexParameteriv = (glTexParameteriv_t) s_gles_lib->findSymbol("glTexParameteriv"); - s_gl.glTexParameterxv = (glTexParameterxv_t) s_gles_lib->findSymbol("glTexParameterxv"); - s_gl.glTexSubImage2D = (glTexSubImage2D_t) s_gles_lib->findSymbol("glTexSubImage2D"); - s_gl.glTranslatex = (glTranslatex_t) s_gles_lib->findSymbol("glTranslatex"); - s_gl.glVertexPointer = (glVertexPointer_t) s_gles_lib->findSymbol("glVertexPointer"); - s_gl.glViewport = (glViewport_t) s_gles_lib->findSymbol("glViewport"); - s_gl.glPointSizePointerOES = (glPointSizePointerOES_t) s_gles_lib->findSymbol("glPointSizePointerOES"); - s_gl.glBlendEquationSeparateOES = (glBlendEquationSeparateOES_t) s_gles_lib->findSymbol("glBlendEquationSeparateOES"); - s_gl.glBlendFuncSeparateOES = (glBlendFuncSeparateOES_t) s_gles_lib->findSymbol("glBlendFuncSeparateOES"); - s_gl.glBlendEquationOES = (glBlendEquationOES_t) s_gles_lib->findSymbol("glBlendEquationOES"); - s_gl.glDrawTexsOES = (glDrawTexsOES_t) s_gles_lib->findSymbol("glDrawTexsOES"); - s_gl.glDrawTexiOES = (glDrawTexiOES_t) s_gles_lib->findSymbol("glDrawTexiOES"); - s_gl.glDrawTexxOES = (glDrawTexxOES_t) s_gles_lib->findSymbol("glDrawTexxOES"); - s_gl.glDrawTexsvOES = (glDrawTexsvOES_t) s_gles_lib->findSymbol("glDrawTexsvOES"); - s_gl.glDrawTexivOES = (glDrawTexivOES_t) s_gles_lib->findSymbol("glDrawTexivOES"); - s_gl.glDrawTexxvOES = (glDrawTexxvOES_t) s_gles_lib->findSymbol("glDrawTexxvOES"); - s_gl.glDrawTexfOES = (glDrawTexfOES_t) s_gles_lib->findSymbol("glDrawTexfOES"); - s_gl.glDrawTexfvOES = (glDrawTexfvOES_t) s_gles_lib->findSymbol("glDrawTexfvOES"); - s_gl.glEGLImageTargetTexture2DOES = (glEGLImageTargetTexture2DOES_t) s_gles_lib->findSymbol("glEGLImageTargetTexture2DOES"); - s_gl.glEGLImageTargetRenderbufferStorageOES = (glEGLImageTargetRenderbufferStorageOES_t) s_gles_lib->findSymbol("glEGLImageTargetRenderbufferStorageOES"); - s_gl.glAlphaFuncxOES = (glAlphaFuncxOES_t) s_gles_lib->findSymbol("glAlphaFuncxOES"); - s_gl.glClearColorxOES = (glClearColorxOES_t) s_gles_lib->findSymbol("glClearColorxOES"); - s_gl.glClearDepthxOES = (glClearDepthxOES_t) s_gles_lib->findSymbol("glClearDepthxOES"); - s_gl.glClipPlanexOES = (glClipPlanexOES_t) s_gles_lib->findSymbol("glClipPlanexOES"); - s_gl.glColor4xOES = (glColor4xOES_t) s_gles_lib->findSymbol("glColor4xOES"); - s_gl.glDepthRangexOES = (glDepthRangexOES_t) s_gles_lib->findSymbol("glDepthRangexOES"); - s_gl.glFogxOES = (glFogxOES_t) s_gles_lib->findSymbol("glFogxOES"); - s_gl.glFogxvOES = (glFogxvOES_t) s_gles_lib->findSymbol("glFogxvOES"); - s_gl.glFrustumxOES = (glFrustumxOES_t) s_gles_lib->findSymbol("glFrustumxOES"); - s_gl.glGetClipPlanexOES = (glGetClipPlanexOES_t) s_gles_lib->findSymbol("glGetClipPlanexOES"); - s_gl.glGetFixedvOES = (glGetFixedvOES_t) s_gles_lib->findSymbol("glGetFixedvOES"); - s_gl.glGetLightxvOES = (glGetLightxvOES_t) s_gles_lib->findSymbol("glGetLightxvOES"); - s_gl.glGetMaterialxvOES = (glGetMaterialxvOES_t) s_gles_lib->findSymbol("glGetMaterialxvOES"); - s_gl.glGetTexEnvxvOES = (glGetTexEnvxvOES_t) s_gles_lib->findSymbol("glGetTexEnvxvOES"); - s_gl.glGetTexParameterxvOES = (glGetTexParameterxvOES_t) s_gles_lib->findSymbol("glGetTexParameterxvOES"); - s_gl.glLightModelxOES = (glLightModelxOES_t) s_gles_lib->findSymbol("glLightModelxOES"); - s_gl.glLightModelxvOES = (glLightModelxvOES_t) s_gles_lib->findSymbol("glLightModelxvOES"); - s_gl.glLightxOES = (glLightxOES_t) s_gles_lib->findSymbol("glLightxOES"); - s_gl.glLightxvOES = (glLightxvOES_t) s_gles_lib->findSymbol("glLightxvOES"); - s_gl.glLineWidthxOES = (glLineWidthxOES_t) s_gles_lib->findSymbol("glLineWidthxOES"); - s_gl.glLoadMatrixxOES = (glLoadMatrixxOES_t) s_gles_lib->findSymbol("glLoadMatrixxOES"); - s_gl.glMaterialxOES = (glMaterialxOES_t) s_gles_lib->findSymbol("glMaterialxOES"); - s_gl.glMaterialxvOES = (glMaterialxvOES_t) s_gles_lib->findSymbol("glMaterialxvOES"); - s_gl.glMultMatrixxOES = (glMultMatrixxOES_t) s_gles_lib->findSymbol("glMultMatrixxOES"); - s_gl.glMultiTexCoord4xOES = (glMultiTexCoord4xOES_t) s_gles_lib->findSymbol("glMultiTexCoord4xOES"); - s_gl.glNormal3xOES = (glNormal3xOES_t) s_gles_lib->findSymbol("glNormal3xOES"); - s_gl.glOrthoxOES = (glOrthoxOES_t) s_gles_lib->findSymbol("glOrthoxOES"); - s_gl.glPointParameterxOES = (glPointParameterxOES_t) s_gles_lib->findSymbol("glPointParameterxOES"); - s_gl.glPointParameterxvOES = (glPointParameterxvOES_t) s_gles_lib->findSymbol("glPointParameterxvOES"); - s_gl.glPointSizexOES = (glPointSizexOES_t) s_gles_lib->findSymbol("glPointSizexOES"); - s_gl.glPolygonOffsetxOES = (glPolygonOffsetxOES_t) s_gles_lib->findSymbol("glPolygonOffsetxOES"); - s_gl.glRotatexOES = (glRotatexOES_t) s_gles_lib->findSymbol("glRotatexOES"); - s_gl.glSampleCoveragexOES = (glSampleCoveragexOES_t) s_gles_lib->findSymbol("glSampleCoveragexOES"); - s_gl.glScalexOES = (glScalexOES_t) s_gles_lib->findSymbol("glScalexOES"); - s_gl.glTexEnvxOES = (glTexEnvxOES_t) s_gles_lib->findSymbol("glTexEnvxOES"); - s_gl.glTexEnvxvOES = (glTexEnvxvOES_t) s_gles_lib->findSymbol("glTexEnvxvOES"); - s_gl.glTexParameterxOES = (glTexParameterxOES_t) s_gles_lib->findSymbol("glTexParameterxOES"); - s_gl.glTexParameterxvOES = (glTexParameterxvOES_t) s_gles_lib->findSymbol("glTexParameterxvOES"); - s_gl.glTranslatexOES = (glTranslatexOES_t) s_gles_lib->findSymbol("glTranslatexOES"); - s_gl.glIsRenderbufferOES = (glIsRenderbufferOES_t) s_gles_lib->findSymbol("glIsRenderbufferOES"); - s_gl.glBindRenderbufferOES = (glBindRenderbufferOES_t) s_gles_lib->findSymbol("glBindRenderbufferOES"); - s_gl.glDeleteRenderbuffersOES = (glDeleteRenderbuffersOES_t) s_gles_lib->findSymbol("glDeleteRenderbuffersOES"); - s_gl.glGenRenderbuffersOES = (glGenRenderbuffersOES_t) s_gles_lib->findSymbol("glGenRenderbuffersOES"); - s_gl.glRenderbufferStorageOES = (glRenderbufferStorageOES_t) s_gles_lib->findSymbol("glRenderbufferStorageOES"); - s_gl.glGetRenderbufferParameterivOES = (glGetRenderbufferParameterivOES_t) s_gles_lib->findSymbol("glGetRenderbufferParameterivOES"); - s_gl.glIsFramebufferOES = (glIsFramebufferOES_t) s_gles_lib->findSymbol("glIsFramebufferOES"); - s_gl.glBindFramebufferOES = (glBindFramebufferOES_t) s_gles_lib->findSymbol("glBindFramebufferOES"); - s_gl.glDeleteFramebuffersOES = (glDeleteFramebuffersOES_t) s_gles_lib->findSymbol("glDeleteFramebuffersOES"); - s_gl.glGenFramebuffersOES = (glGenFramebuffersOES_t) s_gles_lib->findSymbol("glGenFramebuffersOES"); - s_gl.glCheckFramebufferStatusOES = (glCheckFramebufferStatusOES_t) s_gles_lib->findSymbol("glCheckFramebufferStatusOES"); - s_gl.glFramebufferRenderbufferOES = (glFramebufferRenderbufferOES_t) s_gles_lib->findSymbol("glFramebufferRenderbufferOES"); - s_gl.glFramebufferTexture2DOES = (glFramebufferTexture2DOES_t) s_gles_lib->findSymbol("glFramebufferTexture2DOES"); - s_gl.glGetFramebufferAttachmentParameterivOES = (glGetFramebufferAttachmentParameterivOES_t) s_gles_lib->findSymbol("glGetFramebufferAttachmentParameterivOES"); - s_gl.glGenerateMipmapOES = (glGenerateMipmapOES_t) s_gles_lib->findSymbol("glGenerateMipmapOES"); - s_gl.glMapBufferOES = (glMapBufferOES_t) s_gles_lib->findSymbol("glMapBufferOES"); - s_gl.glUnmapBufferOES = (glUnmapBufferOES_t) s_gles_lib->findSymbol("glUnmapBufferOES"); - s_gl.glGetBufferPointervOES = (glGetBufferPointervOES_t) s_gles_lib->findSymbol("glGetBufferPointervOES"); - s_gl.glCurrentPaletteMatrixOES = (glCurrentPaletteMatrixOES_t) s_gles_lib->findSymbol("glCurrentPaletteMatrixOES"); - s_gl.glLoadPaletteFromModelViewMatrixOES = (glLoadPaletteFromModelViewMatrixOES_t) s_gles_lib->findSymbol("glLoadPaletteFromModelViewMatrixOES"); - s_gl.glMatrixIndexPointerOES = (glMatrixIndexPointerOES_t) s_gles_lib->findSymbol("glMatrixIndexPointerOES"); - s_gl.glWeightPointerOES = (glWeightPointerOES_t) s_gles_lib->findSymbol("glWeightPointerOES"); - s_gl.glQueryMatrixxOES = (glQueryMatrixxOES_t) s_gles_lib->findSymbol("glQueryMatrixxOES"); - s_gl.glDepthRangefOES = (glDepthRangefOES_t) s_gles_lib->findSymbol("glDepthRangefOES"); - s_gl.glFrustumfOES = (glFrustumfOES_t) s_gles_lib->findSymbol("glFrustumfOES"); - s_gl.glOrthofOES = (glOrthofOES_t) s_gles_lib->findSymbol("glOrthofOES"); - s_gl.glClipPlanefOES = (glClipPlanefOES_t) s_gles_lib->findSymbol("glClipPlanefOES"); - s_gl.glGetClipPlanefOES = (glGetClipPlanefOES_t) s_gles_lib->findSymbol("glGetClipPlanefOES"); - s_gl.glClearDepthfOES = (glClearDepthfOES_t) s_gles_lib->findSymbol("glClearDepthfOES"); - s_gl.glTexGenfOES = (glTexGenfOES_t) s_gles_lib->findSymbol("glTexGenfOES"); - s_gl.glTexGenfvOES = (glTexGenfvOES_t) s_gles_lib->findSymbol("glTexGenfvOES"); - s_gl.glTexGeniOES = (glTexGeniOES_t) s_gles_lib->findSymbol("glTexGeniOES"); - s_gl.glTexGenivOES = (glTexGenivOES_t) s_gles_lib->findSymbol("glTexGenivOES"); - s_gl.glTexGenxOES = (glTexGenxOES_t) s_gles_lib->findSymbol("glTexGenxOES"); - s_gl.glTexGenxvOES = (glTexGenxvOES_t) s_gles_lib->findSymbol("glTexGenxvOES"); - s_gl.glGetTexGenfvOES = (glGetTexGenfvOES_t) s_gles_lib->findSymbol("glGetTexGenfvOES"); - s_gl.glGetTexGenivOES = (glGetTexGenivOES_t) s_gles_lib->findSymbol("glGetTexGenivOES"); - s_gl.glGetTexGenxvOES = (glGetTexGenxvOES_t) s_gles_lib->findSymbol("glGetTexGenxvOES"); - s_gl.glBindVertexArrayOES = (glBindVertexArrayOES_t) s_gles_lib->findSymbol("glBindVertexArrayOES"); - s_gl.glDeleteVertexArraysOES = (glDeleteVertexArraysOES_t) s_gles_lib->findSymbol("glDeleteVertexArraysOES"); - s_gl.glGenVertexArraysOES = (glGenVertexArraysOES_t) s_gles_lib->findSymbol("glGenVertexArraysOES"); - s_gl.glIsVertexArrayOES = (glIsVertexArrayOES_t) s_gles_lib->findSymbol("glIsVertexArrayOES"); - s_gl.glDiscardFramebufferEXT = (glDiscardFramebufferEXT_t) s_gles_lib->findSymbol("glDiscardFramebufferEXT"); - s_gl.glMultiDrawArraysEXT = (glMultiDrawArraysEXT_t) s_gles_lib->findSymbol("glMultiDrawArraysEXT"); - s_gl.glMultiDrawElementsEXT = (glMultiDrawElementsEXT_t) s_gles_lib->findSymbol("glMultiDrawElementsEXT"); - s_gl.glClipPlanefIMG = (glClipPlanefIMG_t) s_gles_lib->findSymbol("glClipPlanefIMG"); - s_gl.glClipPlanexIMG = (glClipPlanexIMG_t) s_gles_lib->findSymbol("glClipPlanexIMG"); - s_gl.glRenderbufferStorageMultisampleIMG = (glRenderbufferStorageMultisampleIMG_t) s_gles_lib->findSymbol("glRenderbufferStorageMultisampleIMG"); - s_gl.glFramebufferTexture2DMultisampleIMG = (glFramebufferTexture2DMultisampleIMG_t) s_gles_lib->findSymbol("glFramebufferTexture2DMultisampleIMG"); - s_gl.glDeleteFencesNV = (glDeleteFencesNV_t) s_gles_lib->findSymbol("glDeleteFencesNV"); - s_gl.glGenFencesNV = (glGenFencesNV_t) s_gles_lib->findSymbol("glGenFencesNV"); - s_gl.glIsFenceNV = (glIsFenceNV_t) s_gles_lib->findSymbol("glIsFenceNV"); - s_gl.glTestFenceNV = (glTestFenceNV_t) s_gles_lib->findSymbol("glTestFenceNV"); - s_gl.glGetFenceivNV = (glGetFenceivNV_t) s_gles_lib->findSymbol("glGetFenceivNV"); - s_gl.glFinishFenceNV = (glFinishFenceNV_t) s_gles_lib->findSymbol("glFinishFenceNV"); - s_gl.glSetFenceNV = (glSetFenceNV_t) s_gles_lib->findSymbol("glSetFenceNV"); - s_gl.glGetDriverControlsQCOM = (glGetDriverControlsQCOM_t) s_gles_lib->findSymbol("glGetDriverControlsQCOM"); - s_gl.glGetDriverControlStringQCOM = (glGetDriverControlStringQCOM_t) s_gles_lib->findSymbol("glGetDriverControlStringQCOM"); - s_gl.glEnableDriverControlQCOM = (glEnableDriverControlQCOM_t) s_gles_lib->findSymbol("glEnableDriverControlQCOM"); - s_gl.glDisableDriverControlQCOM = (glDisableDriverControlQCOM_t) s_gles_lib->findSymbol("glDisableDriverControlQCOM"); - s_gl.glExtGetTexturesQCOM = (glExtGetTexturesQCOM_t) s_gles_lib->findSymbol("glExtGetTexturesQCOM"); - s_gl.glExtGetBuffersQCOM = (glExtGetBuffersQCOM_t) s_gles_lib->findSymbol("glExtGetBuffersQCOM"); - s_gl.glExtGetRenderbuffersQCOM = (glExtGetRenderbuffersQCOM_t) s_gles_lib->findSymbol("glExtGetRenderbuffersQCOM"); - s_gl.glExtGetFramebuffersQCOM = (glExtGetFramebuffersQCOM_t) s_gles_lib->findSymbol("glExtGetFramebuffersQCOM"); - s_gl.glExtGetTexLevelParameterivQCOM = (glExtGetTexLevelParameterivQCOM_t) s_gles_lib->findSymbol("glExtGetTexLevelParameterivQCOM"); - s_gl.glExtTexObjectStateOverrideiQCOM = (glExtTexObjectStateOverrideiQCOM_t) s_gles_lib->findSymbol("glExtTexObjectStateOverrideiQCOM"); - s_gl.glExtGetTexSubImageQCOM = (glExtGetTexSubImageQCOM_t) s_gles_lib->findSymbol("glExtGetTexSubImageQCOM"); - s_gl.glExtGetBufferPointervQCOM = (glExtGetBufferPointervQCOM_t) s_gles_lib->findSymbol("glExtGetBufferPointervQCOM"); - s_gl.glExtGetShadersQCOM = (glExtGetShadersQCOM_t) s_gles_lib->findSymbol("glExtGetShadersQCOM"); - s_gl.glExtGetProgramsQCOM = (glExtGetProgramsQCOM_t) s_gles_lib->findSymbol("glExtGetProgramsQCOM"); - s_gl.glExtIsProgramBinaryQCOM = (glExtIsProgramBinaryQCOM_t) s_gles_lib->findSymbol("glExtIsProgramBinaryQCOM"); - s_gl.glExtGetProgramBinarySourceQCOM = (glExtGetProgramBinarySourceQCOM_t) s_gles_lib->findSymbol("glExtGetProgramBinarySourceQCOM"); - s_gl.glStartTilingQCOM = (glStartTilingQCOM_t) s_gles_lib->findSymbol("glStartTilingQCOM"); - s_gl.glEndTilingQCOM = (glEndTilingQCOM_t) s_gles_lib->findSymbol("glEndTilingQCOM"); - - return true; -} - -// -// This function is called only during initialiation before -// any thread has been created - hence it should NOT be thread safe. -// -void *gl_dispatch_get_proc_func(const char *name, void *userData) -{ - if (!s_gles_lib) { - return NULL; - } - return (void *)s_gles_lib->findSymbol(name); -} diff --git a/emulator/opengl/host/libs/libOpenglRender/GLDispatch.h b/emulator/opengl/host/libs/libOpenglRender/GLDispatch.h deleted file mode 100644 index 5fe98f1..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/GLDispatch.h +++ /dev/null @@ -1,300 +0,0 @@ -/* -* 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_DISPATCH_H -#define _GLES_DISPATCH_H - -#include "gl_proc.h" - - -struct GLDispatch { - glAlphaFunc_t glAlphaFunc; - glClearColor_t glClearColor; - glClearDepthf_t glClearDepthf; - glClipPlanef_t glClipPlanef; - glColor4f_t glColor4f; - glDepthRangef_t glDepthRangef; - glFogf_t glFogf; - glFogfv_t glFogfv; - glFrustumf_t glFrustumf; - glGetClipPlanef_t glGetClipPlanef; - glGetFloatv_t glGetFloatv; - glGetLightfv_t glGetLightfv; - glGetMaterialfv_t glGetMaterialfv; - glGetTexEnvfv_t glGetTexEnvfv; - glGetTexParameterfv_t glGetTexParameterfv; - glLightModelf_t glLightModelf; - glLightModelfv_t glLightModelfv; - glLightf_t glLightf; - glLightfv_t glLightfv; - glLineWidth_t glLineWidth; - glLoadMatrixf_t glLoadMatrixf; - glMaterialf_t glMaterialf; - glMaterialfv_t glMaterialfv; - glMultMatrixf_t glMultMatrixf; - glMultiTexCoord4f_t glMultiTexCoord4f; - glNormal3f_t glNormal3f; - glOrthof_t glOrthof; - glPointParameterf_t glPointParameterf; - glPointParameterfv_t glPointParameterfv; - glPointSize_t glPointSize; - glPolygonOffset_t glPolygonOffset; - glRotatef_t glRotatef; - glScalef_t glScalef; - glTexEnvf_t glTexEnvf; - glTexEnvfv_t glTexEnvfv; - glTexParameterf_t glTexParameterf; - glTexParameterfv_t glTexParameterfv; - glTranslatef_t glTranslatef; - glActiveTexture_t glActiveTexture; - glAlphaFuncx_t glAlphaFuncx; - glBindBuffer_t glBindBuffer; - glBindTexture_t glBindTexture; - glBlendFunc_t glBlendFunc; - glBufferData_t glBufferData; - glBufferSubData_t glBufferSubData; - glClear_t glClear; - glClearColorx_t glClearColorx; - glClearDepthx_t glClearDepthx; - glClearStencil_t glClearStencil; - glClientActiveTexture_t glClientActiveTexture; - glClipPlanex_t glClipPlanex; - glColor4ub_t glColor4ub; - glColor4x_t glColor4x; - glColorMask_t glColorMask; - glColorPointer_t glColorPointer; - glCompressedTexImage2D_t glCompressedTexImage2D; - glCompressedTexSubImage2D_t glCompressedTexSubImage2D; - glCopyTexImage2D_t glCopyTexImage2D; - glCopyTexSubImage2D_t glCopyTexSubImage2D; - glCullFace_t glCullFace; - glDeleteBuffers_t glDeleteBuffers; - glDeleteTextures_t glDeleteTextures; - glDepthFunc_t glDepthFunc; - glDepthMask_t glDepthMask; - glDepthRangex_t glDepthRangex; - glDisable_t glDisable; - glDisableClientState_t glDisableClientState; - glDrawArrays_t glDrawArrays; - glDrawElements_t glDrawElements; - glEnable_t glEnable; - glEnableClientState_t glEnableClientState; - glFinish_t glFinish; - glFlush_t glFlush; - glFogx_t glFogx; - glFogxv_t glFogxv; - glFrontFace_t glFrontFace; - glFrustumx_t glFrustumx; - glGetBooleanv_t glGetBooleanv; - glGetBufferParameteriv_t glGetBufferParameteriv; - glGetClipPlanex_t glGetClipPlanex; - glGenBuffers_t glGenBuffers; - glGenTextures_t glGenTextures; - glGetError_t glGetError; - glGetFixedv_t glGetFixedv; - glGetIntegerv_t glGetIntegerv; - glGetLightxv_t glGetLightxv; - glGetMaterialxv_t glGetMaterialxv; - glGetPointerv_t glGetPointerv; - glGetString_t glGetString; - glGetTexEnviv_t glGetTexEnviv; - glGetTexEnvxv_t glGetTexEnvxv; - glGetTexParameteriv_t glGetTexParameteriv; - glGetTexParameterxv_t glGetTexParameterxv; - glHint_t glHint; - glIsBuffer_t glIsBuffer; - glIsEnabled_t glIsEnabled; - glIsTexture_t glIsTexture; - glLightModelx_t glLightModelx; - glLightModelxv_t glLightModelxv; - glLightx_t glLightx; - glLightxv_t glLightxv; - glLineWidthx_t glLineWidthx; - glLoadIdentity_t glLoadIdentity; - glLoadMatrixx_t glLoadMatrixx; - glLogicOp_t glLogicOp; - glMaterialx_t glMaterialx; - glMaterialxv_t glMaterialxv; - glMatrixMode_t glMatrixMode; - glMultMatrixx_t glMultMatrixx; - glMultiTexCoord4x_t glMultiTexCoord4x; - glNormal3x_t glNormal3x; - glNormalPointer_t glNormalPointer; - glOrthox_t glOrthox; - glPixelStorei_t glPixelStorei; - glPointParameterx_t glPointParameterx; - glPointParameterxv_t glPointParameterxv; - glPointSizex_t glPointSizex; - glPolygonOffsetx_t glPolygonOffsetx; - glPopMatrix_t glPopMatrix; - glPushMatrix_t glPushMatrix; - glReadPixels_t glReadPixels; - glRotatex_t glRotatex; - glSampleCoverage_t glSampleCoverage; - glSampleCoveragex_t glSampleCoveragex; - glScalex_t glScalex; - glScissor_t glScissor; - glShadeModel_t glShadeModel; - glStencilFunc_t glStencilFunc; - glStencilMask_t glStencilMask; - glStencilOp_t glStencilOp; - glTexCoordPointer_t glTexCoordPointer; - glTexEnvi_t glTexEnvi; - glTexEnvx_t glTexEnvx; - glTexEnviv_t glTexEnviv; - glTexEnvxv_t glTexEnvxv; - glTexImage2D_t glTexImage2D; - glTexParameteri_t glTexParameteri; - glTexParameterx_t glTexParameterx; - glTexParameteriv_t glTexParameteriv; - glTexParameterxv_t glTexParameterxv; - glTexSubImage2D_t glTexSubImage2D; - glTranslatex_t glTranslatex; - glVertexPointer_t glVertexPointer; - glViewport_t glViewport; - glPointSizePointerOES_t glPointSizePointerOES; - glBlendEquationSeparateOES_t glBlendEquationSeparateOES; - glBlendFuncSeparateOES_t glBlendFuncSeparateOES; - glBlendEquationOES_t glBlendEquationOES; - glDrawTexsOES_t glDrawTexsOES; - glDrawTexiOES_t glDrawTexiOES; - glDrawTexxOES_t glDrawTexxOES; - glDrawTexsvOES_t glDrawTexsvOES; - glDrawTexivOES_t glDrawTexivOES; - glDrawTexxvOES_t glDrawTexxvOES; - glDrawTexfOES_t glDrawTexfOES; - glDrawTexfvOES_t glDrawTexfvOES; - glEGLImageTargetTexture2DOES_t glEGLImageTargetTexture2DOES; - glEGLImageTargetRenderbufferStorageOES_t glEGLImageTargetRenderbufferStorageOES; - glAlphaFuncxOES_t glAlphaFuncxOES; - glClearColorxOES_t glClearColorxOES; - glClearDepthxOES_t glClearDepthxOES; - glClipPlanexOES_t glClipPlanexOES; - glColor4xOES_t glColor4xOES; - glDepthRangexOES_t glDepthRangexOES; - glFogxOES_t glFogxOES; - glFogxvOES_t glFogxvOES; - glFrustumxOES_t glFrustumxOES; - glGetClipPlanexOES_t glGetClipPlanexOES; - glGetFixedvOES_t glGetFixedvOES; - glGetLightxvOES_t glGetLightxvOES; - glGetMaterialxvOES_t glGetMaterialxvOES; - glGetTexEnvxvOES_t glGetTexEnvxvOES; - glGetTexParameterxvOES_t glGetTexParameterxvOES; - glLightModelxOES_t glLightModelxOES; - glLightModelxvOES_t glLightModelxvOES; - glLightxOES_t glLightxOES; - glLightxvOES_t glLightxvOES; - glLineWidthxOES_t glLineWidthxOES; - glLoadMatrixxOES_t glLoadMatrixxOES; - glMaterialxOES_t glMaterialxOES; - glMaterialxvOES_t glMaterialxvOES; - glMultMatrixxOES_t glMultMatrixxOES; - glMultiTexCoord4xOES_t glMultiTexCoord4xOES; - glNormal3xOES_t glNormal3xOES; - glOrthoxOES_t glOrthoxOES; - glPointParameterxOES_t glPointParameterxOES; - glPointParameterxvOES_t glPointParameterxvOES; - glPointSizexOES_t glPointSizexOES; - glPolygonOffsetxOES_t glPolygonOffsetxOES; - glRotatexOES_t glRotatexOES; - glSampleCoveragexOES_t glSampleCoveragexOES; - glScalexOES_t glScalexOES; - glTexEnvxOES_t glTexEnvxOES; - glTexEnvxvOES_t glTexEnvxvOES; - glTexParameterxOES_t glTexParameterxOES; - glTexParameterxvOES_t glTexParameterxvOES; - glTranslatexOES_t glTranslatexOES; - glIsRenderbufferOES_t glIsRenderbufferOES; - glBindRenderbufferOES_t glBindRenderbufferOES; - glDeleteRenderbuffersOES_t glDeleteRenderbuffersOES; - glGenRenderbuffersOES_t glGenRenderbuffersOES; - glRenderbufferStorageOES_t glRenderbufferStorageOES; - glGetRenderbufferParameterivOES_t glGetRenderbufferParameterivOES; - glIsFramebufferOES_t glIsFramebufferOES; - glBindFramebufferOES_t glBindFramebufferOES; - glDeleteFramebuffersOES_t glDeleteFramebuffersOES; - glGenFramebuffersOES_t glGenFramebuffersOES; - glCheckFramebufferStatusOES_t glCheckFramebufferStatusOES; - glFramebufferRenderbufferOES_t glFramebufferRenderbufferOES; - glFramebufferTexture2DOES_t glFramebufferTexture2DOES; - glGetFramebufferAttachmentParameterivOES_t glGetFramebufferAttachmentParameterivOES; - glGenerateMipmapOES_t glGenerateMipmapOES; - glMapBufferOES_t glMapBufferOES; - glUnmapBufferOES_t glUnmapBufferOES; - glGetBufferPointervOES_t glGetBufferPointervOES; - glCurrentPaletteMatrixOES_t glCurrentPaletteMatrixOES; - glLoadPaletteFromModelViewMatrixOES_t glLoadPaletteFromModelViewMatrixOES; - glMatrixIndexPointerOES_t glMatrixIndexPointerOES; - glWeightPointerOES_t glWeightPointerOES; - glQueryMatrixxOES_t glQueryMatrixxOES; - glDepthRangefOES_t glDepthRangefOES; - glFrustumfOES_t glFrustumfOES; - glOrthofOES_t glOrthofOES; - glClipPlanefOES_t glClipPlanefOES; - glGetClipPlanefOES_t glGetClipPlanefOES; - glClearDepthfOES_t glClearDepthfOES; - glTexGenfOES_t glTexGenfOES; - glTexGenfvOES_t glTexGenfvOES; - glTexGeniOES_t glTexGeniOES; - glTexGenivOES_t glTexGenivOES; - glTexGenxOES_t glTexGenxOES; - glTexGenxvOES_t glTexGenxvOES; - glGetTexGenfvOES_t glGetTexGenfvOES; - glGetTexGenivOES_t glGetTexGenivOES; - glGetTexGenxvOES_t glGetTexGenxvOES; - glBindVertexArrayOES_t glBindVertexArrayOES; - glDeleteVertexArraysOES_t glDeleteVertexArraysOES; - glGenVertexArraysOES_t glGenVertexArraysOES; - glIsVertexArrayOES_t glIsVertexArrayOES; - glDiscardFramebufferEXT_t glDiscardFramebufferEXT; - glMultiDrawArraysEXT_t glMultiDrawArraysEXT; - glMultiDrawElementsEXT_t glMultiDrawElementsEXT; - glClipPlanefIMG_t glClipPlanefIMG; - glClipPlanexIMG_t glClipPlanexIMG; - glRenderbufferStorageMultisampleIMG_t glRenderbufferStorageMultisampleIMG; - glFramebufferTexture2DMultisampleIMG_t glFramebufferTexture2DMultisampleIMG; - glDeleteFencesNV_t glDeleteFencesNV; - glGenFencesNV_t glGenFencesNV; - glIsFenceNV_t glIsFenceNV; - glTestFenceNV_t glTestFenceNV; - glGetFenceivNV_t glGetFenceivNV; - glFinishFenceNV_t glFinishFenceNV; - glSetFenceNV_t glSetFenceNV; - glGetDriverControlsQCOM_t glGetDriverControlsQCOM; - glGetDriverControlStringQCOM_t glGetDriverControlStringQCOM; - glEnableDriverControlQCOM_t glEnableDriverControlQCOM; - glDisableDriverControlQCOM_t glDisableDriverControlQCOM; - glExtGetTexturesQCOM_t glExtGetTexturesQCOM; - glExtGetBuffersQCOM_t glExtGetBuffersQCOM; - glExtGetRenderbuffersQCOM_t glExtGetRenderbuffersQCOM; - glExtGetFramebuffersQCOM_t glExtGetFramebuffersQCOM; - glExtGetTexLevelParameterivQCOM_t glExtGetTexLevelParameterivQCOM; - glExtTexObjectStateOverrideiQCOM_t glExtTexObjectStateOverrideiQCOM; - glExtGetTexSubImageQCOM_t glExtGetTexSubImageQCOM; - glExtGetBufferPointervQCOM_t glExtGetBufferPointervQCOM; - glExtGetShadersQCOM_t glExtGetShadersQCOM; - glExtGetProgramsQCOM_t glExtGetProgramsQCOM; - glExtIsProgramBinaryQCOM_t glExtIsProgramBinaryQCOM; - glExtGetProgramBinarySourceQCOM_t glExtGetProgramBinarySourceQCOM; - glStartTilingQCOM_t glStartTilingQCOM; - glEndTilingQCOM_t glEndTilingQCOM; -}; - -bool init_gl_dispatch(); -void *gl_dispatch_get_proc_func(const char *name, void *userData); - -extern GLDispatch s_gl; -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/NativeLinuxSubWindow.cpp b/emulator/opengl/host/libs/libOpenglRender/NativeLinuxSubWindow.cpp deleted file mode 100644 index 5f71849..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/NativeLinuxSubWindow.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -* 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. -*/ -#include "NativeSubWindow.h" - -#include <stdio.h> - -static Bool WaitForMapNotify(Display *d, XEvent *e, char *arg) -{ - if (e->type == MapNotify && e->xmap.window == (Window)arg) { - return 1; - } - return 0; -} - -static Display *s_display = NULL; - -EGLNativeWindowType createSubWindow(FBNativeWindowType p_window, - EGLNativeDisplayType* display_out, - int x, int y,int width, int height){ - - // The call to this function is protected by a lock - // in FrameBuffer so it is safe to check and initialize s_display here - if (!s_display) s_display = XOpenDisplay(NULL); - *display_out = s_display; - - XSetWindowAttributes wa; - wa.event_mask = StructureNotifyMask; - Window win = XCreateWindow(*display_out,p_window,x,y, width,height,0,CopyFromParent,CopyFromParent,CopyFromParent,CWEventMask,&wa); - XMapWindow(*display_out,win); - XEvent e; - XIfEvent(*display_out, &e, WaitForMapNotify, (char *)win); - return win; -} - -void destroySubWindow(EGLNativeDisplayType dis,EGLNativeWindowType win){ - XDestroyWindow(dis, win); -} diff --git a/emulator/opengl/host/libs/libOpenglRender/NativeMacSubWindow.m b/emulator/opengl/host/libs/libOpenglRender/NativeMacSubWindow.m deleted file mode 100644 index f57f661..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/NativeMacSubWindow.m +++ /dev/null @@ -1,64 +0,0 @@ -/* -* 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. -*/ -#include "NativeSubWindow.h" -#include <Cocoa/Cocoa.h> - -/* - * EmuGLView inherit from NSView and override the isOpaque - * method to return YES. That prevents drawing of underlying window/view - * when the view needs to be redrawn. - */ -@interface EmuGLView : NSView { -} @end - -@implementation EmuGLView - - - (BOOL)isOpaque { - return YES; - } - -@end - - -EGLNativeWindowType createSubWindow(FBNativeWindowType p_window, - EGLNativeDisplayType* display_out, - int x, int y,int width, int height){ - NSWindow *win = (NSWindow *)p_window; - if (!win) { - return NULL; - } - - /* (x,y) assume an upper-left origin, but Cocoa uses a lower-left origin */ - NSRect content_rect = [win contentRectForFrameRect:[win frame]]; - int cocoa_y = (int)content_rect.size.height - (y + height); - NSRect contentRect = NSMakeRect(x, cocoa_y, width, height); - - NSView *glView = [[EmuGLView alloc] initWithFrame:contentRect]; - if (glView) { - [[win contentView] addSubview:glView]; - [win makeKeyAndOrderFront:nil]; - } - - return (EGLNativeWindowType)glView; -} - -void destroySubWindow(EGLNativeDisplayType dis,EGLNativeWindowType win){ - if(win){ - NSView *glView = (NSView *)win; - [glView removeFromSuperview]; - [glView release]; - } -} diff --git a/emulator/opengl/host/libs/libOpenglRender/NativeSubWindow.h b/emulator/opengl/host/libs/libOpenglRender/NativeSubWindow.h deleted file mode 100644 index 1965978..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/NativeSubWindow.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -* 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 NATIVE_SUB_WINDOW_H -#define NATIVE_SUB_WINDOW_H - -#include <EGL/egl.h> -#include "libOpenglRender/render_api_platform_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -EGLNativeWindowType createSubWindow(FBNativeWindowType p_window, - EGLNativeDisplayType* display_out, - int x, int y,int width, int height); - - -void destroySubWindow(EGLNativeDisplayType dis,EGLNativeWindowType win); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/NativeWindowsSubWindow.cpp b/emulator/opengl/host/libs/libOpenglRender/NativeWindowsSubWindow.cpp deleted file mode 100644 index e519b68..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/NativeWindowsSubWindow.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* -* 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. -*/ -#include "NativeSubWindow.h" -#include <stdio.h> - -LRESULT CALLBACK myWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -EGLNativeWindowType createSubWindow(FBNativeWindowType p_window, - EGLNativeDisplayType* display_out, - int x, int y,int width, int height){ - WNDCLASS wc; - wc.style = CS_OWNDC |CS_HREDRAW |CS_VREDRAW; // redraw if size changes - wc.lpfnWndProc = myWndProc; // points to window procedure - wc.cbClsExtra = 0; // no extra class memory - wc.cbWndExtra = sizeof(void*); // save extra window memory, to store VasWindow instance - wc.hInstance = NULL; // handle to instance - wc.hIcon = NULL; // predefined app. icon - wc.hCursor = NULL; - wc.hbrBackground = NULL; // no background brush - wc.lpszMenuName = NULL; // name of menu resource - wc.lpszClassName = "subWin"; // name of window class - - RegisterClass(&wc); - printf("creating window %d %d %d %d\n",x,y,width,height); - EGLNativeWindowType ret = CreateWindowEx( - WS_EX_NOPARENTNOTIFY, // do not bother our parent window - "subWin", - "sub", - WS_CHILD|WS_DISABLED, - x,y,width,height, - p_window, - NULL, - NULL, - NULL); - ShowWindow(ret,SW_SHOW); - return ret; -} - -void destroySubWindow(EGLNativeDisplayType dis,EGLNativeWindowType win){ - PostMessage(win, WM_CLOSE, 0, 0); -} diff --git a/emulator/opengl/host/libs/libOpenglRender/ReadBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/ReadBuffer.cpp deleted file mode 100644 index 837b094..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/ReadBuffer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* -* 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. -*/ -#include "ReadBuffer.h" -#include <string.h> -#include <assert.h> -#include <limits.h> -#include "ErrorLog.h" - -ReadBuffer::ReadBuffer(IOStream *stream, size_t bufsize) -{ - m_size = bufsize; - m_stream = stream; - m_buf = (unsigned char*)malloc(m_size*sizeof(unsigned char)); - m_validData = 0; - m_readPtr = m_buf; -} - -ReadBuffer::~ReadBuffer() -{ - free(m_buf); -} - -int ReadBuffer::getData() -{ - if ((m_validData > 0) && (m_readPtr > m_buf)) { - memmove(m_buf, m_readPtr, m_validData); - } - // get fresh data into the buffer; - size_t len = m_size - m_validData; - if (len==0) { - //we need to inc our buffer - size_t new_size = m_size*2; - unsigned char* new_buf; - if (new_size < m_size) { // overflow check - new_size = INT_MAX; - } - - new_buf = (unsigned char*)realloc(m_buf, new_size); - if (!new_buf) { - ERR("Failed to alloc %zu bytes for ReadBuffer\n", new_size); - return -1; - } - m_size = new_size; - m_buf = new_buf; - len = m_size - m_validData; - } - m_readPtr = m_buf; - if (NULL != m_stream->read(m_buf + m_validData, &len)) { - m_validData += len; - return len; - } - return -1; -} - -void ReadBuffer::consume(size_t amount) -{ - assert(amount <= m_validData); - m_validData -= amount; - m_readPtr += amount; -} diff --git a/emulator/opengl/host/libs/libOpenglRender/ReadBuffer.h b/emulator/opengl/host/libs/libOpenglRender/ReadBuffer.h deleted file mode 100644 index f2dfbce..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/ReadBuffer.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -* 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 _READ_BUFFER_H -#define _READ_BUFFER_H - -#include "IOStream.h" - -class ReadBuffer { -public: - ReadBuffer(IOStream *stream, size_t bufSize); - ~ReadBuffer(); - int getData(); // get fresh data from the stream - unsigned char *buf() { return m_readPtr; } // return the next read location - size_t validData() { return m_validData; } // return the amount of valid data in readptr - void consume(size_t amount); // notify that 'amount' data has been consumed; -private: - unsigned char *m_buf; - unsigned char *m_readPtr; - size_t m_size; - size_t m_validData; - IOStream *m_stream; -}; -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderContext.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderContext.cpp deleted file mode 100644 index f5cbd67..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/RenderContext.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -* 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. -*/ -#include "RenderContext.h" -#include "FBConfig.h" -#include "FrameBuffer.h" -#include "EGLDispatch.h" -#include "GLDispatch.h" - -RenderContext *RenderContext::create(int p_config, - RenderContextPtr p_shareContext, - bool p_isGL2) -{ - const FBConfig *fbconf = FBConfig::get(p_config); - if (!fbconf) { - return NULL; - } - - RenderContext *c = new RenderContext(); - if (!c) { - return NULL; - } - - EGLContext share = EGL_NO_CONTEXT; - if (p_shareContext.Ptr() != NULL) { - share = p_shareContext->getEGLContext(); - } - - GLint glContextAttribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 1, - EGL_NONE - }; - - if (p_isGL2) { - glContextAttribs[1] = 2; - c->m_isGL2 = true; - } - - c->m_ctx = s_egl.eglCreateContext(FrameBuffer::getFB()->getDisplay(), - fbconf->getEGLConfig(), share, - glContextAttribs); - - if (c->m_ctx == EGL_NO_CONTEXT) { - delete c; - return NULL; - } - - c->m_config = p_config; - return c; -} - -RenderContext::RenderContext() : - m_ctx(EGL_NO_CONTEXT), - m_config(0), - m_isGL2(false) -{ -} - -RenderContext::~RenderContext() -{ - if (m_ctx != EGL_NO_CONTEXT) { - s_egl.eglDestroyContext(FrameBuffer::getFB()->getDisplay(), m_ctx); - } -} diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderContext.h b/emulator/opengl/host/libs/libOpenglRender/RenderContext.h deleted file mode 100644 index 80ac43f..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/RenderContext.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* 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 _LIBRENDER_RENDERCONTEXT_H -#define _LIBRENDER_RENDERCONTEXT_H - -#include "emugl/common/smart_ptr.h" -#include <EGL/egl.h> -#include "GLDecoderContextData.h" - -class RenderContext; -typedef emugl::SmartPtr<RenderContext> RenderContextPtr; - -class RenderContext -{ -public: - static RenderContext *create(int p_config, RenderContextPtr p_shareContext, - bool p_isGL2 = false); - ~RenderContext(); - int getConfig() const { return m_config; } - - EGLContext getEGLContext() const { return m_ctx; } - bool isGL2() const { return m_isGL2; } - - GLDecoderContextData & decoderContextData() { return m_contextData; } - -private: - RenderContext(); - -private: - EGLContext m_ctx; - int m_config; - bool m_isGL2; - GLDecoderContextData m_contextData; -}; - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp deleted file mode 100644 index c7c792a..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/* -* 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. -*/ -#include "renderControl_dec.h" -#include "FrameBuffer.h" -#include "FBConfig.h" -#include "EGLDispatch.h" -#include "GLDispatch.h" -#include "GL2Dispatch.h" -#include "ThreadInfo.h" - -static const GLint rendererVersion = 1; - -static GLint rcGetRendererVersion() -{ - return rendererVersion; -} - -static EGLint rcGetEGLVersion(EGLint* major, EGLint* minor) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return EGL_FALSE; - } - *major = (EGLint)fb->getCaps().eglMajor; - *minor = (EGLint)fb->getCaps().eglMinor; - - return EGL_TRUE; -} - -static EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return 0; - } - - const char *str = s_egl.eglQueryString(fb->getDisplay(), name); - if (!str) { - return 0; - } - - int len = strlen(str) + 1; - if (!buffer || len > bufferSize) { - return -len; - } - - strcpy((char *)buffer, str); - return len; -} - -static EGLint rcGetGLString(EGLenum name, void* buffer, EGLint bufferSize) -{ - RenderThreadInfo *tInfo = RenderThreadInfo::get(); - if (!tInfo || !tInfo->currContext.Ptr()) { - return 0; - } - - const char *str = NULL; -#ifdef WITH_GLES2 - if (tInfo->currContext->isGL2()) { - str = (const char *)s_gl2.glGetString(name); - } - else { -#endif - str = (const char *)s_gl.glGetString(name); -#ifdef WITH_GLES2 - } -#endif - - if (!str) { - return 0; - } - - int len = strlen(str) + 1; - if (!buffer || len > bufferSize) { - return -len; - } - - strcpy((char *)buffer, str); - return len; -} - -static EGLint rcGetNumConfigs(uint32_t* numAttribs) -{ - if (numAttribs) { - *numAttribs = FBConfig::getNumAttribs(); - } - return FBConfig::getNumConfigs(); -} - -static EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer) -{ - int configSize = FBConfig::getNumAttribs(); - int nConfigs = FBConfig::getNumConfigs(); - uint32_t neededSize = (nConfigs + 1) * configSize * sizeof(GLuint); - if (!buffer || bufSize < neededSize) { - return -neededSize; - } - FBConfig::packConfigsInfo(buffer); - return nConfigs; -} - -static EGLint rcChooseConfig(EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return 0; - } - - return FBConfig::chooseConfig(fb, attribs, configs, configs_size); -} - -static EGLint rcGetFBParam(EGLint param) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return 0; - } - - EGLint ret = 0; - - switch(param) { - case FB_WIDTH: - ret = fb->getWidth(); - break; - case FB_HEIGHT: - ret = fb->getHeight(); - break; - case FB_XDPI: - ret = 72; // XXX: should be implemented - break; - case FB_YDPI: - ret = 72; // XXX: should be implemented - break; - case FB_FPS: - ret = 60; - break; - case FB_MIN_SWAP_INTERVAL: - ret = 1; // XXX: should be implemented - break; - case FB_MAX_SWAP_INTERVAL: - ret = 1; // XXX: should be implemented - break; - default: - break; - } - - return ret; -} - -static uint32_t rcCreateContext(uint32_t config, - uint32_t share, uint32_t glVersion) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return 0; - } - - HandleType ret = fb->createRenderContext(config, share, glVersion == 2); - return ret; -} - -static void rcDestroyContext(uint32_t context) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return; - } - - fb->DestroyRenderContext(context); -} - -static uint32_t rcCreateWindowSurface(uint32_t config, - uint32_t width, uint32_t height) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return 0; - } - - return fb->createWindowSurface(config, width, height); -} - -static void rcDestroyWindowSurface(uint32_t windowSurface) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return; - } - - fb->DestroyWindowSurface( windowSurface ); -} - -static uint32_t rcCreateColorBuffer(uint32_t width, - uint32_t height, GLenum internalFormat) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return 0; - } - - return fb->createColorBuffer(width, height, internalFormat); -} - -static int rcOpenColorBuffer2(uint32_t colorbuffer) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return -1; - } - return fb->openColorBuffer( colorbuffer ); -} - -// Deprecated, kept for compatibility with old system images only. -// Use rcOpenColorBuffer2 instead. -static void rcOpenColorBuffer(uint32_t colorbuffer) -{ - (void) rcOpenColorBuffer2(colorbuffer); -} - -static void rcCloseColorBuffer(uint32_t colorbuffer) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return; - } - fb->closeColorBuffer( colorbuffer ); -} - -static int rcFlushWindowColorBuffer(uint32_t windowSurface) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return -1; - } - if (!fb->flushWindowSurfaceColorBuffer(windowSurface)) { - return -1; - } - return 0; -} - -static void rcSetWindowColorBuffer(uint32_t windowSurface, - uint32_t colorBuffer) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return; - } - fb->setWindowSurfaceColorBuffer(windowSurface, colorBuffer); -} - -static EGLint rcMakeCurrent(uint32_t context, - uint32_t drawSurf, uint32_t readSurf) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return EGL_FALSE; - } - - bool ret = fb->bindContext(context, drawSurf, readSurf); - - return (ret ? EGL_TRUE : EGL_FALSE); -} - -static void rcFBPost(uint32_t colorBuffer) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return; - } - - fb->post(colorBuffer); -} - -static void rcFBSetSwapInterval(EGLint interval) -{ - // XXX: TBD - should be implemented -} - -static void rcBindTexture(uint32_t colorBuffer) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return; - } - - fb->bindColorBufferToTexture(colorBuffer); -} - -static void rcBindRenderbuffer(uint32_t colorBuffer) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return; - } - - fb->bindColorBufferToRenderbuffer(colorBuffer); -} - -static EGLint rcColorBufferCacheFlush(uint32_t colorBuffer, - EGLint postCount, int forRead) -{ - // XXX: TBD - should be implemented - return 0; -} - -static void rcReadColorBuffer(uint32_t colorBuffer, - GLint x, GLint y, - GLint width, GLint height, - GLenum format, GLenum type, void* pixels) -{ - // XXX: TBD - should be implemented -} - -static int rcUpdateColorBuffer(uint32_t colorBuffer, - GLint x, GLint y, - GLint width, GLint height, - GLenum format, GLenum type, void* pixels) -{ - FrameBuffer *fb = FrameBuffer::getFB(); - if (!fb) { - return -1; - } - - fb->updateColorBuffer(colorBuffer, x, y, width, height, format, type, pixels); - return 0; -} - -void initRenderControlContext(renderControl_decoder_context_t *dec) -{ - dec->rcGetRendererVersion = rcGetRendererVersion; - dec->rcGetEGLVersion = rcGetEGLVersion; - dec->rcQueryEGLString = rcQueryEGLString; - dec->rcGetGLString = rcGetGLString; - dec->rcGetNumConfigs = rcGetNumConfigs; - dec->rcGetConfigs = rcGetConfigs; - dec->rcChooseConfig = rcChooseConfig; - dec->rcGetFBParam = rcGetFBParam; - dec->rcCreateContext = rcCreateContext; - dec->rcDestroyContext = rcDestroyContext; - dec->rcCreateWindowSurface = rcCreateWindowSurface; - dec->rcDestroyWindowSurface = rcDestroyWindowSurface; - dec->rcCreateColorBuffer = rcCreateColorBuffer; - dec->rcOpenColorBuffer = rcOpenColorBuffer; - dec->rcCloseColorBuffer = rcCloseColorBuffer; - dec->rcSetWindowColorBuffer = rcSetWindowColorBuffer; - dec->rcFlushWindowColorBuffer = rcFlushWindowColorBuffer; - dec->rcMakeCurrent = rcMakeCurrent; - dec->rcFBPost = rcFBPost; - dec->rcFBSetSwapInterval = rcFBSetSwapInterval; - dec->rcBindTexture = rcBindTexture; - dec->rcBindRenderbuffer = rcBindRenderbuffer; - dec->rcColorBufferCacheFlush = rcColorBufferCacheFlush; - dec->rcReadColorBuffer = rcReadColorBuffer; - dec->rcUpdateColorBuffer = rcUpdateColorBuffer; - dec->rcOpenColorBuffer2 = rcOpenColorBuffer2; -} diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderControl.h b/emulator/opengl/host/libs/libOpenglRender/RenderControl.h deleted file mode 100644 index 233e809..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/RenderControl.h +++ /dev/null @@ -1,21 +0,0 @@ -/* -* 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 _RENDER_CONTROL_H -#define _RENDER_CONTROL_H - -void initRenderControlContext(renderControl_decoder_context_t *dec); - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderServer.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderServer.cpp deleted file mode 100644 index 53c65ee..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/RenderServer.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* -* 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. -*/ -#include "RenderServer.h" -#include "TcpStream.h" -#ifdef _WIN32 -#include "Win32PipeStream.h" -#else -#include "UnixStream.h" -#endif -#include "RenderThread.h" -#include "FrameBuffer.h" -#include <set> - -typedef std::set<RenderThread *> RenderThreadsSet; - -RenderServer::RenderServer() : - m_lock(), - m_listenSock(NULL), - m_exiting(false) -{ -} - -RenderServer::~RenderServer() -{ - delete m_listenSock; -} - - -extern "C" int gRendererStreamMode; - -RenderServer *RenderServer::create(char* addr, size_t addrLen) -{ - RenderServer *server = new RenderServer(); - if (!server) { - return NULL; - } - - if (gRendererStreamMode == STREAM_MODE_TCP) { - server->m_listenSock = new TcpStream(); - } else { -#ifdef _WIN32 - server->m_listenSock = new Win32PipeStream(); -#else - server->m_listenSock = new UnixStream(); -#endif - } - - char addrstr[SocketStream::MAX_ADDRSTR_LEN]; - if (server->m_listenSock->listen(addrstr) < 0) { - ERR("RenderServer::create failed to listen\n"); - delete server; - return NULL; - } - - size_t len = strlen(addrstr) + 1; - if (len > addrLen) { - ERR("RenderServer address name too big for provided buffer: %zu > %zu\n", - len, addrLen); - delete server; - return NULL; - } - memcpy(addr, addrstr, len); - - return server; -} - -intptr_t RenderServer::main() -{ - RenderThreadsSet threads; - - while(1) { - SocketStream *stream = m_listenSock->accept(); - if (!stream) { - fprintf(stderr,"Error accepting connection, aborting\n"); - break; - } - - unsigned int clientFlags; - if (!stream->readFully(&clientFlags, sizeof(unsigned int))) { - fprintf(stderr,"Error reading clientFlags\n"); - delete stream; - continue; - } - - DBG("RenderServer: Got new stream!\n"); - - // check if we have been requested to exit while waiting on accept - if ((clientFlags & IOSTREAM_CLIENT_EXIT_SERVER) != 0) { - m_exiting = true; - break; - } - - RenderThread *rt = RenderThread::create(stream, &m_lock); - if (!rt) { - fprintf(stderr,"Failed to create RenderThread\n"); - delete stream; - stream = NULL; - } else if (!rt->start()) { - fprintf(stderr,"Failed to start RenderThread\n"); - delete rt; - rt = NULL; - } - - // - // remove from the threads list threads which are - // no longer running - // - for (RenderThreadsSet::iterator n,t = threads.begin(); - t != threads.end(); - t = n) { - // first find next iterator - n = t; - n++; - - // delete and erase the current iterator - // if thread is no longer running - if ((*t)->isFinished()) { - delete (*t); - threads.erase(t); - } - } - - // if the thread has been created and started, insert it to the list - if (rt) { - threads.insert(rt); - DBG("Started new RenderThread\n"); - } - } - - // - // Wait for all threads to finish - // - for (RenderThreadsSet::iterator t = threads.begin(); - t != threads.end(); - t++) { - (*t)->wait(NULL); - delete (*t); - } - threads.clear(); - - // - // de-initialize the FrameBuffer object - // - FrameBuffer::finalize(); - return 0; -} diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderServer.h b/emulator/opengl/host/libs/libOpenglRender/RenderServer.h deleted file mode 100644 index 8be8a17..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/RenderServer.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* 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 _LIB_OPENGL_RENDER_RENDER_SERVER_H -#define _LIB_OPENGL_RENDER_RENDER_SERVER_H - -#include "SocketStream.h" -#include "emugl/common/mutex.h" -#include "emugl/common/thread.h" - -class RenderServer : public emugl::Thread -{ -public: - static RenderServer *create(char* addr, size_t addrLen); - virtual ~RenderServer(); - - virtual intptr_t main(); - - bool isExiting() const { return m_exiting; } - -private: - RenderServer(); - -private: - emugl::Mutex m_lock; - SocketStream *m_listenSock; - bool m_exiting; -}; - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp deleted file mode 100644 index 3dcfdb5..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -* 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. -*/ -#include "RenderThread.h" -#include "RenderControl.h" -#include "ThreadInfo.h" -#include "ReadBuffer.h" -#include "TimeUtils.h" -#include "GLDispatch.h" -#include "GL2Dispatch.h" -#include "EGLDispatch.h" -#include "FrameBuffer.h" - -#define STREAM_BUFFER_SIZE 4*1024*1024 - -RenderThread::RenderThread(IOStream *stream, emugl::Mutex *lock) : - emugl::Thread(), - m_lock(lock), - m_stream(stream), - m_finished(false) -{ -} - -RenderThread::~RenderThread() -{ - delete m_stream; -} - -RenderThread *RenderThread::create(IOStream *p_stream, emugl::Mutex *lock) -{ - return new RenderThread(p_stream, lock); -} - -intptr_t RenderThread::main() -{ - RenderThreadInfo tInfo; - - // - // initialize decoders - // - tInfo.m_glDec.initGL( gl_dispatch_get_proc_func, NULL ); - tInfo.m_gl2Dec.initGL( gl2_dispatch_get_proc_func, NULL ); - initRenderControlContext( &m_rcDec ); - - ReadBuffer readBuf(m_stream, STREAM_BUFFER_SIZE); - - int stats_totalBytes = 0; - long long stats_t0 = GetCurrentTimeMS(); - - // - // open dump file if RENDER_DUMP_DIR is defined - // - const char *dump_dir = getenv("RENDERER_DUMP_DIR"); - FILE *dumpFP = NULL; - if (dump_dir) { - size_t bsize = strlen(dump_dir) + 32; - char *fname = new char[bsize]; - snprintf(fname,bsize,"%s/stream_%p", dump_dir, this); - dumpFP = fopen(fname, "wb"); - if (!dumpFP) { - fprintf(stderr,"Warning: stream dump failed to open file %s\n",fname); - } - delete [] fname; - } - - while (1) { - - int stat = readBuf.getData(); - if (stat <= 0) { - break; - } - - // - // log received bandwidth statistics - // - stats_totalBytes += readBuf.validData(); - long long dt = GetCurrentTimeMS() - stats_t0; - if (dt > 1000) { - //float dts = (float)dt / 1000.0f; - //printf("Used Bandwidth %5.3f MB/s\n", ((float)stats_totalBytes / dts) / (1024.0f*1024.0f)); - stats_totalBytes = 0; - stats_t0 = GetCurrentTimeMS(); - } - - // - // dump stream to file if needed - // - if (dumpFP) { - int skip = readBuf.validData() - stat; - fwrite(readBuf.buf()+skip, 1, readBuf.validData()-skip, dumpFP); - fflush(dumpFP); - } - - bool progress; - do { - progress = false; - - m_lock->lock(); - // - // try to process some of the command buffer using the GLESv1 decoder - // - size_t last = tInfo.m_glDec.decode(readBuf.buf(), readBuf.validData(), m_stream); - if (last > 0) { - progress = true; - readBuf.consume(last); - } - - // - // try to process some of the command buffer using the GLESv2 decoder - // - last = tInfo.m_gl2Dec.decode(readBuf.buf(), readBuf.validData(), m_stream); - if (last > 0) { - progress = true; - readBuf.consume(last); - } - - // - // try to process some of the command buffer using the - // renderControl decoder - // - last = m_rcDec.decode(readBuf.buf(), readBuf.validData(), m_stream); - if (last > 0) { - readBuf.consume(last); - progress = true; - } - - m_lock->unlock(); - - } while( progress ); - - } - - if (dumpFP) { - fclose(dumpFP); - } - - // - // Release references to the current thread's context/surfaces if any - // - FrameBuffer::getFB()->bindContext(0, 0, 0); - if (tInfo.currContext || tInfo.currDrawSurf || tInfo.currReadSurf) { - fprintf(stderr, "ERROR: RenderThread exiting with current context/surfaces\n"); - } - - // - // flag that this thread has finished execution - m_finished = true; - - return 0; -} diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderThread.h b/emulator/opengl/host/libs/libOpenglRender/RenderThread.h deleted file mode 100644 index c1f919a..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/RenderThread.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -* 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 _LIB_OPENGL_RENDER_RENDER_THREAD_H -#define _LIB_OPENGL_RENDER_RENDER_THREAD_H - -#include "IOStream.h" -#include "GLDecoder.h" -#include "renderControl_dec.h" - -#include "emugl/common/mutex.h" -#include "emugl/common/thread.h" - -class RenderThread : public emugl::Thread -{ -public: - static RenderThread* create(IOStream* p_stream, emugl::Mutex* mutex); - virtual ~RenderThread(); - bool isFinished() const { return m_finished; } - -private: - RenderThread(IOStream* p_stream, emugl::Mutex* mutex); - virtual intptr_t main(); - -private: - emugl::Mutex *m_lock; - IOStream *m_stream; - renderControl_decoder_context_t m_rcDec; - bool m_finished; -}; - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp b/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp deleted file mode 100644 index 5337009..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -* 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. -*/ - -#include "ThreadInfo.h" -#include "emugl/common/lazy_instance.h" -#include "emugl/common/thread_store.h" - -namespace { - -class ThreadInfoStore : public ::emugl::ThreadStore { -public: - ThreadInfoStore() : ::emugl::ThreadStore(NULL) {} -}; - -} // namespace - -static ::emugl::LazyInstance<ThreadInfoStore> s_tls = LAZY_INSTANCE_INIT; - -RenderThreadInfo::RenderThreadInfo() { - s_tls->set(this); -} - -RenderThreadInfo::~RenderThreadInfo() { - s_tls->set(NULL); -} - -RenderThreadInfo* RenderThreadInfo::get() { - return static_cast<RenderThreadInfo*>(s_tls->get()); -} diff --git a/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.h b/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.h deleted file mode 100644 index 2e67521..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -* 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 _LIB_OPENGL_RENDER_THREAD_INFO_H -#define _LIB_OPENGL_RENDER_THREAD_INFO_H - -#include "RenderContext.h" -#include "WindowSurface.h" -#include "GLDecoder.h" -#include "GL2Decoder.h" - -struct RenderThreadInfo -{ - RenderThreadInfo(); - ~RenderThreadInfo(); - static RenderThreadInfo* get(); - - RenderContextPtr currContext; - WindowSurfacePtr currDrawSurf; - WindowSurfacePtr currReadSurf; - GLDecoder m_glDec; - GL2Decoder m_gl2Dec; -}; - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp deleted file mode 100644 index bdda01a..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* -* 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. -*/ -#include "WindowSurface.h" -#include "FBConfig.h" -#include "FrameBuffer.h" -#include <GLES/glext.h> -#include "EGLDispatch.h" -#include "GLDispatch.h" -#include "GL2Dispatch.h" -#include <stdio.h> -#include <string.h> -#include "GLErrorLog.h" - -WindowSurface::WindowSurface() : - m_fbObj(0), - m_depthRB(0), - m_stencilRB(0), - m_eglSurface(NULL), - m_attachedColorBuffer(NULL), - m_readContext(NULL), - m_drawContext(NULL), - m_width(0), - m_height(0), - m_pbufWidth(0), - m_pbufHeight(0) -{ -} - -WindowSurface::~WindowSurface() -{ - s_egl.eglDestroySurface(FrameBuffer::getFB()->getDisplay(), m_eglSurface); -} - -WindowSurface *WindowSurface::create(int p_config, int p_width, int p_height) -{ - const FBConfig *fbconf = FBConfig::get(p_config); - if (!fbconf) { - return NULL; - } - - // allocate space for the WindowSurface object - WindowSurface *win = new WindowSurface(); - if (!win) { - return NULL; - } - win->m_fbconf = fbconf; - - // - // Create a pbuffer to be used as the egl surface - // for that window. - // - if (!win->resizePbuffer(p_width, p_height)) { - delete win; - return NULL; - } - - win->m_width = p_width; - win->m_height = p_height; - - return win; -} - -// -// flushColorBuffer - The function makes sure that the -// previous attached color buffer is updated, if copy or blit should be done -// in order to update it - it is being done here. -// -bool WindowSurface::flushColorBuffer() -{ - if (m_attachedColorBuffer.Ptr() != NULL) { - return blitToColorBuffer(); - } - return true; -} - -// -// setColorBuffer - this function is called when a new color buffer needs to -// be attached to the surface. The function doesn't make sure that the -// previous attached color buffer is updated, this is done by flushColorBuffer -// -void WindowSurface::setColorBuffer(ColorBufferPtr p_colorBuffer) -{ - m_attachedColorBuffer = p_colorBuffer; - - // - // resize the window if the attached color buffer is of different - // size - // - unsigned int cbWidth = m_attachedColorBuffer->getWidth(); - unsigned int cbHeight = m_attachedColorBuffer->getHeight(); - - if (cbWidth != m_width || cbHeight != m_height) { - - if (m_pbufWidth && m_pbufHeight) { - // if we use pbuffer, need to resize it - resizePbuffer(cbWidth, cbHeight); - } - - m_width = cbWidth; - m_height = cbHeight; - } -} - -// -// This function is called after the context and eglSurface is already -// bound in the current thread (eglMakeCurrent has been called). -// This function should take actions required on the other surface objects -// when being bind/unbound -// -void WindowSurface::bind(RenderContextPtr p_ctx, SurfaceBindType p_bindType) -{ - if (p_bindType == SURFACE_BIND_READ) { - m_readContext = p_ctx; - } - else if (p_bindType == SURFACE_BIND_DRAW) { - m_drawContext = p_ctx; - } - else if (p_bindType == SURFACE_BIND_READDRAW) { - m_readContext = p_ctx; - m_drawContext = p_ctx; - } - else { - return; // bad param - } - -} - -bool WindowSurface::blitToColorBuffer() -{ - if (!m_width && !m_height) return false; - - if (m_attachedColorBuffer->getWidth() != m_width || - m_attachedColorBuffer->getHeight() != m_height) { - // XXX: should never happen - how this needs to be handled? - fprintf(stderr, "Dimensions do not match\n"); - return false; - } - - // - // Make the surface current - // - EGLContext prevContext = s_egl.eglGetCurrentContext(); - EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ); - EGLSurface prevDrawSurf = s_egl.eglGetCurrentSurface(EGL_DRAW); - FrameBuffer *fb = FrameBuffer::getFB(); - if (!m_drawContext.Ptr()) { - fprintf(stderr, "Draw context is NULL\n"); - return false; - } - if (!s_egl.eglMakeCurrent(fb->getDisplay(), m_eglSurface, - m_eglSurface, m_drawContext->getEGLContext())) { - fprintf(stderr, "Error making draw context current\n"); - return false; - } - - m_attachedColorBuffer->blitFromCurrentReadBuffer(); - - // restore current context/surface - s_egl.eglMakeCurrent(fb->getDisplay(), prevDrawSurf, - prevReadSurf, prevContext); - return true; -} - -bool WindowSurface::resizePbuffer(unsigned int p_width, unsigned int p_height) -{ - if (m_eglSurface && - m_pbufWidth == p_width && - m_pbufHeight == p_height) { - // no need to resize - return true; - } - - FrameBuffer *fb = FrameBuffer::getFB(); - - EGLContext prevContext = s_egl.eglGetCurrentContext(); - EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ); - EGLSurface prevDrawSurf = s_egl.eglGetCurrentSurface(EGL_DRAW); - EGLSurface prevPbuf = m_eglSurface; - bool needRebindContext = m_eglSurface && - (prevReadSurf == m_eglSurface || - prevDrawSurf == m_eglSurface); - - if (needRebindContext) { - s_egl.eglMakeCurrent(fb->getDisplay(), EGL_NO_SURFACE, - EGL_NO_SURFACE, EGL_NO_CONTEXT); - } - - // - // Destroy previous surface - // - if (m_eglSurface) { - s_egl.eglDestroySurface(fb->getDisplay(), m_eglSurface); - m_eglSurface = NULL; - } - - // - // Create pbuffer surface. - // - EGLint pbufAttribs[5]; - pbufAttribs[0] = EGL_WIDTH; - pbufAttribs[1] = p_width; - pbufAttribs[2] = EGL_HEIGHT; - pbufAttribs[3] = p_height; - pbufAttribs[4] = EGL_NONE; - - m_eglSurface = s_egl.eglCreatePbufferSurface(fb->getDisplay(), - m_fbconf->getEGLConfig(), - pbufAttribs); - if (m_eglSurface == EGL_NO_SURFACE) { - fprintf(stderr, "Renderer error: failed to create/resize pbuffer!!\n"); - return false; - } - - m_pbufWidth = p_width; - m_pbufHeight = p_height; - - if (needRebindContext) { - s_egl.eglMakeCurrent(fb->getDisplay(), - (prevDrawSurf==prevPbuf) ? m_eglSurface : prevDrawSurf, - (prevReadSurf==prevPbuf) ? m_eglSurface : prevReadSurf, - prevContext); - } - - return true; -} diff --git a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h deleted file mode 100644 index fe35a94..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -* 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 _LIBRENDER_WINDOWSURFACE_H -#define _LIBRENDER_WINDOWSURFACE_H - -#include "ColorBuffer.h" -#include "RenderContext.h" -#include "FBConfig.h" -#include "emugl/common/smart_ptr.h" -#include "FixedBuffer.h" -#include <EGL/egl.h> -#include <GLES/gl.h> - -enum SurfaceBindType { - SURFACE_BIND_READ, - SURFACE_BIND_DRAW, - SURFACE_BIND_READDRAW -}; - -class WindowSurface -{ -public: - static WindowSurface *create(int p_config, int p_width, int p_height); - ~WindowSurface(); - EGLSurface getEGLSurface() const { return m_eglSurface; } - - void setColorBuffer(ColorBufferPtr p_colorBuffer); - bool flushColorBuffer(); - void bind(RenderContextPtr p_ctx, SurfaceBindType p_bindType); - -private: - WindowSurface(); - - bool blitToColorBuffer(); // copy pbuffer content with texload and blit - bool resizePbuffer(unsigned int p_width, unsigned int p_height); - -private: - GLuint m_fbObj; // GLES Framebuffer object (when EGLimage is used) - GLuint m_depthRB; - GLuint m_stencilRB; - EGLSurface m_eglSurface; - ColorBufferPtr m_attachedColorBuffer; - RenderContextPtr m_readContext; - RenderContextPtr m_drawContext; - GLuint m_width; - GLuint m_height; - GLuint m_pbufWidth; - GLuint m_pbufHeight; - bool m_useEGLImage; - bool m_useBindToTexture; - FixedBuffer m_xferBuffer; - FixedBuffer m_xUpdateBuf; - const FBConfig *m_fbconf; -}; - -typedef emugl::SmartPtr<WindowSurface> WindowSurfacePtr; - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/egl_proc.h b/emulator/opengl/host/libs/libOpenglRender/egl_proc.h deleted file mode 100644 index 01dc4ae..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/egl_proc.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* 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 _EGL_PROC_H -#define _EGL_PROC_H - -#include <EGL/egl.h> -#define EGL_EGLEXT_PROTOTYPES -#include <EGL/eglext.h> - -typedef EGLint (EGLAPIENTRY *eglGetError_t) (); -typedef EGLDisplay (EGLAPIENTRY *eglGetDisplay_t) (EGLNativeDisplayType); -typedef EGLBoolean (EGLAPIENTRY *eglInitialize_t) (EGLDisplay, EGLint*, EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglTerminate_t) (EGLDisplay); -typedef char* (EGLAPIENTRY *eglQueryString_t) (EGLDisplay, EGLint); -typedef EGLBoolean (EGLAPIENTRY *eglGetConfigs_t) (EGLDisplay, EGLConfig*, EGLint, EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglChooseConfig_t) (EGLDisplay, const EGLint*, EGLConfig*, EGLint, EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglGetConfigAttrib_t) (EGLDisplay, EGLConfig, EGLint, EGLint*); -typedef EGLSurface (EGLAPIENTRY *eglCreateWindowSurface_t) (EGLDisplay, EGLConfig, EGLNativeWindowType, const EGLint*); -typedef EGLSurface (EGLAPIENTRY *eglCreatePbufferSurface_t) (EGLDisplay, EGLConfig, const EGLint*); -typedef EGLSurface (EGLAPIENTRY *eglCreatePixmapSurface_t) (EGLDisplay, EGLConfig, EGLNativePixmapType, const EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglDestroySurface_t) (EGLDisplay, EGLSurface); -typedef EGLBoolean (EGLAPIENTRY *eglQuerySurface_t) (EGLDisplay, EGLSurface, EGLint, EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglBindAPI_t) (EGLenum); -typedef EGLenum (* eglQueryAPI_t) (); -typedef EGLBoolean (EGLAPIENTRY *eglWaitClient_t) (); -typedef EGLBoolean (EGLAPIENTRY *eglReleaseThread_t) (); -typedef EGLSurface (EGLAPIENTRY *eglCreatePbufferFromClientBuffer_t) (EGLDisplay, EGLenum, EGLClientBuffer, EGLConfig, const EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglSurfaceAttrib_t) (EGLDisplay, EGLSurface, EGLint, EGLint); -typedef EGLBoolean (EGLAPIENTRY *eglBindTexImage_t) (EGLDisplay, EGLSurface, EGLint); -typedef EGLBoolean (EGLAPIENTRY *eglReleaseTexImage_t) (EGLDisplay, EGLSurface, EGLint); -typedef EGLBoolean (EGLAPIENTRY *eglSwapInterval_t) (EGLDisplay, EGLint); -typedef EGLContext (EGLAPIENTRY *eglCreateContext_t) (EGLDisplay, EGLConfig, EGLContext, const EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglDestroyContext_t) (EGLDisplay, EGLContext); -typedef EGLBoolean (EGLAPIENTRY *eglMakeCurrent_t) (EGLDisplay, EGLSurface, EGLSurface, EGLContext); -typedef EGLContext (EGLAPIENTRY *eglGetCurrentContext_t) (); -typedef EGLSurface (EGLAPIENTRY *eglGetCurrentSurface_t) (EGLint); -typedef EGLDisplay (EGLAPIENTRY *eglGetCurrentDisplay_t) (); -typedef EGLBoolean (EGLAPIENTRY *eglQueryContext_t) (EGLDisplay, EGLContext, EGLint, EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglWaitGL_t) (); -typedef EGLBoolean (EGLAPIENTRY *eglWaitNative_t) (EGLint); -typedef EGLBoolean (EGLAPIENTRY *eglSwapBuffers_t) (EGLDisplay, EGLSurface); -typedef EGLBoolean (EGLAPIENTRY *eglCopyBuffers_t) (EGLDisplay, EGLSurface, EGLNativePixmapType); -typedef __eglMustCastToProperFunctionPointerType (EGLAPIENTRY *eglGetProcAddress_t) (const char*); -typedef EGLBoolean (EGLAPIENTRY *eglLockSurfaceKHR_t) (EGLDisplay, EGLSurface, const EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglUnlockSurfaceKHR_t) (EGLDisplay, EGLSurface); -typedef EGLImageKHR (EGLAPIENTRY *eglCreateImageKHR_t) (EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglDestroyImageKHR_t) (EGLDisplay, EGLImageKHR image); -typedef EGLSyncKHR (EGLAPIENTRY *eglCreateSyncKHR_t) (EGLDisplay, EGLenum, const EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglDestroySyncKHR_t) (EGLDisplay, EGLSyncKHR sync); -typedef EGLint (EGLAPIENTRY *eglClientWaitSyncKHR_t) (EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR timeout); -typedef EGLBoolean (EGLAPIENTRY *eglSignalSyncKHR_t) (EGLDisplay, EGLSyncKHR, EGLenum); -typedef EGLBoolean (EGLAPIENTRY *eglGetSyncAttribKHR_t) (EGLDisplay, EGLSyncKHR, EGLint, EGLint*); -typedef EGLBoolean (EGLAPIENTRY *eglSetSwapRectangleANDROID_t) (EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint); - -#endif // of _EGL_PROC_H diff --git a/emulator/opengl/host/libs/libOpenglRender/gl_proc.h b/emulator/opengl/host/libs/libOpenglRender/gl_proc.h deleted file mode 100644 index 465a10d..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/gl_proc.h +++ /dev/null @@ -1,296 +0,0 @@ -/* -* 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_PROC_H -#define _GLES_PROC_H - -#include <GLES/gl.h> -#define GL_GLEXT_PROTOTYPES -#include <GLES/glext.h> - -typedef void (GL_APIENTRY *glAlphaFunc_t) (GLenum, GLclampf); -typedef void (GL_APIENTRY *glClearColor_t) (GLclampf, GLclampf, GLclampf, GLclampf); -typedef void (GL_APIENTRY *glClearDepthf_t) (GLclampf); -typedef void (GL_APIENTRY *glClipPlanef_t) (GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glColor4f_t) (GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glDepthRangef_t) (GLclampf, GLclampf); -typedef void (GL_APIENTRY *glFogf_t) (GLenum, GLfloat); -typedef void (GL_APIENTRY *glFogfv_t) (GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glFrustumf_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glGetClipPlanef_t) (GLenum, GLfloat); -typedef void (GL_APIENTRY *glGetFloatv_t) (GLenum, GLfloat*); -typedef void (GL_APIENTRY *glGetLightfv_t) (GLenum, GLenum, GLfloat*); -typedef void (GL_APIENTRY *glGetMaterialfv_t) (GLenum, GLenum, GLfloat*); -typedef void (GL_APIENTRY *glGetTexEnvfv_t) (GLenum, GLenum, GLfloat*); -typedef void (GL_APIENTRY *glGetTexParameterfv_t) (GLenum, GLenum, GLfloat*); -typedef void (GL_APIENTRY *glLightModelf_t) (GLenum, GLfloat); -typedef void (GL_APIENTRY *glLightModelfv_t) (GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glLightf_t) (GLenum, GLenum, GLfloat); -typedef void (GL_APIENTRY *glLightfv_t) (GLenum, GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glLineWidth_t) (GLfloat); -typedef void (GL_APIENTRY *glLoadMatrixf_t) (const GLfloat*); -typedef void (GL_APIENTRY *glMaterialf_t) (GLenum, GLenum, GLfloat); -typedef void (GL_APIENTRY *glMaterialfv_t) (GLenum, GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glMultMatrixf_t) (const GLfloat*); -typedef void (GL_APIENTRY *glMultiTexCoord4f_t) (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glNormal3f_t) (GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glOrthof_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glPointParameterf_t) (GLenum, GLfloat); -typedef void (GL_APIENTRY *glPointParameterfv_t) (GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glPointSize_t) (GLfloat); -typedef void (GL_APIENTRY *glPolygonOffset_t) (GLfloat, GLfloat); -typedef void (GL_APIENTRY *glRotatef_t) (GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glScalef_t) (GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glTexEnvf_t) (GLenum, GLenum, GLfloat); -typedef void (GL_APIENTRY *glTexEnvfv_t) (GLenum, GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glTexParameterf_t) (GLenum, GLenum, GLfloat); -typedef void (GL_APIENTRY *glTexParameterfv_t) (GLenum, GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glTranslatef_t) (GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glActiveTexture_t) (GLenum); -typedef void (GL_APIENTRY *glAlphaFuncx_t) (GLenum, GLclampx); -typedef void (GL_APIENTRY *glBindBuffer_t) (GLenum, GLuint); -typedef void (GL_APIENTRY *glBindTexture_t) (GLenum, GLuint); -typedef void (GL_APIENTRY *glBlendFunc_t) (GLenum, GLenum); -typedef void (GL_APIENTRY *glBufferData_t) (GLenum, GLsizeiptr, const GLvoid*, GLenum); -typedef void (GL_APIENTRY *glBufferSubData_t) (GLenum, GLintptr, GLsizeiptr, const GLvoid*); -typedef void (GL_APIENTRY *glClear_t) (GLbitfield); -typedef void (GL_APIENTRY *glClearColorx_t) (GLclampx, GLclampx, GLclampx, GLclampx); -typedef void (GL_APIENTRY *glClearDepthx_t) (GLclampx); -typedef void (GL_APIENTRY *glClearStencil_t) (GLint); -typedef void (GL_APIENTRY *glClientActiveTexture_t) (GLenum); -typedef void (GL_APIENTRY *glClipPlanex_t) (GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glColor4ub_t) (GLubyte, GLubyte, GLubyte, GLubyte); -typedef void (GL_APIENTRY *glColor4x_t) (GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glColorMask_t) (GLboolean, GLboolean, GLboolean, GLboolean); -typedef void (GL_APIENTRY *glColorPointer_t) (GLint, GLenum, GLsizei, const GLvoid*); -typedef void (GL_APIENTRY *glCompressedTexImage2D_t) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*); -typedef void (GL_APIENTRY *glCompressedTexSubImage2D_t) (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*); -typedef void (GL_APIENTRY *glCopyTexImage2D_t) (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -typedef void (GL_APIENTRY *glCopyTexSubImage2D_t) (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -typedef void (GL_APIENTRY *glCullFace_t) (GLenum); -typedef void (GL_APIENTRY *glDeleteBuffers_t) (GLsizei, const GLuint*); -typedef void (GL_APIENTRY *glDeleteTextures_t) (GLsizei, const GLuint*); -typedef void (GL_APIENTRY *glDepthFunc_t) (GLenum); -typedef void (GL_APIENTRY *glDepthMask_t) (GLboolean); -typedef void (GL_APIENTRY *glDepthRangex_t) (GLclampx, GLclampx); -typedef void (GL_APIENTRY *glDisable_t) (GLenum); -typedef void (GL_APIENTRY *glDisableClientState_t) (GLenum); -typedef void (GL_APIENTRY *glDrawArrays_t) (GLenum, GLint, GLsizei); -typedef void (GL_APIENTRY *glDrawElements_t) (GLenum, GLsizei, GLenum, const GLvoid*); -typedef void (GL_APIENTRY *glEnable_t) (GLenum); -typedef void (GL_APIENTRY *glEnableClientState_t) (GLenum); -typedef void (GL_APIENTRY *glFinish_t) (); -typedef void (GL_APIENTRY *glFlush_t) (); -typedef void (GL_APIENTRY *glFogx_t) (GLenum, GLfixed); -typedef void (GL_APIENTRY *glFogxv_t) (GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glFrontFace_t) (GLenum); -typedef void (GL_APIENTRY *glFrustumx_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glGetBooleanv_t) (GLenum, GLboolean*); -typedef void (GL_APIENTRY *glGetBufferParameteriv_t) (GLenum, GLenum, GLint*); -typedef void (GL_APIENTRY *glGetClipPlanex_t) (GLenum, GLfixed); -typedef void (GL_APIENTRY *glGenBuffers_t) (GLsizei, GLuint*); -typedef void (GL_APIENTRY *glGenTextures_t) (GLsizei, GLuint*); -typedef GLenum (GL_APIENTRY *glGetError_t) (); -typedef void (GL_APIENTRY *glGetFixedv_t) (GLenum, GLfixed*); -typedef void (GL_APIENTRY *glGetIntegerv_t) (GLenum, GLint*); -typedef void (GL_APIENTRY *glGetLightxv_t) (GLenum, GLenum, GLfixed*); -typedef void (GL_APIENTRY *glGetMaterialxv_t) (GLenum, GLenum, GLfixed*); -typedef void (GL_APIENTRY *glGetPointerv_t) (GLenum, GLvoid*); -typedef const GLubyte* (GL_APIENTRY *glGetString_t) (GLenum); -typedef void (GL_APIENTRY *glGetTexEnviv_t) (GLenum, GLenum, GLint*); -typedef void (GL_APIENTRY *glGetTexEnvxv_t) (GLenum, GLenum, GLfixed*); -typedef void (GL_APIENTRY *glGetTexParameteriv_t) (GLenum, GLenum, GLint*); -typedef void (GL_APIENTRY *glGetTexParameterxv_t) (GLenum, GLenum, GLfixed*); -typedef void (GL_APIENTRY *glHint_t) (GLenum, GLenum); -typedef GLboolean (GL_APIENTRY *glIsBuffer_t) (GLuint); -typedef GLboolean (GL_APIENTRY *glIsEnabled_t) (GLenum); -typedef GLboolean (GL_APIENTRY *glIsTexture_t) (GLuint); -typedef void (GL_APIENTRY *glLightModelx_t) (GLenum, GLfixed); -typedef void (GL_APIENTRY *glLightModelxv_t) (GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glLightx_t) (GLenum, GLenum, GLfixed); -typedef void (GL_APIENTRY *glLightxv_t) (GLenum, GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glLineWidthx_t) (GLfixed); -typedef void (GL_APIENTRY *glLoadIdentity_t) (); -typedef void (GL_APIENTRY *glLoadMatrixx_t) (const GLfixed*); -typedef void (GL_APIENTRY *glLogicOp_t) (GLenum); -typedef void (GL_APIENTRY *glMaterialx_t) (GLenum, GLenum, GLfixed); -typedef void (GL_APIENTRY *glMaterialxv_t) (GLenum, GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glMatrixMode_t) (GLenum); -typedef void (GL_APIENTRY *glMultMatrixx_t) (const GLfixed*); -typedef void (GL_APIENTRY *glMultiTexCoord4x_t) (GLenum, GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glNormal3x_t) (GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glNormalPointer_t) (GLenum, GLsizei, const GLvoid*); -typedef void (GL_APIENTRY *glOrthox_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glPixelStorei_t) (GLenum, GLint); -typedef void (GL_APIENTRY *glPointParameterx_t) (GLenum, GLfixed); -typedef void (GL_APIENTRY *glPointParameterxv_t) (GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glPointSizex_t) (GLfixed); -typedef void (GL_APIENTRY *glPolygonOffsetx_t) (GLfixed, GLfixed); -typedef void (GL_APIENTRY *glPopMatrix_t) (); -typedef void (GL_APIENTRY *glPushMatrix_t) (); -typedef void (GL_APIENTRY *glReadPixels_t) (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*); -typedef void (GL_APIENTRY *glRotatex_t) (GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glSampleCoverage_t) (GLclampf, GLboolean); -typedef void (GL_APIENTRY *glSampleCoveragex_t) (GLclampx, GLboolean); -typedef void (GL_APIENTRY *glScalex_t) (GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glScissor_t) (GLint, GLint, GLsizei, GLsizei); -typedef void (GL_APIENTRY *glShadeModel_t) (GLenum); -typedef void (GL_APIENTRY *glStencilFunc_t) (GLenum, GLint, GLuint); -typedef void (GL_APIENTRY *glStencilMask_t) (GLuint); -typedef void (GL_APIENTRY *glStencilOp_t) (GLenum, GLenum, GLenum); -typedef void (GL_APIENTRY *glTexCoordPointer_t) (GLint, GLenum, GLsizei, const GLvoid*); -typedef void (GL_APIENTRY *glTexEnvi_t) (GLenum, GLenum, GLint); -typedef void (GL_APIENTRY *glTexEnvx_t) (GLenum, GLenum, GLfixed); -typedef void (GL_APIENTRY *glTexEnviv_t) (GLenum, GLenum, const GLint*); -typedef void (GL_APIENTRY *glTexEnvxv_t) (GLenum, GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glTexImage2D_t) (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*); -typedef void (GL_APIENTRY *glTexParameteri_t) (GLenum, GLenum, GLint); -typedef void (GL_APIENTRY *glTexParameterx_t) (GLenum, GLenum, GLfixed); -typedef void (GL_APIENTRY *glTexParameteriv_t) (GLenum, GLenum, const GLint*); -typedef void (GL_APIENTRY *glTexParameterxv_t) (GLenum, GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glTexSubImage2D_t) (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*); -typedef void (GL_APIENTRY *glTranslatex_t) (GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glVertexPointer_t) (GLint, GLenum, GLsizei, const GLvoid*); -typedef void (GL_APIENTRY *glViewport_t) (GLint, GLint, GLsizei, GLsizei); -typedef void (GL_APIENTRY *glPointSizePointerOES_t) (GLenum, GLsizei, const GLvoid*); -typedef void (GL_APIENTRY *glBlendEquationSeparateOES_t) (GLenum, GLenum); -typedef void (GL_APIENTRY *glBlendFuncSeparateOES_t) (GLenum, GLenum, GLenum, GLenum); -typedef void (GL_APIENTRY *glBlendEquationOES_t) (GLenum); -typedef void (GL_APIENTRY *glDrawTexsOES_t) (GLshort, GLshort, GLshort, GLshort, GLshort); -typedef void (GL_APIENTRY *glDrawTexiOES_t) (GLint, GLint, GLint, GLint, GLint); -typedef void (GL_APIENTRY *glDrawTexxOES_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glDrawTexsvOES_t) (const GLshort*); -typedef void (GL_APIENTRY *glDrawTexivOES_t) (const GLint*); -typedef void (GL_APIENTRY *glDrawTexxvOES_t) (const GLfixed*); -typedef void (GL_APIENTRY *glDrawTexfOES_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glDrawTexfvOES_t) (const GLfloat*); -typedef void (GL_APIENTRY *glEGLImageTargetTexture2DOES_t) (GLenum, GLeglImageOES); -typedef void (GL_APIENTRY *glEGLImageTargetRenderbufferStorageOES_t) (GLenum, GLeglImageOES); -typedef void (GL_APIENTRY *glAlphaFuncxOES_t) (GLenum, GLclampx); -typedef void (GL_APIENTRY *glClearColorxOES_t) (GLclampx, GLclampx, GLclampx, GLclampx); -typedef void (GL_APIENTRY *glClearDepthxOES_t) (GLclampx); -typedef void (GL_APIENTRY *glClipPlanexOES_t) (GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glColor4xOES_t) (GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glDepthRangexOES_t) (GLclampx, GLclampx); -typedef void (GL_APIENTRY *glFogxOES_t) (GLenum, GLfixed); -typedef void (GL_APIENTRY *glFogxvOES_t) (GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glFrustumxOES_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glGetClipPlanexOES_t) (GLenum, GLfixed); -typedef void (GL_APIENTRY *glGetFixedvOES_t) (GLenum, GLfixed*); -typedef void (GL_APIENTRY *glGetLightxvOES_t) (GLenum, GLenum, GLfixed*); -typedef void (GL_APIENTRY *glGetMaterialxvOES_t) (GLenum, GLenum, GLfixed*); -typedef void (GL_APIENTRY *glGetTexEnvxvOES_t) (GLenum, GLenum, GLfixed*); -typedef void (GL_APIENTRY *glGetTexParameterxvOES_t) (GLenum, GLenum, GLfixed*); -typedef void (GL_APIENTRY *glLightModelxOES_t) (GLenum, GLfixed); -typedef void (GL_APIENTRY *glLightModelxvOES_t) (GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glLightxOES_t) (GLenum, GLenum, GLfixed); -typedef void (GL_APIENTRY *glLightxvOES_t) (GLenum, GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glLineWidthxOES_t) (GLfixed); -typedef void (GL_APIENTRY *glLoadMatrixxOES_t) (const GLfixed*); -typedef void (GL_APIENTRY *glMaterialxOES_t) (GLenum, GLenum, GLfixed); -typedef void (GL_APIENTRY *glMaterialxvOES_t) (GLenum, GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glMultMatrixxOES_t) (const GLfixed*); -typedef void (GL_APIENTRY *glMultiTexCoord4xOES_t) (GLenum, GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glNormal3xOES_t) (GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glOrthoxOES_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glPointParameterxOES_t) (GLenum, GLfixed); -typedef void (GL_APIENTRY *glPointParameterxvOES_t) (GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glPointSizexOES_t) (GLfixed); -typedef void (GL_APIENTRY *glPolygonOffsetxOES_t) (GLfixed, GLfixed); -typedef void (GL_APIENTRY *glRotatexOES_t) (GLfixed, GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glSampleCoveragexOES_t) (GLclampx, GLboolean); -typedef void (GL_APIENTRY *glScalexOES_t) (GLfixed, GLfixed, GLfixed); -typedef void (GL_APIENTRY *glTexEnvxOES_t) (GLenum, GLenum, GLfixed); -typedef void (GL_APIENTRY *glTexEnvxvOES_t) (GLenum, GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glTexParameterxOES_t) (GLenum, GLenum, GLfixed); -typedef void (GL_APIENTRY *glTexParameterxvOES_t) (GLenum, GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glTranslatexOES_t) (GLfixed, GLfixed, GLfixed); -typedef GLboolean (GL_APIENTRY *glIsRenderbufferOES_t) (GLuint); -typedef void (GL_APIENTRY *glBindRenderbufferOES_t) (GLenum, GLuint); -typedef void (GL_APIENTRY *glDeleteRenderbuffersOES_t) (GLsizei, const GLuint*); -typedef void (GL_APIENTRY *glGenRenderbuffersOES_t) (GLsizei, GLuint*); -typedef void (GL_APIENTRY *glRenderbufferStorageOES_t) (GLenum, GLenum, GLsizei, GLsizei); -typedef void (GL_APIENTRY *glGetRenderbufferParameterivOES_t) (GLenum, GLenum, GLint*); -typedef GLboolean (GL_APIENTRY *glIsFramebufferOES_t) (GLuint); -typedef void (GL_APIENTRY *glBindFramebufferOES_t) (GLenum, GLuint); -typedef void (GL_APIENTRY *glDeleteFramebuffersOES_t) (GLsizei, const GLuint*); -typedef void (GL_APIENTRY *glGenFramebuffersOES_t) (GLsizei, GLuint*); -typedef GLenum (GL_APIENTRY *glCheckFramebufferStatusOES_t) (GLenum); -typedef void (GL_APIENTRY *glFramebufferRenderbufferOES_t) (GLenum, GLenum, GLenum, GLuint); -typedef void (GL_APIENTRY *glFramebufferTexture2DOES_t) (GLenum, GLenum, GLenum, GLuint, GLint); -typedef void (GL_APIENTRY *glGetFramebufferAttachmentParameterivOES_t) (GLenum, GLenum, GLenum, GLint*); -typedef void (GL_APIENTRY *glGenerateMipmapOES_t) (GLenum); -typedef void* (GL_APIENTRY *glMapBufferOES_t) (GLenum, GLenum); -typedef GLboolean (GL_APIENTRY *glUnmapBufferOES_t) (GLenum); -typedef void (GL_APIENTRY *glGetBufferPointervOES_t) (GLenum, GLenum, GLvoid*); -typedef void (GL_APIENTRY *glCurrentPaletteMatrixOES_t) (GLuint); -typedef void (GL_APIENTRY *glLoadPaletteFromModelViewMatrixOES_t) (); -typedef void (GL_APIENTRY *glMatrixIndexPointerOES_t) (GLint, GLenum, GLsizei, const GLvoid*); -typedef void (GL_APIENTRY *glWeightPointerOES_t) (GLint, GLenum, GLsizei, const GLvoid*); -typedef GLbitfield (GL_APIENTRY *glQueryMatrixxOES_t) (GLfixed, GLint); -typedef void (GL_APIENTRY *glDepthRangefOES_t) (GLclampf, GLclampf); -typedef void (GL_APIENTRY *glFrustumfOES_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glOrthofOES_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (GL_APIENTRY *glClipPlanefOES_t) (GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glGetClipPlanefOES_t) (GLenum, GLfloat); -typedef void (GL_APIENTRY *glClearDepthfOES_t) (GLclampf); -typedef void (GL_APIENTRY *glTexGenfOES_t) (GLenum, GLenum, GLfloat); -typedef void (GL_APIENTRY *glTexGenfvOES_t) (GLenum, GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glTexGeniOES_t) (GLenum, GLenum, GLint); -typedef void (GL_APIENTRY *glTexGenivOES_t) (GLenum, GLenum, const GLint*); -typedef void (GL_APIENTRY *glTexGenxOES_t) (GLenum, GLenum, GLfixed); -typedef void (GL_APIENTRY *glTexGenxvOES_t) (GLenum, GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glGetTexGenfvOES_t) (GLenum, GLenum, GLfloat*); -typedef void (GL_APIENTRY *glGetTexGenivOES_t) (GLenum, GLenum, GLint*); -typedef void (GL_APIENTRY *glGetTexGenxvOES_t) (GLenum, GLenum, GLfixed*); -typedef void (GL_APIENTRY *glBindVertexArrayOES_t) (GLuint); -typedef void (GL_APIENTRY *glDeleteVertexArraysOES_t) (GLsizei, const GLuint*); -typedef void (GL_APIENTRY *glGenVertexArraysOES_t) (GLsizei, GLuint*); -typedef GLboolean (GL_APIENTRY *glIsVertexArrayOES_t) (GLuint); -typedef void (GL_APIENTRY *glDiscardFramebufferEXT_t) (GLenum, GLsizei, const GLenum*); -typedef void (GL_APIENTRY *glMultiDrawArraysEXT_t) (GLenum, GLint*, GLsizei*, GLsizei); -typedef void (GL_APIENTRY *glMultiDrawElementsEXT_t) (GLenum, const GLsizei*, GLenum, const GLvoid**, GLsizei); -typedef void (GL_APIENTRY *glClipPlanefIMG_t) (GLenum, const GLfloat*); -typedef void (GL_APIENTRY *glClipPlanexIMG_t) (GLenum, const GLfixed*); -typedef void (GL_APIENTRY *glRenderbufferStorageMultisampleIMG_t) (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -typedef void (GL_APIENTRY *glFramebufferTexture2DMultisampleIMG_t) (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); -typedef void (GL_APIENTRY *glDeleteFencesNV_t) (GLsizei, const GLuint*); -typedef void (GL_APIENTRY *glGenFencesNV_t) (GLsizei, GLuint*); -typedef GLboolean (GL_APIENTRY *glIsFenceNV_t) (GLuint); -typedef GLboolean (GL_APIENTRY *glTestFenceNV_t) (GLuint); -typedef void (GL_APIENTRY *glGetFenceivNV_t) (GLuint, GLenum, GLint*); -typedef void (GL_APIENTRY *glFinishFenceNV_t) (GLuint); -typedef void (GL_APIENTRY *glSetFenceNV_t) (GLuint, GLenum); -typedef void (GL_APIENTRY *glGetDriverControlsQCOM_t) (GLint*, GLsizei, GLuint*); -typedef void (GL_APIENTRY *glGetDriverControlStringQCOM_t) (GLuint, GLsizei, GLsizei*, GLchar*); -typedef void (GL_APIENTRY *glEnableDriverControlQCOM_t) (GLuint); -typedef void (GL_APIENTRY *glDisableDriverControlQCOM_t) (GLuint); -typedef void (GL_APIENTRY *glExtGetTexturesQCOM_t) (GLuint*, GLint, GLint*); -typedef void (GL_APIENTRY *glExtGetBuffersQCOM_t) (GLuint*, GLint, GLint*); -typedef void (GL_APIENTRY *glExtGetRenderbuffersQCOM_t) (GLuint*, GLint, GLint*); -typedef void (GL_APIENTRY *glExtGetFramebuffersQCOM_t) (GLuint*, GLint, GLint*); -typedef void (GL_APIENTRY *glExtGetTexLevelParameterivQCOM_t) (GLuint, GLenum, GLint, GLenum, GLint*); -typedef void (GL_APIENTRY *glExtTexObjectStateOverrideiQCOM_t) (GLenum, GLenum, GLint); -typedef void (GL_APIENTRY *glExtGetTexSubImageQCOM_t) (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoid*); -typedef void (GL_APIENTRY *glExtGetBufferPointervQCOM_t) (GLenum, GLvoid*); -typedef void (GL_APIENTRY *glExtGetShadersQCOM_t) (GLuint*, GLint, GLint*); -typedef void (GL_APIENTRY *glExtGetProgramsQCOM_t) (GLuint*, GLint, GLint*); -typedef GLboolean (GL_APIENTRY *glExtIsProgramBinaryQCOM_t) (GLuint); -typedef void (GL_APIENTRY *glExtGetProgramBinarySourceQCOM_t) (GLuint, GLenum, GLchar*, GLint*); -typedef void (GL_APIENTRY *glStartTilingQCOM_t) (GLuint, GLuint, GLuint, GLuint, GLbitfield); -typedef void (GL_APIENTRY *glEndTilingQCOM_t) (GLbitfield); - - -#endif diff --git a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp b/emulator/opengl/host/libs/libOpenglRender/render_api.cpp deleted file mode 100644 index 9586091..0000000 --- a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* -* 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. -*/ -#include "libOpenglRender/render_api.h" -#include "IOStream.h" -#include "FrameBuffer.h" -#include "RenderServer.h" -#include "TimeUtils.h" - -#include "TcpStream.h" -#ifdef _WIN32 -#include "Win32PipeStream.h" -#else -#include "UnixStream.h" -#endif - -#include "EGLDispatch.h" -#include "GLDispatch.h" -#include "GL2Dispatch.h" - -static RenderServer *s_renderThread = NULL; -static char s_renderAddr[256]; - -static IOStream *createRenderThread(int p_stream_buffer_size, - unsigned int clientFlags); - -int initLibrary(void) -{ - // - // Load EGL Plugin - // - if (!init_egl_dispatch()) { - // Failed to load EGL - printf("Failed to init_egl_dispatch\n"); - return false; - } - - // - // Load GLES Plugin - // - if (!init_gl_dispatch()) { - // Failed to load GLES - ERR("Failed to init_gl_dispatch\n"); - return false; - } - - /* failure to init the GLES2 dispatch table is not fatal */ - init_gl2_dispatch(); - - return true; -} - -int initOpenGLRenderer(int width, int height, char* addr, size_t addrLen) -{ - - // - // Fail if renderer is already initialized - // - if (s_renderThread) { - return false; - } - - // - // initialize the renderer and listen to connections - // on a thread in the current process. - // - bool inited = FrameBuffer::initialize(width, height); - if (!inited) { - return false; - } - - s_renderThread = RenderServer::create(addr, addrLen); - if (!s_renderThread) { - return false; - } - strncpy(s_renderAddr, addr, sizeof(s_renderAddr)); - - s_renderThread->start(); - - return true; -} - -void setPostCallback(OnPostFn onPost, void* onPostContext) -{ - FrameBuffer* fb = FrameBuffer::getFB(); - if (fb) { - fb->setPostCallback(onPost, onPostContext); - } -} - -void getHardwareStrings(const char** vendor, const char** renderer, const char** version) -{ - FrameBuffer* fb = FrameBuffer::getFB(); - if (fb) { - fb->getGLStrings(vendor, renderer, version); - } else { - *vendor = *renderer = *version = NULL; - } -} - -int stopOpenGLRenderer(void) -{ - bool ret = false; - - // open a dummy connection to the renderer to make it - // realize the exit request. - // (send the exit request in clientFlags) - IOStream *dummy = createRenderThread(8, IOSTREAM_CLIENT_EXIT_SERVER); - if (!dummy) return false; - - if (s_renderThread) { - - // wait for the thread to exit - ret = s_renderThread->wait(NULL); - - delete s_renderThread; - s_renderThread = NULL; - } - - return ret; -} - -int createOpenGLSubwindow(FBNativeWindowType window, - int x, int y, int width, int height, float zRot) -{ - if (s_renderThread) { - return FrameBuffer::setupSubWindow(window,x,y,width,height, zRot); - } - else { - // - // XXX: should be implemented by sending the renderer process - // a request - ERR("%s not implemented for separate renderer process !!!\n", - __FUNCTION__); - } - return false; -} - -int destroyOpenGLSubwindow(void) -{ - if (s_renderThread) { - return FrameBuffer::removeSubWindow(); - } - else { - // - // XXX: should be implemented by sending the renderer process - // a request - ERR("%s not implemented for separate renderer process !!!\n", - __FUNCTION__); - return false; - } -} - -void setOpenGLDisplayRotation(float zRot) -{ - if (s_renderThread) { - FrameBuffer *fb = FrameBuffer::getFB(); - if (fb) { - fb->setDisplayRotation(zRot); - } - } - else { - // - // XXX: should be implemented by sending the renderer process - // a request - ERR("%s not implemented for separate renderer process !!!\n", - __FUNCTION__); - } -} - -void repaintOpenGLDisplay(void) -{ - if (s_renderThread) { - FrameBuffer *fb = FrameBuffer::getFB(); - if (fb) { - fb->repost(); - } - } - else { - // - // XXX: should be implemented by sending the renderer process - // a request - ERR("%s not implemented for separate renderer process !!!\n", - __FUNCTION__); - } -} - - -/* NOTE: For now, always use TCP mode by default, until the emulator - * has been updated to support Unix and Win32 pipes - */ -#define DEFAULT_STREAM_MODE STREAM_MODE_TCP - -int gRendererStreamMode = DEFAULT_STREAM_MODE; - -IOStream *createRenderThread(int p_stream_buffer_size, unsigned int clientFlags) -{ - SocketStream* stream = NULL; - - if (gRendererStreamMode == STREAM_MODE_TCP) { - stream = new TcpStream(p_stream_buffer_size); - } else { -#ifdef _WIN32 - stream = new Win32PipeStream(p_stream_buffer_size); -#else /* !_WIN32 */ - stream = new UnixStream(p_stream_buffer_size); -#endif - } - - if (!stream) { - ERR("createRenderThread failed to create stream\n"); - return NULL; - } - if (stream->connect(s_renderAddr) < 0) { - ERR("createRenderThread failed to connect\n"); - delete stream; - return NULL; - } - - // - // send clientFlags to the renderer - // - unsigned int *pClientFlags = - (unsigned int *)stream->allocBuffer(sizeof(unsigned int)); - *pClientFlags = clientFlags; - stream->commitBuffer(sizeof(unsigned int)); - - return stream; -} - -int -setStreamMode(int mode) -{ - switch (mode) { - case STREAM_MODE_DEFAULT: - mode = DEFAULT_STREAM_MODE; - break; - - case STREAM_MODE_TCP: - break; - -#ifndef _WIN32 - case STREAM_MODE_UNIX: - break; -#else /* _WIN32 */ - case STREAM_MODE_PIPE: - break; -#endif /* _WIN32 */ - default: - // Invalid stream mode - return false; - } - gRendererStreamMode = mode; - return true; -} diff --git a/emulator/opengl/host/libs/renderControl_dec/Android.mk b/emulator/opengl/host/libs/renderControl_dec/Android.mk deleted file mode 100644 index f1ba595..0000000 --- a/emulator/opengl/host/libs/renderControl_dec/Android.mk +++ /dev/null @@ -1,18 +0,0 @@ -LOCAL_PATH := $(call my-dir) - - -### host library ############################################ -$(call emugl-begin-host-static-library,lib_renderControl_dec) -$(call emugl-import,libOpenglCodecCommon) -$(call emugl-gen-decoder,$(LOCAL_PATH),renderControl) -# For renderControl_types.h -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) -$(call emugl-end-module) - -### host library, 64-bit #################################### -$(call emugl-begin-host64-static-library,lib64_renderControl_dec) -$(call emugl-import,lib64OpenglCodecCommon) -$(call emugl-gen-decoder,$(LOCAL_PATH),renderControl) -# For renderControl_types.h -$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) -$(call emugl-end-module) diff --git a/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib b/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib deleted file mode 100644 index 0afa9d3..0000000 --- a/emulator/opengl/host/libs/renderControl_dec/renderControl.attrib +++ /dev/null @@ -1,44 +0,0 @@ -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 - -rcCloseColorBuffer - flag flushOnEncode diff --git a/emulator/opengl/host/libs/renderControl_dec/renderControl.in b/emulator/opengl/host/libs/renderControl_dec/renderControl.in deleted file mode 100644 index 55539f9..0000000 --- a/emulator/opengl/host/libs/renderControl_dec/renderControl.in +++ /dev/null @@ -1,26 +0,0 @@ -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) -GL_ENTRY(int, rcOpenColorBuffer2, uint32_t colorbuffer) diff --git a/emulator/opengl/host/libs/renderControl_dec/renderControl.types b/emulator/opengl/host/libs/renderControl_dec/renderControl.types deleted file mode 100644 index 2b38470..0000000 --- a/emulator/opengl/host/libs/renderControl_dec/renderControl.types +++ /dev/null @@ -1,11 +0,0 @@ -uint32_t 32 0x%08x -EGLint 32 0x%08x -GLint 32 0x%08x -GLuint 32 0x%08x -GLenum 32 0x%08x -EGLenum 32 0x%08x -uint32_t* 32 0x%08x -EGLint* 32 0x%08x -GLint* 32 0x%08x -GLuint* 32 0x%08x -void* 32 0x%08x diff --git a/emulator/opengl/host/libs/renderControl_dec/renderControl_types.h b/emulator/opengl/host/libs/renderControl_dec/renderControl_types.h deleted file mode 100644 index da215bb..0000000 --- a/emulator/opengl/host/libs/renderControl_dec/renderControl_types.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -* 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 diff --git a/emulator/opengl/host/tools/emugen/Android.mk b/emulator/opengl/host/tools/emugen/Android.mk deleted file mode 100644 index 4d09c42..0000000 --- a/emulator/opengl/host/tools/emugen/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Determine if the emugen build needs to be builts from -# sources. -LOCAL_PATH:=$(call my-dir) - -$(call emugl-begin-host-executable,emugen) - -LOCAL_SRC_FILES := \ - ApiGen.cpp \ - EntryPoint.cpp \ - main.cpp \ - Parser.cpp \ - strUtils.cpp \ - TypeFactory.cpp \ - -LOCAL_HOST_BUILD := true - -$(call emugl-end-module) - -# The location of the emugen host tool that is used to generate wire -# protocol encoders/ decoders. This variable is used by other emugl modules. -EMUGL_EMUGEN := $(LOCAL_BUILT_MODULE) - -$(call emugl-begin-host-executable,emugen_unittests) -LOCAL_SRC_FILES := \ - Parser.cpp \ - Parser_unittest.cpp -LOCAL_HOST_BUILD := true -$(call emugl-import,libemugl_gtest_host) -$(call emugl-end-module) diff --git a/emulator/opengl/host/tools/emugen/ApiGen.cpp b/emulator/opengl/host/tools/emugen/ApiGen.cpp deleted file mode 100644 index 8be0270..0000000 --- a/emulator/opengl/host/tools/emugen/ApiGen.cpp +++ /dev/null @@ -1,1232 +0,0 @@ -/* -* 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. -*/ -#include "ApiGen.h" -#include "EntryPoint.h" -#include <stdio.h> -#include <stdlib.h> -#include "strUtils.h" -#include <errno.h> -#include <sys/types.h> - -/* Define this to 1 to enable support for the 'isLarge' variable flag - * that instructs the encoder to send large data buffers by a direct - * write through the pipe (i.e. without copying it into a temporary - * buffer. This has definite performance benefits when using a QEMU Pipe. - * - * Set to 0 otherwise. - */ -#define WITH_LARGE_SUPPORT 1 - -// Set to 1 to ensure buffers passed to/from EGL/GL are properly aligned. -// This prevents crashes with certain backends (e.g. OSMesa). -#define USE_ALIGNED_BUFFERS 1 - -EntryPoint * ApiGen::findEntryByName(const std::string & name) -{ - EntryPoint * entry = NULL; - - size_t n = this->size(); - for (size_t i = 0; i < n; i++) { - if (at(i).name() == name) { - entry = &(at(i)); - break; - } - } - return entry; -} - -void ApiGen::printHeader(FILE *fp) const -{ - fprintf(fp, "// Generated Code - DO NOT EDIT !!\n"); - fprintf(fp, "// generated by 'emugen'\n"); -} - -int ApiGen::genProcTypes(const std::string &filename, SideType side) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - printHeader(fp); - - const char* basename = m_basename.c_str(); - - fprintf(fp, "#ifndef __%s_%s_proc_t_h\n", basename, sideString(side)); - fprintf(fp, "#define __%s_%s_proc_t_h\n", basename, sideString(side)); - fprintf(fp, "\n\n"); - fprintf(fp, "\n#include \"%s_types.h\"\n",basename); - fprintf(fp, "#ifndef %s_APIENTRY\n",basename); - fprintf(fp, "#define %s_APIENTRY \n",basename); - fprintf(fp, "#endif\n"); - - - for (size_t i = 0; i < size(); i++) { - EntryPoint *e = &at(i); - - fprintf(fp, "typedef "); - e->retval().printType(fp); - fprintf(fp, " (%s_APIENTRY *%s_%s_proc_t) (", basename, e->name().c_str(), sideString(side)); - if (side == CLIENT_SIDE) { fprintf(fp, "void * ctx"); } - if (e->customDecoder() && side == SERVER_SIDE) { fprintf(fp, "void *ctx"); } - - VarsArray & evars = e->vars(); - size_t n = evars.size(); - - for (size_t j = 0; j < n; j++) { - if (!evars[j].isVoid()) { - if (j != 0 || side == CLIENT_SIDE || (side == SERVER_SIDE && e->customDecoder())) fprintf(fp, ", "); - evars[j].printType(fp); - } - } - fprintf(fp, ");\n"); - } - fprintf(fp, "\n\n#endif\n"); - return 0; -} - -int ApiGen::genFuncTable(const std::string &filename, SideType side) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - printHeader(fp); - - fprintf(fp, "#ifndef __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side)); - fprintf(fp, "#define __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side)); - fprintf(fp, "\n\n"); - fprintf(fp, "static const struct _%s_funcs_by_name {\n", m_basename.c_str()); - fprintf(fp, - "\tconst char *name;\n" \ - "\tvoid *proc;\n" \ - "} %s_funcs_by_name[] = {\n", m_basename.c_str()); - - - for (size_t i = 0; i < size(); i++) { - EntryPoint *e = &at(i); - if (e->notApi()) continue; - fprintf(fp, "\t{\"%s\", (void*)%s},\n", e->name().c_str(), e->name().c_str()); - } - fprintf(fp, "};\n"); - fprintf(fp, "static const int %s_num_funcs = sizeof(%s_funcs_by_name) / sizeof(struct _%s_funcs_by_name);\n", - m_basename.c_str(), m_basename.c_str(), m_basename.c_str()); - fprintf(fp, "\n\n#endif\n"); - return 0; -} - - -int ApiGen::genContext(const std::string & filename, SideType side) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - printHeader(fp); - - fprintf(fp, "#ifndef __%s_%s_context_t_h\n", m_basename.c_str(), sideString(side)); - fprintf(fp, "#define __%s_%s_context_t_h\n", m_basename.c_str(), sideString(side)); - - // fprintf(fp, "\n#include \"%s_types.h\"\n", m_basename.c_str()); - fprintf(fp, "\n#include \"%s_%s_proc.h\"\n", m_basename.c_str(), sideString(side)); - - StringVec & contextHeaders = side == CLIENT_SIDE ? m_clientContextHeaders : m_serverContextHeaders; - for (size_t i = 0; i < contextHeaders.size(); i++) { - fprintf(fp, "#include %s\n", contextHeaders[i].c_str()); - } - fprintf(fp, "\n"); - - fprintf(fp, "\nstruct %s_%s_context_t {\n\n", m_basename.c_str(), sideString(side)); - for (size_t i = 0; i < size(); i++) { - EntryPoint *e = &at(i); - fprintf(fp, "\t%s_%s_proc_t %s;\n", e->name().c_str(), sideString(side), e->name().c_str()); - } - - // virtual destructor - fprintf(fp, "\t virtual ~%s_%s_context_t() {}\n", m_basename.c_str(), sideString(side)); - // accessor - if (side == CLIENT_SIDE || side == WRAPPER_SIDE) { - fprintf(fp, "\n\ttypedef %s_%s_context_t *CONTEXT_ACCESSOR_TYPE(void);\n", - m_basename.c_str(), sideString(side)); - fprintf(fp, "\tstatic void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);\n"); - } - - // init function - fprintf(fp, "\tint initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);\n"); - - //client site set error virtual func - if (side == CLIENT_SIDE) { - fprintf(fp, "\tvirtual void setError(unsigned int error){ (void)error; };\n"); - fprintf(fp, "\tvirtual unsigned int getError(){ return 0; };\n"); - } - - fprintf(fp, "};\n"); - - fprintf(fp, "\n#endif\n"); - fclose(fp); - return 0; -} - -int ApiGen::genEntryPoints(const std::string & filename, SideType side) -{ - - if (side != CLIENT_SIDE && side != WRAPPER_SIDE) { - fprintf(stderr, "Entry points are only defined for Client and Wrapper components\n"); - return -999; - } - - - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return errno; - } - - printHeader(fp); - fprintf(fp, "#include <stdio.h>\n"); - fprintf(fp, "#include <stdlib.h>\n"); - fprintf(fp, "#include \"%s_%s_context.h\"\n", m_basename.c_str(), sideString(side)); - fprintf(fp, "\n"); - - fprintf(fp, "#ifndef GL_TRUE\n"); - fprintf(fp, "extern \"C\" {\n"); - - for (size_t i = 0; i < size(); i++) { - fprintf(fp, "\t"); at(i).print(fp, false); fprintf(fp, ";\n"); - } - fprintf(fp, "};\n\n"); - fprintf(fp, "#endif\n"); - - fprintf(fp, "#ifndef GET_CONTEXT\n"); - fprintf(fp, "static %s_%s_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;\n", - m_basename.c_str(), sideString(side)); - - fprintf(fp, - "void %s_%s_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }\n", - m_basename.c_str(), sideString(side)); - fprintf(fp, "#define GET_CONTEXT %s_%s_context_t * ctx = getCurrentContext()\n", - m_basename.c_str(), sideString(side)); - fprintf(fp, "#endif\n\n"); - - - for (size_t i = 0; i < size(); i++) { - EntryPoint *e = &at(i); - e->print(fp); - fprintf(fp, "{\n"); - fprintf(fp, "\tGET_CONTEXT;\n"); - - bool shouldReturn = !e->retval().isVoid(); - bool shouldCallWithContext = (side == CLIENT_SIDE); - //param check - if (shouldCallWithContext) { - for (size_t j=0; j<e->vars().size(); j++) { - if (e->vars()[j].paramCheckExpression() != "") - fprintf(fp, "\t%s\n", e->vars()[j].paramCheckExpression().c_str()); - } - } - fprintf(fp, "\t%sctx->%s(%s", - shouldReturn ? "return " : "", - e->name().c_str(), - shouldCallWithContext ? "ctx" : ""); - size_t nvars = e->vars().size(); - - for (size_t j = 0; j < nvars; j++) { - if (!e->vars()[j].isVoid()) { - fprintf(fp, "%s %s", - j != 0 || shouldCallWithContext ? "," : "", - e->vars()[j].name().c_str()); - } - } - fprintf(fp, ");\n"); - fprintf(fp, "}\n\n"); - } - fclose(fp); - return 0; -} - - -int ApiGen::genOpcodes(const std::string &filename) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return errno; - } - - printHeader(fp); - fprintf(fp, "#ifndef __GUARD_%s_opcodes_h_\n", m_basename.c_str()); - fprintf(fp, "#define __GUARD_%s_opcodes_h_\n\n", m_basename.c_str()); - for (size_t i = 0; i < size(); i++) { - fprintf(fp, "#define OP_%s \t\t\t\t\t%u\n", at(i).name().c_str(), (unsigned int)i + m_baseOpcode); - } - fprintf(fp, "#define OP_last \t\t\t\t\t%u\n", (unsigned int)size() + m_baseOpcode); - fprintf(fp,"\n\n#endif\n"); - fclose(fp); - return 0; - -} -int ApiGen::genAttributesTemplate(const std::string &filename ) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - - for (size_t i = 0; i < size(); i++) { - if (at(i).hasPointers()) { - fprintf(fp, "#"); - at(i).print(fp); - fprintf(fp, "%s\n\n", at(i).name().c_str()); - } - } - fclose(fp); - return 0; -} - -int ApiGen::genEncoderHeader(const std::string &filename) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - - printHeader(fp); - std::string classname = m_basename + "_encoder_context_t"; - - fprintf(fp, "\n#ifndef GUARD_%s\n", classname.c_str()); - fprintf(fp, "#define GUARD_%s\n\n", classname.c_str()); - - fprintf(fp, "#include \"IOStream.h\"\n"); - fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(CLIENT_SIDE)); - - for (size_t i = 0; i < m_encoderHeaders.size(); i++) { - fprintf(fp, "#include %s\n", m_encoderHeaders[i].c_str()); - } - fprintf(fp, "\n"); - - fprintf(fp, "struct %s : public %s_%s_context_t {\n\n", - classname.c_str(), m_basename.c_str(), sideString(CLIENT_SIDE)); - fprintf(fp, "\tIOStream *m_stream;\n\n"); - - fprintf(fp, "\t%s(IOStream *stream);\n", classname.c_str()); - fprintf(fp, "};\n\n"); - - fprintf(fp, "#endif // GUARD_%s", classname.c_str()); - - fclose(fp); - return 0; -} - -// Format the byte length expression for a given variable into a user-provided buffer -// If the variable type is not a pointer, this is simply its size as a decimal constant -// If the variable is a pointer, this will be an expression provided by the .attrib file -// through the 'len' attribute. -// -// Returns 1 if the variable is a pointer, 0 otherwise -// -static int getVarEncodingSizeExpression(Var& var, EntryPoint* e, char* buff, size_t bufflen) -{ - int ret = 0; - if (!var.isPointer()) { - snprintf(buff, bufflen, "%u", (unsigned int) var.type()->bytes()); - } else { - ret = 1; - const char* lenExpr = var.lenExpression().c_str(); - const char* varname = var.name().c_str(); - if (e != NULL && lenExpr[0] == '\0') { - fprintf(stderr, "%s: data len is undefined for '%s'\n", - e->name().c_str(), varname); - } - if (var.nullAllowed()) { - snprintf(buff, bufflen, "((%s != NULL) ? %s : 0)", varname, lenExpr); - } else { - snprintf(buff, bufflen, "%s", lenExpr); - } - } - return ret; -} - -static int writeVarEncodingSize(Var& var, FILE* fp) -{ - int ret = 0; - if (!var.isPointer()) { - fprintf(fp, "%u", (unsigned int) var.type()->bytes()); - } else { - ret = 1; - fprintf(fp, "__size_%s", var.name().c_str()); - } - return ret; -} - - - -static void writeVarEncodingExpression(Var& var, FILE* fp) -{ - const char* varname = var.name().c_str(); - - if (var.isPointer()) { - // encode a pointer header - fprintf(fp, "\t*(unsigned int *)(ptr) = __size_%s; ptr += 4;\n", varname); - - Var::PointerDir dir = var.pointerDir(); - if (dir == Var::POINTER_INOUT || dir == Var::POINTER_IN) { - if (var.nullAllowed()) { - fprintf(fp, "\tif (%s != NULL) ", varname); - } else { - fprintf(fp, "\t"); - } - - if (var.packExpression().size() != 0) { - fprintf(fp, "%s;", var.packExpression().c_str()); - } else { - fprintf(fp, "memcpy(ptr, %s, __size_%s);", - varname, varname); - } - - fprintf(fp, "ptr += __size_%s;\n", varname); - } - } else { - // encode a non pointer variable - if (!var.isVoid()) { - fprintf(fp, "\t\tmemcpy(ptr, &%s, %u); ptr += %u;\n", - varname, - (unsigned) var.type()->bytes(), - (unsigned) var.type()->bytes()); - } - } -} - -#if WITH_LARGE_SUPPORT -static void writeVarLargeEncodingExpression(Var& var, FILE* fp) -{ - const char* varname = var.name().c_str(); - - fprintf(fp, "\tstream->writeFully(&__size_%s,4);\n", varname); - if (var.nullAllowed()) { - fprintf(fp, "\tif (%s != NULL) ", varname); - } else { - fprintf(fp, "\t"); - } - if (var.writeExpression() != "") { - fprintf(fp, "%s", var.writeExpression().c_str()); - } else { - fprintf(fp, "stream->writeFully(%s, __size_%s)", varname, varname); - } - fprintf(fp, ";\n"); -} -#endif /* WITH_LARGE_SUPPORT */ - -int ApiGen::genEncoderImpl(const std::string &filename) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - - printHeader(fp); - fprintf(fp, "\n\n#include <string.h>\n"); - fprintf(fp, "#include \"%s_opcodes.h\"\n\n", m_basename.c_str()); - fprintf(fp, "#include \"%s_enc.h\"\n\n\n", m_basename.c_str()); - fprintf(fp, "#include <stdio.h>\n\n"); - fprintf(fp, "namespace {\n\n"); - - // unsupport printout - fprintf(fp, - "void enc_unsupported()\n" - "{\n" - "\tALOGE(\"Function is unsupported\\n\");\n" - "}\n\n"); - - // entry points; - std::string classname = m_basename + "_encoder_context_t"; - - size_t n = size(); - for (size_t i = 0; i < n; i++) { - EntryPoint *e = &at(i); - - if (e->unsupported()) continue; - - - e->print(fp, true, "_enc", /* classname + "::" */"", "void *self"); - fprintf(fp, "{\n"); - -// fprintf(fp, "\n\tDBG(\">>>> %s\\n\");\n", e->name().c_str()); - fprintf(fp, "\n\t%s *ctx = (%s *)self;\n", - classname.c_str(), - classname.c_str()); - fprintf(fp, "\tIOStream *stream = ctx->m_stream;\n\n"); - VarsArray & evars = e->vars(); - size_t maxvars = evars.size(); - size_t j; - - char buff[256]; - - // Define the __size_XXX variables that contain the size of data - // associated with pointers. - for (j = 0; j < maxvars; j++) { - Var& var = evars[j]; - - if (!var.isPointer()) - continue; - - const char* varname = var.name().c_str(); - fprintf(fp, "\tconst unsigned int __size_%s = ", varname); - - getVarEncodingSizeExpression(var, e, buff, sizeof(buff)); - fprintf(fp, "%s;\n", buff); - } - -#if WITH_LARGE_SUPPORT - // We need to take care of 'isLarge' variable in a special way - // Anything before an isLarge variable can be packed into a single - // buffer, which is then commited. Each isLarge variable is a pointer - // to data that can be written to directly through the pipe, which - // will be instant when using a QEMU pipe - - size_t nvars = 0; - size_t npointers = 0; - - // First, compute the total size, 8 bytes for the opcode + payload size - fprintf(fp, "\t unsigned char *ptr;\n"); - fprintf(fp, "\t const size_t packetSize = 8"); - - for (j = 0; j < maxvars; j++) { - fprintf(fp, " + "); - npointers += writeVarEncodingSize(evars[j], fp); - } - if (npointers > 0) { - fprintf(fp, " + %zu*4", npointers); - } - fprintf(fp, ";\n"); - - // We need to divide the packet into fragments. Each fragment contains - // either copied arguments to a temporary buffer, or direct writes for - // large variables. - // - // The first fragment must also contain the opcode+payload_size - // - nvars = 0; - while (nvars < maxvars || maxvars == 0) { - - // Skip over non-large fields - for (j = nvars; j < maxvars; j++) { - if (evars[j].isLarge()) - break; - } - - // Write a fragment if needed. - if (nvars == 0 || j > nvars) { - const char* plus = ""; - - if (nvars == 0 && j == maxvars) { - // Simple shortcut for the common case where we don't have large variables; - fprintf(fp, "\tptr = stream->alloc(packetSize);\n"); - - } else { - // allocate buffer from the stream until the first large variable - fprintf(fp, "\tptr = stream->alloc("); - plus = ""; - - if (nvars == 0) { - fprintf(fp,"8"); plus = " + "; - } - if (j > nvars) { - npointers = 0; - for (j = nvars; j < maxvars && !evars[j].isLarge(); j++) { - fprintf(fp, "%s", plus); plus = " + "; - npointers += writeVarEncodingSize(evars[j], fp); - } - if (npointers > 0) { - fprintf(fp, "%s%zu*4", plus, npointers); plus = " + "; - } - } - fprintf(fp,");\n"); - } - - // encode packet header if needed. - if (nvars == 0) { - fprintf(fp, "\tint tmp = OP_%s;memcpy(ptr, &tmp, 4); ptr += 4;\n", e->name().c_str()); - fprintf(fp, "\tmemcpy(ptr, &packetSize, 4); ptr += 4;\n\n"); - } - - if (maxvars == 0) - break; - - // encode non-large fields in this fragment - for (j = nvars; j < maxvars && !evars[j].isLarge(); j++) { - writeVarEncodingExpression(evars[j],fp); - } - - // Ensure the fragment is commited if it is followed by a large variable - if (j < maxvars) { - fprintf(fp, "\tstream->flush();\n"); - } - } - - // If we have one or more large variables, write them directly. - // As size + data - for ( ; j < maxvars && evars[j].isLarge(); j++) { - writeVarLargeEncodingExpression(evars[j], fp); - } - - nvars = j; - } - -#else /* !WITH_LARGE_SUPPORT */ - size_t nvars = evars.size(); - size_t npointers = 0; - fprintf(fp, "\t const size_t packetSize = 8"); - for (size_t j = 0; j < nvars; j++) { - npointers += getVarEncodingSizeExpression(evars[j],e,buff,sizeof(buff)); - fprintf(fp, " + %s", buff); - } - fprintf(fp, " + %u * 4;\n", (unsigned int) npointers); - - // allocate buffer from the stream; - fprintf(fp, "\t unsigned char *ptr = stream->alloc(packetSize);\n\n"); - - // encode into the stream; - fprintf(fp, "\tint tmp = OP_%s; memcpy(ptr, &tmp, 4); ptr += 4;\n", e->name().c_str()); - fprintf(fp, "\tmemcpy(ptr, &packetSize, 4); ptr += 4;\n\n"); - - // out variables - for (size_t j = 0; j < nvars; j++) { - writeVarEncodingExpression(evars[j], fp); - } -#endif /* !WITH_LARGE_SUPPORT */ - - // in variables; - for (size_t j = 0; j < nvars; j++) { - if (evars[j].isPointer()) { - Var::PointerDir dir = evars[j].pointerDir(); - if (dir == Var::POINTER_INOUT || dir == Var::POINTER_OUT) { - const char* varname = evars[j].name().c_str(); - if (evars[j].nullAllowed()) { - fprintf(fp, "\tif (%s != NULL) ",varname); - } else { - fprintf(fp, "\t"); - } - fprintf(fp, "stream->readback(%s, __size_%s);\n", - varname, varname); - } - } - } -//XXX fprintf(fp, "\n\tDBG(\"<<<< %s\\n\");\n", e->name().c_str()); - - // todo - return value for pointers - if (e->retval().isPointer()) { - fprintf(stderr, "WARNING: %s : return value of pointer is unsupported\n", - e->name().c_str()); - if (e->flushOnEncode()) { - fprintf(fp, "\tstream->flush();\n"); - } - fprintf(fp, "\t return NULL;\n"); - } else if (e->retval().type()->name() != "void") { - fprintf(fp, "\n\t%s retval;\n", e->retval().type()->name().c_str()); - fprintf(fp, "\tstream->readback(&retval, %u);\n",(unsigned) e->retval().type()->bytes()); - fprintf(fp, "\treturn retval;\n"); - } else if (e->flushOnEncode()) { - fprintf(fp, "\tstream->flush();\n"); - } - fprintf(fp, "}\n\n"); - } - - fprintf(fp, "} // namespace\n\n"); - - // constructor - fprintf(fp, "%s::%s(IOStream *stream)\n{\n", classname.c_str(), classname.c_str()); - fprintf(fp, "\tm_stream = stream;\n\n"); - - for (size_t i = 0; i < n; i++) { - EntryPoint *e = &at(i); - if (e->unsupported()) { - fprintf(fp, - "\tthis->%s = (%s_%s_proc_t) &enc_unsupported;\n", - e->name().c_str(), - e->name().c_str(), - sideString(CLIENT_SIDE)); - } else { - fprintf(fp, - "\tthis->%s = &%s_enc;\n", - e->name().c_str(), - e->name().c_str()); - } - } - fprintf(fp, "}\n\n"); - - fclose(fp); - return 0; -} - - -int ApiGen::genDecoderHeader(const std::string &filename) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - - printHeader(fp); - std::string classname = m_basename + "_decoder_context_t"; - - fprintf(fp, "\n#ifndef GUARD_%s\n", classname.c_str()); - fprintf(fp, "#define GUARD_%s\n\n", classname.c_str()); - - fprintf(fp, "#include \"IOStream.h\" \n"); - fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(SERVER_SIDE)); - - for (size_t i = 0; i < m_decoderHeaders.size(); i++) { - fprintf(fp, "#include %s\n", m_decoderHeaders[i].c_str()); - } - fprintf(fp, "\n"); - - fprintf(fp, "struct %s : public %s_%s_context_t {\n\n", - classname.c_str(), m_basename.c_str(), sideString(SERVER_SIDE)); - fprintf(fp, "\tsize_t decode(void *buf, size_t bufsize, IOStream *stream);\n"); - fprintf(fp, "\n};\n\n"); - fprintf(fp, "#endif // GUARD_%s\n", classname.c_str()); - - fclose(fp); - return 0; -} - -int ApiGen::genContextImpl(const std::string &filename, SideType side) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - printHeader(fp); - - std::string classname = m_basename + "_" + sideString(side) + "_context_t"; - size_t n = size(); - fprintf(fp, "\n\n#include <string.h>\n"); - fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(side)); - fprintf(fp, "#include <stdio.h>\n\n"); - - // init function; - fprintf(fp, "int %s::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)\n{\n", classname.c_str()); - for (size_t i = 0; i < n; i++) { - EntryPoint *e = &at(i); - fprintf(fp, "\t%s = (%s_%s_proc_t) getProc(\"%s\", userData);\n", - e->name().c_str(), - e->name().c_str(), - sideString(side), - e->name().c_str()); - } - fprintf(fp, "\treturn 0;\n"); - fprintf(fp, "}\n\n"); - fclose(fp); - return 0; -} - -int ApiGen::genDecoderImpl(const std::string &filename) -{ - FILE *fp = fopen(filename.c_str(), "wt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - - printHeader(fp); - - std::string classname = m_basename + "_decoder_context_t"; - - size_t n = size(); - - fprintf(fp, "\n\n#include <string.h>\n"); - 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 \"ProtocolUtils.h\"\n\n"); - 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"); - - // helper macros - fprintf(fp, - "#ifdef DEBUG_PRINTOUT\n" - "# define DEBUG(...) fprintf(stderr, __VA_ARGS__)\n" - "#else\n" - "# define DEBUG(...) ((void)0)\n" - "#endif\n\n"); - - fprintf(fp, - "#ifdef CHECK_GLERROR\n" - "# define SET_LASTCALL(name) sprintf(lastCall, #name)\n" - "#else\n" - "# define SET_LASTCALL(name) ((void)0)\n" - "#endif\n\n"); - - // helper templates - fprintf(fp, "using namespace emugl;\n\n"); - - // decoder switch; - fprintf(fp, "size_t %s::decode(void *buf, size_t len, IOStream *stream)\n{\n", classname.c_str()); - fprintf(fp, - " \n\ -\tsize_t pos = 0;\n\ -\tif (len < 8) return pos; \n\ -\tunsigned char *ptr = (unsigned char *)buf;\n\ -\tbool unknownOpcode = false; \n\ -#ifdef CHECK_GL_ERROR \n\ -\tchar lastCall[256] = {0}; \n\ -#endif \n\ -\twhile ((len - pos >= 8) && !unknownOpcode) { \n\ -\t\tuint32_t opcode = *(uint32_t *)ptr; \n\ -\t\tsize_t packetLen = *(uint32_t *)(ptr + 4);\n\ -\t\tif (len - pos < packetLen) return pos; \n\ -\t\tswitch(opcode) {\n"); - - for (size_t f = 0; f < n; f++) { - enum Pass_t { - PASS_FIRST = 0, - PASS_VariableDeclarations = PASS_FIRST, - PASS_TmpBuffAlloc, - PASS_MemAlloc, - PASS_DebugPrint, - PASS_FunctionCall, - PASS_FlushOutput, - PASS_Epilog, - PASS_LAST }; - EntryPoint *e = &at(f); - - // construct a printout string; - std::string printString = ""; - for (size_t i = 0; i < e->vars().size(); i++) { - Var *v = &e->vars()[i]; - if (!v->isVoid()) printString += (v->isPointer() ? "%p(%u)" : v->type()->printFormat()) + " "; - } - printString += ""; - // TODO - add for return value; - - fprintf(fp, "\t\tcase OP_%s: {\n", e->name().c_str()); - - bool totalTmpBuffExist = false; - std::string totalTmpBuffOffset = "0"; - std::string *tmpBufOffset = new std::string[e->vars().size()]; - - // construct retval type string - std::string retvalType; - if (!e->retval().isVoid()) { - retvalType = e->retval().type()->name(); - } - - for (int pass = PASS_FIRST; pass < PASS_LAST; pass++) { - if (pass == PASS_FunctionCall && - !e->retval().isVoid() && - !e->retval().isPointer()) { - fprintf(fp, "\t\t\t*(%s *)(&tmpBuf[%s]) = ", retvalType.c_str(), - totalTmpBuffOffset.c_str()); - } - - - if (pass == PASS_FunctionCall) { - fprintf(fp, "\t\t\tthis->%s(", e->name().c_str()); - if (e->customDecoder()) { - fprintf(fp, "this"); // add a context to the call - } - } else if (pass == PASS_DebugPrint) { - fprintf(fp, - "\t\t\tDEBUG(\"%s(%%p): %s(%s)\\n\", stream", - m_basename.c_str(), - e->name().c_str(), - printString.c_str()); - if (e->vars().size() > 0 && !e->vars()[0].isVoid()) { - fprintf(fp, ","); - } - } - - std::string varoffset = "8"; // skip the header - VarsArray & evars = e->vars(); - // allocate memory for out pointers; - for (size_t j = 0; j < evars.size(); j++) { - Var *v = & evars[j]; - if (v->isVoid()) { - continue; - } - const char* var_name = v->name().c_str(); - const char* var_type_name = v->type()->name().c_str(); - const unsigned var_type_bytes = v->type()->bytes(); - - if ((pass == PASS_FunctionCall) && - (j != 0 || e->customDecoder())) { - fprintf(fp, ", "); - } - if (pass == PASS_DebugPrint && j != 0) { - fprintf(fp, ", "); - } - - if (!v->isPointer()) { - if (pass == PASS_VariableDeclarations) { - fprintf(fp, - "\t\t\t%s var_%s = Unpack<%s,uint%u_t>(ptr + %s);\n", - var_type_name, - var_name, - var_type_name, - var_type_bytes * 8U, - varoffset.c_str()); - } - - if (pass == PASS_FunctionCall || - pass == PASS_DebugPrint) { - fprintf(fp, "var_%s", var_name); - } - varoffset += " + " + toString(var_type_bytes); - continue; - } - - if (pass == PASS_VariableDeclarations) { - fprintf(fp, - "\t\t\tuint32_t size_%s __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + %s);\n", - var_name, - varoffset.c_str()); - } - - if (v->pointerDir() == Var::POINTER_IN || - v->pointerDir() == Var::POINTER_INOUT) { - if (pass == PASS_VariableDeclarations) { -#if USE_ALIGNED_BUFFERS - fprintf(fp, - "\t\t\tInputBuffer inptr_%s(ptr + %s + 4, size_%s);\n", - var_name, - varoffset.c_str(), - var_name); - } - if (pass == PASS_FunctionCall) { - if (v->nullAllowed()) { - fprintf(fp, - "size_%s == 0 ? NULL : (%s)(inptr_%s.get())", - var_name, - var_type_name, - var_name); - } else { - fprintf(fp, - "(%s)(inptr_%s.get())", - var_type_name, - var_name); - } - } else if (pass == PASS_DebugPrint) { - fprintf(fp, - "(%s)(inptr_%s.get()), size_%s", - var_type_name, - var_name, - var_name); - } -#else // !USE_ALIGNED_BUFFERS - fprintf(fp, - "unsigned char *inptr_%s = (ptr + %s + 4);\n", - var_name, - varoffset.c_str()); - } - if (pass == PASS_FunctionCall) { - if (v->nullAllowed()) { - fprintf(fp, - "size_%s == 0 ? NULL : (%s)(inptr_%s)", - var_name, - var_type_name, - var_name); - } else { - fprintf(fp, - "(%s)(inptr_%s)", - var_type_name, - var_name); - } - } else if (pass == PASS_DebugPrint) { - fprintf(fp, - "(%s)(inptr_%s), size_%s", - var_type_name, - var_name, - var_name); - } -#endif // !USE_ALIGNED_BUFFERS - varoffset += " + 4 + size_"; - varoffset += var_name; - } else { // out pointer; - if (pass == PASS_TmpBuffAlloc) { - if (!totalTmpBuffExist) { - fprintf(fp, - "\t\t\tsize_t totalTmpSize = size_%s;\n", - var_name); - } else { - fprintf(fp, - "\t\t\ttotalTmpSize += size_%s;\n", - var_name); - } - tmpBufOffset[j] = totalTmpBuffOffset; - totalTmpBuffOffset += " + size_"; - totalTmpBuffOffset += var_name; - totalTmpBuffExist = true; - } else if (pass == PASS_MemAlloc) { -#if USE_ALIGNED_BUFFERS - fprintf(fp, - "\t\t\tOutputBuffer outptr_%s(&tmpBuf[%s], size_%s);\n", - var_name, - tmpBufOffset[j].c_str(), - var_name); - } else if (pass == PASS_FunctionCall) { - if (v->nullAllowed()) { - fprintf(fp, - "size_%s == 0 ? NULL : (%s)(outptr_%s.get())", - var_name, - var_type_name, - var_name); - } else { - fprintf(fp, - "(%s)(outptr_%s.get())", - var_type_name, - var_name); - } - } else if (pass == PASS_DebugPrint) { - fprintf(fp, - "(%s)(outptr_%s.get()), size_%s", - var_type_name, - var_name, - var_name); - } - if (pass == PASS_FlushOutput) { - fprintf(fp, - "\t\t\toutptr_%s.flush();\n", - var_name); - } -#else // !USE_ALIGNED_BUFFERS - fprintf(fp, - "\t\t\tunsigned char *outptr_%s = &tmpBuf[%s];\n", - var_name, - tmpBufOffset[j].c_str()); - fprintf(fp, - "\t\t\tmemset(outptr_%s, 0, %s);\n", - var_name, - toString(v->type()->bytes()).c_str()); - } else if (pass == PASS_FunctionCall) { - if (v->nullAllowed()) { - fprintf(fp, - "size_%s == 0 ? NULL : (%s)(outptr_%s)", - var_name, - var_type_name, - var_name); - } else { - fprintf(fp, - "(%s)(outptr_%s)", - var_type_name, - var_name); - } - } else if (pass == PASS_DebugPrint) { - fprintf(fp, - "(%s)(outptr_%s), size_%s", - var_type_name, - var_name, - varoffset.c_str()); - } -#endif // !USE_ALIGNED_BUFFERS - varoffset += " + 4"; - } - } - - if (pass == PASS_FunctionCall || - pass == PASS_DebugPrint) { - fprintf(fp, ");\n"); - } - - if (pass == PASS_TmpBuffAlloc) { - if (!e->retval().isVoid() && !e->retval().isPointer()) { - if (!totalTmpBuffExist) - fprintf(fp, - "\t\t\tsize_t totalTmpSize = sizeof(%s);\n", - retvalType.c_str()); - else - fprintf(fp, - "\t\t\ttotalTmpSize += sizeof(%s);\n", - retvalType.c_str()); - - totalTmpBuffExist = true; - } - if (totalTmpBuffExist) { - fprintf(fp, - "\t\t\tunsigned char *tmpBuf = stream->alloc(totalTmpSize);\n"); - } - } - - if (pass == PASS_Epilog) { - // send back out pointers data as well as retval - if (totalTmpBuffExist) { - fprintf(fp, "\t\t\tstream->flush();\n"); - } - } - - } // pass; - fprintf(fp, "\t\t\tSET_LASTCALL(\"%s\");\n", e->name().c_str()); - fprintf(fp, "\t\t\tbreak;\n"); - fprintf(fp, "\t\t}\n"); - - delete [] tmpBufOffset; - } - fprintf(fp, "\t\t\tdefault:\n"); - fprintf(fp, "\t\t\t\tunknownOpcode = true;\n"); - fprintf(fp, "\t\t} //switch\n"); - if (strstr(m_basename.c_str(), "gl")) { - fprintf(fp, "#ifdef CHECK_GL_ERROR\n"); - fprintf(fp, "\tint err = lastCall[0] ? this->glGetError() : GL_NO_ERROR;\n"); - fprintf(fp, "\tif (err) fprintf(stderr, \"%s Error: 0x%%X in %%s\\n\", err, lastCall);\n", m_basename.c_str()); - fprintf(fp, "#endif\n"); - } - - fprintf(fp, "\t\tif (!unknownOpcode) {\n"); - fprintf(fp, "\t\t\tpos += packetLen;\n"); - fprintf(fp, "\t\t\tptr += packetLen;\n"); - fprintf(fp, "\t\t}\n"); - fprintf(fp, "\t} // while\n"); - fprintf(fp, "\treturn pos;\n"); - fprintf(fp, "}\n"); - - fclose(fp); - return 0; -} - -int ApiGen::readSpec(const std::string & filename) -{ - FILE *specfp = fopen(filename.c_str(), "rt"); - if (specfp == NULL) { - return -1; - } - - char line[1000]; - unsigned int lc = 0; - while (fgets(line, sizeof(line), specfp) != NULL) { - lc++; - EntryPoint ref; - if (ref.parse(lc, std::string(line))) { - push_back(ref); - updateMaxEntryPointsParams(ref.vars().size()); - } - } - fclose(specfp); - return 0; -} - -int ApiGen::readAttributes(const std::string & attribFilename) -{ - enum { ST_NAME, ST_ATT } state; - - FILE *fp = fopen(attribFilename.c_str(), "rt"); - if (fp == NULL) { - perror(attribFilename.c_str()); - return -1; - } - char buf[1000]; - - state = ST_NAME; - EntryPoint *currentEntry = NULL; - size_t lc = 0; - bool globalAttributes = false; - while (fgets(buf, sizeof(buf), fp) != NULL) { - lc++; - std::string line(buf); - if (line.size() == 0) continue; // could that happen? - - if (line.at(0) == '#') continue; // comment - - size_t first = line.find_first_not_of(" \t\n"); - if (state == ST_ATT && (first == std::string::npos || first == 0)) state = ST_NAME; - - line = trim(line); - if (line.size() == 0 || line.at(0) == '#') continue; - - switch(state) { - case ST_NAME: - if (line == "GLOBAL") { - globalAttributes = true; - } else { - globalAttributes = false; - currentEntry = findEntryByName(line); - if (currentEntry == NULL) { - fprintf(stderr, "WARNING: %u: attribute of non existant entry point %s\n", (unsigned int)lc, line.c_str()); - } - } - state = ST_ATT; - break; - case ST_ATT: - if (globalAttributes) { - setGlobalAttribute(line, lc); - } else if (currentEntry != NULL) { - currentEntry->setAttribute(line, lc); - } - break; - } - } - return 0; -} - - -int ApiGen::setGlobalAttribute(const std::string & line, size_t lc) -{ - size_t pos = 0; - size_t last; - std::string token = getNextToken(line, pos, &last, WHITESPACE); - pos = last; - - if (token == "base_opcode") { - std::string str = getNextToken(line, pos, &last, WHITESPACE); - if (str.size() == 0) { - fprintf(stderr, "line %u: missing value for base_opcode\n", (unsigned) lc); - } else { - setBaseOpcode(atoi(str.c_str())); - } - } else if (token == "encoder_headers") { - std::string str = getNextToken(line, pos, &last, WHITESPACE); - pos = last; - while (str.size() != 0) { - encoderHeaders().push_back(str); - str = getNextToken(line, pos, &last, WHITESPACE); - pos = last; - } - } else if (token == "client_context_headers") { - std::string str = getNextToken(line, pos, &last, WHITESPACE); - pos = last; - while (str.size() != 0) { - clientContextHeaders().push_back(str); - str = getNextToken(line, pos, &last, WHITESPACE); - pos = last; - } - } else if (token == "server_context_headers") { - std::string str = getNextToken(line, pos, &last, WHITESPACE); - pos = last; - while (str.size() != 0) { - serverContextHeaders().push_back(str); - str = getNextToken(line, pos, &last, WHITESPACE); - pos = last; - } - } else if (token == "decoder_headers") { - std::string str = getNextToken(line, pos, &last, WHITESPACE); - pos = last; - while (str.size() != 0) { - decoderHeaders().push_back(str); - str = getNextToken(line, pos, &last, WHITESPACE); - pos = last; - } - } - else { - fprintf(stderr, "WARNING: %u : unknown global attribute %s\n", (unsigned int)lc, line.c_str()); - } - - return 0; -} - diff --git a/emulator/opengl/host/tools/emugen/ApiGen.h b/emulator/opengl/host/tools/emugen/ApiGen.h deleted file mode 100644 index 8ba18af..0000000 --- a/emulator/opengl/host/tools/emugen/ApiGen.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -* 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 __API_GEN_H_ -#define __API_GEN_H_ - -#include <vector> -#include <string.h> -#include "EntryPoint.h" - - -class ApiGen : public std::vector<EntryPoint> { - -public: - typedef std::vector<std::string> StringVec; - typedef enum { CLIENT_SIDE, SERVER_SIDE, WRAPPER_SIDE } SideType; - - ApiGen(const std::string & basename) : - m_basename(basename), - m_maxEntryPointsParams(0), - m_baseOpcode(0) - { } - virtual ~ApiGen() {} - int readSpec(const std::string & filename); - int readAttributes(const std::string & attribFilename); - size_t maxEntryPointsParams() { return m_maxEntryPointsParams; } - void updateMaxEntryPointsParams(size_t val) { - if (m_maxEntryPointsParams == 0 || val > m_maxEntryPointsParams) m_maxEntryPointsParams = val; - } - int baseOpcode() { return m_baseOpcode; } - void setBaseOpcode(int base) { m_baseOpcode = base; } - - const char *sideString(SideType side) { - const char *retval; - switch(side) { - case CLIENT_SIDE: - retval = "client"; - break; - case SERVER_SIDE: - retval = "server"; - break; - case WRAPPER_SIDE: - retval = "wrapper"; - break; - default: - retval = "unknown"; - } - return retval; - } - - StringVec & clientContextHeaders() { return m_clientContextHeaders; } - StringVec & encoderHeaders() { return m_encoderHeaders; } - StringVec & serverContextHeaders() { return m_serverContextHeaders; } - StringVec & decoderHeaders() { return m_decoderHeaders; } - - EntryPoint * findEntryByName(const std::string & name); - int genOpcodes(const std::string &filename); - int genAttributesTemplate(const std::string &filename); - int genProcTypes(const std::string &filename, SideType side); - int genFuncTable(const std::string &filename, SideType side); - - int genContext(const std::string &filename, SideType side); - int genContextImpl(const std::string &filename, SideType side); - - int genEntryPoints(const std::string &filename, SideType side); - - int genEncoderHeader(const std::string &filename); - int genEncoderImpl(const std::string &filename); - - int genDecoderHeader(const std::string &filename); - int genDecoderImpl(const std::string &filename); - -protected: - virtual void printHeader(FILE *fp) const; - std::string m_basename; - StringVec m_clientContextHeaders; - StringVec m_encoderHeaders; - StringVec m_serverContextHeaders; - StringVec m_decoderHeaders; - size_t m_maxEntryPointsParams; // record the maximum number of parameters in the entry points; - int m_baseOpcode; - int setGlobalAttribute(const std::string & line, size_t lc); -}; - -#endif diff --git a/emulator/opengl/host/tools/emugen/EntryPoint.cpp b/emulator/opengl/host/tools/emugen/EntryPoint.cpp deleted file mode 100644 index cc3bef1..0000000 --- a/emulator/opengl/host/tools/emugen/EntryPoint.cpp +++ /dev/null @@ -1,349 +0,0 @@ -/* -* 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. -*/ -#include "EntryPoint.h" - -#include "Parser.h" -#include "TypeFactory.h" -#include "strUtils.h" - -#include <sstream> -#include <string> - -#include <stdio.h> - -EntryPoint::EntryPoint() -{ - reset(); -} - -EntryPoint::~EntryPoint() -{ -} - -void EntryPoint::reset() -{ - m_unsupported = false; - m_customDecoder = false; - m_notApi = false; - m_flushOnEncode = false; - m_vars.empty(); -} - -// return true for valid line (need to get into the entry points list) -bool EntryPoint::parse(unsigned int lc, const std::string & str) -{ - size_t pos, last; - std::string field; - - reset(); - std::string linestr = trim(str); - - if (linestr.size() == 0) return false; - if (linestr.at(0) == '#') return false; - - // skip PREFIX - field = getNextToken(linestr, 0, &last, "("); - pos = last + 1; - // return type - field = getNextToken(linestr, pos, &last, ",)"); - - std::string error; - std::string retTypeName; - if (!parseTypeDeclaration(field, &retTypeName, &error)) { - fprintf(stderr, - "line: %d: Parsing error in field <%s>: %s\n", - lc, - field.c_str(), - error.c_str()); - return false; - } - pos = last + 1; - const VarType *theType = TypeFactory::instance()->getVarTypeByName(retTypeName); - if (theType->name() == "UNKNOWN") { - fprintf(stderr, "UNKNOWN retval: %s\n", linestr.c_str()); - } - - m_retval.init(std::string(""), - theType, - std::string(""), - Var::POINTER_OUT, - std::string(""), - std::string("")); - - // function name - m_name = getNextToken(linestr, pos, &last, ",)"); - pos = last + 1; - - // parameters; - int nvars = 0; - while (pos < linestr.size() - 1) { - field = getNextToken(linestr, pos, &last, ",)"); - if (field == "void") { - // 'void' is used as a special case for functions that don't take - // parameters at all. - break; - } - std::string vartype, varname; - if (!parseParameterDeclaration(field, &vartype, &varname, &error)) { - fprintf(stderr, - "line: %d: Parsing error in field <%s>\n", - lc, - field.c_str(), - error.c_str()); - return false; - } - nvars++; - const VarType *v = TypeFactory::instance()->getVarTypeByName(vartype); - if (v->id() == 0) { - fprintf(stderr, "%d: Unknown type: %s\n", lc, vartype.c_str()); - } else { - if (varname == "" && - !(v->name() == "void" && !v->isPointer())) { - std::ostringstream oss; - oss << "var" << nvars; - varname = oss.str(); - } - - m_vars.push_back(Var(varname, v, std::string(""), Var::POINTER_IN, "", "")); - } - pos = last + 1; - } - return true; -} - -void EntryPoint::print(FILE *fp, bool newline, - const std::string & name_suffix, - const std::string & name_prefix, - const std::string & ctx_param ) const -{ - fprintf(fp, "%s %s%s%s(", - m_retval.type()->name().c_str(), - name_prefix.c_str(), - m_name.c_str(), - name_suffix.c_str()); - - if (ctx_param != "") fprintf(fp, "%s ", ctx_param.c_str()); - - for (size_t i = 0; i < m_vars.size(); i++) { - if (m_vars[i].isVoid()) continue; - if (i != 0 || ctx_param != "") fprintf(fp, ", "); - fprintf(fp, "%s %s", m_vars[i].type()->name().c_str(), - m_vars[i].name().c_str()); - } - fprintf(fp, ")%s", newline? "\n" : ""); -} - -Var * EntryPoint::var(const std::string & name) -{ - Var *v = NULL; - for (size_t i = 0; i < m_vars.size(); i++) { - if (m_vars[i].name() == name) { - v = &m_vars[i]; - break; - } - } - return v; -} - -bool EntryPoint::hasPointers() -{ - bool pointers = false; - if (m_retval.isPointer()) pointers = true; - if (!pointers) { - for (size_t i = 0; i < m_vars.size(); i++) { - if (m_vars[i].isPointer()) { - pointers = true; - break; - } - } - } - return pointers; -} - -int EntryPoint::setAttribute(const std::string &line, size_t lc) -{ - size_t pos = 0; - size_t last; - std::string token = getNextToken(line, 0, &last, WHITESPACE); - - if (token == "len") { - pos = last; - std::string varname = getNextToken(line, pos, &last, WHITESPACE); - - if (varname.size() == 0) { - fprintf(stderr, "ERROR: %u: Missing variable name in 'len' attribute\n", (unsigned int)lc); - return -1; - } - Var * v = var(varname); - if (v == NULL) { - fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", - (unsigned int)lc, varname.c_str(), name().c_str()); - return -2; - } - // set the size expression into var - pos = last; - v->setLenExpression(line.substr(pos)); - } else if (token == "param_check") { - pos = last; - std::string varname = getNextToken(line, pos, &last, WHITESPACE); - - if (varname.size() == 0) { - fprintf(stderr, "ERROR: %u: Missing variable name in 'param_check' attribute\n", (unsigned int)lc); - return -1; - } - Var * v = var(varname); - if (v == NULL) { - fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", - (unsigned int)lc, varname.c_str(), name().c_str()); - return -2; - } - // set the size expression into var - pos = last; - v->setParamCheckExpression(line.substr(pos)); - - } else if (token == "dir") { - pos = last; - std::string varname = getNextToken(line, pos, &last, WHITESPACE); - if (varname.size() == 0) { - fprintf(stderr, "ERROR: %u: Missing variable name in 'dir' attribute\n", (unsigned int)lc); - return -1; - } - Var * v = var(varname); - if (v == NULL) { - fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", - (unsigned int)lc, varname.c_str(), name().c_str()); - return -2; - } - - pos = last; - std::string pointerDirStr = getNextToken(line, pos, &last, WHITESPACE); - if (pointerDirStr.size() == 0) { - fprintf(stderr, "ERROR: %u: missing pointer directions\n", (unsigned int)lc); - return -3; - } - - if (pointerDirStr == "out") { - v->setPointerDir(Var::POINTER_OUT); - } else if (pointerDirStr == "inout") { - v->setPointerDir(Var::POINTER_INOUT); - } else if (pointerDirStr == "in") { - v->setPointerDir(Var::POINTER_IN); - } else { - fprintf(stderr, "ERROR: %u: unknow pointer direction %s\n", (unsigned int)lc, pointerDirStr.c_str()); - } - } else if (token == "var_flag") { - pos = last; - std::string varname = getNextToken(line, pos, &last, WHITESPACE); - if (varname.size() == 0) { - fprintf(stderr, "ERROR: %u: Missing variable name in 'var_flag' attribute\n", (unsigned int)lc); - return -1; - } - Var * v = var(varname); - if (v == NULL) { - fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", - (unsigned int)lc, varname.c_str(), name().c_str()); - return -2; - } - int count = 0; - for (;;) { - pos = last; - std::string flag = getNextToken(line, pos, &last, WHITESPACE); - if (flag.size() == 0) { - if (count == 0) { - fprintf(stderr, "ERROR: %u: missing flag\n", (unsigned int) lc); - return -3; - } - break; - } - count++; - - if (flag == "nullAllowed") { - if (v->isPointer()) { - v->setNullAllowed(true); - } else { - fprintf(stderr, "WARNING: %u: setting nullAllowed for non-pointer variable %s\n", - (unsigned int) lc, v->name().c_str()); - } - } else if (flag == "isLarge") { - if (v->isPointer()) { - v->setIsLarge(true); - } else { - fprintf(stderr, "WARNING: %u: setting isLarge flag for a non-pointer variable %s\n", - (unsigned int) lc, v->name().c_str()); - } - } else { - fprintf(stderr, "WARNING: %u: unknow flag %s\n", (unsigned int)lc, flag.c_str()); - } - } - } else if (token == "custom_pack") { - pos = last; - std::string varname = getNextToken(line, pos, &last, WHITESPACE); - - if (varname.size() == 0) { - fprintf(stderr, "ERROR: %u: Missing variable name in 'custom_pack' attribute\n", (unsigned int)lc); - return -1; - } - Var * v = var(varname); - if (v == NULL) { - fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", - (unsigned int)lc, varname.c_str(), name().c_str()); - return -2; - } - // set the size expression into var - pos = last; - v->setPackExpression(line.substr(pos)); - } else if (token == "custom_write") { - pos = last; - std::string varname = getNextToken(line, pos, &last, WHITESPACE); - - if (varname.size() == 0) { - fprintf(stderr, "ERROR: %u: Missing variable name in 'custom_write' attribute\n", (unsigned int)lc); - return -1; - } - Var * v = var(varname); - if (v == NULL) { - fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", - (unsigned int)lc, varname.c_str(), name().c_str()); - return -2; - } - // set the size expression into var - pos = last; - v->setWriteExpression(line.substr(pos)); - } else if (token == "flag") { - pos = last; - std::string flag = getNextToken(line, pos, &last, WHITESPACE); - if (flag.size() == 0) { - fprintf(stderr, "ERROR: %u: missing flag\n", (unsigned int) lc); - return -4; - } - - if (flag == "unsupported") { - setUnsupported(true); - } else if (flag == "custom_decoder") { - setCustomDecoder(true); - } else if (flag == "not_api") { - setNotApi(true); - } else if (flag == "flushOnEncode") { - setFlushOnEncode(true); - } else { - fprintf(stderr, "WARNING: %u: unknown flag %s\n", (unsigned int)lc, flag.c_str()); - } - } else { - fprintf(stderr, "WARNING: %u: unknown attribute %s\n", (unsigned int)lc, token.c_str()); - } - - return 0; -} diff --git a/emulator/opengl/host/tools/emugen/EntryPoint.h b/emulator/opengl/host/tools/emugen/EntryPoint.h deleted file mode 100644 index 1061d25..0000000 --- a/emulator/opengl/host/tools/emugen/EntryPoint.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -* 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 __EntryPoint__H__ -#define __EntryPoint__H__ - -#include <string> -#include <vector> -#include <stdio.h> - -#include "Var.h" - -//--------------------------------------------------- - -typedef std::vector<Var> VarsArray; - -class EntryPoint { -public: - EntryPoint(); - virtual ~EntryPoint(); - bool parse(unsigned int lc, const std::string & str); - void reset(); // reset the class to empty; - void print(FILE *fp = stdout, bool newline = true, - const std::string & name_suffix = std::string(""), - const std::string & name_prefix = std::string(""), - const std::string & ctx_param = std::string("")) const; - const std::string & name() const { return m_name; } - VarsArray & vars() { return m_vars; } - Var & retval() { return m_retval; } - Var * var(const std::string & name); - bool hasPointers(); - bool unsupported() const { return m_unsupported; } - void setUnsupported(bool state) { m_unsupported = state; } - bool customDecoder() { return m_customDecoder; } - void setCustomDecoder(bool state) { m_customDecoder = state; } - bool notApi() const { return m_notApi; } - void setNotApi(bool state) { m_notApi = state; } - bool flushOnEncode() const { return m_flushOnEncode; } - void setFlushOnEncode(bool state) { m_flushOnEncode = state; } - int setAttribute(const std::string &line, size_t lc); - -private: - enum { PR_RETVAL = 0, PR_NAME, PR_VARS, PR_DONE } prState; - std::string m_name; - Var m_retval; - VarsArray m_vars; - bool m_unsupported; - bool m_customDecoder; - bool m_notApi; - bool m_flushOnEncode; - - void err(unsigned int lc, const char *msg) { - fprintf(stderr, "line %d: %s\n", lc, msg); - } -}; - - -#endif diff --git a/emulator/opengl/host/tools/emugen/Parser.cpp b/emulator/opengl/host/tools/emugen/Parser.cpp deleted file mode 100644 index 0839f20..0000000 --- a/emulator/opengl/host/tools/emugen/Parser.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* -* Copyright 2014 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 "Parser.h" - -#include <vector> - -#define WHITESPACE " \t\n" - -// Parse the |input| string as a list of type-specific tokens. -// This tokenizes the input, using whitespace as separators and '*' as -// a single token too. On success, return true and sets |*out| to the -// list of tokens. On failure, return false. -// -// Example: 'const char**foo' -> ['const', 'char', '*', '*', 'foo'] -// -static bool parseTypeTokens(const std::string& input, - std::vector<std::string>* out, - std::string* error) { - out->clear(); - size_t pos = 0U; - - // Parse all tokens in the input, treat '*' as a single token. - // I.e. - for (;;) { - // skip leading whitespace. - pos = input.find_first_not_of(WHITESPACE, pos); - if (pos == std::string::npos) { - break; // end of parse. - } - - // If this is a star, ensure it follows a type name. - // otherwise treat it as part of the final type. - if (input[pos] == '*') { - out->push_back(std::string("*")); - pos += 1U; - continue; - } - - // find end of type/token. - size_t end = input.find_first_of(WHITESPACE "*", pos); - if (end == std::string::npos) { - end = input.size(); - } - - std::string str = input.substr(pos, end - pos); - if (str.size() == 0) { - // Sanity check: should not happen. - if (error != NULL) { - *error = "Unexpected empty token !?"; - } - return false; - } - - out->push_back(str); - pos = end; - } - - if (error != NULL) { - // Sanity check: require non-empty input - if (out->empty()) { - *error = "Empty parameter declaration!"; - return false; - } - - // Sanity check: There must be base type name before any '*' - for (size_t n = 0; n < out->size(); ++n) { - std::string& token = (*out)[n]; - if (token == "*") { - *error = "Unexpected '*' before type name"; - return false; - } else if (token != "const") { - break; - } - } - } - - return true; -} - -// Given |tokens|, an input vector of strings, join the first |count| items -// into a normalized type string, and return it. -static std::string buildTypeString(const std::vector<std::string>& tokens, - size_t count) { - std::string result; - - for (size_t n = 0; n < count; ++n) { - const std::string& token = tokens[n]; - if (n > 0 && token != "*") { - result.append(" "); - } - result.append(token); - } - return result; -} - - -std::string normalizeTypeDeclaration(const std::string& input) { - std::vector<std::string> tokens; - if (!parseTypeTokens(input, &tokens, NULL)) { - return ""; - } - return buildTypeString(tokens, tokens.size()); -} - -bool parseTypeDeclaration(const std::string& input, - std::string* typeName, - std::string* error) { - // The type name can be made of several tokens, e.g. 'unsigned int' - // use an array to store them, and a count variable. Each item can be - // one of '*', 'const' or a type name component (e.g. 'struct', 'unsigned') - std::vector<std::string> tokens; - - if (!parseTypeTokens(input, &tokens, error)) { - return false; - } - - // Sanity check, there must be a least one non-special tokens. - size_t nonSpecialCount = 0; - for (size_t n = 0; n < tokens.size(); ++n) { - if (tokens[n] != "*" && tokens[n] != "const") { - nonSpecialCount++; - } - } - if (nonSpecialCount == 0) { - *error = "Missing type name"; - return false; - } - // Build the type name from all tokens before it. - *typeName = buildTypeString(tokens, tokens.size()); - return true; -} - - -bool parseParameterDeclaration(const std::string& param, - std::string* typeName, - std::string* variableName, - std::string* error) { - std::vector<std::string> tokens; - - if (!parseTypeTokens(param, &tokens, error)) { - return false; - } - - // Sanity check, there must be a least two non-special tokens. - size_t nonSpecialCount = 0; - for (size_t n = 0; n < tokens.size(); ++n) { - if (tokens[n] != "*" && tokens[n] != "const") { - nonSpecialCount++; - } - } - if (nonSpecialCount == 0) { - *error = "Missing type name"; - return false; - } - if (nonSpecialCount == 1) { - *error = "Missing variable name"; - return false; - } - - // Sanity check: variable name must not be followed by 'const' or '*' - const std::string& lastToken = tokens[tokens.size() - 1U]; - if (lastToken == "*") { - *error = "Extra '*' after variable name"; - return false; - } - if (lastToken == "const") { - *error = "Extra 'const' after variable name"; - return false; - } - - // Extract the variable name as the last token. - if (variableName) { - *variableName = lastToken; - } - // Build the type name from all tokens before it. - *typeName = buildTypeString(tokens, tokens.size() - 1U); - return true; -} diff --git a/emulator/opengl/host/tools/emugen/Parser.h b/emulator/opengl/host/tools/emugen/Parser.h deleted file mode 100644 index f62c076..0000000 --- a/emulator/opengl/host/tools/emugen/Parser.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright 2014 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 PARSER_H -#define PARSER_H - -#include <string> - -// Normalize a type declaration. This gets rid of leading/trailing whitespace -// as well as ensure there is a single space separating all input tokens, -// with the exception of '*' which is treated specially by never being -// prepended with a space. -// |input| is the input type declaration. Return normalized form. -// Note that this doesn't try to validate the input. -std::string normalizeTypeDeclaration(const std::string& input); - -// Parse a return type declaration. |input| is the type declaration -// (e.g. 'const char**'). On success return true and sets |*typeName| to -// the appropriate normalized type string. On failure, return false and -// sets |*error| with a human-friendly message explaining the reason for -// failure. -// -// Note that the returned type string is normalized, see comment for -// parseParameterDeclaration() for examples. -// -// NOTE: This does not support declarations of arrays or functions! -// -bool parseTypeDeclaration(const std::string& input, - std::string* typeName, - std::string* error); - -// Parse a function parameter declaration and extract the type and variable -// name from it. |param| is the individual parameter declaration from the -// function's signature (e.g. 'const char *items') -// -// On success, returns true and sets |*vartype| and |*varname| to the -// appropriate type name and variable name. |varname| can be NULL if the caller -// isn't interested in the variable name. -// -// On failure, return false and sets |*error| to a human-friendly message -// explaining the reason for failure. -// -// Note that the returned type name is normalized with regards to whitespace -// and star location, e.g.: -// -// const void *items -> 'const void*' -// char* *items -> 'char**' -// const void * const * items -> 'const void* const*' -// unsigned int *const data -> 'unsigned int* const' -// -bool parseParameterDeclaration(const std::string& param, - std::string* typeName, - std::string* variableName, - std::string* error); - -#endif // PARSER_H diff --git a/emulator/opengl/host/tools/emugen/Parser_unittest.cpp b/emulator/opengl/host/tools/emugen/Parser_unittest.cpp deleted file mode 100644 index 904b247..0000000 --- a/emulator/opengl/host/tools/emugen/Parser_unittest.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -* Copyright 2014 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 "Parser.h" - -#include <gtest/gtest.h> - -#define ARRAYLEN(x) (sizeof(x) / sizeof(x[0])) - -TEST(ParserTest, normalizeTypeDeclaration) { - static const struct { - const char* expected; - const char* input; - } kData[] = { - { "char", "char" }, - { "const unsigned int", " const unsigned\tint\n" }, - { "char* const**", "char *const* *" }, - }; - const size_t kDataSize = ARRAYLEN(kData); - for (size_t n = 0; n < kDataSize; ++n) { - std::string result; - std::string text = "When parsing '"; - text += kData[n].input; - text += "'"; - - result = normalizeTypeDeclaration(kData[n].input); - EXPECT_STREQ(kData[n].expected, result.c_str()) << text; - } -} - -TEST(ParserTest, parseTypeDeclaration) { - static const struct { - const char* input; - bool expected; - const char* expectedType; - const char* expectedError; - } kData[] = { - { "const", false, NULL, "Missing type name" }, - { "const const", false, NULL, "Missing type name" }, - { "foo", true, "foo", NULL }, - { "void", true, "void", NULL }, - { "const foo", true, "const foo", NULL }, - { "foo *", true, "foo*", NULL }, - { "char foo", true, "char foo", NULL }, - { "\tunsigned \t int\n", true, "unsigned int", NULL }, - { "const * char", false, NULL, "Unexpected '*' before type name" }, - { "const char * ", true, "const char*", NULL }, - { "const void*const * *", true, "const void* const**", NULL }, - }; - const size_t kDataSize = ARRAYLEN(kData); - for (size_t n = 0; n < kDataSize; ++n) { - std::string varname, vartype, error; - std::string text = "When parsing '"; - text += kData[n].input; - text += "'"; - - EXPECT_EQ(kData[n].expected, - parseTypeDeclaration(kData[n].input, - &vartype, - &error)) << text; - if (kData[n].expected) { - EXPECT_STREQ(kData[n].expectedType, vartype.c_str()) << text; - } else { - EXPECT_STREQ(kData[n].expectedError, error.c_str()) << text; - } - } -} - -TEST(ParserTest, parseParameterDeclaration) { - static const struct { - const char* input; - bool expected; - const char* expectedType; - const char* expectedVariable; - const char* expectedError; - } kData[] = { - { "foo", false, NULL, NULL, "Missing variable name" }, - { "const", false, NULL, NULL, "Missing type name" }, - { "const foo", false, NULL, NULL, "Missing variable name" }, - { "const const", false, NULL, NULL, "Missing type name" }, - { "char foo", true, "char", "foo", NULL }, - { "unsigned int\t bar\n", true, "unsigned int", "bar", NULL }, - { "const * char foo", false, NULL, NULL, "Unexpected '*' before type name" }, - { "const char * foo", true, "const char*", "foo", NULL }, - { "const void*const *data", true, "const void* const*", "data", NULL }, - { "char foo const", false, NULL, NULL, "Extra 'const' after variable name" }, - { "int bar*", false, NULL, NULL, "Extra '*' after variable name" }, - }; - const size_t kDataSize = ARRAYLEN(kData); - for (size_t n = 0; n < kDataSize; ++n) { - std::string varname, vartype, error; - std::string text = "When parsing '"; - text += kData[n].input; - text += "'"; - - EXPECT_EQ(kData[n].expected, - parseParameterDeclaration(kData[n].input, - &vartype, - &varname, - &error)) << text; - if (kData[n].expected) { - EXPECT_STREQ(kData[n].expectedType, vartype.c_str()) << text; - EXPECT_STREQ(kData[n].expectedVariable, varname.c_str()) << text; - } else { - EXPECT_STREQ(kData[n].expectedError, error.c_str()) << text; - } - } -} diff --git a/emulator/opengl/host/tools/emugen/README b/emulator/opengl/host/tools/emugen/README deleted file mode 100644 index 0fe85f9..0000000 --- a/emulator/opengl/host/tools/emugen/README +++ /dev/null @@ -1,332 +0,0 @@ -Introduction: -------------- -The emugen tool is a tool to generate a wire protocol implementation -based on provided API. The tool generates c++ encoder code that takes -API calls and encodes them into the wire and decoder code that decodes -the wire stream and calls server matching API. -The emugen tool includes additional functionality that enables to -generate an wrapper library. The wrapper library provides entry points -for the specified API, where each entry routes the call via a dispatch -table. The dispatch table may be initialized as required by a specific application. - -The following paragraphs includes the following: - * Wire Protocol Description - * Input files description & format - * Generated code description. - - -Note: In this document, the caller is referred to as Encoder or Client -and the callee is referred to as the Decoder or Server. These terms -are used interchangeably by the context. - - - -Wire Protocol packet structure: -------------------------------- -A general Encoder->Decoder packet is structured as following: -struct Packet { - unsigned int opcode; - unsigned int packet_len; - … parameter 1 - … parameter 2 -}; -A general Decoder->Encoder reply is expected to be received in the -context of the ‘call’ that triggered it, thus it includes the reply -data only, with no context headers. In precise term terms, a reply -packet will look like: - -struct { - ...// reply data -}; - -consider the following function call: -int foo(int p1, short s1) -will be encoded into : -{ - 101, // foo opcode - 14, // sizeof(opcode) + sizeof(packet_len) + sizeof(int) + sizeof(short) - p1, // 4 bytes - s1 // 2 bytes -} - -Since ‘foo’ returns value, the caller is expected to read back the return packet from the server->client stream. The return value in this example is in thus the return packet is: -{ - int retval; -} - - -Pointer decoding: ----------------- -The wire protocol also allows exchanging of pointer data -(arrays). Pointers are defined with directions: - - in : Data is sent from the caller to the calle - out: Data is sent from the callee to the caller - in_out: data is sent from the caller and return in place. - -‘in’ and ‘in_out’ encoded with their len: -{ - unsinged int pointer_data_len; - unsigned char data[pointer_data_len];… // pointer data -} - -‘out’ pointers are encoded by data length only: -{ -unsigned int pointer_data_len; -} - -‘out’ and ‘in_out’ pointer’s data is returned in the return -packet. For example, consider the following call: - -int foo(int n, int *ptr); // assume that ‘data’ is in_out pointer which contains ‘n’ ints - -The caller packet will have the following form: -{ - 101, // foo opcode - xx, sizeof(opcode) + sizeof(datalen) + sizeof(int) + sizeof(unsigned int) + n * sizeof(int); - n, // the n parameter - n * sizeof(int), // size of the data in ptr - … // n* sizeof(int) bytes -} - -The return packet is; -{ - …. // n * sizeof(int) bytes of data return in ptr - retval // sizeof(int) - the return value of the function; -} - -Endianess ---------- -The Wire protocol is designed to impose minimum overhead on the client -side. Thus, the data endianness that is sent across the wire is -determined by the ‘client’ side. It is up to the server side to -determine the client endianess and marshal the packets as required. - - - -Emugen input files - protocol specification -------------------------------------------- -The protocol generated by emugen consists of two input files: - -1. basename.in - A sepcification of the protocol RPC procedures. This -part of the specification is expected to be generated automatically -from c/c++ header files or similar. - -‘basename’ is the basename for the protocol and will be used to prefix -the files that are generated for this protocol. A line in the .in -file has the following format: - -[prefix](retvalType, FuncName, <param type> [param name],...) -where - retvalType - The function return value type - FuncName - function name - <param type> mandatory parameter type - [param name] - optional parameter name -Examples: -GL_ENTRY(void, glVertex1f, float v) -XXX(int *, foo, int n, float, short) -XXX(void, glFlush, void) - -Note: Empty lines in the file are ignored. A line starts with # is a comment - -2. basename.attrib - Attributes information of the API. -This file includes additional flags, pointers datalen information and -global attributes of the protocol. For uptodate format of the file, -please refer to the specification file in the project source -tree. The format of the .attrib file is described below. - -3. basename.types - Types information - -This files describes the types that are described by the API. A type -is defined as follows: -<type name> <size in bits> <print format string> <is a pointer? true|false> -where: -<type name> is the name of the type as described in the API -<size in bits> 0, 8, 16, 32 sizes are accepted -<print format string> a string to format the value of the type, as -acceted by printf(3) -<is pointer?> true or false string species whether the type should be -treated as a pointer. - -example: -GLint 32 %d false -GLint* 32 %p true -GLptr 32 %p true - -Encoder generated code files ----------------------------- -In order to generate the encoder files, one should run the ‘emugen’ -tool as follows: - -emugen -i <input directory> -E <encoder files output directory> <basename> -where: - <input directory> containes the api specification files (basename.in + basename.attrib) - <encoder directory> - a directory name to generate the encoder output files - basename - The basename for the api. - -Assuming the basename is ‘api’, The following files are generated: - -api_opcodes.h - defines the protocol opcodes. The first opcode value -is 0, unless defined otherwise in the .attrib file - -api_entry.cpp - defines entry points for the functions that are -defined by the protocol. this File also includes a function call -‘setContextAccessor(void *(*f)()). This function should be used to -provide a callback function that is used by the functions to access -the encoder context. For example, such callback could fetch the -context from a Thread Local Storage (TLS) location. - -api_client_proc.h - type defintions for the protocol procedures. - -api_client_context.h - defines the client side dispatch table data -structure that stores the encoding functions. This data structure also -includes ‘accessors’ methods such that library user can override -default entries for special case handling. - -api_client_context.cpp - defines an initialization function for -dispatch table - -api_enc.h - This header file defines the encoder data strcuture. The -encoder data structure inherits its functionality from the -‘client_context’ class above and adds encoding and streaming -functionality. - -api_enc.cpp - Encoder implementation. - -Decoder generated files ------------------------ -In order to generate the decoder files, one should run the ‘emugen’ -tool as follows: -emugen -i <input directory> -D <decoder files output directory> basename -where: - <input directory> containes the api specification files (basename.in + basename.attrib) - <decoder directory> - a directory name to generate the decoder output files - basename - The basename for the api. - -With resepct to the example above, Emugen will generate the following -files: - -api_opcodes.h - Protocol opcodes - -api_server_proc.h - type definitions for the server side procedures - -api_server_context.h - dispatch table the decoder functions - -api_server_context.cpp - dispatch table initialization function -api_dec.h - Decoder header file - -api_dec.cpp - Decoder implementation. In addtion, this file includes -an intiailization function that uses a user provided callback to -initialize the API server implementation. An example for such -initialization is loading a set of functions from a shared library -module. - -Wrapper generated files ------------------------ -In order to generate a wrapper library files, one should run the -'emugen' tool as follows: - -emugen -i <input directory> -W <wrapper files output directory> basename -where: - <input directory> containes the api specification files (basename.in + basename.attrib) - <wrapper directory> - a directory name to generate the wrapper output files - basename - The basename for the api. - -With resepct to the example above, Emugen will generate the following -files: - -api_wrapper_proc.h - type definitions for the wrapper procedures - -api_wrapper_context.h - dispatch table the wrapper functions - -api_wrapper_context.cpp - dispatch table initialization function -api_wrapper_entry.cpp - entry points for the API - - -.attrib file format description: -------------------------------- -The .attrib file is an input file to emugen and is used to provide - additional information that is required for the code generation. -The file format is as follows: - -a line that starts with # is ignored (comment) -a empty line just whitespace of (" " "\t" "\n") is ignored. - -The file is divided into 'sections', each describes a specific API -function call. A section starts with the name of the function in -column 0. - -A section that starts with the reserved word 'GLOBAL' provides global -attributes. - -below are few sections examples: - -GLOBAL - encoder_headers string.h kuku.h - -glVertex3fv - len data (size) -glTexImage2D - len pixels (pixels == NULL? 0 : (format_pixel_size(internalformat) * width * height * type_size(type))) - - -Global section flags description: - -base_opcode - set the base opcode value for this api - format: base_opcode 100 - -encoder_headers - a list of headers that will be included in the encoder header file - format: encoder_headers <stdio.h> "kuku.h" - -client_context_headers - a list of headers that will be included in the client context header file - format: client_context_headers <stdio.h> "kuku.h" - -decoder_headers - a list of headers that will be included in the decoder header file - format: decoder_headers <stdio.h> "kuku.h" - -server_context_headers - a list of headers that will be included in the server context header file - format: server_context_headers <stdio.h> "kuku.h" - - -Entry point flags description: - - len - desciption : provide an expression to calcualte an expression data len - format: len <var name> <c expression that calcluates the data len> - -custom_pack - description: provide an expression to pack data into the stream. - format: custom_pack <var name> <c++ expression that pack data from var into the stream> - The stream is represented by a (unsigned char *)ptr. The expression may also refer - to other function parameters. In addition, the expression may refer to 'void *self' which - is the encoding context as provided by the caller. - - dir - description : set a pointer direction (in - for data that goes - to the codec, out from data that returns from the codec. - format: dir <varname> <[in | out | inout]> - - var_flag - description : set variable flags - format: var_flag <varname> < nullAllowed | isLarge | ... > - - nullAllowed -> for pointer variables, indicates that NULL is a valid value - isLarge -> for pointer variables, indicates that the data should be sent without an intermediate copy - - flag - description: set entry point flag; - format: flag < unsupported | ... > - supported flags are: - unsupported - The encoder side implementation is pointed to "unsuppored reporting function". - custom_decoder - The decoder is expected to be provided with - custom implementation. The call to the - deocder function includes a pointer to the - context - not_api - the function is not native gl api - - diff --git a/emulator/opengl/host/tools/emugen/TypeFactory.cpp b/emulator/opengl/host/tools/emugen/TypeFactory.cpp deleted file mode 100644 index 1e0cc96..0000000 --- a/emulator/opengl/host/tools/emugen/TypeFactory.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* -* 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. -*/ -#include "TypeFactory.h" - -#include "Parser.h" -#include "VarType.h" -#include "strUtils.h" - -#include <map> -#include <string> - -#include <stdio.h> -#include <stdlib.h> - - -TypeFactory * TypeFactory::m_instance = NULL; - -typedef std::map<std::string, VarType> TypeMap; -static TypeMap g_varMap; -static bool g_initialized = false; -static int g_typeId = 0; - - -#define ADD_TYPE(name, size, printformat,ispointer) \ - g_varMap.insert(std::pair<std::string, VarType>(name, VarType(g_typeId++, name, (size + 7) >> 3, printformat , ispointer))); - -void TypeFactory::initBaseTypes() -{ - g_initialized = true; - ADD_TYPE("UNKNOWN", 0, "0x%x", false); - ADD_TYPE("void", 0, "0x%x", false); - ADD_TYPE("char", 8, "%c", false); - ADD_TYPE("int", 32, "%d", false); - ADD_TYPE("float", 32, "%d", false); - ADD_TYPE("short", 16, "%d", false); -} - -int TypeFactory::initFromFile(const std::string &filename) -{ - if (!g_initialized) { - initBaseTypes(); - } - - FILE *fp = fopen(filename.c_str(), "rt"); - if (fp == NULL) { - perror(filename.c_str()); - return -1; - } - char line[1000]; - int lc = 0; - while(fgets(line, sizeof(line), fp) != NULL) { - lc++; - std::string str = trim(line); - if (str.size() == 0 || str.at(0) == '#') { - continue; - } - size_t pos = 0, last; - std::string name; - name = getNextToken(str, pos, &last, WHITESPACE); - name = normalizeTypeDeclaration(name); - if (name.size() == 0) { - fprintf(stderr, "Error: %d : missing type name\n", lc); - return -2; - } - pos = last + 1; - std::string size; - size = getNextToken(str, pos, &last, WHITESPACE); - if (size.size() == 0) { - fprintf(stderr, "Error: %d : missing type width\n", lc); - return -2; - } - pos = last + 1; - std::string printString; - printString = getNextToken(str, pos, &last, WHITESPACE); - if (printString.size() == 0) { - fprintf(stderr, "Error: %d : missing print-string\n", lc); - return -2; - } - - // The ispointer definition is optional since we can just - // look at the type name, and determine it is a pointer if - // it ends with '*'. - bool isPointer = (name[name.size() - 1U] == '*'); - - pos = last + 1; - std::string pointerDef; - pointerDef = getNextToken(str, pos, &last, WHITESPACE); - if (pointerDef.size() != 0) { - // Just a little sanity check. - if (std::string("true")==pointerDef) { - if (!isPointer) { - fprintf(stderr, "Error: %d: invalid isPointer definition: 'true' but name does not end with '*'!\n", lc); - return -2; - } - } else if (std::string("false")==pointerDef) { - if (isPointer) { - fprintf(stderr, "Error: %d: invalid isPointer definition: 'false' but name does end with '*'!\n", lc); - return -2; - } - } else { - fprintf(stderr, "Error: %d : invalid isPointer definition, must be either \"true\" or \"false\"\n", lc); - return -2; - } - } - - size_t bitSize = atoi(size.c_str()); - size_t byteSize = (bitSize + 7) >> 3; - - if (getVarTypeByName(name)->id() != 0) { - fprintf(stderr, - "Warining: %d : type %s is already known, definition in line %d is taken\n", - lc, name.c_str(), lc); - } - g_varMap.insert(std::pair<std::string, VarType>( - name, VarType(g_typeId++, - name, - byteSize, - printString, - isPointer))); - std::string constName = "const " + name; - g_varMap.insert(std::pair<std::string, VarType>( - constName, VarType(g_typeId++, - constName, - byteSize, - printString, - isPointer))); //add a const type - } - g_initialized = true; - return 0; -} - - -const VarType * TypeFactory::getVarTypeByName(const std::string & type) -{ - if (!g_initialized) { - initBaseTypes(); - } - TypeMap::iterator i = g_varMap.find(type); - if (i == g_varMap.end()) { - i = g_varMap.find("UNKNOWN"); - } - return &(i->second); -} - diff --git a/emulator/opengl/host/tools/emugen/TypeFactory.h b/emulator/opengl/host/tools/emugen/TypeFactory.h deleted file mode 100644 index deee2ca..0000000 --- a/emulator/opengl/host/tools/emugen/TypeFactory.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -* 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 __TYPE__FACTORY__H__ -#define __TYPE__FACTORY__H__ - -#include <string> -#include "VarType.h" - -class TypeFactory { -public: - static TypeFactory *instance() { - if (m_instance == NULL) { - m_instance = new TypeFactory; - } - return m_instance; - } - const VarType * getVarTypeByName(const std::string &type); - int initFromFile(const std::string &filename); -private: - static TypeFactory *m_instance; - void initBaseTypes(); - TypeFactory() {} -}; -#endif diff --git a/emulator/opengl/host/tools/emugen/Var.h b/emulator/opengl/host/tools/emugen/Var.h deleted file mode 100644 index 322c66a..0000000 --- a/emulator/opengl/host/tools/emugen/Var.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -* 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 __VAR__H__ -#define __VAR__H__ - -#include "VarType.h" -#include <string> -#include <stdio.h> - -class Var { -public: - // pointer data direction - from the client point of view. - typedef enum { POINTER_OUT = 0x1, POINTER_IN = 0x2, POINTER_INOUT = 0x3 } PointerDir; - Var() : - m_name(""), - m_type(NULL), - m_lenExpression(""), - m_pointerDir(POINTER_IN), - m_nullAllowed(false), - m_isLarge(false), - m_packExpression(""), - m_writeExpression(""), - m_paramCheckExpression("") - - { - } - - Var(const std::string & name, - const VarType * vartype, - const std::string & lenExpression, - PointerDir dir, - const std::string &packExpression, - const std::string &writeExpression) : - m_name(name), - m_type(const_cast<VarType *>(vartype)), - m_lenExpression(lenExpression), - m_pointerDir(dir), - m_nullAllowed(false), - m_isLarge(false), - m_packExpression(packExpression), - m_writeExpression(writeExpression), - m_paramCheckExpression("") - { - } - - void init(const std::string name, const VarType * vartype, - std::string lenExpression, - PointerDir dir, - std::string packExpression, - std::string writeExpression) { - m_name = name; - m_type = vartype; - m_lenExpression = lenExpression; - m_packExpression = packExpression; - m_writeExpression = writeExpression; - m_pointerDir = dir; - m_nullAllowed = false; - m_isLarge = false; - - } - - const std::string & name() const { return m_name; } - const VarType * type() const { return m_type; } - bool isPointer() const { return m_type->isPointer(); } - bool isVoid() const { return ((m_type->bytes() == 0) && (!m_type->isPointer())); } - const std::string & lenExpression() const { return m_lenExpression; } - const std::string & packExpression() const { return(m_packExpression); } - const std::string & writeExpression() const { return(m_writeExpression); } - const std::string & paramCheckExpression() const { return m_paramCheckExpression; } - void setLenExpression(const std::string & lenExpression) { m_lenExpression = lenExpression; } - void setPackExpression(const std::string & packExpression) { m_packExpression = packExpression; } - void setWriteExpression(const std::string & writeExpression) { m_writeExpression = writeExpression; } - void setParamCheckExpression(const std::string & paramCheckExpression) { m_paramCheckExpression = paramCheckExpression; } - void setPointerDir(PointerDir dir) { m_pointerDir = dir; } - PointerDir pointerDir() { return m_pointerDir; } - void setNullAllowed(bool state) { m_nullAllowed = state; } - void setIsLarge(bool state) { m_isLarge = state; } - bool nullAllowed() const { return m_nullAllowed; } - bool isLarge() const { return m_isLarge; } - void printType(FILE *fp) { fprintf(fp, "%s", m_type->name().c_str()); } - void printTypeName(FILE *fp) { printType(fp); fprintf(fp, " %s", m_name.c_str()); } - -private: - std::string m_name; - const VarType * m_type; - bool m_pointer; // is this variable a pointer; - std::string m_lenExpression; // an expression to calcualte a pointer data size - PointerDir m_pointerDir; - bool m_nullAllowed; - bool m_isLarge; - std::string m_packExpression; // an expression to pack data into the stream - std::string m_writeExpression; // an expression to write data into the stream - std::string m_paramCheckExpression; //an expression to check parameter value - -}; - -#endif diff --git a/emulator/opengl/host/tools/emugen/VarType.h b/emulator/opengl/host/tools/emugen/VarType.h deleted file mode 100644 index b6937a0..0000000 --- a/emulator/opengl/host/tools/emugen/VarType.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -* 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 __VARTYPE__H__ -#define __VARTYPE__H__ - -#include <string> - -// VarType models the types of values used on the wire protocol by -// both encoders and decoders. Each type is identified by a unique id, -// and a name, and provides a size in bytes for the values, a printf-like -// formatter string, and a flag telling if the value corresponds to a -// pointer. -class VarType { -public: - VarType() : - m_id(0), - m_name("default_constructed"), - m_byteSize(0), - m_printFormat("0x%x"), - m_isPointer(false) {} - - VarType(size_t id, - const std::string& name, - size_t byteSize, - const std::string& printFormat, - bool isPointer) : - m_id(id), - m_name(name), - m_byteSize(byteSize), - m_printFormat(printFormat), - m_isPointer(isPointer) {} - - ~VarType() {} - - size_t id() const { return m_id; } - const std::string& name() const { return m_name; } - size_t bytes() const { return m_byteSize; } - const std::string& printFormat() const { return m_printFormat; } - bool isPointer() const { return m_isPointer; } - -private: - size_t m_id; - std::string m_name; - size_t m_byteSize; - std::string m_printFormat; - bool m_isPointer; -}; - -#endif diff --git a/emulator/opengl/host/tools/emugen/errors.h b/emulator/opengl/host/tools/emugen/errors.h deleted file mode 100644 index d09c292..0000000 --- a/emulator/opengl/host/tools/emugen/errors.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -* 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 _ERRORS_H_ -#define _ERRORS_H_ - -#define BAD_USAGE -1 -#define BAD_SPEC_FILE -2 -#define BAD_TYPES_FILE -3 -#define BAD_ATTRIBUTES_FILE -4 - -#endif diff --git a/emulator/opengl/host/tools/emugen/getopt.c b/emulator/opengl/host/tools/emugen/getopt.c deleted file mode 100644 index 3523538..0000000 --- a/emulator/opengl/host/tools/emugen/getopt.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "getopt.h" - -#include <stdio.h> -#include <string.h> - -#define _getprogname() nargv[0] - -int opterr = 1; -int optind = 1; -int optopt = 0; -char* optarg; - -int getopt(int argc, char* const argv[], const char* ostr) { - static const char kEmpty[] = ""; - static const char* place = kEmpty; - if (!*place) { - if (optind >= argc) - return -1; - - const char* arg = argv[optind]; - if (arg[0] != '-') { - // Not an option. - return -1; - } - if (arg[1] == '-' && !arg[2]) { - // '--' -> end of options. - return -1; - } - if (!arg[1]) { - // Single '-', If the program wants it, treat it as an option. - // Otherwise, it's the end of options. - if (!strchr(ostr, '-')) { - return -1; - } - optopt = '-'; - place = arg + 1; - } else { - optopt = arg[1]; - place = arg + 2; - } - }; - - char* oindex = strchr(ostr, optopt); - if (!oindex) { - // Unsupported option. - (void)fprintf(stderr, "%s: illegal option -- %c\n", argv[0]); - return '?'; - } - if (oindex[1] != ':') { - // No argument needed. - optarg = NULL; - if (!*place) - optind++; - return optopt; - } - - // This option needs an argument. Either after the option character, - // or the argument that follows. - if (*place) { - optarg = (char *)place; - } else if (argc > ++optind) { - optarg = (char *)argv[optind]; - } else if (oindex[2] == ':') { - // Optional argument is missing. - place = kEmpty; - optarg = NULL; - return optopt; - } else { - // Missing argument. - place = kEmpty; - (void)fprintf(stderr, "%s: option requires an argument --%c\n", - argv[0], optopt); - return ':'; - } - return optopt; -} diff --git a/emulator/opengl/host/tools/emugen/getopt.h b/emulator/opengl/host/tools/emugen/getopt.h deleted file mode 100644 index cc04850..0000000 --- a/emulator/opengl/host/tools/emugen/getopt.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef GETOPT_H -#define GETOPT_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern int optind; -extern char* optarg; -extern int optopt; - -int getopt(int argc, char* const argv[], const char* ostr); - -#ifdef __cplusplus -} -#endif - -#endif // GETOPT_H diff --git a/emulator/opengl/host/tools/emugen/main.cpp b/emulator/opengl/host/tools/emugen/main.cpp deleted file mode 100644 index c0c24e9..0000000 --- a/emulator/opengl/host/tools/emugen/main.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* -* 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. -*/ -#include <stdio.h> -#include <stdlib.h> -#include "errors.h" -#include "EntryPoint.h" -#include "strUtils.h" -#include "ApiGen.h" -#include "TypeFactory.h" -#include "getopt.h" - -const std::string SPEC_EXTENSION = std::string(".in"); -const std::string ATTRIB_EXTENSION = std::string(".attrib"); -const std::string TYPES_EXTENTION = std::string(".types"); - - -void usage(const char *filename) -{ - fprintf(stderr, "Usage: %s [options] <base name>\n", filename); - fprintf(stderr, "\t-h: This message\n"); - fprintf(stderr, "\t-E <dir>: generate encoder into dir\n"); - fprintf(stderr, "\t-D <dir>: generate decoder into dir\n"); - fprintf(stderr, "\t-i: input dir, local directory by default\n"); - fprintf(stderr, "\t-T : generate attribute template into the input directory\n\t\tno other files are generated\n"); - fprintf(stderr, "\t-W : generate wrapper into dir\n"); -} - -int main(int argc, char *argv[]) -{ - std::string encoderDir = ""; - std::string decoderDir = ""; - std::string wrapperDir = ""; - std::string inDir = "."; - bool generateAttributesTemplate = false; - - int c; - while((c = getopt(argc, argv, "TE:D:i:hW:")) != -1) { - switch(c) { - case 'W': - wrapperDir = std::string(optarg); - break; - case 'T': - generateAttributesTemplate = true; - break; - case 'h': - usage(argv[0]); - exit(0); - break; - case 'E': - encoderDir = std::string(optarg); - break; - case 'D': - decoderDir = std::string(optarg); - break; - case 'i': - inDir = std::string(optarg); - break; - case ':': - fprintf(stderr, "Missing argument !!\n"); - // fall through - default: - usage(argv[0]); - exit(0); - } - } - - if (optind >= argc) { - fprintf(stderr, "Usage: %s [options] <base name> \n", argv[0]); - return BAD_USAGE; - } - - if (encoderDir.size() == 0 && - decoderDir.size() == 0 && - generateAttributesTemplate == false && - wrapperDir.size() == 0) { - fprintf(stderr, "No output specified - aborting\n"); - return BAD_USAGE; - } - - std::string baseName = std::string(argv[optind]); - ApiGen apiEntries(baseName); - - // init types; - std::string typesFilename = inDir + "/" + baseName + TYPES_EXTENTION; - - if (TypeFactory::instance()->initFromFile(typesFilename) < 0) { - fprintf(stderr, "missing or error reading types file: %s...ignored\n", typesFilename.c_str()); - } - - std::string filename = inDir + "/" + baseName + SPEC_EXTENSION; - if (apiEntries.readSpec(filename) < 0) { - perror(filename.c_str()); - return BAD_SPEC_FILE; - } - - - if (generateAttributesTemplate) { - apiEntries.genAttributesTemplate(inDir + "/" + baseName + ATTRIB_EXTENSION); - exit(0); - } - - std::string attribFileName = inDir + "/" + baseName + ATTRIB_EXTENSION; - if (apiEntries.readAttributes(attribFileName) < 0) { - perror(attribFileName.c_str()); - fprintf(stderr, "failed to parse attributes\n"); - exit(1); - } - - if (encoderDir.size() != 0) { - - apiEntries.genOpcodes(encoderDir + "/" + baseName + "_opcodes.h"); - apiEntries.genContext(encoderDir + "/" + baseName + "_client_context.h", ApiGen::CLIENT_SIDE); - apiEntries.genContextImpl(encoderDir + "/" + baseName + "_client_context.cpp", ApiGen::CLIENT_SIDE); - - apiEntries.genProcTypes(encoderDir + "/" + baseName + "_client_proc.h", ApiGen::CLIENT_SIDE); - apiEntries.genFuncTable(encoderDir + "/" + baseName + "_ftable.h", ApiGen::CLIENT_SIDE); - - apiEntries.genEntryPoints(encoderDir + "/" + baseName + "_entry.cpp", ApiGen::CLIENT_SIDE); - apiEntries.genEncoderHeader(encoderDir + "/" + baseName + "_enc.h"); - apiEntries.genEncoderImpl(encoderDir + "/" + baseName + "_enc.cpp"); - } - - if (decoderDir.size() != 0) { - apiEntries.genOpcodes(decoderDir + "/" + baseName + "_opcodes.h"); - apiEntries.genProcTypes(decoderDir + "/" + baseName + "_server_proc.h", ApiGen::SERVER_SIDE); - apiEntries.genContext(decoderDir + "/" + baseName + "_server_context.h", ApiGen::SERVER_SIDE); - apiEntries.genContextImpl(decoderDir + "/" + baseName + "_server_context.cpp", ApiGen::SERVER_SIDE); - apiEntries.genDecoderHeader(decoderDir + "/" + baseName + "_dec.h"); - apiEntries.genDecoderImpl(decoderDir + "/" + baseName + "_dec.cpp"); - } - - if (wrapperDir.size() != 0) { - apiEntries.genProcTypes(wrapperDir + "/" + baseName + "_wrapper_proc.h", ApiGen::WRAPPER_SIDE); - apiEntries.genContext(wrapperDir + "/" + baseName + "_wrapper_context.h", ApiGen::WRAPPER_SIDE); - apiEntries.genContextImpl(wrapperDir + "/" + baseName + "_wrapper_context.cpp", ApiGen::WRAPPER_SIDE); - apiEntries.genEntryPoints(wrapperDir + "/" + baseName + "_wrapper_entry.cpp", ApiGen::WRAPPER_SIDE); - } - -#ifdef DEBUG_DUMP - int withPointers = 0; - printf("%d functions found\n", int(apiEntries.size())); - for (int i = 0; i < apiEntries.size(); i++) { - if (apiEntries[i].hasPointers()) { - withPointers++; - apiEntries[i].print(); - } - } - fprintf(stdout, "%d entries has poitners\n", withPointers); -#endif - -} - diff --git a/emulator/opengl/host/tools/emugen/strUtils.cpp b/emulator/opengl/host/tools/emugen/strUtils.cpp deleted file mode 100644 index 357054b..0000000 --- a/emulator/opengl/host/tools/emugen/strUtils.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* -* 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. -*/ -#include "strUtils.h" - -using namespace std; - - -std::string getNextToken(const std::string & str, size_t pos, size_t * last, const std::string & delim) -{ - if (str.size() == 0 || pos >= str.size()) return ""; - - pos = str.find_first_not_of(WHITESPACE, pos); - if (pos == std::string::npos) return ""; - - *last = str.find_first_of(delim, pos); - if (*last == std::string::npos) *last = str.size(); - std::string retval = str.substr(pos, *last - pos); - retval = trim(retval); - return retval; -} - - -std::string trim(const string & str) -{ - string result; - string::size_type start = str.find_first_not_of(WHITESPACE, 0); - string::size_type end = str.find_last_not_of(WHITESPACE); - if (start == string::npos || end == string::npos) { - result = string(""); - } else { - result = str.substr(start, end - start + 1); - } - return result; -} - - diff --git a/emulator/opengl/host/tools/emugen/strUtils.h b/emulator/opengl/host/tools/emugen/strUtils.h deleted file mode 100644 index 3fa0908..0000000 --- a/emulator/opengl/host/tools/emugen/strUtils.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -* 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 STR_UTILS_H_ -#define STR_UTILS_H_ - -#include <string> -#include <sstream> - -#define WHITESPACE " \t\n" - -std::string trim(const std::string & str); -std::string getNextToken(const std::string & str, size_t pos, size_t * last, const std::string & delim); -template <class T> std::string inline toString(const T& t) { - std::stringstream ss; - ss << t; - return ss.str(); - -} - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/run-tests.sh b/emulator/opengl/host/tools/emugen/tests/run-tests.sh deleted file mode 100755 index 67409ed..0000000 --- a/emulator/opengl/host/tools/emugen/tests/run-tests.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/sh - -# Copyright 2014 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. -# - -set -e - -export LANG=C -export LC_ALL=C - -PROGDIR=$(dirname "$0") -PROGNAME=$(basename "$0") - -fatal () { - echo "ERROR: $@" - exit 1 -} - -OPT_EMUGEN= -OPT_HELP= -OPT_OUT_DIR= -OPT_TOOL= - -for OPT; do - OPTARG=$(expr "x$OPT" : "x[^=]*=\\(.*\\)" || true) - case $OPT in - --help|-h|-?) - OPT_HELP=true - ;; - --emugen=*) - OPT_EMUGEN=$OPTARG - ;; - --out-dir=*) - OPT_OUT_DIR=$OPTARG - ;; - --tool=*) - OPT_TOOL=$OPTARG - ;; - -*) - fatal "Invalid option '$OPT', see --help." - ;; - *) - fatal "This script doesn't take arguments, see --help." - ;; - esac -done - -if [ "$OPT_HELP" ]; then - cat <<EOF -Usage: $PROGNAME [options] - -Run the emugen test suite. This scripts looks for sub-directories -named t.<number>/input, and uses them as input to 'emugen'. It then -compares the output to t.<number>/expected/ content. - -Valid options: - --help|-h|-? Print this help. - --out-dir=<dir> Generate outputs into <dir>. - --emugen=<program> Emugen program path, if not in path. - --tool=<tool> Launch visual diff tool in case of differences. -EOF - exit 0 -fi - -# Find emugen program -EMUGEN= -if [ "$OPT_EMUGEN" ]; then - EMUGEN=$OPT_EMUGEN -else - EMUGEN=$(which emugen 2>/dev/null || true) - if [ -z "$EMUGEN" ]; then - fatal "Cannot find 'emugen' program in PATH, use --emugen=<program> option." - fi - echo "Auto-config: --emugen=$EMUGEN" -fi -if [ ! -f "$EMUGEN" ]; then - fatal "Emugen program doesn't exist: $EMUGEN" -fi - -# Create output directory. -OUT_DIR= -if [ "$OPT_OUT_DIR" ]; then - OUT_DIR=$OPT_OUT_DIR -else - OUT_DIR=/tmp/$USER-emugen-testing - echo "Auto-config: --out-dir=$OUT_DIR" -fi -mkdir -p "$OUT_DIR" && rm -rf "$OUT_DIR/emugen" - -OUT_DIR=$OUT_DIR/emugen - -# Find test directories -TEST_DIRS=$(cd "$PROGDIR" && find . -name "t.*" | sed -e 's|^\./||') -for TEST_DIR in $TEST_DIRS; do - IN=$PROGDIR/$TEST_DIR/input - PREFIXES=$(cd $IN && find . -name "*.in" | sed -e 's|^\./||g' -e 's|\.in$||g') - OUT=$OUT_DIR/$TEST_DIR - mkdir -p "$OUT/encoder" - mkdir -p "$OUT/decoder" - mkdir -p "$OUT/wrapper" - for PREFIX in $PREFIXES; do - echo "Processing $IN/foo.*" - $EMUGEN -i "$PROGDIR/$TEST_DIR/input" -D "$OUT/decoder" -E "$OUT/encoder" -W "$OUT/wrapper" $PREFIX - done - if ! diff -qr "$PROGDIR/$TEST_DIR/expected" "$OUT"; then - if [ "$OPT_TOOL" ]; then - $OPT_TOOL "$PROGDIR/$TEST_DIR/expected" "$OUT" - else - echo "ERROR: Invalid differences between actual and expected output!" - diff -burN "$PROGDIR/$TEST_DIR/expected" "$OUT" - exit 1 - fi - fi -done - -echo "All good!" -exit 0 diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp deleted file mode 100644 index 0319284..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' - - -#include <string.h> -#include "foo_opcodes.h" - -#include "foo_dec.h" - - -#include "ProtocolUtils.h" - -#include <stdio.h> - -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. - -#ifdef DEBUG_PRINTOUT -# define DEBUG(...) fprintf(stderr, __VA_ARGS__) -#else -# define DEBUG(...) ((void)0) -#endif - -#ifdef CHECK_GLERROR -# define SET_LASTCALL(name) sprintf(lastCall, #name) -#else -# define SET_LASTCALL(name) ((void)0) -#endif - -using namespace emugl; - -size_t foo_decoder_context_t::decode(void *buf, size_t len, IOStream *stream) -{ - - size_t pos = 0; - if (len < 8) return pos; - unsigned char *ptr = (unsigned char *)buf; - bool unknownOpcode = false; -#ifdef CHECK_GL_ERROR - char lastCall[256] = {0}; -#endif - while ((len - pos >= 8) && !unknownOpcode) { - uint32_t opcode = *(uint32_t *)ptr; - size_t packetLen = *(uint32_t *)(ptr + 4); - if (len - pos < packetLen) return pos; - switch(opcode) { - case OP_fooAlphaFunc: { - FooInt var_func = Unpack<FooInt,uint32_t>(ptr + 8); - FooFloat var_ref = Unpack<FooFloat,uint32_t>(ptr + 8 + 4); - DEBUG("foo(%p): fooAlphaFunc(%d %f )\n", stream,var_func, var_ref); - this->fooAlphaFunc(var_func, var_ref); - SET_LASTCALL("fooAlphaFunc"); - break; - } - case OP_fooIsBuffer: { - uint32_t size_stuff __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8); - InputBuffer inptr_stuff(ptr + 8 + 4, size_stuff); - size_t totalTmpSize = sizeof(FooBoolean); - unsigned char *tmpBuf = stream->alloc(totalTmpSize); - DEBUG("foo(%p): fooIsBuffer(%p(%u) )\n", stream,(void*)(inptr_stuff.get()), size_stuff); - *(FooBoolean *)(&tmpBuf[0]) = this->fooIsBuffer((void*)(inptr_stuff.get())); - stream->flush(); - SET_LASTCALL("fooIsBuffer"); - break; - } - case OP_fooUnsupported: { - uint32_t size_params __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8); - InputBuffer inptr_params(ptr + 8 + 4, size_params); - DEBUG("foo(%p): fooUnsupported(%p(%u) )\n", stream,(void*)(inptr_params.get()), size_params); - this->fooUnsupported((void*)(inptr_params.get())); - SET_LASTCALL("fooUnsupported"); - break; - } - case OP_fooDoEncoderFlush: { - FooInt var_param = Unpack<FooInt,uint32_t>(ptr + 8); - DEBUG("foo(%p): fooDoEncoderFlush(%d )\n", stream,var_param); - this->fooDoEncoderFlush(var_param); - SET_LASTCALL("fooDoEncoderFlush"); - break; - } - case OP_fooTakeConstVoidPtrConstPtr: { - uint32_t size_param __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8); - InputBuffer inptr_param(ptr + 8 + 4, size_param); - DEBUG("foo(%p): fooTakeConstVoidPtrConstPtr(%p(%u) )\n", stream,(const void* const*)(inptr_param.get()), size_param); - this->fooTakeConstVoidPtrConstPtr((const void* const*)(inptr_param.get())); - SET_LASTCALL("fooTakeConstVoidPtrConstPtr"); - break; - } - default: - unknownOpcode = true; - } //switch - if (!unknownOpcode) { - pos += packetLen; - ptr += packetLen; - } - } // while - return pos; -} diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h deleted file mode 100644 index 3646de5..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h +++ /dev/null @@ -1,18 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' - -#ifndef GUARD_foo_decoder_context_t -#define GUARD_foo_decoder_context_t - -#include "IOStream.h" -#include "foo_server_context.h" - - - -struct foo_decoder_context_t : public foo_server_context_t { - - size_t decode(void *buf, size_t bufsize, IOStream *stream); - -}; - -#endif // GUARD_foo_decoder_context_t diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h deleted file mode 100644 index 7219caa..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h +++ /dev/null @@ -1,14 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#ifndef __GUARD_foo_opcodes_h_ -#define __GUARD_foo_opcodes_h_ - -#define OP_fooAlphaFunc 200 -#define OP_fooIsBuffer 201 -#define OP_fooUnsupported 202 -#define OP_fooDoEncoderFlush 203 -#define OP_fooTakeConstVoidPtrConstPtr 204 -#define OP_last 205 - - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp deleted file mode 100644 index 22ff47f..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' - - -#include <string.h> -#include "foo_server_context.h" - - -#include <stdio.h> - -int foo_server_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) -{ - fooAlphaFunc = (fooAlphaFunc_server_proc_t) getProc("fooAlphaFunc", userData); - fooIsBuffer = (fooIsBuffer_server_proc_t) getProc("fooIsBuffer", userData); - fooUnsupported = (fooUnsupported_server_proc_t) getProc("fooUnsupported", userData); - fooDoEncoderFlush = (fooDoEncoderFlush_server_proc_t) getProc("fooDoEncoderFlush", userData); - fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_server_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); - return 0; -} - diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h deleted file mode 100644 index 186a3d1..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h +++ /dev/null @@ -1,20 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#ifndef __foo_server_context_t_h -#define __foo_server_context_t_h - -#include "foo_server_proc.h" - - -struct foo_server_context_t { - - fooAlphaFunc_server_proc_t fooAlphaFunc; - fooIsBuffer_server_proc_t fooIsBuffer; - fooUnsupported_server_proc_t fooUnsupported; - fooDoEncoderFlush_server_proc_t fooDoEncoderFlush; - fooTakeConstVoidPtrConstPtr_server_proc_t fooTakeConstVoidPtrConstPtr; - virtual ~foo_server_context_t() {} - int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); -}; - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h deleted file mode 100644 index da104a1..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h +++ /dev/null @@ -1,19 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#ifndef __foo_server_proc_t_h -#define __foo_server_proc_t_h - - - -#include "foo_types.h" -#ifndef foo_APIENTRY -#define foo_APIENTRY -#endif -typedef void (foo_APIENTRY *fooAlphaFunc_server_proc_t) (FooInt, FooFloat); -typedef FooBoolean (foo_APIENTRY *fooIsBuffer_server_proc_t) (void*); -typedef void (foo_APIENTRY *fooUnsupported_server_proc_t) (void*); -typedef void (foo_APIENTRY *fooDoEncoderFlush_server_proc_t) (FooInt); -typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_server_proc_t) (const void* const*); - - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp deleted file mode 100644 index f09e881..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' - - -#include <string.h> -#include "foo_client_context.h" - - -#include <stdio.h> - -int foo_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) -{ - fooAlphaFunc = (fooAlphaFunc_client_proc_t) getProc("fooAlphaFunc", userData); - fooIsBuffer = (fooIsBuffer_client_proc_t) getProc("fooIsBuffer", userData); - fooUnsupported = (fooUnsupported_client_proc_t) getProc("fooUnsupported", userData); - fooDoEncoderFlush = (fooDoEncoderFlush_client_proc_t) getProc("fooDoEncoderFlush", userData); - fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_client_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); - return 0; -} - diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h deleted file mode 100644 index 84e9d6f..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h +++ /dev/null @@ -1,25 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#ifndef __foo_client_context_t_h -#define __foo_client_context_t_h - -#include "foo_client_proc.h" - - -struct foo_client_context_t { - - fooAlphaFunc_client_proc_t fooAlphaFunc; - fooIsBuffer_client_proc_t fooIsBuffer; - fooUnsupported_client_proc_t fooUnsupported; - fooDoEncoderFlush_client_proc_t fooDoEncoderFlush; - fooTakeConstVoidPtrConstPtr_client_proc_t fooTakeConstVoidPtrConstPtr; - virtual ~foo_client_context_t() {} - - typedef foo_client_context_t *CONTEXT_ACCESSOR_TYPE(void); - static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f); - int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); - virtual void setError(unsigned int error){ (void)error; }; - virtual unsigned int getError(){ return 0; }; -}; - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h deleted file mode 100644 index 6fc27f0..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h +++ /dev/null @@ -1,19 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#ifndef __foo_client_proc_t_h -#define __foo_client_proc_t_h - - - -#include "foo_types.h" -#ifndef foo_APIENTRY -#define foo_APIENTRY -#endif -typedef void (foo_APIENTRY *fooAlphaFunc_client_proc_t) (void * ctx, FooInt, FooFloat); -typedef FooBoolean (foo_APIENTRY *fooIsBuffer_client_proc_t) (void * ctx, void*); -typedef void (foo_APIENTRY *fooUnsupported_client_proc_t) (void * ctx, void*); -typedef void (foo_APIENTRY *fooDoEncoderFlush_client_proc_t) (void * ctx, FooInt); -typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_client_proc_t) (void * ctx, const void* const*); - - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp deleted file mode 100644 index 3a7a94b..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' - - -#include <string.h> -#include "foo_opcodes.h" - -#include "foo_enc.h" - - -#include <stdio.h> - -namespace { - -void enc_unsupported() -{ - ALOGE("Function is unsupported\n"); -} - -void fooAlphaFunc_enc(void *self , FooInt func, FooFloat ref) -{ - - foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; - IOStream *stream = ctx->m_stream; - - unsigned char *ptr; - const size_t packetSize = 8 + 4 + 4; - ptr = stream->alloc(packetSize); - int tmp = OP_fooAlphaFunc;memcpy(ptr, &tmp, 4); ptr += 4; - memcpy(ptr, &packetSize, 4); ptr += 4; - - memcpy(ptr, &func, 4); ptr += 4; - memcpy(ptr, &ref, 4); ptr += 4; -} - -FooBoolean fooIsBuffer_enc(void *self , void* stuff) -{ - - foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; - IOStream *stream = ctx->m_stream; - - const unsigned int __size_stuff = (4 * sizeof(float)); - unsigned char *ptr; - const size_t packetSize = 8 + __size_stuff + 1*4; - ptr = stream->alloc(packetSize); - int tmp = OP_fooIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4; - memcpy(ptr, &packetSize, 4); ptr += 4; - - *(unsigned int *)(ptr) = __size_stuff; ptr += 4; - memcpy(ptr, stuff, __size_stuff);ptr += __size_stuff; - - FooBoolean retval; - stream->readback(&retval, 1); - return retval; -} - -void fooDoEncoderFlush_enc(void *self , FooInt param) -{ - - foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; - IOStream *stream = ctx->m_stream; - - unsigned char *ptr; - const size_t packetSize = 8 + 4; - ptr = stream->alloc(packetSize); - int tmp = OP_fooDoEncoderFlush;memcpy(ptr, &tmp, 4); ptr += 4; - memcpy(ptr, &packetSize, 4); ptr += 4; - - memcpy(ptr, ¶m, 4); ptr += 4; - stream->flush(); -} - -void fooTakeConstVoidPtrConstPtr_enc(void *self , const void* const* param) -{ - - foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; - IOStream *stream = ctx->m_stream; - - const unsigned int __size_param = ; - unsigned char *ptr; - const size_t packetSize = 8 + __size_param + 1*4; - ptr = stream->alloc(packetSize); - int tmp = OP_fooTakeConstVoidPtrConstPtr;memcpy(ptr, &tmp, 4); ptr += 4; - memcpy(ptr, &packetSize, 4); ptr += 4; - - *(unsigned int *)(ptr) = __size_param; ptr += 4; - memcpy(ptr, param, __size_param);ptr += __size_param; -} - -} // namespace - -foo_encoder_context_t::foo_encoder_context_t(IOStream *stream) -{ - m_stream = stream; - - this->fooAlphaFunc = &fooAlphaFunc_enc; - this->fooIsBuffer = &fooIsBuffer_enc; - this->fooUnsupported = (fooUnsupported_client_proc_t) &enc_unsupported; - this->fooDoEncoderFlush = &fooDoEncoderFlush_enc; - this->fooTakeConstVoidPtrConstPtr = &fooTakeConstVoidPtrConstPtr_enc; -} - diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h deleted file mode 100644 index 195b37a..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h +++ /dev/null @@ -1,21 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' - -#ifndef GUARD_foo_encoder_context_t -#define GUARD_foo_encoder_context_t - -#include "IOStream.h" -#include "foo_client_context.h" - - -#include "fooUtils.h" -#include "fooBase.h" - -struct foo_encoder_context_t : public foo_client_context_t { - - IOStream *m_stream; - - foo_encoder_context_t(IOStream *stream); -}; - -#endif // GUARD_foo_encoder_context_t
\ No newline at end of file diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp deleted file mode 100644 index b91129c..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#include <stdio.h> -#include <stdlib.h> -#include "foo_client_context.h" - -#ifndef GL_TRUE -extern "C" { - void fooAlphaFunc(FooInt func, FooFloat ref); - FooBoolean fooIsBuffer(void* stuff); - void fooUnsupported(void* params); - void fooDoEncoderFlush(FooInt param); - void fooTakeConstVoidPtrConstPtr(const void* const* param); -}; - -#endif -#ifndef GET_CONTEXT -static foo_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL; -void foo_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; } -#define GET_CONTEXT foo_client_context_t * ctx = getCurrentContext() -#endif - -void fooAlphaFunc(FooInt func, FooFloat ref) -{ - GET_CONTEXT; - ctx->fooAlphaFunc(ctx, func, ref); -} - -FooBoolean fooIsBuffer(void* stuff) -{ - GET_CONTEXT; - if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; } - return ctx->fooIsBuffer(ctx, stuff); -} - -void fooUnsupported(void* params) -{ - GET_CONTEXT; - ctx->fooUnsupported(ctx, params); -} - -void fooDoEncoderFlush(FooInt param) -{ - GET_CONTEXT; - ctx->fooDoEncoderFlush(ctx, param); -} - -void fooTakeConstVoidPtrConstPtr(const void* const* param) -{ - GET_CONTEXT; - ctx->fooTakeConstVoidPtrConstPtr(ctx, param); -} - diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h deleted file mode 100644 index e397e50..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h +++ /dev/null @@ -1,20 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#ifndef __foo_client_ftable_t_h -#define __foo_client_ftable_t_h - - -static const struct _foo_funcs_by_name { - const char *name; - void *proc; -} foo_funcs_by_name[] = { - {"fooAlphaFunc", (void*)fooAlphaFunc}, - {"fooIsBuffer", (void*)fooIsBuffer}, - {"fooUnsupported", (void*)fooUnsupported}, - {"fooDoEncoderFlush", (void*)fooDoEncoderFlush}, - {"fooTakeConstVoidPtrConstPtr", (void*)fooTakeConstVoidPtrConstPtr}, -}; -static const int foo_num_funcs = sizeof(foo_funcs_by_name) / sizeof(struct _foo_funcs_by_name); - - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h deleted file mode 100644 index 7219caa..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h +++ /dev/null @@ -1,14 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#ifndef __GUARD_foo_opcodes_h_ -#define __GUARD_foo_opcodes_h_ - -#define OP_fooAlphaFunc 200 -#define OP_fooIsBuffer 201 -#define OP_fooUnsupported 202 -#define OP_fooDoEncoderFlush 203 -#define OP_fooTakeConstVoidPtrConstPtr 204 -#define OP_last 205 - - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp deleted file mode 100644 index 6e132b1..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' - - -#include <string.h> -#include "foo_wrapper_context.h" - - -#include <stdio.h> - -int foo_wrapper_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) -{ - fooAlphaFunc = (fooAlphaFunc_wrapper_proc_t) getProc("fooAlphaFunc", userData); - fooIsBuffer = (fooIsBuffer_wrapper_proc_t) getProc("fooIsBuffer", userData); - fooUnsupported = (fooUnsupported_wrapper_proc_t) getProc("fooUnsupported", userData); - fooDoEncoderFlush = (fooDoEncoderFlush_wrapper_proc_t) getProc("fooDoEncoderFlush", userData); - fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_wrapper_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); - return 0; -} - diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h deleted file mode 100644 index e5e30e6..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h +++ /dev/null @@ -1,23 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#ifndef __foo_wrapper_context_t_h -#define __foo_wrapper_context_t_h - -#include "foo_wrapper_proc.h" - - -struct foo_wrapper_context_t { - - fooAlphaFunc_wrapper_proc_t fooAlphaFunc; - fooIsBuffer_wrapper_proc_t fooIsBuffer; - fooUnsupported_wrapper_proc_t fooUnsupported; - fooDoEncoderFlush_wrapper_proc_t fooDoEncoderFlush; - fooTakeConstVoidPtrConstPtr_wrapper_proc_t fooTakeConstVoidPtrConstPtr; - virtual ~foo_wrapper_context_t() {} - - typedef foo_wrapper_context_t *CONTEXT_ACCESSOR_TYPE(void); - static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f); - int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); -}; - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp deleted file mode 100644 index 7591393..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#include <stdio.h> -#include <stdlib.h> -#include "foo_wrapper_context.h" - -#ifndef GL_TRUE -extern "C" { - void fooAlphaFunc(FooInt func, FooFloat ref); - FooBoolean fooIsBuffer(void* stuff); - void fooUnsupported(void* params); - void fooDoEncoderFlush(FooInt param); - void fooTakeConstVoidPtrConstPtr(const void* const* param); -}; - -#endif -#ifndef GET_CONTEXT -static foo_wrapper_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL; -void foo_wrapper_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; } -#define GET_CONTEXT foo_wrapper_context_t * ctx = getCurrentContext() -#endif - -void fooAlphaFunc(FooInt func, FooFloat ref) -{ - GET_CONTEXT; - ctx->fooAlphaFunc( func, ref); -} - -FooBoolean fooIsBuffer(void* stuff) -{ - GET_CONTEXT; - return ctx->fooIsBuffer( stuff); -} - -void fooUnsupported(void* params) -{ - GET_CONTEXT; - ctx->fooUnsupported( params); -} - -void fooDoEncoderFlush(FooInt param) -{ - GET_CONTEXT; - ctx->fooDoEncoderFlush( param); -} - -void fooTakeConstVoidPtrConstPtr(const void* const* param) -{ - GET_CONTEXT; - ctx->fooTakeConstVoidPtrConstPtr( param); -} - diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h deleted file mode 100644 index 294b958..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h +++ /dev/null @@ -1,19 +0,0 @@ -// Generated Code - DO NOT EDIT !! -// generated by 'emugen' -#ifndef __foo_wrapper_proc_t_h -#define __foo_wrapper_proc_t_h - - - -#include "foo_types.h" -#ifndef foo_APIENTRY -#define foo_APIENTRY -#endif -typedef void (foo_APIENTRY *fooAlphaFunc_wrapper_proc_t) (FooInt, FooFloat); -typedef FooBoolean (foo_APIENTRY *fooIsBuffer_wrapper_proc_t) (void*); -typedef void (foo_APIENTRY *fooUnsupported_wrapper_proc_t) (void*); -typedef void (foo_APIENTRY *fooDoEncoderFlush_wrapper_proc_t) (FooInt); -typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_wrapper_proc_t) (const void* const*); - - -#endif diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib deleted file mode 100644 index 80644d8..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib +++ /dev/null @@ -1,15 +0,0 @@ -GLOBAL - base_opcode 200 - encoder_headers "fooUtils.h" "fooBase.h" - -fooIsBuffer - dir stuff in - len stuff (4 * sizeof(float)) - param_check stuff if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; } - -fooUnsupported - dir params in - flag unsupported - -fooDoEncoderFlush - flag flushOnEncode diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in deleted file mode 100644 index 4e98f88..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in +++ /dev/null @@ -1,5 +0,0 @@ -FOO_ENTRY(void, fooAlphaFunc, FooInt func, FooFloat ref) -FOO_ENTRY(FooBoolean, fooIsBuffer, void* stuff) -FOO_ENTRY(void, fooUnsupported, void* params) -FOO_ENTRY(void, fooDoEncoderFlush, FooInt param) -FOO_ENTRY(void, fooTakeConstVoidPtrConstPtr, const void* const* param) diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types deleted file mode 100644 index 05d72fb..0000000 --- a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types +++ /dev/null @@ -1,10 +0,0 @@ -FooBoolean 8 %d -FooInt 32 %d -FooShort 16 %d -FooFloat 32 %f -FooEnum 32 %08x -FooVoid 0 %x -FooChar 8 %d -FooChar* 32 0x%08x -void* 32 0x%08x -void*const* 32 0x%08x diff --git a/emulator/opengl/shared/OpenglCodecCommon/Android.mk b/emulator/opengl/shared/OpenglCodecCommon/Android.mk deleted file mode 100644 index ff680eb..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/Android.mk +++ /dev/null @@ -1,44 +0,0 @@ -# This build script corresponds to a library containing many definitions -# common to both the guest and the host. They relate to -# -LOCAL_PATH := $(call my-dir) - -commonSources := \ - GLClientState.cpp \ - GLSharedGroup.cpp \ - glUtils.cpp \ - SocketStream.cpp \ - TcpStream.cpp \ - TimeUtils.cpp - -host_commonSources := $(commonSources) - -host_commonLdLibs := -lstdc++ - -ifeq ($(HOST_OS),windows) - host_commonSources += Win32PipeStream.cpp - host_commonLdLibs += -lws2_32 -lpsapi -else - host_commonSources += UnixStream.cpp -endif - - -### OpenglCodecCommon host ############################################## -$(call emugl-begin-host-static-library,libOpenglCodecCommon) - -LOCAL_SRC_FILES := $(host_commonSources) -$(call emugl-import, libemugl_common) -$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include/libOpenglRender $(LOCAL_PATH)) -$(call emugl-export,LDLIBS,$(host_commonLdLibs)) -$(call emugl-end-module) - - -### OpenglCodecCommon host, 64-bit ######################################### -$(call emugl-begin-host64-static-library,lib64OpenglCodecCommon) - -LOCAL_SRC_FILES := $(host_commonSources) -$(call emugl-import, lib64emugl_common) -$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include/libOpenglRender $(LOCAL_PATH)) -$(call emugl-export,LDLIBS,$(host_commonLdLibs)) -$(call emugl-end-module) - diff --git a/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h b/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h deleted file mode 100644 index 4cad61f..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -* 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 _ERROR_LOG_H_ -#define _ERROR_LOG_H_ - -#include <stdio.h> -#define ERR(...) fprintf(stderr, __VA_ARGS__) -#ifdef EMUGL_DEBUG -# define DBG(...) fprintf(stderr, __VA_ARGS__) -#else -# define DBG(...) ((void)0) -#endif - -#endif // _ERROR_LOG_H_ diff --git a/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h b/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h deleted file mode 100644 index 30b9a80..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* 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 _FIXED_BUFFER_H -#define _FIXED_BUFFER_H - -class FixedBuffer { -public: - FixedBuffer(size_t initialSize = 0) { - m_buffer = NULL; - m_bufferLen = 0; - alloc(m_bufferLen); - } - - ~FixedBuffer() { - delete [] m_buffer; - m_bufferLen = 0; - } - - void * alloc(size_t size) { - if (m_bufferLen >= size) - return (void *)(m_buffer); - - if (m_buffer != NULL) - delete[] m_buffer; - - m_bufferLen = size; - m_buffer = new unsigned char[m_bufferLen]; - if (m_buffer == NULL) - m_bufferLen = 0; - - return m_buffer; - } - void *ptr() { return m_buffer; } - size_t len() { return m_bufferLen; } -private: - unsigned char *m_buffer; - size_t m_bufferLen; -}; - -#endif diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp b/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp deleted file mode 100644 index b02131c..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp +++ /dev/null @@ -1,416 +0,0 @@ -/* -* 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. -*/ -#include "GLClientState.h" -#include "ErrorLog.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "glUtils.h" - -#ifndef MAX -#define MAX(a, b) ((a) < (b) ? (b) : (a)) -#endif - -GLClientState::GLClientState(int nLocations) -{ - if (nLocations < LAST_LOCATION) { - nLocations = LAST_LOCATION; - } - m_nLocations = nLocations; - m_states = new VertexAttribState[m_nLocations]; - for (int i = 0; i < m_nLocations; i++) { - m_states[i].enabled = 0; - m_states[i].enableDirty = false; - } - m_currentArrayVbo = 0; - m_currentIndexVbo = 0; - // init gl constans; - m_states[VERTEX_LOCATION].glConst = GL_VERTEX_ARRAY; - m_states[NORMAL_LOCATION].glConst = GL_NORMAL_ARRAY; - m_states[COLOR_LOCATION].glConst = GL_COLOR_ARRAY; - m_states[POINTSIZE_LOCATION].glConst = GL_POINT_SIZE_ARRAY_OES; - m_states[TEXCOORD0_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; - m_states[TEXCOORD1_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; - m_states[TEXCOORD2_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; - m_states[TEXCOORD3_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; - m_states[TEXCOORD4_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; - m_states[TEXCOORD5_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; - m_states[TEXCOORD6_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; - m_states[TEXCOORD7_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; - m_states[MATRIXINDEX_LOCATION].glConst = GL_MATRIX_INDEX_ARRAY_OES; - m_states[WEIGHT_LOCATION].glConst = GL_WEIGHT_ARRAY_OES; - m_activeTexture = 0; - m_currentProgram = 0; - - m_pixelStore.unpack_alignment = 4; - m_pixelStore.pack_alignment = 4; - - memset(m_tex.unit, 0, sizeof(m_tex.unit)); - m_tex.activeUnit = &m_tex.unit[0]; - m_tex.textures = NULL; - m_tex.numTextures = 0; - m_tex.allocTextures = 0; -} - -GLClientState::~GLClientState() -{ - delete m_states; -} - -void GLClientState::enable(int location, int state) -{ - if (!validLocation(location)) { - return; - } - - m_states[location].enableDirty |= (state != m_states[location].enabled); - m_states[location].enabled = state; -} - -void GLClientState::setState(int location, int size, GLenum type, GLboolean normalized, GLsizei stride, const void *data) -{ - if (!validLocation(location)) { - return; - } - m_states[location].size = size; - m_states[location].type = type; - m_states[location].stride = stride; - m_states[location].data = (void*)data; - m_states[location].bufferObject = m_currentArrayVbo; - m_states[location].elementSize = glSizeof(type) * size; - m_states[location].normalized = normalized; -} - -void GLClientState::setBufferObject(int location, GLuint id) -{ - if (!validLocation(location)) { - return; - } - - m_states[location].bufferObject = id; -} - -const GLClientState::VertexAttribState * GLClientState::getState(int location) -{ - if (!validLocation(location)) { - return NULL; - } - return & m_states[location]; -} - -const GLClientState::VertexAttribState * GLClientState::getStateAndEnableDirty(int location, bool *enableChanged) -{ - if (!validLocation(location)) { - return NULL; - } - - if (enableChanged) { - *enableChanged = m_states[location].enableDirty; - } - - m_states[location].enableDirty = false; - return & m_states[location]; -} - -int GLClientState::getLocation(GLenum loc) -{ - int retval; - - switch(loc) { - case GL_VERTEX_ARRAY: - retval = int(VERTEX_LOCATION); - break; - case GL_NORMAL_ARRAY: - retval = int(NORMAL_LOCATION); - break; - case GL_COLOR_ARRAY: - retval = int(COLOR_LOCATION); - break; - case GL_POINT_SIZE_ARRAY_OES: - retval = int(POINTSIZE_LOCATION); - break; - case GL_TEXTURE_COORD_ARRAY: - retval = int (TEXCOORD0_LOCATION + m_activeTexture); - break; - case GL_MATRIX_INDEX_ARRAY_OES: - retval = int (MATRIXINDEX_LOCATION); - break; - case GL_WEIGHT_ARRAY_OES: - retval = int (WEIGHT_LOCATION); - break; - default: - retval = loc; - } - return retval; -} - -void GLClientState::getClientStatePointer(GLenum pname, GLvoid** params) -{ - const GLClientState::VertexAttribState *state = NULL; - switch (pname) { - case GL_VERTEX_ARRAY_POINTER: { - state = getState(GLClientState::VERTEX_LOCATION); - break; - } - case GL_NORMAL_ARRAY_POINTER: { - state = getState(GLClientState::NORMAL_LOCATION); - break; - } - case GL_COLOR_ARRAY_POINTER: { - state = getState(GLClientState::COLOR_LOCATION); - break; - } - case GL_TEXTURE_COORD_ARRAY_POINTER: { - state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION); - break; - } - case GL_POINT_SIZE_ARRAY_POINTER_OES: { - state = getState(GLClientState::POINTSIZE_LOCATION); - break; - } - case GL_MATRIX_INDEX_ARRAY_POINTER_OES: { - state = getState(GLClientState::MATRIXINDEX_LOCATION); - break; - } - case GL_WEIGHT_ARRAY_POINTER_OES: { - state = getState(GLClientState::WEIGHT_LOCATION); - break; - } - } - if (state && params) - *params = state->data; -} - -int GLClientState::setPixelStore(GLenum param, GLint value) -{ - int retval = 0; - switch(param) { - case GL_UNPACK_ALIGNMENT: - if (value == 1 || value == 2 || value == 4 || value == 8) { - m_pixelStore.unpack_alignment = value; - } else { - retval = GL_INVALID_VALUE; - } - break; - case GL_PACK_ALIGNMENT: - if (value == 1 || value == 2 || value == 4 || value == 8) { - m_pixelStore.pack_alignment = value; - } else { - retval = GL_INVALID_VALUE; - } - break; - default: - retval = GL_INVALID_ENUM; - } - return retval; -} - - - - -size_t GLClientState::pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const -{ - int pixelsize = glUtilsPixelBitSize(format, type) >> 3; - - int alignment = pack ? m_pixelStore.pack_alignment : m_pixelStore.unpack_alignment; - - if (pixelsize == 0 ) { - ERR("unknown pixel size: width: %d height: %d format: %d type: %d pack: %d align: %d\n", - width, height, format, type, pack, alignment); - } - size_t linesize = pixelsize * width; - size_t aligned_linesize = int(linesize / alignment) * alignment; - if (aligned_linesize < linesize) { - aligned_linesize += alignment; - } - return aligned_linesize * height; -} - -GLenum GLClientState::setActiveTextureUnit(GLenum texture) -{ - GLuint unit = texture - GL_TEXTURE0; - if (unit >= MAX_TEXTURE_UNITS) { - return GL_INVALID_OPERATION; - } - m_tex.activeUnit = &m_tex.unit[unit]; - return GL_NO_ERROR; -} - -GLenum GLClientState::getActiveTextureUnit() const -{ - return GL_TEXTURE0 + (m_tex.activeUnit - &m_tex.unit[0]); -} - -void GLClientState::enableTextureTarget(GLenum target) -{ - switch (target) { - case GL_TEXTURE_2D: - m_tex.activeUnit->enables |= (1u << TEXTURE_2D); - break; - case GL_TEXTURE_EXTERNAL_OES: - m_tex.activeUnit->enables |= (1u << TEXTURE_EXTERNAL); - break; - } -} - -void GLClientState::disableTextureTarget(GLenum target) -{ - switch (target) { - case GL_TEXTURE_2D: - m_tex.activeUnit->enables &= ~(1u << TEXTURE_2D); - break; - case GL_TEXTURE_EXTERNAL_OES: - m_tex.activeUnit->enables &= ~(1u << TEXTURE_EXTERNAL); - break; - } -} - -GLenum GLClientState::getPriorityEnabledTarget(GLenum allDisabled) const -{ - unsigned int enables = m_tex.activeUnit->enables; - if (enables & (1u << TEXTURE_EXTERNAL)) { - return GL_TEXTURE_EXTERNAL_OES; - } else if (enables & (1u << TEXTURE_2D)) { - return GL_TEXTURE_2D; - } else { - return allDisabled; - } -} - -int GLClientState::compareTexId(const void* pid, const void* prec) -{ - const GLuint* id = (const GLuint*)pid; - const TextureRec* rec = (const TextureRec*)prec; - return (GLint)(*id) - (GLint)rec->id; -} - -GLenum GLClientState::bindTexture(GLenum target, GLuint texture, - GLboolean* firstUse) -{ - GLboolean first = GL_FALSE; - TextureRec* texrec = NULL; - if (texture != 0) { - if (m_tex.textures) { - texrec = (TextureRec*)bsearch(&texture, m_tex.textures, - m_tex.numTextures, sizeof(TextureRec), compareTexId); - } - if (!texrec) { - if (!(texrec = addTextureRec(texture, target))) { - return GL_OUT_OF_MEMORY; - } - first = GL_TRUE; - } - if (target != texrec->target) { - return GL_INVALID_OPERATION; - } - } - - switch (target) { - case GL_TEXTURE_2D: - m_tex.activeUnit->texture[TEXTURE_2D] = texture; - break; - case GL_TEXTURE_EXTERNAL_OES: - m_tex.activeUnit->texture[TEXTURE_EXTERNAL] = texture; - break; - } - - if (firstUse) { - *firstUse = first; - } - - return GL_NO_ERROR; -} - -GLClientState::TextureRec* GLClientState::addTextureRec(GLuint id, - GLenum target) -{ - if (m_tex.numTextures == m_tex.allocTextures) { - const GLuint MAX_TEXTURES = 0xFFFFFFFFu; - - GLuint newAlloc; - if (MAX_TEXTURES - m_tex.allocTextures >= m_tex.allocTextures) { - newAlloc = MAX(4, 2 * m_tex.allocTextures); - } else { - if (m_tex.allocTextures == MAX_TEXTURES) { - return NULL; - } - newAlloc = MAX_TEXTURES; - } - - TextureRec* newTextures = (TextureRec*)realloc(m_tex.textures, - newAlloc * sizeof(TextureRec)); - if (!newTextures) { - return NULL; - } - - m_tex.textures = newTextures; - m_tex.allocTextures = newAlloc; - } - - TextureRec* tex = m_tex.textures + m_tex.numTextures; - TextureRec* prev = tex - 1; - while (tex != m_tex.textures && id < prev->id) { - *tex-- = *prev--; - } - tex->id = id; - tex->target = target; - m_tex.numTextures++; - - return tex; -} - -GLuint GLClientState::getBoundTexture(GLenum target) const -{ - switch (target) { - case GL_TEXTURE_2D: - return m_tex.activeUnit->texture[TEXTURE_2D]; - case GL_TEXTURE_EXTERNAL_OES: - return m_tex.activeUnit->texture[TEXTURE_EXTERNAL]; - default: - return 0; - } -} - -void GLClientState::deleteTextures(GLsizei n, const GLuint* textures) -{ - // Updating the textures array could be made more efficient when deleting - // several textures: - // - compacting the array could be done in a single pass once the deleted - // textures are marked, or - // - could swap deleted textures to the end and re-sort. - TextureRec* texrec; - for (const GLuint* texture = textures; texture != textures + n; texture++) { - texrec = (TextureRec*)bsearch(texture, m_tex.textures, - m_tex.numTextures, sizeof(TextureRec), compareTexId); - if (texrec) { - const TextureRec* end = m_tex.textures + m_tex.numTextures; - memmove(texrec, texrec + 1, - (end - texrec - 1) * sizeof(TextureRec)); - m_tex.numTextures--; - - for (TextureUnit* unit = m_tex.unit; - unit != m_tex.unit + MAX_TEXTURE_UNITS; - unit++) - { - if (unit->texture[TEXTURE_2D] == *texture) { - unit->texture[TEXTURE_2D] = 0; - } else if (unit->texture[TEXTURE_EXTERNAL] == *texture) { - unit->texture[TEXTURE_EXTERNAL] = 0; - } - } - } - } -} diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h b/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h deleted file mode 100644 index c86329b..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h +++ /dev/null @@ -1,441 +0,0 @@ -/* -* 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_CLIENT_STATE_H_ -#define _GL_CLIENT_STATE_H_ - -#define GL_API -#ifndef ANDROID -#define GL_APIENTRY -#define GL_APIENTRYP -#endif - -#include <GLES/gl.h> -#include <GLES/glext.h> -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> - -#include <stdio.h> -#include <stdlib.h> -#include "ErrorLog.h" -#include "codec_defs.h" - -class GLClientState { -public: - typedef enum { - VERTEX_LOCATION = 0, - NORMAL_LOCATION = 1, - COLOR_LOCATION = 2, - POINTSIZE_LOCATION = 3, - TEXCOORD0_LOCATION = 4, - TEXCOORD1_LOCATION = 5, - TEXCOORD2_LOCATION = 6, - TEXCOORD3_LOCATION = 7, - TEXCOORD4_LOCATION = 8, - TEXCOORD5_LOCATION = 9, - TEXCOORD6_LOCATION = 10, - TEXCOORD7_LOCATION = 11, - MATRIXINDEX_LOCATION = 12, - WEIGHT_LOCATION = 13, - LAST_LOCATION = 14 - } StateLocation; - - typedef struct { - GLint enabled; - GLint size; - GLenum type; - GLsizei stride; - void *data; - GLuint bufferObject; - GLenum glConst; - unsigned int elementSize; - bool enableDirty; // true if any enable state has changed since last draw - bool normalized; - } VertexAttribState; - - typedef struct { - int unpack_alignment; - int pack_alignment; - } PixelStoreState; - - enum { - MAX_TEXTURE_UNITS = 32, - }; - -public: - GLClientState(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES); - ~GLClientState(); - int nLocations() { return m_nLocations; } - const PixelStoreState *pixelStoreState() { return &m_pixelStore; } - int setPixelStore(GLenum param, GLint value); - GLuint currentArrayVbo() { return m_currentArrayVbo; } - GLuint currentIndexVbo() { return m_currentIndexVbo; } - void enable(int location, int state); - void setState(int location, int size, GLenum type, GLboolean normalized, GLsizei stride, const void *data); - void setBufferObject(int location, GLuint id); - const VertexAttribState *getState(int location); - const VertexAttribState *getStateAndEnableDirty(int location, bool *enableChanged); - int getLocation(GLenum loc); - void setActiveTexture(int texUnit) {m_activeTexture = texUnit; }; - int getActiveTexture() const { return m_activeTexture; } - - int bindBuffer(GLenum target, GLuint id) - { - int err = 0; - switch(target) { - case GL_ARRAY_BUFFER: - m_currentArrayVbo = id; - break; - case GL_ELEMENT_ARRAY_BUFFER: - m_currentIndexVbo = id; - break; - default: - err = -1; - } - return err; - } - - int getBuffer(GLenum target) - { - int ret=0; - switch (target) { - case GL_ARRAY_BUFFER: - ret = m_currentArrayVbo; - break; - case GL_ELEMENT_ARRAY_BUFFER: - ret = m_currentIndexVbo; - break; - default: - ret = -1; - } - return ret; - } - size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const; - - void setCurrentProgram(GLint program) { m_currentProgram = program; } - GLint currentProgram() const { return m_currentProgram; } - - /* OES_EGL_image_external - * - * These functions manipulate GL state which interacts with the - * OES_EGL_image_external extension, to support client-side emulation on - * top of host implementations that don't have it. - * - * Most of these calls should only be used with TEXTURE_2D or - * TEXTURE_EXTERNAL_OES texture targets; TEXTURE_CUBE_MAP or other extension - * targets should bypass this. An exception is bindTexture(), which should - * see all glBindTexture() calls for any target. - */ - - // glActiveTexture(GL_TEXTURE0 + i) - // Sets the active texture unit. Up to MAX_TEXTURE_UNITS are supported. - GLenum setActiveTextureUnit(GLenum texture); - GLenum getActiveTextureUnit() const; - - // glEnable(GL_TEXTURE_(2D|EXTERNAL_OES)) - void enableTextureTarget(GLenum target); - - // glDisable(GL_TEXTURE_(2D|EXTERNAL_OES)) - void disableTextureTarget(GLenum target); - - // Implements the target priority logic: - // * Return GL_TEXTURE_EXTERNAL_OES if enabled, else - // * Return GL_TEXTURE_2D if enabled, else - // * Return the allDisabled value. - // For some cases passing GL_TEXTURE_2D for allDisabled makes callee code - // simpler; for other cases passing a recognizable enum like GL_ZERO or - // GL_INVALID_ENUM is appropriate. - GLenum getPriorityEnabledTarget(GLenum allDisabled) const; - - // glBindTexture(GL_TEXTURE_*, ...) - // Set the target binding of the active texture unit to texture. Returns - // GL_NO_ERROR on success or GL_INVALID_OPERATION if the texture has - // previously been bound to a different target. If firstUse is not NULL, - // it is set to indicate whether this is the first use of the texture. - // For accurate error detection, bindTexture should be called for *all* - // targets, not just 2D and EXTERNAL_OES. - GLenum bindTexture(GLenum target, GLuint texture, GLboolean* firstUse); - - // Return the texture currently bound to GL_TEXTURE_(2D|EXTERNAL_OES). - GLuint getBoundTexture(GLenum target) const; - - // glDeleteTextures(...) - // Remove references to the to-be-deleted textures. - void deleteTextures(GLsizei n, const GLuint* textures); - -private: - PixelStoreState m_pixelStore; - VertexAttribState *m_states; - int m_nLocations; - GLuint m_currentArrayVbo; - GLuint m_currentIndexVbo; - int m_activeTexture; - GLint m_currentProgram; - - bool validLocation(int location) { return (location >= 0 && location < m_nLocations); } - - enum TextureTarget { - TEXTURE_2D = 0, - TEXTURE_EXTERNAL = 1, - TEXTURE_TARGET_COUNT - }; - struct TextureUnit { - unsigned int enables; - GLuint texture[TEXTURE_TARGET_COUNT]; - }; - struct TextureRec { - GLuint id; - GLenum target; - }; - struct TextureState { - TextureUnit unit[MAX_TEXTURE_UNITS]; - TextureUnit* activeUnit; - TextureRec* textures; - GLuint numTextures; - GLuint allocTextures; - }; - TextureState m_tex; - - static int compareTexId(const void* pid, const void* prec); - TextureRec* addTextureRec(GLuint id, GLenum target); - -public: - void getClientStatePointer(GLenum pname, GLvoid** params); - - template <class T> - int getVertexAttribParameter(GLuint index, GLenum param, T *ptr) - { - bool handled = true; - const VertexAttribState *vertexAttrib = getState(index); - if (vertexAttrib == NULL) { - ERR("getVeterxAttriParameter for non existant index %d\n", index); - // set gl error; - return handled; - } - - switch(param) { - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: - *ptr = (T)(vertexAttrib->bufferObject); - break; - case GL_VERTEX_ATTRIB_ARRAY_ENABLED: - *ptr = (T)(vertexAttrib->enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY_SIZE: - *ptr = (T)(vertexAttrib->size); - break; - case GL_VERTEX_ATTRIB_ARRAY_STRIDE: - *ptr = (T)(vertexAttrib->stride); - break; - case GL_VERTEX_ATTRIB_ARRAY_TYPE: - *ptr = (T)(vertexAttrib->type); - break; - case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: - *ptr = (T)(vertexAttrib->normalized); - break; - case GL_CURRENT_VERTEX_ATTRIB: - handled = false; - break; - default: - handled = false; - ERR("unknown vertex-attrib parameter param %d\n", param); - } - return handled; - } - - template <class T> - bool getClientStateParameter(GLenum param, T* ptr) - { - bool isClientStateParam = false; - switch (param) { - case GL_CLIENT_ACTIVE_TEXTURE: { - GLint tex = getActiveTexture() + GL_TEXTURE0; - *ptr = tex; - isClientStateParam = true; - break; - } - case GL_VERTEX_ARRAY_SIZE: { - const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION); - *ptr = state->size; - isClientStateParam = true; - break; - } - case GL_VERTEX_ARRAY_TYPE: { - const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION); - *ptr = state->type; - isClientStateParam = true; - break; - } - case GL_VERTEX_ARRAY_STRIDE: { - const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION); - *ptr = state->stride; - isClientStateParam = true; - break; - } - case GL_COLOR_ARRAY_SIZE: { - const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION); - *ptr = state->size; - isClientStateParam = true; - break; - } - case GL_COLOR_ARRAY_TYPE: { - const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION); - *ptr = state->type; - isClientStateParam = true; - break; - } - case GL_COLOR_ARRAY_STRIDE: { - const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION); - *ptr = state->stride; - isClientStateParam = true; - break; - } - case GL_NORMAL_ARRAY_TYPE: { - const GLClientState::VertexAttribState *state = getState(GLClientState::NORMAL_LOCATION); - *ptr = state->type; - isClientStateParam = true; - break; - } - case GL_NORMAL_ARRAY_STRIDE: { - const GLClientState::VertexAttribState *state = getState(GLClientState::NORMAL_LOCATION); - *ptr = state->stride; - isClientStateParam = true; - break; - } - case GL_TEXTURE_COORD_ARRAY_SIZE: { - const GLClientState::VertexAttribState *state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION); - *ptr = state->size; - isClientStateParam = true; - break; - } - case GL_TEXTURE_COORD_ARRAY_TYPE: { - const GLClientState::VertexAttribState *state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION); - *ptr = state->type; - isClientStateParam = true; - break; - } - case GL_TEXTURE_COORD_ARRAY_STRIDE: { - const GLClientState::VertexAttribState *state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION); - *ptr = state->stride; - isClientStateParam = true; - break; - } - case GL_POINT_SIZE_ARRAY_TYPE_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::POINTSIZE_LOCATION); - *ptr = state->type; - isClientStateParam = true; - break; - } - case GL_POINT_SIZE_ARRAY_STRIDE_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::POINTSIZE_LOCATION); - *ptr = state->stride; - isClientStateParam = true; - break; - } - case GL_MATRIX_INDEX_ARRAY_SIZE_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION); - *ptr = state->size; - isClientStateParam = true; - break; - } - case GL_MATRIX_INDEX_ARRAY_TYPE_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION); - *ptr = state->type; - isClientStateParam = true; - break; - } - case GL_MATRIX_INDEX_ARRAY_STRIDE_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION); - *ptr = state->stride; - isClientStateParam = true; - break; - } - case GL_WEIGHT_ARRAY_SIZE_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION); - *ptr = state->size; - isClientStateParam = true; - break; - } - case GL_WEIGHT_ARRAY_TYPE_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION); - *ptr = state->type; - isClientStateParam = true; - break; - } - case GL_WEIGHT_ARRAY_STRIDE_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION); - *ptr = state->stride; - isClientStateParam = true; - break; - } - case GL_VERTEX_ARRAY_BUFFER_BINDING: { - const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION); - *ptr = state->bufferObject; - isClientStateParam = true; - break; - } - case GL_NORMAL_ARRAY_BUFFER_BINDING: { - const GLClientState::VertexAttribState *state = getState(GLClientState::NORMAL_LOCATION); - *ptr = state->bufferObject; - isClientStateParam = true; - break; - } - case GL_COLOR_ARRAY_BUFFER_BINDING: { - const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION); - *ptr = state->bufferObject; - isClientStateParam = true; - break; - } - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: { - const GLClientState::VertexAttribState *state = getState(getActiveTexture()+GLClientState::TEXCOORD0_LOCATION); - *ptr = state->bufferObject; - isClientStateParam = true; - break; - } - case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::POINTSIZE_LOCATION); - *ptr = state->bufferObject; - isClientStateParam = true; - break; - } - case GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION); - *ptr = state->bufferObject; - isClientStateParam = true; - break; - } - case GL_WEIGHT_ARRAY_BUFFER_BINDING_OES: { - const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION); - *ptr = state->bufferObject; - isClientStateParam = true; - break; - } - case GL_ARRAY_BUFFER_BINDING: { - int buffer = getBuffer(GL_ARRAY_BUFFER); - *ptr = buffer; - isClientStateParam = true; - break; - } - case GL_ELEMENT_ARRAY_BUFFER_BINDING: { - int buffer = getBuffer(GL_ELEMENT_ARRAY_BUFFER); - *ptr = buffer; - isClientStateParam = true; - break; - } - } - return isClientStateParam; - } - -}; -#endif diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h b/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h deleted file mode 100644 index d5b5189..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -* 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_DECODER_CONTEXT_DATA_H_ -#define _GL_DECODER_CONTEXT_DATA_H_ - -#include <assert.h> -#include <string.h> -#include "FixedBuffer.h" -#include "codec_defs.h" - -class GLDecoderContextData { -public: - typedef enum { - VERTEX_LOCATION = 0, - NORMAL_LOCATION = 1, - COLOR_LOCATION = 2, - POINTSIZE_LOCATION = 3, - TEXCOORD0_LOCATION = 4, - TEXCOORD1_LOCATION = 5, - TEXCOORD2_LOCATION = 6, - TEXCOORD3_LOCATION = 7, - TEXCOORD4_LOCATION = 8, - TEXCOORD5_LOCATION = 9, - TEXCOORD6_LOCATION = 10, - TEXCOORD7_LOCATION = 11, - MATRIXINDEX_LOCATION = 12, - WEIGHT_LOCATION = 13, - LAST_LOCATION = 14 - } PointerDataLocation; - - GLDecoderContextData(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES) : - m_nLocations(nLocations) - { - m_pointerData = new FixedBuffer[m_nLocations]; - } - - ~GLDecoderContextData() { - delete [] m_pointerData; - } - - void storePointerData(unsigned int loc, void *data, size_t len) { - - assert(loc < (unsigned)m_nLocations); - m_pointerData[loc].alloc(len); - memcpy(m_pointerData[loc].ptr(), data, len); - } - void *pointerData(unsigned int loc) { - assert(loc < (unsigned)m_nLocations); - return m_pointerData[loc].ptr(); - } -private: - FixedBuffer *m_pointerData; - int m_nLocations; -}; - -#endif diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h b/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h deleted file mode 100644 index 5654aea..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -* 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 __GL_ERROR_LOG_H__ -#define __GL_ERROR_LOG_H__ - -#include "ErrorLog.h" - -#ifdef CHECK_GL_ERROR -void dbg(){} -#define GET_GL_ERROR(gl) \ - { \ - int err = gl.glGetError(); \ - if (err) { dbg(); ERR("Error: 0x%X in %s (%s:%d)\n", err, __FUNCTION__, __FILE__, __LINE__); } \ - } - -#else -#define GET_GL_ERROR(gl) -#endif - -#endif //__GL_ERROR_LOG_H__ diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp b/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp deleted file mode 100644 index 59f7b97..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp +++ /dev/null @@ -1,453 +0,0 @@ -/* -* 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. -*/ - -#include "GLSharedGroup.h" - -#include <string.h> - -/**** BufferData ****/ - -BufferData::BufferData() : m_size(0) {}; - -BufferData::BufferData(GLsizeiptr size, void * data) : m_size(size) -{ - void* buffer = NULL; - - if (size > 0) { - buffer = m_fixedBuffer.alloc(size); - if (data) { - memcpy(buffer, data, size); - } - } -} - -/**** ProgramData ****/ -ProgramData::ProgramData() : m_numIndexes(0), - m_initialized(false), - m_locShiftWAR(false) -{ - m_Indexes = NULL; -} - -void ProgramData::initProgramData(GLuint numIndexes) -{ - m_initialized = true; - m_numIndexes = numIndexes; - delete[] m_Indexes; - m_Indexes = new IndexInfo[numIndexes]; - m_locShiftWAR = false; -} - -bool ProgramData::isInitialized() -{ - return m_initialized; -} - -ProgramData::~ProgramData() -{ - delete[] m_Indexes; - m_Indexes = NULL; -} - -void ProgramData::setIndexInfo(GLuint index, GLint base, GLint size, GLenum type) -{ - if (index>=m_numIndexes) - return; - m_Indexes[index].base = base; - m_Indexes[index].size = size; - m_Indexes[index].type = type; - if (index > 0) { - m_Indexes[index].appBase = m_Indexes[index-1].appBase + - m_Indexes[index-1].size; - } - else { - m_Indexes[index].appBase = 0; - } - m_Indexes[index].hostLocsPerElement = 1; - m_Indexes[index].flags = 0; - m_Indexes[index].samplerValue = 0; -} - -void ProgramData::setIndexFlags(GLuint index, GLuint flags) -{ - if (index >= m_numIndexes) - return; - m_Indexes[index].flags |= flags; -} - -GLuint ProgramData::getIndexForLocation(GLint location) -{ - GLuint index = m_numIndexes; - GLint minDist = -1; - for (GLuint i=0;i<m_numIndexes;++i) - { - GLint dist = location - m_Indexes[i].base; - if (dist >= 0 && - (minDist < 0 || dist < minDist)) { - index = i; - minDist = dist; - } - } - return index; -} - -GLenum ProgramData::getTypeForLocation(GLint location) -{ - GLuint index = getIndexForLocation(location); - if (index<m_numIndexes) { - return m_Indexes[index].type; - } - return 0; -} - -void ProgramData::setupLocationShiftWAR() -{ - m_locShiftWAR = false; - for (GLuint i=0; i<m_numIndexes; i++) { - if (0 != (m_Indexes[i].base & 0xffff)) { - return; - } - } - // if we have one uniform at location 0, we do not need the WAR. - if (m_numIndexes > 1) { - m_locShiftWAR = true; - } -} - -GLint ProgramData::locationWARHostToApp(GLint hostLoc, GLint arrIndex) -{ - if (!m_locShiftWAR) return hostLoc; - - GLuint index = getIndexForLocation(hostLoc); - if (index<m_numIndexes) { - if (arrIndex > 0) { - m_Indexes[index].hostLocsPerElement = - (hostLoc - m_Indexes[index].base) / arrIndex; - } - return m_Indexes[index].appBase + arrIndex; - } - return -1; -} - -GLint ProgramData::locationWARAppToHost(GLint appLoc) -{ - if (!m_locShiftWAR) return appLoc; - - for(GLuint i=0; i<m_numIndexes; i++) { - GLint elemIndex = appLoc - m_Indexes[i].appBase; - if (elemIndex >= 0 && elemIndex < m_Indexes[i].size) { - return m_Indexes[i].base + - elemIndex * m_Indexes[i].hostLocsPerElement; - } - } - return -1; -} - -GLint ProgramData::getNextSamplerUniform(GLint index, GLint* val, GLenum* target) -{ - for (GLint i = index + 1; i >= 0 && i < (GLint)m_numIndexes; i++) { - if (m_Indexes[i].type == GL_SAMPLER_2D) { - if (val) *val = m_Indexes[i].samplerValue; - if (target) { - if (m_Indexes[i].flags & INDEX_FLAG_SAMPLER_EXTERNAL) { - *target = GL_TEXTURE_EXTERNAL_OES; - } else { - *target = GL_TEXTURE_2D; - } - } - return i; - } - } - return -1; -} - -bool ProgramData::setSamplerUniform(GLint appLoc, GLint val, GLenum* target) -{ - for (GLuint i = 0; i < m_numIndexes; i++) { - GLint elemIndex = appLoc - m_Indexes[i].appBase; - if (elemIndex >= 0 && elemIndex < m_Indexes[i].size) { - if (m_Indexes[i].type == GL_TEXTURE_2D) { - m_Indexes[i].samplerValue = val; - if (target) { - if (m_Indexes[i].flags & INDEX_FLAG_SAMPLER_EXTERNAL) { - *target = GL_TEXTURE_EXTERNAL_OES; - } else { - *target = GL_TEXTURE_2D; - } - } - return true; - } - } - } - return false; -} - -bool ProgramData::attachShader(GLuint shader) -{ - size_t n = m_shaders.size(); - for (size_t i = 0; i < n; i++) { - if (m_shaders[i] == shader) { - return false; - } - } - m_shaders.append(shader); - return true; -} - -bool ProgramData::detachShader(GLuint shader) -{ - size_t n = m_shaders.size(); - for (size_t i = 0; i < n; i++) { - if (m_shaders[i] == shader) { - m_shaders.remove(i); - return true; - } - } - return false; -} - -/***** GLSharedGroup ****/ - -GLSharedGroup::GLSharedGroup() : - m_buffers(), m_programs(), m_shaders() {} - -GLSharedGroup::~GLSharedGroup() {} - -BufferData * GLSharedGroup::getBufferData(GLuint bufferId) -{ - emugl::Mutex::AutoLock _lock(m_lock); - return m_buffers.get(bufferId); -} - -void GLSharedGroup::addBufferData(GLuint bufferId, GLsizeiptr size, void * data) -{ - emugl::Mutex::AutoLock _lock(m_lock); - m_buffers.set(bufferId, new BufferData(size, data)); -} - -void GLSharedGroup::updateBufferData(GLuint bufferId, GLsizeiptr size, void * data) -{ - emugl::Mutex::AutoLock _lock(m_lock); - m_buffers.set(bufferId, new BufferData(size, data)); -} - -GLenum GLSharedGroup::subUpdateBufferData(GLuint bufferId, GLintptr offset, GLsizeiptr size, void * data) -{ - emugl::Mutex::AutoLock _lock(m_lock); - BufferData * buf = m_buffers.get(bufferId); - if ((!buf) || (buf->m_size < offset+size) || (offset < 0) || (size<0)) return GL_INVALID_VALUE; - - //it's safe to update now - memcpy((char*)buf->m_fixedBuffer.ptr() + offset, data, size); - return GL_NO_ERROR; -} - -void GLSharedGroup::deleteBufferData(GLuint bufferId) -{ - emugl::Mutex::AutoLock _lock(m_lock); - (void) m_buffers.remove(bufferId); -} - -void GLSharedGroup::addProgramData(GLuint program) -{ - emugl::Mutex::AutoLock _lock(m_lock); - m_programs.set(program, new ProgramData()); -} - -void GLSharedGroup::initProgramData(GLuint program, GLuint numIndexes) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData *pData = m_programs.get(program); - if (pData) { - pData->initProgramData(numIndexes); - } -} - -bool GLSharedGroup::isProgramInitialized(GLuint program) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - return pData && pData->isInitialized(); -} - -void GLSharedGroup::deleteProgramData(GLuint program) -{ - emugl::Mutex::AutoLock _lock(m_lock); - m_programs.remove(program); -} - -void GLSharedGroup::attachShader(GLuint program, GLuint shader) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* programData = m_programs.get(program); - if (programData && programData->attachShader(shader)) { - refShaderDataLocked(shader); - } -} - -void GLSharedGroup::detachShader(GLuint program, GLuint shader) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* programData = m_programs.get(program); - if (programData && programData->detachShader(shader)) { - unrefShaderDataLocked(shader); - } -} - -void GLSharedGroup::setProgramIndexInfo(GLuint program, - GLuint index, - GLint base, - GLint size, - GLenum type, - const char* name) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - if (!pData) { - return; - } - pData->setIndexInfo(index,base,size,type); - - if (type == GL_SAMPLER_2D) { - size_t n = pData->getNumShaders(); - for (size_t i = 0; i < n; i++) { - GLuint shaderId = pData->getShader(i); - ShaderData* shader = m_shaders.get(shaderId); - if (!shader) continue; -#if 0 // TODO(digit): Understand why samplerExternalNames is always empty? - ShaderData::StringList::iterator nameIter = - shader->samplerExternalNames.begin(); - ShaderData::StringList::iterator nameEnd = - shader->samplerExternalNames.end(); - while (nameIter != nameEnd) { - if (*nameIter == name) { - pData->setIndexFlags( - index, - ProgramData::INDEX_FLAG_SAMPLER_EXTERNAL); - break; - } - ++nameIter; - } -#endif - } - } -} - - -GLenum GLSharedGroup::getProgramUniformType(GLuint program, GLint location) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - return pData ? pData->getTypeForLocation(location) : 0; -} - -bool GLSharedGroup::isProgram(GLuint program) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - return (pData != NULL); -} - -void GLSharedGroup::setupLocationShiftWAR(GLuint program) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - if (pData) pData->setupLocationShiftWAR(); -} - -GLint GLSharedGroup::locationWARHostToApp(GLuint program, - GLint hostLoc, - GLint arrIndex) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - return pData ? pData->locationWARHostToApp(hostLoc, arrIndex) : hostLoc; -} - -GLint GLSharedGroup::locationWARAppToHost(GLuint program, GLint appLoc) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - return pData ? pData->locationWARAppToHost(appLoc) : appLoc; -} - -bool GLSharedGroup::needUniformLocationWAR(GLuint program) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - return pData ? pData->needUniformLocationWAR() : false; -} - -GLint GLSharedGroup::getNextSamplerUniform(GLuint program, - GLint index, - GLint* val, - GLenum* target) const -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - return pData ? pData->getNextSamplerUniform(index, val, target) : -1; -} - -bool GLSharedGroup::setSamplerUniform(GLuint program, - GLint appLoc, - GLint val, - GLenum* target) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ProgramData* pData = m_programs.get(program); - return pData ? pData->setSamplerUniform(appLoc, val, target) : false; -} - -bool GLSharedGroup::addShaderData(GLuint shader) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ShaderData* data = new ShaderData; - data->refcount = 1; - m_shaders.set(shader, data); - return true; -} - -ShaderData* GLSharedGroup::getShaderData(GLuint shader) -{ - emugl::Mutex::AutoLock _lock(m_lock); - ShaderData* data = m_shaders.get(shader); - if (data) { - data->refcount++; - } - return data; -} - -void GLSharedGroup::unrefShaderData(GLuint shader) -{ - emugl::Mutex::AutoLock _lock(m_lock); - unrefShaderDataLocked(shader); -} - -void GLSharedGroup::refShaderDataLocked(GLuint shader) -{ - ShaderData* data = m_shaders.get(shader); - if (data) { - data->refcount++; - } -} - -void GLSharedGroup::unrefShaderDataLocked(GLuint shader) -{ - ShaderData* data = m_shaders.get(shader); - if (data && --data->refcount == 0) { - m_shaders.remove(shader); - } -} diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h b/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h deleted file mode 100644 index f111f99..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h +++ /dev/null @@ -1,145 +0,0 @@ -/* -* 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_SHARED_GROUP_H_ -#define _GL_SHARED_GROUP_H_ - -#include "emugl/common/id_to_object_map.h" -#include "emugl/common/mutex.h" -#include "emugl/common/pod_vector.h" -#include "emugl/common/smart_ptr.h" - -#define GL_API -#ifndef ANDROID -#define GL_APIENTRY -#define GL_APIENTRYP -#endif - -#include <GLES/gl.h> -#include <GLES/glext.h> -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> - -#include <stdio.h> -#include <stdlib.h> -#include "ErrorLog.h" -#include "FixedBuffer.h" - -struct BufferData { - BufferData(); - BufferData(GLsizeiptr size, void * data); - GLsizeiptr m_size; - FixedBuffer m_fixedBuffer; -}; - -class ProgramData { -private: - typedef struct _IndexInfo { - GLint base; - GLint size; - GLenum type; - GLint appBase; - GLint hostLocsPerElement; - GLuint flags; - GLint samplerValue; // only set for sampler uniforms - } IndexInfo; - - GLuint m_numIndexes; - IndexInfo* m_Indexes; - bool m_initialized; - bool m_locShiftWAR; - - emugl::PodVector<GLuint> m_shaders; - -public: - enum { - INDEX_FLAG_SAMPLER_EXTERNAL = 0x00000001, - }; - - ProgramData(); - void initProgramData(GLuint numIndexes); - bool isInitialized(); - virtual ~ProgramData(); - void setIndexInfo(GLuint index, GLint base, GLint size, GLenum type); - void setIndexFlags(GLuint index, GLuint flags); - GLuint getIndexForLocation(GLint location); - GLenum getTypeForLocation(GLint location); - - bool needUniformLocationWAR() const { return m_locShiftWAR; } - void setupLocationShiftWAR(); - GLint locationWARHostToApp(GLint hostLoc, GLint arrIndex); - GLint locationWARAppToHost(GLint appLoc); - - GLint getNextSamplerUniform(GLint index, GLint* val, GLenum* target); - bool setSamplerUniform(GLint appLoc, GLint val, GLenum* target); - - bool attachShader(GLuint shader); - bool detachShader(GLuint shader); - size_t getNumShaders() const { return m_shaders.size(); } - GLuint getShader(size_t i) const { return m_shaders[i]; } -}; - -struct ShaderData { -#if 0 // TODO(digit): Undertand why this is never used? - typedef android::List<android::String8> StringList; - StringList samplerExternalNames; -#endif - int refcount; -}; - -class GLSharedGroup { -private: - emugl::IdToObjectMap<BufferData> m_buffers; - emugl::IdToObjectMap<ProgramData> m_programs; - emugl::IdToObjectMap<ShaderData> m_shaders; - mutable emugl::Mutex m_lock; - - void refShaderDataLocked(GLuint shader); - void unrefShaderDataLocked(GLuint shader); - -public: - GLSharedGroup(); - ~GLSharedGroup(); - BufferData * getBufferData(GLuint bufferId); - void addBufferData(GLuint bufferId, GLsizeiptr size, void * data); - void updateBufferData(GLuint bufferId, GLsizeiptr size, void * data); - GLenum subUpdateBufferData(GLuint bufferId, GLintptr offset, GLsizeiptr size, void * data); - void deleteBufferData(GLuint); - - bool isProgram(GLuint program); - bool isProgramInitialized(GLuint program); - void addProgramData(GLuint program); - void initProgramData(GLuint program, GLuint numIndexes); - void attachShader(GLuint program, GLuint shader); - void detachShader(GLuint program, GLuint shader); - void deleteProgramData(GLuint program); - void setProgramIndexInfo(GLuint program, GLuint index, GLint base, GLint size, GLenum type, const char* name); - GLenum getProgramUniformType(GLuint program, GLint location); - void setupLocationShiftWAR(GLuint program); - GLint locationWARHostToApp(GLuint program, GLint hostLoc, GLint arrIndex); - GLint locationWARAppToHost(GLuint program, GLint appLoc); - bool needUniformLocationWAR(GLuint program); - GLint getNextSamplerUniform(GLuint program, GLint index, GLint* val, GLenum* target) const; - bool setSamplerUniform(GLuint program, GLint appLoc, GLint val, GLenum* target); - - bool addShaderData(GLuint shader); - // caller must hold a reference to the shader as long as it holds the pointer - ShaderData* getShaderData(GLuint shader); - void unrefShaderData(GLuint shader); -}; - -typedef emugl::SmartPtr<GLSharedGroup> GLSharedGroupPtr; - -#endif //_GL_SHARED_GROUP_H_ diff --git a/emulator/opengl/shared/OpenglCodecCommon/Makefile b/emulator/opengl/shared/OpenglCodecCommon/Makefile deleted file mode 100644 index e8bf431..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/Makefile +++ /dev/null @@ -1,13 +0,0 @@ - -ROOT=../.. - -include $(ROOT)/make/commondefs - -CXXFILES = TcpStream.cpp GLClientState.cpp glUtils.cpp -CXXINCS += -I$(ROOT)/libs/GLESv1 -I$(ROOT)/include - -LIBRARY_NAME = libcodecCommon.a - -include $(COMMONRULES) - - diff --git a/emulator/opengl/shared/OpenglCodecCommon/ProtocolUtils.h b/emulator/opengl/shared/OpenglCodecCommon/ProtocolUtils.h deleted file mode 100644 index 472d7ea..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/ProtocolUtils.h +++ /dev/null @@ -1,187 +0,0 @@ -#ifndef EMUGL_PROTOCOL_UTILS_H -#define EMUGL_PROTOCOL_UTILS_H - -#include <stddef.h> -#include <stdint.h> -#include <stdlib.h> -#include <string.h> - -namespace emugl { - -// Helper macro -#define COMPILE_ASSERT(cond) static char kAssert##__LINE__[1 - 2 * !(cond)] __attribute__((unused)) = { 0 } - -// Helper template: is_pointer. -// is_pointer<T>::value is true iff |T| is a pointer type. -template <typename T> struct is_pointer { - static const bool value = false; -}; - -template <typename T> struct is_pointer<T*> { - static const bool value = true; -}; - -// A helper template to extract values form the wire protocol stream -// and convert them to appropriate host values. -// -// The wire protocol uses 32-bit exclusively when transferring -// GLintptr or GLsizei values, as well as opaque handles like GLeglImage, -// from the guest (even when the guest is 64-bit). -// -// The corresponding host definitions depend on the host bitness. For -// example, GLintptr is 64-bit on linux-x86_64. The following is a set -// of templates that can simplify the conversion of protocol values -// into host ones. -// -// The most important one is: -// -// unpack<HOST_TYPE,SIZE_TYPE>(const void* ptr) -// -// Which reads bytes from |ptr|, using |SIZE_TYPE| as the underlying -// sized-integer specifier (e.g. 'uint32_t'), and converting the result -// into a |HOST_TYPE| value. For example: -// -// unpack<EGLImage,uint32_t>(ptr + 12); -// -// will read a 4-byte value from |ptr + 12| and convert it into -// an EGLImage, which is a host void*. The template detects host -// pointer types to perform proper type casting. -// -// TODO(digit): Add custom unpackers to handle generic opaque void* values. -// and map them to unique 32-bit values. - -template <typename T, typename S, bool IS_POINTER> -struct UnpackerT {}; - -template <typename T, typename S> -struct UnpackerT<T,S,false> { - static inline T unpack(const void* ptr) { - COMPILE_ASSERT(sizeof(T) == sizeof(S)); - return (T)(*(S*)(ptr)); - } -}; - -template <typename T, typename S> -struct UnpackerT<T,S,true> { - static inline T unpack(const void* ptr) { - return (T)(uintptr_t)(*(S*)(ptr)); - } -}; - -template <> -struct UnpackerT<float,uint32_t,false> { - static inline float unpack(const void* ptr) { - union { - float f; - uint32_t u; - } v; - v.u = *(uint32_t*)(ptr); - return v.f; - } -}; - -template <> -struct UnpackerT<double,uint64_t,false> { - static inline double unpack(const void* ptr) { - union { - double d; - uint32_t u; - } v; - v.u = *(uint64_t*)(ptr); - return v.d; - } -}; - -template <> -struct UnpackerT<ssize_t,uint32_t,false> { - static inline ssize_t unpack(const void* ptr) { - return (ssize_t)*(int32_t*)(ptr); - } -}; - -template <typename T, typename S> -inline T Unpack(const void* ptr) { - return UnpackerT<T, S, is_pointer<T>::value>::unpack(ptr); -} - -// Helper class used to ensure input buffers passed to EGL/GL functions -// are properly aligned (preventing crashes with some backends). -// Usage example: -// -// InputBuffer inputBuffer(ptr, size); -// glDoStuff(inputBuffer.get()); -// -// inputBuffer.get() will return the original value of |ptr| if it was -// aligned on an 8-byte boundary. Otherwise, it will return the address -// of an aligned heap-allocated copy of the original |size| bytes starting -// from |ptr|. The heap block is released at scope exit. -class InputBuffer { -public: - InputBuffer(const void* input, size_t size, size_t align = 8) : - mBuff(input), mIsCopy(false) { - if (((uintptr_t)input & (align - 1U)) != 0) { - void* newBuff = malloc(size); - memcpy(newBuff, input, size); - mBuff = newBuff; - mIsCopy = true; - } - } - - ~InputBuffer() { - if (mIsCopy) { - free((void*)mBuff); - } - } - - const void* get() const { - return mBuff; - } - -private: - const void* mBuff; - bool mIsCopy; -}; - -// Helper class used to ensure that output buffers passed to EGL/GL functions -// are aligned on 8-byte addresses. -// Usage example: -// -// ptr = stream->alloc(size); -// OutputBuffer outputBuffer(ptr, size); -// glGetStuff(outputBuffer.get()); -// outputBuffer.flush(); -// -// outputBuffer.get() returns the original value of |ptr| if it was already -// aligned on an 8=byte boundary. Otherwise, it returns the size of an heap -// allocated zeroed buffer of |size| bytes. -// -// outputBuffer.flush() copies the content of the heap allocated buffer back -// to |ptr| explictly, if needed. If a no-op if |ptr| was aligned. -class OutputBuffer { -public: - OutputBuffer(unsigned char* ptr, size_t size, size_t align = 8) : - mOrgBuff(ptr), mBuff(ptr), mSize(size) { - if (((uintptr_t)ptr & (align - 1U)) != 0) { - void* newBuff = calloc(1, size); - mBuff = newBuff; - } - } - - void* get() const { - return mBuff; - } - - void flush() { - if (mBuff != mOrgBuff) { - memcpy(mOrgBuff, mBuff, mSize); - } - } -private: - unsigned char* mOrgBuff; - void* mBuff; - size_t mSize; -}; - -} // namespace emugl - -#endif // EMUGL_PROTOCOL_UTILS_H diff --git a/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp b/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp deleted file mode 100644 index 726d359..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* -* 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. -*/ -#include "SocketStream.h" -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#ifndef _WIN32 -#include <netinet/in.h> -#include <netinet/tcp.h> -#include <sys/un.h> -#else -#include <ws2tcpip.h> -#endif - -SocketStream::SocketStream(size_t bufSize) : - IOStream(bufSize), - m_sock(-1), - m_bufsize(bufSize), - m_buf(NULL) -{ -} - -SocketStream::SocketStream(int sock, size_t bufSize) : - IOStream(bufSize), - m_sock(sock), - m_bufsize(bufSize), - m_buf(NULL) -{ -} - -SocketStream::~SocketStream() -{ - if (m_sock >= 0) { -#ifdef _WIN32 - closesocket(m_sock); -#else - ::close(m_sock); -#endif - m_sock = -1; - } - if (m_buf != NULL) { - free(m_buf); - m_buf = NULL; - } -} - - -void *SocketStream::allocBuffer(size_t minSize) -{ - size_t allocSize = (m_bufsize < minSize ? minSize : m_bufsize); - if (!m_buf) { - m_buf = (unsigned char *)malloc(allocSize); - } - else if (m_bufsize < allocSize) { - unsigned char *p = (unsigned char *)realloc(m_buf, allocSize); - if (p != NULL) { - m_buf = p; - m_bufsize = allocSize; - } else { - ERR("%s: realloc (%zu) failed\n", __FUNCTION__, allocSize); - free(m_buf); - m_buf = NULL; - m_bufsize = 0; - } - } - - return m_buf; -}; - -int SocketStream::commitBuffer(size_t size) -{ - return writeFully(m_buf, size); -} - -int SocketStream::writeFully(const void* buffer, size_t size) -{ - if (!valid()) return -1; - - size_t res = size; - int retval = 0; - - while (res > 0) { - ssize_t stat = ::send(m_sock, (const char *)buffer + (size - res), res, 0); - if (stat < 0) { - if (errno != EINTR) { - retval = stat; - ERR("%s: failed: %s\n", __FUNCTION__, strerror(errno)); - break; - } - } else { - res -= stat; - } - } - return retval; -} - -const unsigned char *SocketStream::readFully(void *buf, size_t len) -{ - if (!valid()) return NULL; - if (!buf) { - return NULL; // do not allow NULL buf in that implementation - } - size_t res = len; - while (res > 0) { - ssize_t stat = ::recv(m_sock, (char *)(buf) + len - res, res, 0); - if (stat > 0) { - res -= stat; - continue; - } - if (stat == 0 || errno != EINTR) { // client shutdown or error - return NULL; - } - } - return (const unsigned char *)buf; -} - -const unsigned char *SocketStream::read( void *buf, size_t *inout_len) -{ - if (!valid()) return NULL; - if (!buf) { - return NULL; // do not allow NULL buf in that implementation - } - - int n; - do { - n = this->recv(buf, *inout_len); - } while( n < 0 && errno == EINTR ); - - if (n > 0) { - *inout_len = n; - return (const unsigned char *)buf; - } - - return NULL; -} - -int SocketStream::recv(void *buf, size_t len) -{ - if (!valid()) return int(ERR_INVALID_SOCKET); - int res = 0; - while(true) { - res = ::recv(m_sock, (char *)buf, len, 0); - if (res < 0) { - if (errno == EINTR) { - continue; - } - } - break; - } - return res; -} diff --git a/emulator/opengl/shared/OpenglCodecCommon/SocketStream.h b/emulator/opengl/shared/OpenglCodecCommon/SocketStream.h deleted file mode 100644 index b0a481b..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/SocketStream.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* 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 __SOCKET_STREAM_H -#define __SOCKET_STREAM_H - -#include <stdlib.h> -#include "IOStream.h" - -class SocketStream : public IOStream { -public: - typedef enum { ERR_INVALID_SOCKET = -1000 } SocketStreamError; - static const size_t MAX_ADDRSTR_LEN = 256; - - explicit SocketStream(size_t bufsize = 10000); - virtual ~SocketStream(); - - virtual int listen(char addrstr[MAX_ADDRSTR_LEN]) = 0; - virtual SocketStream *accept() = 0; - virtual int connect(const char* addr) = 0; - - virtual void *allocBuffer(size_t minSize); - virtual int commitBuffer(size_t size); - virtual const unsigned char *readFully(void *buf, size_t len); - virtual const unsigned char *read(void *buf, size_t *inout_len); - - bool valid() { return m_sock >= 0; } - virtual int recv(void *buf, size_t len); - virtual int writeFully(const void *buf, size_t len); - -protected: - int m_sock; - size_t m_bufsize; - unsigned char *m_buf; - - SocketStream(int sock, size_t bufSize); -}; - -#endif /* __SOCKET_STREAM_H */ diff --git a/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp b/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp deleted file mode 100644 index ba355ab..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -* 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. -*/ -#include "TcpStream.h" -#include "emugl/common/sockets.h" - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#ifndef _WIN32 -#include <netinet/in.h> -#include <netinet/tcp.h> -#else -#include <ws2tcpip.h> -#endif - -#define LISTEN_BACKLOG 4 - -TcpStream::TcpStream(size_t bufSize) : SocketStream(bufSize) {} - -TcpStream::TcpStream(int sock, size_t bufSize) : - SocketStream(sock, bufSize) { - // disable Nagle algorithm to improve bandwidth of small - // packets which are quite common in our implementation. - emugl::socketTcpDisableNagle(sock); -} - -int TcpStream::listen(char addrstr[MAX_ADDRSTR_LEN]) { - m_sock = emugl::socketTcpLoopbackServer(0, SOCK_STREAM); - if (!valid()) - return int(ERR_INVALID_SOCKET); - - int port = emugl::socketGetPort(m_sock); - if (port < 0) { - ::close(m_sock); - return int(ERR_INVALID_SOCKET); - } - - snprintf(addrstr, MAX_ADDRSTR_LEN - 1, "%hu", port); - addrstr[MAX_ADDRSTR_LEN-1] = '\0'; - - return 0; -} - -SocketStream * TcpStream::accept() { - int clientSock = emugl::socketAccept(m_sock); - if (clientSock < 0) - return NULL; - - return new TcpStream(clientSock, m_bufsize); -} - -int TcpStream::connect(const char* addr) { - int port = atoi(addr); - m_sock = emugl::socketTcpLoopbackClient(port, SOCK_STREAM); - return valid() ? 0 : -1; -} - -int TcpStream::connect(const char* hostname, unsigned short port) -{ - m_sock = emugl::socketTcpClient(hostname, port, SOCK_STREAM); - return valid() ? 0 : -1; -} diff --git a/emulator/opengl/shared/OpenglCodecCommon/TcpStream.h b/emulator/opengl/shared/OpenglCodecCommon/TcpStream.h deleted file mode 100644 index f5b462b..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/TcpStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -* 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 __TCP_STREAM_H -#define __TCP_STREAM_H - -#include "SocketStream.h" - -class TcpStream : public SocketStream { -public: - explicit TcpStream(size_t bufsize = 10000); - virtual int listen(char addrstr[MAX_ADDRSTR_LEN]); - virtual SocketStream *accept(); - virtual int connect(const char* addr); - int connect(const char* hostname, unsigned short port); -private: - TcpStream(int sock, size_t bufSize); -}; - -#endif diff --git a/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.cpp b/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.cpp deleted file mode 100644 index 50aeb03..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* -* 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. -*/ -#include "TimeUtils.h" - -#ifdef _WIN32 -#include <windows.h> -#include <time.h> -#include <stdio.h> -#elif defined(__linux__) -#include <stdlib.h> -#include <sys/time.h> -#include <time.h> -#include <unistd.h> -#else -#include <sys/time.h> -#include <unistd.h> -#endif - -long long GetCurrentTimeMS() -{ -#ifdef _WIN32 - static LARGE_INTEGER freq; - static bool bNotInit = true; - if ( bNotInit ) { - bNotInit = (QueryPerformanceFrequency( &freq ) == FALSE); - } - LARGE_INTEGER currVal; - QueryPerformanceCounter( &currVal ); - - return currVal.QuadPart / (freq.QuadPart / 1000); - -#elif defined(__linux__) - - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - long long iDiff = (now.tv_sec * 1000LL) + now.tv_nsec/1000000LL; - return iDiff; - -#else /* Others, e.g. OS X */ - - struct timeval now; - gettimeofday(&now, NULL); - long long iDiff = (now.tv_sec * 1000LL) + now.tv_usec/1000LL; - return iDiff; - -#endif -} - -void TimeSleepMS(int p_mili) -{ -#ifdef _WIN32 - Sleep(p_mili); -#else - usleep(p_mili * 1000); -#endif -} diff --git a/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.h b/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.h deleted file mode 100644 index bc4fd1c..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/TimeUtils.h +++ /dev/null @@ -1,22 +0,0 @@ -/* -* 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 _TIME_UTILS_H -#define _TIME_UTILS_H - -long long GetCurrentTimeMS(); -void TimeSleepMS(int p_mili); - -#endif diff --git a/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp b/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp deleted file mode 100644 index 7b2f67d..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* -* 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. -*/ -#include "UnixStream.h" - -#include "emugl/common/sockets.h" - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <netinet/in.h> -#include <netinet/tcp.h> -#include <sys/un.h> -#include <sys/stat.h> - -/* Not all systems define PATH_MAX, those who don't generally don't - * have a limit on the maximum path size, so use a value that is - * large enough for our very limited needs. - */ -#ifndef PATH_MAX -#define PATH_MAX 128 -#endif - -UnixStream::UnixStream(size_t bufSize) : - SocketStream(bufSize) -{ -} - -UnixStream::UnixStream(int sock, size_t bufSize) : - SocketStream(sock, bufSize) -{ -} - -/* Initialize a sockaddr_un with the appropriate values corresponding - * to a given 'virtual port'. Returns 0 on success, -1 on error. - */ -static int -make_unix_path(char *path, size_t pathlen, int port_number) -{ - char tmp[PATH_MAX]; // temp directory - int ret = 0; - - // First, create user-specific temp directory if needed - const char* user = getenv("USER"); - if (user != NULL) { - struct stat st; - snprintf(tmp, sizeof(tmp), "/tmp/android-%s", user); - do { - ret = ::lstat(tmp, &st); - } while (ret < 0 && errno == EINTR); - - if (ret < 0 && errno == ENOENT) { - do { - ret = ::mkdir(tmp, 0766); - } while (ret < 0 && errno == EINTR); - if (ret < 0) { - ERR("Could not create temp directory: %s", tmp); - user = NULL; // will fall-back to /tmp - } - } - else if (ret < 0) { - user = NULL; // will fallback to /tmp - } - } - - if (user == NULL) { // fallback to /tmp in case of error - snprintf(tmp, sizeof(tmp), "/tmp"); - } - - // Now, initialize it properly - snprintf(path, pathlen, "%s/qemu-gles-%d", tmp, port_number); - return 0; -} - - -int UnixStream::listen(char addrstr[MAX_ADDRSTR_LEN]) -{ - if (make_unix_path(addrstr, MAX_ADDRSTR_LEN, getpid()) < 0) { - return -1; - } - - m_sock = emugl::socketLocalServer(addrstr, SOCK_STREAM); - if (!valid()) return int(ERR_INVALID_SOCKET); - - return 0; -} - -SocketStream * UnixStream::accept() -{ - int clientSock = -1; - - while (true) { - struct sockaddr_un addr; - socklen_t len = sizeof(addr); - clientSock = ::accept(m_sock, (sockaddr *)&addr, &len); - - if (clientSock < 0 && errno == EINTR) { - continue; - } - break; - } - - UnixStream *clientStream = NULL; - - if (clientSock >= 0) { - clientStream = new UnixStream(clientSock, m_bufsize); - } - return clientStream; -} - -int UnixStream::connect(const char* addr) -{ - m_sock = emugl::socketLocalClient(addr, SOCK_STREAM); - if (!valid()) return -1; - - return 0; -} diff --git a/emulator/opengl/shared/OpenglCodecCommon/UnixStream.h b/emulator/opengl/shared/OpenglCodecCommon/UnixStream.h deleted file mode 100644 index 95e7431..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/UnixStream.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -* 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 __UNIX_STREAM_H -#define __UNIX_STREAM_H - -#include "SocketStream.h" - -class UnixStream : public SocketStream { -public: - explicit UnixStream(size_t bufsize = 10000); - virtual int listen(char addrstr[MAX_ADDRSTR_LEN]); - virtual SocketStream *accept(); - virtual int connect(const char* addr); -private: - UnixStream(int sock, size_t bufSize); -}; - -#endif diff --git a/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp b/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp deleted file mode 100644 index dcfb0c0..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* -* 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. -*/ -#include "Win32PipeStream.h" - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <windows.h> - -#ifndef _WIN32 -#error ONLY BUILD THIS SOURCE FILE FOR WINDOWS! -#endif - -/* The official documentation states that the name of a given named - * pipe cannot be more than 256 characters long. - */ -#define NAMED_PIPE_MAX 256 - -Win32PipeStream::Win32PipeStream(size_t bufSize) : - SocketStream(bufSize), - m_pipe(INVALID_HANDLE_VALUE) -{ -} - -Win32PipeStream::Win32PipeStream(HANDLE pipe, size_t bufSize) : - SocketStream(-1, bufSize), - m_pipe(pipe) -{ -} - -Win32PipeStream::~Win32PipeStream() -{ - if (m_pipe != INVALID_HANDLE_VALUE) { - CloseHandle(m_pipe); - m_pipe = INVALID_HANDLE_VALUE; - } -} - -/* Initialize the pipe name corresponding to a given port - */ -static void -make_pipe_name(char *path, size_t pathlen, int port_number) -{ - snprintf(path, pathlen, "\\\\.\\pipe\\qemu-gles-%d", port_number); -} - - -/* Technical note: Named pipes work differently from BSD Sockets. - * One does not create/bind a pipe, and collect a new handle each - * time a client connects with accept(). - * - * Instead, the server creates a new pipe instance each time it wants - * to get a new client connection, then calls ConnectNamedPipe() to - * wait for a connection. - * - * So listen() is a no-op, and accept() really creates the pipe handle. - * - * Also, connect() must create a pipe handle with CreateFile() and - * wait for a server instance with WaitNamedPipe() - */ -int Win32PipeStream::listen(char addrstr[MAX_ADDRSTR_LEN]) -{ - m_port = GetCurrentProcessId(); - make_pipe_name(addrstr, MAX_ADDRSTR_LEN, m_port); - return 0; -} - -SocketStream * Win32PipeStream::accept() -{ - char path[NAMED_PIPE_MAX+1]; - SocketStream* clientStream; - HANDLE pipe; - - make_pipe_name(path, sizeof(path), m_port); - - pipe = ::CreateNamedPipe( - path, // pipe name - PIPE_ACCESS_DUPLEX, // read-write access - PIPE_TYPE_BYTE | // byte-oriented writes - PIPE_READMODE_BYTE | // byte-oriented reads - PIPE_WAIT, // blocking operations - PIPE_UNLIMITED_INSTANCES, // no limit on clients - 4096, // input buffer size - 4096, // output buffer size - 0, // client time-out - NULL); // default security attributes - - if (pipe == INVALID_HANDLE_VALUE) { - ERR("%s: CreateNamedPipe failed %d\n", __FUNCTION__, (int)GetLastError()); - return NULL; - } - - // Stupid Win32 API design: If a client is already connected, then - // ConnectNamedPipe will return 0, and GetLastError() will return - // ERROR_PIPE_CONNECTED. This is not an error! It just means that the - // function didn't have to wait. - // - if (::ConnectNamedPipe(pipe, NULL) == 0 && GetLastError() != ERROR_PIPE_CONNECTED) { - ERR("%s: ConnectNamedPipe failed: %d\n", __FUNCTION__, (int)GetLastError()); - CloseHandle(pipe); - return NULL; - } - - clientStream = new Win32PipeStream(pipe, m_bufsize); - return clientStream; -} - -int Win32PipeStream::connect(const char* addr) -{ - HANDLE pipe; - int tries = 10; - - /* We're going to loop in order to wait for the pipe server to - * be setup properly. - */ - for (; tries > 0; tries--) { - pipe = ::CreateFile( - addr, // pipe name - GENERIC_READ | GENERIC_WRITE, // read & write - 0, // no sharing - NULL, // default security attrs - OPEN_EXISTING, // open existing pipe - 0, // default attributes - NULL); // no template file - - /* If we have a valid pipe handle, break from the loop */ - if (pipe != INVALID_HANDLE_VALUE) { - break; - } - - /* We can get here if the pipe is busy, i.e. if the server hasn't - * create a new pipe instance to service our request. In which case - * GetLastError() will return ERROR_PIPE_BUSY. - * - * If so, then use WaitNamedPipe() to wait for a decent time - * to try again. - */ - if (GetLastError() != ERROR_PIPE_BUSY) { - /* Not ERROR_PIPE_BUSY */ - ERR("%s: CreateFile failed: %d\n", __FUNCTION__, (int)GetLastError()); - errno = EINVAL; - return -1; - } - - /* Wait for 5 seconds */ - if ( !WaitNamedPipe(addr, 5000) ) { - ERR("%s: WaitNamedPipe failed: %d\n", __FUNCTION__, (int)GetLastError()); - errno = EINVAL; - return -1; - } - } - - m_pipe = pipe; - return 0; -} - -/* Special buffer methods, since we can't use socket functions here */ - -int Win32PipeStream::commitBuffer(size_t size) -{ - if (m_pipe == INVALID_HANDLE_VALUE) - return -1; - - size_t res = size; - int retval = 0; - - while (res > 0) { - DWORD written; - if (! ::WriteFile(m_pipe, (const char *)m_buf + (size - res), res, &written, NULL)) { - retval = -1; - ERR("%s: failed: %d\n", __FUNCTION__, (int)GetLastError()); - break; - } - res -= written; - } - return retval; -} - -const unsigned char *Win32PipeStream::readFully(void *buf, size_t len) -{ - if (m_pipe == INVALID_HANDLE_VALUE) - return NULL; - - if (!buf) { - return NULL; // do not allow NULL buf in that implementation - } - - size_t res = len; - while (res > 0) { - DWORD readcount = 0; - if (! ::ReadFile(m_pipe, (char *)buf + (len - res), res, &readcount, NULL) || readcount == 0) { - errno = (int)GetLastError(); - return NULL; - } - res -= readcount; - } - return (const unsigned char *)buf; -} - -const unsigned char *Win32PipeStream::read( void *buf, size_t *inout_len) -{ - size_t len = *inout_len; - DWORD readcount; - - if (m_pipe == INVALID_HANDLE_VALUE) - return NULL; - - if (!buf) { - return NULL; // do not allow NULL buf in that implementation - } - - if (!::ReadFile(m_pipe, (char *)buf, len, &readcount, NULL)) { - errno = (int)GetLastError(); - return NULL; - } - - *inout_len = (size_t)readcount; - return (const unsigned char *)buf; -} diff --git a/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.h b/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.h deleted file mode 100644 index 0897e55..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -* 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 __WIN32_PIPE_STREAM_H -#define __WIN32_PIPE_STREAM_H - -#include "SocketStream.h" -#include <windows.h> - -class Win32PipeStream : public SocketStream { -public: - explicit Win32PipeStream(size_t bufsize = 10000); - virtual ~Win32PipeStream(); - virtual int listen(char addrstr[MAX_ADDRSTR_LEN]); - virtual SocketStream *accept(); - virtual int connect(const char* addr); - - virtual int commitBuffer(size_t size); - virtual const unsigned char *readFully(void *buf, size_t len); - virtual const unsigned char *read(void *buf, size_t *inout_len); - -private: - Win32PipeStream(HANDLE pipe, size_t bufSize); - HANDLE m_pipe; - int m_port; -}; - - -#endif diff --git a/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h b/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h deleted file mode 100644 index f19f514..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -* 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 _CODEC_DEFS_H -#define _CODEC_DEFS_H - -#define CODEC_SERVER_PORT 22468 - -#define CODEC_MAX_VERTEX_ATTRIBUTES 64 - -#endif diff --git a/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp b/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp deleted file mode 100644 index 4b7fc89..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* -* 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. -*/ -#include "glUtils.h" -#include <string.h> -#include "ErrorLog.h" -#include <IOStream.h> - -size_t glSizeof(GLenum type) -{ - size_t retval = 0; - switch(type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - retval = 1; - break; - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_HALF_FLOAT_OES: - retval = 2; - break; - case GL_INT: - case GL_FLOAT: - case GL_FIXED: - case GL_BOOL: - retval = 4; - break; -#ifdef GL_DOUBLE - case GL_DOUBLE: - retval = 8; - break; -#endif - case GL_FLOAT_VEC2: - case GL_INT_VEC2: - case GL_BOOL_VEC2: - retval = 8; - break; - case GL_INT_VEC3: - case GL_BOOL_VEC3: - case GL_FLOAT_VEC3: - retval = 12; - break; - case GL_FLOAT_VEC4: - case GL_BOOL_VEC4: - case GL_INT_VEC4: - case GL_FLOAT_MAT2: - retval = 16; - break; - case GL_FLOAT_MAT3: - retval = 36; - break; - case GL_FLOAT_MAT4: - retval = 64; - break; - case GL_SAMPLER_2D: - case GL_SAMPLER_CUBE: - retval = 4; - break; - default: - ERR("**** ERROR unknown type 0x%x (%s,%d)\n", type, __FUNCTION__,__LINE__); - } - return retval; - -} - -size_t glUtilsParamSize(GLenum param) -{ - size_t s = 0; - - switch(param) - { - case GL_DEPTH_TEST: - case GL_DEPTH_FUNC: - case GL_DEPTH_BITS: - case GL_MAX_CLIP_PLANES: - case GL_GREEN_BITS: - case GL_MAX_MODELVIEW_STACK_DEPTH: - case GL_MAX_PROJECTION_STACK_DEPTH: - case GL_MAX_TEXTURE_STACK_DEPTH: - case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: - case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: - case GL_NUM_COMPRESSED_TEXTURE_FORMATS: - case GL_MAX_TEXTURE_SIZE: - case GL_TEXTURE_GEN_MODE_OES: - case GL_TEXTURE_ENV_MODE: - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_SPOT_EXPONENT: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - case GL_SHININESS: - case GL_LIGHT_MODEL_TWO_SIDE: - case GL_POINT_SIZE: - case GL_POINT_SIZE_MIN: - case GL_POINT_SIZE_MAX: - case GL_POINT_FADE_THRESHOLD_SIZE: - case GL_CULL_FACE_MODE: - case GL_FRONT_FACE: - case GL_SHADE_MODEL: - case GL_DEPTH_WRITEMASK: - case GL_DEPTH_CLEAR_VALUE: - case GL_STENCIL_FAIL: - case GL_STENCIL_PASS_DEPTH_FAIL: - case GL_STENCIL_PASS_DEPTH_PASS: - case GL_STENCIL_REF: - case GL_STENCIL_WRITEMASK: - case GL_MATRIX_MODE: - case GL_MODELVIEW_STACK_DEPTH: - case GL_PROJECTION_STACK_DEPTH: - case GL_TEXTURE_STACK_DEPTH: - case GL_ALPHA_TEST_FUNC: - case GL_ALPHA_TEST_REF: - case GL_ALPHA_TEST: - case GL_BLEND_DST: - case GL_BLEND_SRC: - case GL_BLEND: - case GL_LOGIC_OP_MODE: - case GL_SCISSOR_TEST: - case GL_MAX_TEXTURE_UNITS: - case GL_ACTIVE_TEXTURE: - case GL_ALPHA_BITS: - case GL_ARRAY_BUFFER_BINDING: - case GL_BLUE_BITS: - case GL_CLIENT_ACTIVE_TEXTURE: - case GL_CLIP_PLANE0: - case GL_CLIP_PLANE1: - case GL_CLIP_PLANE2: - case GL_CLIP_PLANE3: - case GL_CLIP_PLANE4: - case GL_CLIP_PLANE5: - case GL_COLOR_ARRAY: - case GL_COLOR_ARRAY_BUFFER_BINDING: - case GL_COLOR_ARRAY_SIZE: - case GL_COLOR_ARRAY_STRIDE: - case GL_COLOR_ARRAY_TYPE: - case GL_COLOR_LOGIC_OP: - case GL_COLOR_MATERIAL: - case GL_PACK_ALIGNMENT: - case GL_PERSPECTIVE_CORRECTION_HINT: - case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: - case GL_POINT_SIZE_ARRAY_STRIDE_OES: - case GL_POINT_SIZE_ARRAY_TYPE_OES: - case GL_POINT_SMOOTH: - case GL_POINT_SMOOTH_HINT: - case GL_POINT_SPRITE_OES: - case GL_COORD_REPLACE_OES: - case GL_COMBINE_ALPHA: - case GL_SRC0_RGB: - case GL_SRC1_RGB: - case GL_SRC2_RGB: - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - case GL_SRC0_ALPHA: - case GL_SRC1_ALPHA: - case GL_SRC2_ALPHA: - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - case GL_RGB_SCALE: - case GL_ALPHA_SCALE: - case GL_COMBINE_RGB: - case GL_POLYGON_OFFSET_FACTOR: - case GL_POLYGON_OFFSET_FILL: - case GL_POLYGON_OFFSET_UNITS: - case GL_RED_BITS: - case GL_RESCALE_NORMAL: - case GL_SAMPLE_ALPHA_TO_COVERAGE: - case GL_SAMPLE_ALPHA_TO_ONE: - case GL_SAMPLE_BUFFERS: - case GL_SAMPLE_COVERAGE: - case GL_SAMPLE_COVERAGE_INVERT: - case GL_SAMPLE_COVERAGE_VALUE: - case GL_SAMPLES: - case GL_STENCIL_BITS: - case GL_STENCIL_CLEAR_VALUE: - case GL_STENCIL_FUNC: - case GL_STENCIL_TEST: - case GL_STENCIL_VALUE_MASK: - case GL_STENCIL_BACK_FUNC: - case GL_STENCIL_BACK_VALUE_MASK: - case GL_STENCIL_BACK_REF: - case GL_STENCIL_BACK_FAIL: - case GL_STENCIL_BACK_PASS_DEPTH_FAIL: - case GL_STENCIL_BACK_PASS_DEPTH_PASS: - case GL_STENCIL_BACK_WRITEMASK: - case GL_TEXTURE_2D: - case GL_TEXTURE_BINDING_2D: - case GL_TEXTURE_BINDING_CUBE_MAP: - case GL_TEXTURE_BINDING_EXTERNAL_OES: - case GL_TEXTURE_COORD_ARRAY: - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: - case GL_TEXTURE_COORD_ARRAY_SIZE: - case GL_TEXTURE_COORD_ARRAY_STRIDE: - case GL_TEXTURE_COORD_ARRAY_TYPE: - case GL_UNPACK_ALIGNMENT: - case GL_VERTEX_ARRAY: - case GL_VERTEX_ARRAY_BUFFER_BINDING: - case GL_VERTEX_ARRAY_SIZE: - case GL_VERTEX_ARRAY_STRIDE: - case GL_VERTEX_ARRAY_TYPE: - case GL_SPOT_CUTOFF: - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_GENERATE_MIPMAP: - case GL_GENERATE_MIPMAP_HINT: - case GL_RENDERBUFFER_WIDTH_OES: - case GL_RENDERBUFFER_HEIGHT_OES: - case GL_RENDERBUFFER_INTERNAL_FORMAT_OES: - case GL_RENDERBUFFER_RED_SIZE_OES: - case GL_RENDERBUFFER_GREEN_SIZE_OES: - case GL_RENDERBUFFER_BLUE_SIZE_OES: - case GL_RENDERBUFFER_ALPHA_SIZE_OES: - case GL_RENDERBUFFER_DEPTH_SIZE_OES: - case GL_RENDERBUFFER_STENCIL_SIZE_OES: - case GL_RENDERBUFFER_BINDING: - case GL_FRAMEBUFFER_BINDING: - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES: - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES: - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES: - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES: - case GL_FENCE_STATUS_NV: - case GL_FENCE_CONDITION_NV: - case GL_TEXTURE_WIDTH_QCOM: - case GL_TEXTURE_HEIGHT_QCOM: - case GL_TEXTURE_DEPTH_QCOM: - case GL_TEXTURE_INTERNAL_FORMAT_QCOM: - case GL_TEXTURE_FORMAT_QCOM: - case GL_TEXTURE_TYPE_QCOM: - case GL_TEXTURE_IMAGE_VALID_QCOM: - case GL_TEXTURE_NUM_LEVELS_QCOM: - case GL_TEXTURE_TARGET_QCOM: - case GL_TEXTURE_OBJECT_VALID_QCOM: - case GL_BLEND_EQUATION_RGB_OES: - case GL_BLEND_EQUATION_ALPHA_OES: - case GL_BLEND_DST_RGB_OES: - case GL_BLEND_SRC_RGB_OES: - case GL_BLEND_DST_ALPHA_OES: - case GL_BLEND_SRC_ALPHA_OES: - case GL_MAX_LIGHTS: - case GL_SHADER_TYPE: - case GL_DELETE_STATUS: - case GL_COMPILE_STATUS: - case GL_INFO_LOG_LENGTH: - case GL_SHADER_SOURCE_LENGTH: - case GL_CURRENT_PROGRAM: - case GL_LINK_STATUS: - case GL_VALIDATE_STATUS: - case GL_ATTACHED_SHADERS: - case GL_ACTIVE_UNIFORMS: - case GL_ACTIVE_ATTRIBUTES: - case GL_SUBPIXEL_BITS: - case GL_MAX_CUBE_MAP_TEXTURE_SIZE: - case GL_NUM_SHADER_BINARY_FORMATS: - case GL_SHADER_COMPILER: - case GL_MAX_VERTEX_ATTRIBS: - case GL_MAX_VERTEX_UNIFORM_VECTORS: - case GL_MAX_VARYING_VECTORS: - case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: - case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: - case GL_MAX_FRAGMENT_UNIFORM_VECTORS: - case GL_MAX_RENDERBUFFER_SIZE: - case GL_MAX_TEXTURE_IMAGE_UNITS: - case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: - case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: - case GL_LINE_WIDTH: - s = 1; - break; - case GL_ALIASED_LINE_WIDTH_RANGE: - case GL_ALIASED_POINT_SIZE_RANGE: - case GL_DEPTH_RANGE: - case GL_MAX_VIEWPORT_DIMS: - case GL_SMOOTH_POINT_SIZE_RANGE: - case GL_SMOOTH_LINE_WIDTH_RANGE: - s= 2; - break; - case GL_SPOT_DIRECTION: - case GL_POINT_DISTANCE_ATTENUATION: - case GL_CURRENT_NORMAL: - s = 3; - break; - case GL_CURRENT_VERTEX_ATTRIB: - case GL_CURRENT_TEXTURE_COORDS: - case GL_CURRENT_COLOR: - case GL_FOG_COLOR: - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_EMISSION: - case GL_POSITION: - case GL_LIGHT_MODEL_AMBIENT: - case GL_TEXTURE_ENV_COLOR: - case GL_SCISSOR_BOX: - case GL_VIEWPORT: - case GL_TEXTURE_CROP_RECT_OES: - case GL_COLOR_CLEAR_VALUE: - case GL_COLOR_WRITEMASK: - case GL_AMBIENT_AND_DIFFUSE: - case GL_BLEND_COLOR: - s = 4; - break; - case GL_MODELVIEW_MATRIX: - case GL_PROJECTION_MATRIX: - case GL_TEXTURE_MATRIX: - s = 16; - break; - default: - ERR("glUtilsParamSize: unknow param 0x%08x\n", param); - s = 1; // assume 1 - } - return s; -} - -void glUtilsPackPointerData(unsigned char *dst, unsigned char *src, - int size, GLenum type, unsigned int stride, - unsigned int datalen) -{ - unsigned int vsize = size * glSizeof(type); - if (stride == 0) stride = vsize; - - if (stride == vsize) { - memcpy(dst, src, datalen); - } else { - for (unsigned int i = 0; i < datalen; i += vsize) { - memcpy(dst, src, vsize); - dst += vsize; - src += stride; - } - } -} - -void glUtilsWritePackPointerData(void* _stream, unsigned char *src, - int size, GLenum type, unsigned int stride, - unsigned int datalen) -{ - IOStream* stream = reinterpret_cast<IOStream*>(_stream); - - unsigned int vsize = size * glSizeof(type); - if (stride == 0) stride = vsize; - - if (stride == vsize) { - stream->writeFully(src, datalen); - } else { - for (unsigned int i = 0; i < datalen; i += vsize) { - stream->writeFully(src, (size_t)vsize); - src += stride; - } - } -} - -int glUtilsPixelBitSize(GLenum format, GLenum type) -{ - int components = 0; - int componentsize = 0; - int pixelsize = 0; - switch(type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - componentsize = 8; - break; - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_RGB565_OES: - case GL_RGB5_A1_OES: - case GL_RGBA4_OES: - pixelsize = 16; - break; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_FIXED: - case GL_UNSIGNED_INT_24_8_OES: - pixelsize = 32; - break; - default: - ERR("glUtilsPixelBitSize: unknown pixel type - assuming pixel data 0\n"); - componentsize = 0; - } - - if (pixelsize == 0) { - switch(format) { -#if 0 - case GL_RED: - case GL_GREEN: - case GL_BLUE: -#endif - case GL_ALPHA: - case GL_LUMINANCE: - case GL_DEPTH_COMPONENT: - case GL_DEPTH_STENCIL_OES: - components = 1; - break; - case GL_LUMINANCE_ALPHA: - components = 2; - break; - case GL_RGB: -#if 0 - case GL_BGR: -#endif - components = 3; - break; - case GL_RGBA: - case GL_BGRA_EXT: - components = 4; - break; - default: - ERR("glUtilsPixelBitSize: unknown pixel format...\n"); - components = 0; - } - pixelsize = components * componentsize; - } - - return pixelsize; -} - -// pack a list of strings into one. -void glUtilsPackStrings(char *ptr, char **strings, GLint *length, GLsizei count) -{ - char *p = ptr; - *p = '\0'; - for (int i = 0; i < count; i++) { - int l=0; - if (strings[i]!=NULL) { - if (length == NULL || length[i] < 0) { - l = strlen(strings[i]); - strcat(p, strings[i]); - } else { - l = length[i]; - strncat(p, strings[i], l); - } - } - p += l; - } -} - -// claculate the length of a list of strings -int glUtilsCalcShaderSourceLen( char **strings, GLint *length, GLsizei count) -{ - int len = 0; - for (int i = 0; i < count; i++) { - int l; - if (length == NULL || length[i] < 0) { - l = strings[i]!=NULL ? strlen(strings[i]) : 0; - } else { - l = length[i]; - } - len += l; - } - return len; - -} diff --git a/emulator/opengl/shared/OpenglCodecCommon/glUtils.h b/emulator/opengl/shared/OpenglCodecCommon/glUtils.h deleted file mode 100644 index f8857f1..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/glUtils.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -* 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 <stdio.h> -#include <stdlib.h> - -#ifdef GL_API - #undef GL_API -#endif -#define GL_API - -#ifdef GL_APIENTRY - #undef GL_APIENTRY -#endif - -#ifdef GL_APIENTRYP - #undef GL_APIENTRYP -#endif -#define GL_APIENTRYP - -#ifndef ANDROID -#define GL_APIENTRY -#endif - -#include <GLES/gl.h> -#include <GLES/glext.h> -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> - -#ifdef __cplusplus -extern "C" { -#endif - - size_t glSizeof(GLenum type); - size_t glUtilsParamSize(GLenum param); - void glUtilsPackPointerData(unsigned char *dst, unsigned char *str, - int size, GLenum type, unsigned int stride, - unsigned int datalen); - void glUtilsWritePackPointerData(void* stream, unsigned char *src, - int size, GLenum type, unsigned int stride, - unsigned int datalen); - int glUtilsPixelBitSize(GLenum format, GLenum type); - void glUtilsPackStrings(char *ptr, char **strings, GLint *length, GLsizei count); - int glUtilsCalcShaderSourceLen(char **strings, GLint *length, GLsizei count); -#ifdef __cplusplus -}; -#endif - -namespace GLUtils { - - template <class T> void minmax(T *indices, int count, int *min, int *max) { - *min = -1; - *max = -1; - T *ptr = indices; - for (int i = 0; i < count; i++) { - if (*min == -1 || *ptr < *min) *min = *ptr; - if (*max == -1 || *ptr > *max) *max = *ptr; - ptr++; - } - } - - template <class T> void shiftIndices(T *indices, int count, int offset) { - T *ptr = indices; - for (int i = 0; i < count; i++) { - *ptr += offset; - ptr++; - } - } - - - template <class T> void shiftIndices(T *src, T *dst, int count, int offset) - { - for (int i = 0; i < count; i++) { - *dst = *src + offset; - dst++; - src++; - } - } -}; // namespace GLUtils -#endif diff --git a/emulator/opengl/shared/OpenglCodecCommon/gl_base_types.h b/emulator/opengl/shared/OpenglCodecCommon/gl_base_types.h deleted file mode 100644 index d7bdef8..0000000 --- a/emulator/opengl/shared/OpenglCodecCommon/gl_base_types.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -* 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_BASE_TYPES__H -#define __GL_BASE_TYPES__H - -#include <KHR/khrplatform.h> - -#ifndef gl_APIENTRY -#define gl_APIENTRY KHRONOS_APIENTRY -#endif - -#ifndef gl2_APIENTRY -#define gl2_APIENTRY KHRONOS_APIENTRY -#endif - -typedef void GLvoid; -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef char GLchar; -typedef khronos_int8_t GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef khronos_float_t GLfloat; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; -typedef khronos_int32_t GLclampx; -typedef khronos_intptr_t GLintptr; -typedef khronos_ssize_t GLsizeiptr; -typedef char *GLstr; -/* JR XXX Treating this as an in handle - is this correct? */ -typedef void * GLeglImageOES; - -/* ErrorCode */ -#ifndef GL_INVALID_ENUM -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 -#endif - -#endif diff --git a/emulator/opengl/shared/emugl/common/Android.mk b/emulator/opengl/shared/emugl/common/Android.mk deleted file mode 100644 index f481c0c..0000000 --- a/emulator/opengl/shared/emugl/common/Android.mk +++ /dev/null @@ -1,71 +0,0 @@ -# This build script corresponds to a library containing many definitions -# common to both the guest and the host. They relate to -# -LOCAL_PATH := $(call my-dir) - -### emugl_common host library ########################################### - -commonSources := \ - id_to_object_map.cpp \ - lazy_instance.cpp \ - pod_vector.cpp \ - shared_library.cpp \ - smart_ptr.cpp \ - sockets.cpp \ - thread_store.cpp \ - -host_commonSources := $(commonSources) - -host_commonLdLibs := -lstdc++ - -ifneq (windows,$(HOST_OS)) - host_commonSources += thread_pthread.cpp - host_commonLdLibs += -ldl -lpthread -else - host_commonSources += thread_win32.cpp -endif - -$(call emugl-begin-host-static-library,libemugl_common) -LOCAL_SRC_FILES := $(host_commonSources) -$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/shared) -$(call emugl-export,LDLIBS,$(host_commonLdLibs)) -$(call emugl-end-module) - -$(call emugl-begin-host64-static-library,lib64emugl_common) -LOCAL_SRC_FILES := $(host_commonSources) -$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/shared) -$(call emugl-export,LDLIBS,$(host_commonLdLibs)) -$(call emugl-end-module) - - -### emugl_common_unittests ############################################## - -host_commonSources := \ - id_to_object_map_unittest.cpp \ - lazy_instance_unittest.cpp \ - pod_vector_unittest.cpp \ - mutex_unittest.cpp \ - shared_library_unittest.cpp \ - smart_ptr_unittest.cpp \ - thread_store_unittest.cpp \ - thread_unittest.cpp \ - unique_integer_map_unittest.cpp \ - -$(call emugl-begin-host-executable,emugl_common_host_unittests) -LOCAL_SRC_FILES := $(host_commonSources) -$(call emugl-import,libemugl_common libemugl_gtest) -$(call emugl-end-module) - -$(call emugl-begin-host64-executable,emugl64_common_host_unittests) -LOCAL_SRC_FILES := $(host_commonSources) -$(call emugl-import,lib64emugl_common lib64emugl_gtest) -$(call emugl-end-module) - - -$(call emugl-begin-host-shared-library,libemugl_test_shared_library) -LOCAL_SRC_FILES := testing/test_shared_library.cpp -$(call emugl-end-module) - -$(call emugl-begin-host64-shared-library,lib64emugl_test_shared_library) -LOCAL_SRC_FILES := testing/test_shared_library.cpp -$(call emugl-end-module) diff --git a/emulator/opengl/shared/emugl/common/id_to_object_map.cpp b/emulator/opengl/shared/emugl/common/id_to_object_map.cpp deleted file mode 100644 index 597c9eb..0000000 --- a/emulator/opengl/shared/emugl/common/id_to_object_map.cpp +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/id_to_object_map.h" - -#include <stdlib.h> - -namespace emugl { - -namespace { - -typedef IdToObjectMapBase::KeyType KeyType; - -enum { - kMinShift = 3, - kMaxShift = 31, - kMinCapacity = (1 << kMinShift), - kLoadScale = 1024, - kMinLoad = kLoadScale/4, // 25% minimum load. - kMaxLoad = kLoadScale*3/4, // 75% maximum load. - - kInvalidKey = IdToObjectMapBase::kMaxId + 1U, - kTombstone = IdToObjectMapBase::kMaxId + 2U, -}; - -// Return a number that indicates if the current |capacity| is appropriate -// to hold |size| items in our map. -// -1 -> the capacity is too small and needs to be increased. -// 0 -> the capacity is ok. -// +1 -> the capacity is too large and needs to be decreased. -int capacityCompare(size_t shift, size_t size) { - size_t capacity = 1U << shift; - // Essentially, one can rewrite: - // load < minLoad - // as: - // size / capacity < minLoad - // capacity * minLoad > size - if (capacity * kMinLoad > size * kLoadScale) - return +1; - - // Similarly, one can rewrite: - // load > maxLoad - // as: - // size / capacity > maxLoad - // capacity * maxLoad < size - if (capacity * kMaxLoad < size * kLoadScale) - return -1; - - return 0; -} - -size_t probeKeys(const KeyType* keys, size_t shift, KeyType key) { - static const int kPrimes[] = { - 1, /* For 1 << 0 */ - 2, - 3, - 7, - 13, - 31, - 61, - 127, - 251, - 509, - 1021, - 2039, - 4093, - 8191, - 16381, - 32749, - 65521, /* For 1 << 16 */ - 131071, - 262139, - 524287, - 1048573, - 2097143, - 4194301, - 8388593, - 16777213, - 33554393, - 67108859, - 134217689, - 268435399, - 536870909, - 1073741789, - 2147483647 /* For 1 << 31 */ - }; - - size_t slot = key % kPrimes[shift]; - size_t step = 0; - for (;;) { - KeyType k = keys[slot]; - if (k == kInvalidKey || k == kTombstone || k == key) - return slot; - - step += 1; - slot = (slot + step) & (1U << shift); - } -} - -} // namespace - -IdToObjectMapBase::IdToObjectMapBase() : - mCount(0), mShift(kMinShift) { - size_t capacity = 1U << mShift; - mKeys = static_cast<KeyType*>(::calloc(sizeof(mKeys[0]), capacity)); - mValues = static_cast<void**>(::calloc(sizeof(mValues[0]), capacity)); - for (size_t n = 0; n < capacity; ++n) { - mKeys[n] = kInvalidKey; - } -} - -IdToObjectMapBase::~IdToObjectMapBase() { - mShift = 0; - mCount = 0; - ::free(mKeys); - ::free(mValues); -} - -bool IdToObjectMapBase::contains(KeyType key) const { - size_t slot = probeKeys(mKeys, mShift, key); - switch (mKeys[slot]) { - case kInvalidKey: - case kTombstone: - return false; - default: - ; - } - return true; -} - -bool IdToObjectMapBase::find(KeyType key, void** value) const { - size_t slot = probeKeys(mKeys, mShift, key); - if (!isValidKey(mKeys[slot])) { - *value = NULL; - return false; - } - *value = mValues[slot]; - return true; -} - -void* IdToObjectMapBase::set(KeyType key, void* value) { - if (!value) - return remove(key); - - size_t slot = probeKeys(mKeys, mShift, key); - void* result; - if (isValidKey(mKeys[slot])) { - result = mValues[slot]; - mValues[slot] = value; - } else { - mKeys[slot] = key; - mValues[slot] = value; - result = NULL; - mCount++; - resize(mCount); - } - return result; -} - -void* IdToObjectMapBase::remove(KeyType key) { - size_t slot = probeKeys(mKeys, mShift, key); - if (!isValidKey(mKeys[slot])) - return NULL; - - void* result = mValues[slot]; - mValues[slot] = NULL; - mKeys[slot] = kTombstone; - mCount--; - return result; -} - -void IdToObjectMapBase::resize(size_t newSize) { - int ret = capacityCompare(mShift, newSize); - if (!ret) - return; - - size_t oldCapacity = 1U << mShift; - size_t newShift = mShift; - - if (ret < 0) { - // Capacity is too small and must be increased. - do { - if (newShift == kMaxShift) - break; - ++newShift; - } while (capacityCompare(newShift, newSize) < 0); - } else { - // Capacity is too large and must be decreased. - do { - if (newShift == kMinShift) - break; - newShift--; - } while (capacityCompare(newShift, newSize) > 0); - } - if (newShift == mShift) - return; - - // Allocate new arrays. - size_t newCapacity = 1U << newShift; - KeyType* newKeys = static_cast<KeyType*>( - ::calloc(sizeof(newKeys[0]), newCapacity)); - void** newValues = static_cast<void**>( - ::calloc(sizeof(newValues[0]), newCapacity)); - for (size_t n = 0; n < newCapacity; ++n) - newKeys[n] = kInvalidKey; - - // Copy old entries into new arrays. - for (size_t n = 0; n < oldCapacity; ++n) { - KeyType key = mKeys[n]; - if (isValidKey(key)) { - size_t newSlot = probeKeys(newKeys, newShift, key); - newKeys[newSlot] = key; - newValues[newSlot] = mValues[n]; - } - } - - // Swap arrays, and get rid of old ones. - ::free(mKeys); - ::free(mValues); - mKeys = newKeys; - mValues = newValues; - mShift = newShift; -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/id_to_object_map.h b/emulator/opengl/shared/emugl/common/id_to_object_map.h deleted file mode 100644 index e3d0a81..0000000 --- a/emulator/opengl/shared/emugl/common/id_to_object_map.h +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_ID_TO_OBJECT_MAP_H -#define EMUGL_COMMON_ID_TO_OBJECT_MAP_H - -#include <stddef.h> - -namespace emugl { - -// Base implementation class for IdToObjectMap template. -// Used to reduce template-instanciated code generation. -class IdToObjectMapBase { -public: - // The type of keys in this map. - typedef unsigned KeyType; - - // Values higher than kMaxId cannot be used as map keys. - enum { - kMaxId = 0xfffffffdU, - }; - - static inline bool isValidKey(KeyType key) { - return key <= kMaxId; - } - -protected: - IdToObjectMapBase(); - - ~IdToObjectMapBase(); - - void clear(); - - // Return size - inline size_t size() const { return mCount; } - - inline size_t capacity() const { return 1U << mShift; } - - // Return true iff the map contains a given key. - bool contains(KeyType key) const; - - // Find a value associated with a given |key| in the map. - // On success, return true and sets |*value| to the value/pointer, - // which is _still_ owned by the map. - // On failure, return false and sets |*value| to NULL. - bool find(KeyType key, void** value) const; - - // Associate a value with a given |key| in the map. - // Return the old value for the key, if any. Caller is responsible - // for freeing it. - void* set(KeyType key, void* value); - - // Remove the value associated with a given |key|. - // Return the old value, if any. Caller is responsible for - // freeing it. - void* remove(KeyType key); - - size_t mCount; - size_t mShift; - KeyType* mKeys; - void** mValues; - -private: - // Resize the map if needed to ensure it can hold at least |newSize| - // entries. - void resize(size_t newSize); -}; - -// A templated data container that acts as a dictionary mapping unsigned -// integer keys to heap-allocated objects of type T. The dictionary -// owns the objects associated with its keys, and automatically destroys -// them when it is destroyed, or during replacement or removal. -template <class T> -class IdToObjectMap : public IdToObjectMapBase { -public: - // Initialize an empty instance. - IdToObjectMap() : IdToObjectMapBase() {} - - // Destroy this instance. - ~IdToObjectMap() { - clear(); - } - - // Return the number of items in this map. - inline size_t size() const { return IdToObjectMapBase::size(); } - - // Return true iff the map is empty. - inline bool empty() const { return !IdToObjectMapBase::size(); } - - // Remove all items from the map. - void clear(); - - // Returns true iff the dictionary contains a value for |key|. - inline bool contains(KeyType key) const { - return IdToObjectMapBase::contains(key); - } - - // Find the value corresponding to |key| in this map. - // On success, return true, and sets |*value| to point to the - // value (still owned by the instance). On failure, return false. - inline bool find(KeyType key, T** value) const { - return IdToObjectMapBase::find(key, reinterpret_cast<void**>(value)); - } - - // Return the value associated with a given |key|, or NULL if it is - // not in the map. Result is still owned by the map. - inline T* get(KeyType key) const { - T* result = NULL; - this->find(key, &result); - return result; - } - - // Associate |value| with a given |key|. Returns true if a previous - // value was replaced, and false if this is the first time a value - // was associated with the given key. IMPORTANT: This transfers - // ownership of |value| to the map instance. In case of replacement, - // the old value is automatically destroyed. Using NULL as the value - // is equivalent to calling remove(). - bool set(KeyType key, T* value); - - // Remove any value associated with |key|. - // Return true iff a value was associated with the key and destroyed - // by this function, false if there was no value associated with the - // key (or if it was NULL). - bool remove(KeyType key); -}; - -template <class T> -void IdToObjectMap<T>::clear() { - size_t n = capacity(); - while (n > 0) { - --n; - if (!isValidKey(mKeys[n])) - continue; - - delete static_cast<T*>(mValues[n]); - mValues[n] = NULL; - mKeys[n] = kMaxId + 1U; - } - mCount = 0; -} - -template <class T> -bool IdToObjectMap<T>::set(KeyType key, T* value) { - T* oldValue = static_cast<T*>(IdToObjectMapBase::set(key, value)); - if (!oldValue) { - return false; - } - delete oldValue; - return true; -} - -template <class T> -bool IdToObjectMap<T>::remove(KeyType key) { - T* oldValue = static_cast<T*>(IdToObjectMapBase::remove(key)); - if (!oldValue) - return false; - delete oldValue; - return true; -} - -} // namespace emugl - - -#endif // EMUGL_COMMON_ID_TO_OBJECT_MAP_H diff --git a/emulator/opengl/shared/emugl/common/id_to_object_map_unittest.cpp b/emulator/opengl/shared/emugl/common/id_to_object_map_unittest.cpp deleted file mode 100644 index 50740be..0000000 --- a/emulator/opengl/shared/emugl/common/id_to_object_map_unittest.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/id_to_object_map.h" - -#include <gtest/gtest.h> - -namespace emugl { - -namespace { - -typedef IdToObjectMapBase::KeyType KeyType; - -class Foo { -public: - Foo() : mVal(0) {} - Foo(int val) : mVal(val) {} - ~Foo() {} - int val() const { return mVal; } - void setVal(int val) { mVal = val; } -private: - int mVal; -}; - -} // namespace - -TEST(IdToObjectMap, Empty) { - IdToObjectMap<Foo> map; - EXPECT_TRUE(map.empty()); - EXPECT_EQ(0U, map.size()); -} - -TEST(IdToObjectMap, SetIntegerRange) { - IdToObjectMap<Foo> map; - KeyType kMax = 10000; - - // Add all items in the map. - for (KeyType n = 0; n < kMax; ++n) { - EXPECT_FALSE(map.set(n, new Foo(n))) << "For key " << n; - } - - // Check final size. - EXPECT_EQ(static_cast<size_t>(kMax), map.size()); - - // Find all items in the map. - for (KeyType n = 0; n < kMax; ++n) { - EXPECT_TRUE(map.contains(n)) << "For key " << n; - Foo* foo = NULL; - EXPECT_TRUE(map.find(n, &foo)) << "For key " << n; - if (foo) { - EXPECT_EQ(static_cast<int>(n), foo->val()) << "For key " << n; - } - } -} - -TEST(IdToObjectMap, RemoveAll) { - IdToObjectMap<Foo> map; - KeyType kMax = 10000; - - // Add all items in the map. - for (KeyType n = 0; n < kMax; ++n) { - EXPECT_FALSE(map.set(n, new Foo(n))) << "For key " << n; - } - - EXPECT_EQ(static_cast<size_t>(kMax), map.size()); - - for (KeyType n = 0; n < kMax; ++n) { - EXPECT_TRUE(map.remove(n)) << "For key " << n; - } - EXPECT_EQ(0U, map.size()); -} - -TEST(IdToObjectMap, RemoveOdd) { - IdToObjectMap<Foo> map; - KeyType kMax = 10000; - - // Add all items in the map. - for (KeyType n = 0; n < kMax; ++n) { - EXPECT_FALSE(map.set(n, new Foo(n))) << "For key " << n; - } - - EXPECT_EQ(static_cast<size_t>(kMax), map.size()); - - for (KeyType n = 0; n < kMax; ++n) { - if (n & 1) { - EXPECT_TRUE(map.remove(n)) << "For key " << n; - } - } - EXPECT_EQ(static_cast<size_t>(kMax / 2), map.size()); - - for (KeyType n = 0; n < kMax; ++n) { - if (n & 1) { - EXPECT_FALSE(map.contains(n)) << "For key " << n; - } else { - EXPECT_TRUE(map.contains(n)) << "For key " << n; - Foo* foo = NULL; - EXPECT_TRUE(map.find(n, &foo)) << "For key " << n; - if (foo) { - EXPECT_EQ(static_cast<int>(n), foo->val()); - } - } - } -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/lazy_instance.cpp b/emulator/opengl/shared/emugl/common/lazy_instance.cpp deleted file mode 100644 index ee715fa..0000000 --- a/emulator/opengl/shared/emugl/common/lazy_instance.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/lazy_instance.h" - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN 1 -# include <windows.h> -#else -# include <sched.h> -#endif - -namespace emugl { -namespace internal { - -typedef LazyInstanceState::AtomicType AtomicType; - -#if defined(__GNUC__) -static inline void compilerBarrier() { - __asm__ __volatile__ ("" : : : "memory"); -} -#else -#error "Your compiler is not supported" -#endif - -#if defined(__i386__) || defined(__x86_64__) -# define acquireBarrier() compilerBarrier() -# define releaseBarrier() compilerBarrier() -#else -# error "Your CPU is not supported" -#endif - -static inline AtomicType loadAcquire(AtomicType volatile* ptr) { - AtomicType ret = *ptr; - acquireBarrier(); - return ret; -} - -static inline void storeRelease(AtomicType volatile* ptr, AtomicType value) { - releaseBarrier(); - *ptr = value; -} - -static int atomicCompareAndSwap(AtomicType volatile* ptr, - int expected, - int value) { -#ifdef _WIN32 - return InterlockedCompareExchange(ptr, value, expected); -#elif defined(__GNUC__) - return __sync_val_compare_and_swap(ptr, expected, value); -#else -#error "Your compiler is not supported" -#endif -} - -static void yieldThread() { -#ifdef _WIN32 - ::Sleep(0); -#else - sched_yield(); -#endif -} - -bool LazyInstanceState::inInitState() { - return loadAcquire(&mState) == STATE_INIT; -} - -bool LazyInstanceState::needConstruction() { - AtomicType state = loadAcquire(&mState); - if (mState == STATE_DONE) - return false; - - state = atomicCompareAndSwap(&mState, STATE_INIT, STATE_CONSTRUCTING); - if (state == STATE_INIT) - return true; - - do { - yieldThread(); - state = loadAcquire(&mState); - } while (state != STATE_DONE); - - return false; -} - -void LazyInstanceState::doneConstructing() { - storeRelease(&mState, STATE_DONE); -} - -} // namespace internal -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/lazy_instance.h b/emulator/opengl/shared/emugl/common/lazy_instance.h deleted file mode 100644 index 6641c93..0000000 --- a/emulator/opengl/shared/emugl/common/lazy_instance.h +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_LAZY_INSTANCE_H -#define EMUGL_COMMON_LAZY_INSTANCE_H - -#include <new> - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN 1 -# include <windows.h> -#endif - -namespace emugl { -namespace internal { - -// A LazyInstance is a helper template that can be used to perform -// thread-safe lazy initialization of static C++ objects without forcing -// the generation of C++ static constructors in the final executable. -// -// In a nutshell, you can replace a statement like: -// -// static Foo gFoo; -// -// With: -// -// static LazyInstance<Foo> gFoo = LAZY_INSTANCE_INIT; -// -// In the first case, a hidden static C++ constructor is embedded in the -// final executable, and executed at *load* *time* to call the Foo::Foo -// constructor on the gFoo object. -// -// On the second case, gFoo will only be initialized lazily, i.e. the first -// time any code actually tries to access the variable. -// -// Note that access is slightly different, i.e.: -// -// gFoo.get() returns a reference to the lazy-initialized object. -// gFoo.ptr() returns a pointer to it. -// gFoo->Something() is equivalent to doing gFoo.ptr()->Something(). -// -// 'gFoo' is stored in the .bss section and this doesn't use heap allocation. -// This class can only be used to perform lazy initialization through the -// class' default constructor. For more specialized cases, you will have -// to create a derived class, e.g.: -// -// class FoorWithDefaultParams : public Foo { -// public: -// FooWithDefaultParams() : Foo(<default-parameters>) {} -// }; -// -// LazyInstance<FooWithDefaultParams> gFoo = LAZY_INSTANCE_INIT; -// -// The implementation of LazyInstance relies on atomic operations and -// POD-struct class definitions, i.e. one that doesn't have any constructor, -// destructor, virtual members, or private ones, and that can be -// zero-initialized at link time. -// -// You can also use LazyInstance<> instances as static local variables, -// e.g.: -// -// Foo* getFooSingleton() { -// static LazyInstance<Foo> sFoo = LAZY_INSTANCE_INIT; -// return sFoo.ptr(); -// } -// -// This is useful on Windows which doesn't support thread-safe lazy -// initialization of static C++ local variables, or when the code is -// compiled with -fno-threadsafe-statics. -// -// This class is heavily inspired by Chromium's implementation of the -// same-named class (see $CHROMIUM/src/base/lazy_instance.h). - -// Atomic state variable type. Used to ensure to synchronize concurrent -// initialization and access without incurring the full cost of a mutex -// lock/unlock. -struct LazyInstanceState { - enum { - STATE_INIT = 0, - STATE_CONSTRUCTING = 1, - STATE_DONE = 2, - }; - - bool inInitState(); - bool needConstruction(); - void doneConstructing(); - -#ifdef _WIN32 - typedef LONG volatile AtomicType; -#else - typedef int volatile AtomicType; -#endif - - volatile AtomicType mState; -}; - -#define LAZY_INSTANCE_STATE_INIT \ - { ::emugl::internal::LazyInstanceState::STATE_INIT } - -} // namespace internal - -// LazyInstance template definition, see comment above for usage -// instructions. It is crucial to make this a POD-struct compatible -// type [1]. -// -// [1] http://en.wikipedia.org/wiki/Plain_Old_Data_Structures -// -template <class T> -struct LazyInstance { - bool hasInstance() const { return !mState.inInitState(); } - - T& get() const { return *ptr(); } - - T* ptr() const; - - const T* operator->() const { return ptr(); } - - T* operator->() { return ptr(); } - - T& operator*() { return get(); } - - // Really private, do not use. - union { - mutable internal::LazyInstanceState mState; - double mPadding; - }; - mutable char mStorage[sizeof(T)]; -}; - -// Initialization value, must resolve to all-0 to ensure the object -// instance is actually placed in the .bss -#define LAZY_INSTANCE_INIT { { LAZY_INSTANCE_STATE_INIT }, { 0 } } - -template <class T> -T* LazyInstance<T>::ptr() const { - if (mState.needConstruction()) { - new (mStorage) T(); - mState.doneConstructing(); - } - return reinterpret_cast<T*>(mStorage); -} - -} // namespace emugl - -#endif // EMUGL_COMMON_LAZY_INSTANCE_H diff --git a/emulator/opengl/shared/emugl/common/lazy_instance_unittest.cpp b/emulator/opengl/shared/emugl/common/lazy_instance_unittest.cpp deleted file mode 100644 index 824845f..0000000 --- a/emulator/opengl/shared/emugl/common/lazy_instance_unittest.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/lazy_instance.h" - -#include "emugl/common/mutex.h" -#include "emugl/common/testing/test_thread.h" - -#include <gtest/gtest.h> - -namespace emugl { - -namespace { - -class Foo { -public: - Foo() : mValue(42) {} - int get() const { return mValue; } - void set(int value) { mValue = value; } - ~Foo() { mValue = 13; } -private: - int mValue; -}; - -class StaticCounter { -public: - StaticCounter() { - Mutex::AutoLock lock(mMutex); - mCounter++; - } - - int getValue() const { - Mutex::AutoLock lock(mMutex); - return mCounter; - } - -private: - static Mutex mMutex; - static int mCounter; -}; - -// NOTE: This introduces a static C++ constructor for this object file, -// but that's ok because a LazyInstance<Mutex> should not be used to -// test the behaviour of LazyInstance :-) -Mutex StaticCounter::mMutex; -int StaticCounter::mCounter = 0; - -} // namespace - -TEST(LazyInstance, HasInstance) { - LazyInstance<Foo> foo_instance = LAZY_INSTANCE_INIT; - EXPECT_FALSE(foo_instance.hasInstance()); - EXPECT_FALSE(foo_instance.hasInstance()); - foo_instance.ptr(); - EXPECT_TRUE(foo_instance.hasInstance()); -} - -TEST(LazyInstance, Simple) { - LazyInstance<Foo> foo_instance = LAZY_INSTANCE_INIT; - Foo* foo1 = foo_instance.ptr(); - EXPECT_TRUE(foo1); - EXPECT_EQ(42, foo_instance->get()); - foo1->set(10); - EXPECT_EQ(10, foo_instance->get()); - EXPECT_EQ(foo1, foo_instance.ptr()); -} - -// For the following test, launch 1000 threads that each try to get -// the instance pointer of a lazy instance. Then verify that they're all -// the same value. -// -// The lazy instance has a special constructor that will increment a -// global counter. This allows us to ensure that it is only called once. -// - -namespace { - -// The following is the shared structure between all threads. -struct MultiState { - MultiState(LazyInstance<StaticCounter>* staticCounter) : - mMutex(), mStaticCounter(staticCounter), mCount(0) {} - - enum { - kMaxThreads = 1000, - }; - - Mutex mMutex; - LazyInstance<StaticCounter>* mStaticCounter; - size_t mCount; - void* mValues[kMaxThreads]; - TestThread* mThreads[kMaxThreads]; -}; - -// The thread function for the test below. -static void* threadFunc(void* param) { - MultiState* state = static_cast<MultiState*>(param); - Mutex::AutoLock lock(state->mMutex); - if (state->mCount < MultiState::kMaxThreads) { - state->mValues[state->mCount++] = state->mStaticCounter->ptr(); - } - return NULL; -} - -} // namespace - -TEST(LazyInstance, MultipleThreads) { - LazyInstance<StaticCounter> counter_instance = LAZY_INSTANCE_INIT; - MultiState state(&counter_instance); - const size_t kNumThreads = MultiState::kMaxThreads; - - // Create all threads. - for (size_t n = 0; n < kNumThreads; ++n) { - state.mThreads[n] = new TestThread(threadFunc, &state); - } - - // Wait for their completion. - for (size_t n = 0; n < kNumThreads; ++n) { - state.mThreads[n]->join(); - } - - // Now check that the constructor was only called once. - EXPECT_EQ(1, counter_instance->getValue()); - - // Now compare all the store values, they should be the same. - StaticCounter* expectedValue = counter_instance.ptr(); - for (size_t n = 0; n < kNumThreads; ++n) { - EXPECT_EQ(expectedValue, state.mValues[n]) << "For thread " << n; - } - - for (size_t n = 0; n < kNumThreads; ++n) { - delete state.mThreads[n]; - } -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/mutex.h b/emulator/opengl/shared/emugl/common/mutex.h deleted file mode 100644 index c6cdcf2..0000000 --- a/emulator/opengl/shared/emugl/common/mutex.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_MUTEX_H -#define EMUGL_MUTEX_H - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN 1 -# include <windows.h> -#else -# include <pthread.h> -#endif - -namespace emugl { - -// Simple wrapper class for mutexes. -class Mutex { -public: - // Constructor. - Mutex() { -#ifdef _WIN32 - ::InitializeCriticalSection(&mLock); -#else - ::pthread_mutex_init(&mLock, NULL); -#endif - } - - // Destructor. - ~Mutex() { -#ifdef _WIN32 - ::DeleteCriticalSection(&mLock); -#else - ::pthread_mutex_destroy(&mLock); -#endif - } - - // Acquire the mutex. - void lock() { -#ifdef _WIN32 - ::EnterCriticalSection(&mLock); -#else - ::pthread_mutex_lock(&mLock); -#endif - } - - // Release the mutex. - void unlock() { -#ifdef _WIN32 - ::LeaveCriticalSection(&mLock); -#else - ::pthread_mutex_unlock(&mLock); -#endif - } - - // Helper class to lock / unlock a mutex automatically on scope - // entry and exit. - class AutoLock { - public: - AutoLock(Mutex& mutex) : mMutex(&mutex) { - mMutex->lock(); - } - - ~AutoLock() { - mMutex->unlock(); - } - private: - Mutex* mMutex; - }; - -private: -#ifdef _WIN32 - CRITICAL_SECTION mLock; -#else - pthread_mutex_t mLock; -#endif - -}; - -} // namespace emugl - -#endif // EMUGL_MUTEX_H diff --git a/emulator/opengl/shared/emugl/common/mutex_unittest.cpp b/emulator/opengl/shared/emugl/common/mutex_unittest.cpp deleted file mode 100644 index e952d75..0000000 --- a/emulator/opengl/shared/emugl/common/mutex_unittest.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/mutex.h" - -#include "emugl/common/testing/test_thread.h" - -#include <gtest/gtest.h> - -namespace emugl { - -// Check that construction and destruction doesn't crash. -TEST(Mutex, ConstructionDestruction) { - Mutex lock; -} - -// Check that a simple lock + unlock works. -TEST(Mutex, LockUnlock) { - Mutex lock; - lock.lock(); - lock.unlock(); -} - -// Check that AutoLock compiles and doesn't crash. -TEST(Mutex, AutoLock) { - Mutex mutex; - Mutex::AutoLock lock(mutex); -} - -// Wrapper class for threads. Does not use emugl::Thread intentionally. -// Common data type used by the following tests below. -struct ThreadParams { - ThreadParams() : mutex(), counter(0) {} - - Mutex mutex; - int counter; -}; - -// This thread function uses Mutex::lock/unlock to synchronize a counter -// increment operation. -static void* threadFunction(void* param) { - ThreadParams* p = static_cast<ThreadParams*>(param); - - p->mutex.lock(); - p->counter++; - p->mutex.unlock(); - return NULL; -} - -TEST(Mutex, Synchronization) { - const size_t kNumThreads = 2000; - TestThread* threads[kNumThreads]; - ThreadParams p; - - // Create and launch all threads. - for (size_t n = 0; n < kNumThreads; ++n) { - threads[n] = new TestThread(threadFunction, &p); - } - - // Wait until their completion. - for (size_t n = 0; n < kNumThreads; ++n) { - threads[n]->join(); - delete threads[n]; - } - - EXPECT_EQ(static_cast<int>(kNumThreads), p.counter); -} - -// This thread function uses a Mutex::AutoLock to protect the counter. -static void* threadAutoLockFunction(void* param) { - ThreadParams* p = static_cast<ThreadParams*>(param); - - Mutex::AutoLock lock(p->mutex); - p->counter++; - return NULL; -} - -TEST(Mutex, AutoLockSynchronization) { - const size_t kNumThreads = 2000; - TestThread* threads[kNumThreads]; - ThreadParams p; - - // Create and launch all threads. - for (size_t n = 0; n < kNumThreads; ++n) { - threads[n] = new TestThread(threadAutoLockFunction, &p); - } - - // Wait until their completion. - for (size_t n = 0; n < kNumThreads; ++n) { - threads[n]->join(); - delete threads[n]; - } - - EXPECT_EQ(static_cast<int>(kNumThreads), p.counter); -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/pod_vector.cpp b/emulator/opengl/shared/emugl/common/pod_vector.cpp deleted file mode 100644 index c8ec3a6..0000000 --- a/emulator/opengl/shared/emugl/common/pod_vector.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/pod_vector.h" - -#include <stdlib.h> -#include <string.h> - -#define USE_MALLOC_USABLE_SIZE 0 - -namespace emugl { - -static inline void swapPointers(char** p1, char** p2) { - char* tmp = *p1; - *p1 = *p2; - *p2 = tmp; -} - -PodVectorBase::PodVectorBase(const PodVectorBase& other) { - initFrom(other.begin(), other.byteSize()); -} - -PodVectorBase& PodVectorBase::operator=(const PodVectorBase& other) { - initFrom(other.begin(), other.byteSize()); - return *this; -} - -PodVectorBase::~PodVectorBase() { - if (mBegin) { - // Sanity. - ::memset(mBegin, 0xee, byteSize()); - ::free(mBegin); - mBegin = NULL; - mEnd = NULL; - mLimit = NULL; - } -} - -void PodVectorBase::initFrom(const void* from, size_t fromLen) { - if (!fromLen || !from) { - mBegin = NULL; - mEnd = NULL; - mLimit = NULL; - } else { - mBegin = static_cast<char*>(::malloc(fromLen)); - mEnd = mLimit = mBegin + fromLen; - ::memcpy(mBegin, from, fromLen); - } -} - -void PodVectorBase::assignFrom(const PodVectorBase& other) { - resize(other.byteSize(), 1U); - ::memmove(begin(), other.begin(), byteSize()); -} - -void PodVectorBase::resize(size_t newSize, size_t itemSize) { - const size_t kMaxSize = maxItemCapacity(itemSize); - size_t oldCapacity = itemCapacity(itemSize); - const size_t kMinCapacity = 256 / itemSize; - - if (newSize < oldCapacity) { - // Only shrink if the new size is really small. - if (newSize < oldCapacity / 2 && oldCapacity > kMinCapacity) { - reserve(newSize, itemSize); - } - } else if (newSize > oldCapacity) { - size_t newCapacity = oldCapacity; - while (newCapacity < newSize) { - size_t newCapacity2 = newCapacity + (newCapacity >> 2) + 8; - if (newCapacity2 < newCapacity || newCapacity > kMaxSize) { - newCapacity = kMaxSize; - } else { - newCapacity = newCapacity2; - } - } - reserve(newCapacity, itemSize); - } - mEnd = mBegin + newSize * itemSize; -} - -void PodVectorBase::reserve(size_t newSize, size_t itemSize) { - if (newSize == 0) { - ::free(mBegin); - mBegin = NULL; - mEnd = NULL; - mLimit = NULL; - return; - } - - size_t oldByteSize = byteSize(); - size_t newByteCapacity = newSize * itemSize; - char* newBegin = static_cast<char*>(::realloc(mBegin, newByteCapacity)); - mBegin = newBegin; - mEnd = newBegin + oldByteSize; -#if USE_MALLOC_USABLE_SIZE - size_t usableSize = malloc_usable_size(mBegin); - if (usableSize > newByteCapacity) { - newByteCapacity = usableSize - (usableSize % itemSize); - } -#endif - mLimit = newBegin + newByteCapacity; - // Sanity. - if (newByteCapacity > oldByteSize) { - ::memset(mBegin + oldByteSize, 0, newByteCapacity - oldByteSize); - } -} - -void PodVectorBase::removeAt(size_t itemPos, size_t itemSize) { - size_t count = itemCount(itemSize); - if (itemPos < count) { - size_t pos = itemPos * itemSize; - ::memmove(mBegin + pos, - mBegin + pos + itemSize, - byteSize() - pos - itemSize); - resize(count - 1U, itemSize); - } -} - -void* PodVectorBase::insertAt(size_t itemPos, size_t itemSize) { - size_t count = this->itemCount(itemSize); - resize(count + 1, itemSize); - size_t pos = itemPos * itemSize; - if (itemPos < count) { - ::memmove(mBegin + pos + itemSize, - mBegin + pos, - count * itemSize - pos); - // Sanity to avoid copying pointers and other bad stuff. - ::memset(mBegin + pos, 0, itemSize); - } - return mBegin + pos; -} - -void PodVectorBase::swapAll(PodVectorBase* other) { - swapPointers(&mBegin, &other->mBegin); - swapPointers(&mEnd, &other->mEnd); - swapPointers(&mLimit, &other->mLimit); -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/pod_vector.h b/emulator/opengl/shared/emugl/common/pod_vector.h deleted file mode 100644 index c4e184b..0000000 --- a/emulator/opengl/shared/emugl/common/pod_vector.h +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_POD_VECTOR_H -#define EMUGL_COMMON_POD_VECTOR_H - - -#include <stddef.h> - -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS 1 -#endif -#include <stdint.h> - -#ifndef SIZE_MAX -#error "You must define __STDC_LIMIT_MACROS before including <stddint.h>" -#endif - -namespace emugl { - -// A PodVector is a templated vector-like type that is used to store -// POD-struct compatible items only. This allows the implementation to -// use ::memmove() to move items, and also malloc_usable_size() to -// determine the best capacity. -// -// std::vector<> is capable of doing this in theory, using horrible -// templating tricks that make error messages very difficult to -// understand. -// -// Note that a PodVector can be used to store items that contain pointers, -// as long as these do not point to items in the same container. -// -// The PodVector provides methods that also follow the std::vector<> -// conventions, i.e. push_back() is an alias for append(). -// - -// NOTE: This is a re-implementation of -// external/qemu/android/base/containers/PodVector.h for emugl. - -// PodVectorBase is a base, non-templated, implementation class that all -// PodVector instances derive from. This is used to reduce template -// specialization. Do not use directly, i..e it's an implementation detail. -class PodVectorBase { -protected: - PodVectorBase() : mBegin(NULL), mEnd(NULL), mLimit(NULL) {} - explicit PodVectorBase(const PodVectorBase& other); - PodVectorBase& operator=(const PodVectorBase& other); - ~PodVectorBase(); - - bool empty() const { return mEnd == mBegin; } - - size_t byteSize() const { return mEnd - mBegin; } - - size_t byteCapacity() const { return mLimit - mBegin; } - - void* begin() { return mBegin; } - const void* begin() const { return mBegin; } - void* end() { return mEnd; } - const void* end() const { return mEnd; } - - void* itemAt(size_t pos, size_t itemSize) { - return mBegin + pos * itemSize; - } - - const void* itemAt(size_t pos, size_t itemSize) const { - return mBegin + pos * itemSize; - } - - void assignFrom(const PodVectorBase& other); - - inline size_t itemCount(size_t itemSize) const { - return byteSize() / itemSize; - } - - inline size_t itemCapacity(size_t itemSize) const { - return byteCapacity() / itemSize; - } - - inline size_t maxItemCapacity(size_t itemSize) const { - return SIZE_MAX / itemSize; - } - - void resize(size_t newSize, size_t itemSize); - void reserve(size_t newSize, size_t itemSize); - - void removeAt(size_t index, size_t itemSize); - void* insertAt(size_t index, size_t itemSize); - void swapAll(PodVectorBase* other); - - char* mBegin; - char* mEnd; - char* mLimit; - -private: - void initFrom(const void* from, size_t fromLen); -}; - - -// A PodVector<T> holds a vector (dynamically resizable array) or items -// that must be POD-struct compatible (i.e. they cannot have constructors, -// destructors, or virtual members). This allows the implementation to be -// small, fast and efficient, memory-wise. -// -// If you want to implement a vector of C++ objects, consider using -// std::vector<> instead, but keep in mind that this implies a non-trivial -// cost when appending, inserting, removing items in the collection. -// -template <typename T> -class PodVector : public PodVectorBase { -public: - // Default constructor for an empty PodVector<T> - PodVector() : PodVectorBase() {} - - // Copy constructor. This copies all items from |other| into - // the new instance with ::memmove(). - PodVector(const PodVector& other) : PodVectorBase(other) {} - - // Assignment operator. - PodVector& operator=(const PodVector& other) { - this->assignFrom(other); - return *this; - } - - // Destructor, this simply releases the internal storage block that - // holds all the items, but doesn't touch them otherwise. - ~PodVector() {} - - // Return true iff the PodVector<T> instance is empty, i.e. does not - // have any items. - bool empty() const { return PodVectorBase::empty(); } - - // Return the number of items in the current PodVector<T> instance. - size_t size() const { return PodVectorBase::itemCount(sizeof(T)); } - - // Return the current capacity in the current PodVector<T> instance. - // Do not use directly, except if you know what you're doing. Try to - // use resize() or reserve() instead. - size_t capacity() const { - return PodVectorBase::itemCapacity(sizeof(T)); - } - - // Return the maximum capacity of any PodVector<T> instance. - static inline size_t maxCapacity() { return SIZE_MAX / sizeof(T); } - - // Resize the vector to ensure it can hold |newSize| - // items. This may or may not call reserve() under the hood. - // It's a fatal error to try to resize above maxCapacity(). - void resize(size_t newSize) { - PodVectorBase::resize(newSize, sizeof(T)); - } - - // Resize the vector's storage array to ensure that it can hold at - // least |newSize| items. It's a fatal error to try to resize above - // maxCapacity(). - void reserve(size_t newSize) { - PodVectorBase::reserve(newSize, sizeof(T)); - } - - // Return a pointer to the first item in the vector. This is only - // valid until the next call to any function that changes the size - // or capacity of the vector. Can be NULL if the vector is empty. - T* begin() { - return reinterpret_cast<T*>(PodVectorBase::begin()); - } - - // Return a constant pointer to the first item in the vector. This is - // only valid until the next call to any function that changes the - // size of capacity of the vector. - const T* begin() const { - return reinterpret_cast<T*>(PodVectorBase::begin()); - } - - // Return a pointer past the last item in the vector. I.e. if the - // result is not NULL, then |result - 1| points to the last item. - // Can be NULL if the vector is empty. - T* end() { - return reinterpret_cast<T*>(PodVectorBase::end()); - } - - // Return a constant pointer past the last item in the vector. I.e. if - // the result is not NULL, then |result - 1| points to the last item. - // Can be NULL if the vector is empty. - const T* end() const { - return reinterpret_cast<T*>(PodVectorBase::end()); - } - - // Returns a reference to the item a position |index| in the vector. - // It may be a fatal error to access an out-of-bounds position. - T& operator[](size_t index) { - return *reinterpret_cast<T*>( - PodVectorBase::itemAt(index, sizeof(T))); - } - - const T& operator[](size_t index) const { - return *reinterpret_cast<const T*>( - PodVectorBase::itemAt(index, sizeof(T))); - } - - // Increase the vector's size by 1, then move all items past a given - // position to the right. Return the position of the insertion point - // to let the caller copy the content it desires there. It's preferrable - // to use insert() directly, which will do the item copy for you. - T* emplace(size_t index) { - return reinterpret_cast<T*>( - PodVectorBase::insertAt(index, sizeof(T))); - } - - // Insert an item at a given position. |index| is the insertion position - // which must be between 0 and size() included, or a fatal error may - // occur. |item| is a reference to an item to copy into the array, - // byte-by-byte. - void insert(size_t index, const T& item) { - *(this->emplace(index)) = item; - } - - // Prepend an item at the start of a vector. This moves all vector items - // to the right, and is thus costly. |item| is a reference to an item - // to copy to the start of the vector. - void prepend(const T& item) { - *(this->emplace(0U)) = item; - } - - // Append an item at the end of a vector. Specialized version of insert() - // which always uses size() as the insertion position. - void append(const T& item) { - *(this->emplace(this->size())) = item; - } - - // Remove the item at a given position. |index| is the position of the - // item to delete. It must be between 0 and size(), included, or - // a fatal error may occur. Deleting the item at position size() - // doesn't do anything. - void remove(size_t index) { - PodVectorBase::removeAt(index, sizeof(T)); - } - - void swap(PodVector* other) { - PodVectorBase::swapAll(other); - } - - // Compatibility methods for std::vector<> - void push_back(const T& item) { append(item); } - void pop() { remove(0U); } - - typedef T* iterator; - typedef const T* const_iterator; -}; - -} // namespace emugl - -#endif // EMUGL_COMMON_POD_VECTOR_H diff --git a/emulator/opengl/shared/emugl/common/pod_vector_unittest.cpp b/emulator/opengl/shared/emugl/common/pod_vector_unittest.cpp deleted file mode 100644 index 9ce509a..0000000 --- a/emulator/opengl/shared/emugl/common/pod_vector_unittest.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/pod_vector.h" - -#include <gtest/gtest.h> - -namespace emugl { - -static int hashIndex(size_t n) { - return static_cast<int>(((n >> 14) * 13773) + (n * 51)); -} - -TEST(PodVector, Empty) { - PodVector<int> v; - EXPECT_TRUE(v.empty()); - EXPECT_EQ(0U, v.size()); -} - -TEST(PodVector, AppendOneItem) { - PodVector<int> v; - v.append(10234); - EXPECT_FALSE(v.empty()); - EXPECT_EQ(1U, v.size()); - EXPECT_EQ(10234, v[0]); -} - -TEST(PodVector, AppendLotsOfItems) { - PodVector<int> v; - const size_t kMaxCount = 10000; - for (size_t n = 0; n < kMaxCount; ++n) { - v.append(hashIndex(n)); - } - EXPECT_EQ(kMaxCount, v.size()); - for (size_t n = 0; n < kMaxCount; ++n) { - EXPECT_EQ(hashIndex(n), v[n]) << "At index " << n; - } -} - -TEST(PodVector, RemoveFrontItems) { - PodVector<int> v; - const size_t kMaxCount = 100; - for (size_t n = 0; n < kMaxCount; ++n) { - v.append(hashIndex(n)); - } - EXPECT_EQ(kMaxCount, v.size()); - for (size_t n = 0; n < kMaxCount; ++n) { - EXPECT_EQ(hashIndex(n), v[0]) << "At index " << n; - v.remove(0U); - EXPECT_EQ(kMaxCount - n - 1U, v.size()) << "At index " << n; - } -} - -TEST(PodVector, PrependItems) { - PodVector<int> v; - const size_t kMaxCount = 100; - for (size_t n = 0; n < kMaxCount; ++n) { - v.prepend(hashIndex(n)); - } - EXPECT_EQ(kMaxCount, v.size()); - for (size_t n = 0; n < kMaxCount; ++n) { - EXPECT_EQ(hashIndex(kMaxCount - n - 1), v[n]) << "At index " << n; - } -} - -TEST(PodVector, ResizeExpands) { - PodVector<int> v; - const size_t kMaxCount = 100; - const size_t kMaxCount2 = 10000; - for (size_t n = 0; n < kMaxCount; ++n) { - v.append(hashIndex(n)); - } - EXPECT_EQ(kMaxCount, v.size()); - v.resize(kMaxCount2); - EXPECT_EQ(kMaxCount2, v.size()); - for (size_t n = 0; n < kMaxCount; ++n) { - EXPECT_EQ(hashIndex(n), v[n]) << "At index " << n; - } -} - -TEST(PodVector, ResizeTruncates) { - PodVector<int> v; - const size_t kMaxCount = 10000; - const size_t kMaxCount2 = 10; - for (size_t n = 0; n < kMaxCount; ++n) { - v.append(hashIndex(n)); - } - EXPECT_EQ(kMaxCount, v.size()); - v.resize(kMaxCount2); - EXPECT_EQ(kMaxCount2, v.size()); - for (size_t n = 0; n < kMaxCount2; ++n) { - EXPECT_EQ(hashIndex(n), v[n]) << "At index " << n; - } -} - - -TEST(PodVector, AssignmentOperator) { - PodVector<int> v1; - const size_t kMaxCount = 10000; - for (size_t n = 0; n < kMaxCount; ++n) { - v1.append(hashIndex(n)); - } - EXPECT_EQ(kMaxCount, v1.size()); - - PodVector<int> v2; - v2 = v1; - - v1.reserve(0); - - EXPECT_EQ(kMaxCount, v2.size()); - for (size_t n = 0; n < kMaxCount; ++n) { - EXPECT_EQ(hashIndex(n), v2[n]) << "At index " << n; - } -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/scoped_pointer_vector.h b/emulator/opengl/shared/emugl/common/scoped_pointer_vector.h deleted file mode 100644 index 3d263e9..0000000 --- a/emulator/opengl/shared/emugl/common/scoped_pointer_vector.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_SCOPED_POINTER_VECTOR_H -#define EMUGL_COMMON_SCOPED_POINTER_VECTOR_H - -namespace emugl { - -template <class T> -class ScopedPointerVector { - ScopedPointerVector -}; - -} // namespace emugl - -#endif // EMUGL_COMMON_SCOPED_POINTER_VECTOR_H diff --git a/emulator/opengl/shared/emugl/common/shared_library.cpp b/emulator/opengl/shared/emugl/common/shared_library.cpp deleted file mode 100644 index e78e36b..0000000 --- a/emulator/opengl/shared/emugl/common/shared_library.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/shared_library.h" - -#include <stddef.h> -#include <string.h> -#include <stdio.h> - -#ifndef _WIN32 -#include <dlfcn.h> -#include <stdlib.h> -#endif - -namespace emugl { - -#ifdef _WIN32 - -// static -SharedLibrary* SharedLibrary::open(const char* libraryName) { - HMODULE lib = LoadLibrary(libraryName); - return lib ? new SharedLibrary(lib) : NULL; -} - -SharedLibrary::SharedLibrary(HandleType lib) : mLib(lib) {} - -SharedLibrary::~SharedLibrary() { - if (mLib) { - FreeLibrary(mLib); - } -} - -SharedLibrary::FunctionPtr SharedLibrary::findSymbol( - const char* symbolName) { - if (!mLib || !symbolName) { - return NULL; - } - return reinterpret_cast<FunctionPtr>( - GetProcAddress(mLib, symbolName)); -} - -#else // !_WIN32 - -// static -SharedLibrary* SharedLibrary::open(const char* libraryName) { - const char* libPath = libraryName; - char* path = NULL; - - const char* libBaseName = strrchr(libraryName, '/'); - if (!libBaseName) { - libBaseName = libraryName; - } - - if (!strchr(libBaseName, '.')) { - // There is no extension in this library name, so append one. -#ifdef __APPLE__ - static const char kDllExtension[] = ".dylib"; -#else - static const char kDllExtension[] = ".so"; -#endif - size_t pathLen = strlen(libraryName) + sizeof(kDllExtension); - path = static_cast<char*>(malloc(pathLen)); - snprintf(path, pathLen, "%s%s", libraryName, kDllExtension); - libPath = path; - } - -#ifdef __APPLE__ - // On OSX, some libraries don't include an extension (notably OpenGL) - // On OSX we try to open |libraryName| first. If that doesn't exist, - // we try |libraryName|.dylib - void* lib = dlopen(libraryName, RTLD_NOW); - if (lib == NULL) { - lib = dlopen(libPath, RTLD_NOW); - } -#else - void* lib = dlopen(libPath, RTLD_NOW); -#endif - - if (path) { - free(path); - } - - return lib ? new SharedLibrary(lib) : NULL; -} - -SharedLibrary::SharedLibrary(HandleType lib) : mLib(lib) {} - -SharedLibrary::~SharedLibrary() { - if (mLib) { - dlclose(mLib); - } -} - -SharedLibrary::FunctionPtr SharedLibrary::findSymbol( - const char* symbolName) { - if (!mLib || !symbolName) { - return NULL; - } - return reinterpret_cast<FunctionPtr>(dlsym(mLib, symbolName)); -} - -#endif // !_WIN32 - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/shared_library.h b/emulator/opengl/shared/emugl/common/shared_library.h deleted file mode 100644 index f1d82fc..0000000 --- a/emulator/opengl/shared/emugl/common/shared_library.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_SHARED_LIBRARY_H -#define EMUGL_COMMON_SHARED_LIBRARY_H - -#ifdef _WIN32 -#include <windows.h> -#endif - -namespace emugl { - -// A class used to open a platform-specific shared library, and probe -// it for symbols. Usage is the following: -// -// // Open the library. -// SharedLibrary* library = SharedLibrary::open("libFoo"); -// if (!library) { -// ... could not find / open library! -// } -// -// //Probe for function symbol. -// FunctionPtr my_func = library->findSymbol("my_func"); -// -// // Closes library/ -// delete library; -// -class SharedLibrary { -public: - // Open a given library. If |libraryName| has no extension, a - // platform-appropriate extension is added and that path is opened. - // If the |libraryName| has an extension, that form is opened. - // - // On OSX, some libraries don't include an extension (notably OpenGL) - // On OSX we try to open |libraryName| first. If that doesn't exist, - // we try |libraryName|.dylib - // - // On success, returns a new SharedLibrary instance that must be - // deleted by the caller. - static SharedLibrary* open(const char* libraryName); - - // Closes an existing SharedLibrary instance. - ~SharedLibrary(); - - // Generic function pointer type, for values returned by the - // findSymbol() method. - typedef void (*FunctionPtr)(void); - - // Probe a given SharedLibrary instance to find a symbol named - // |symbolName| in it. Return its address as a FunctionPtr, or - // NULL if the symbol is not found. - FunctionPtr findSymbol(const char* symbolName); - -private: -#ifdef _WIN32 - typedef HMODULE HandleType; -#else - typedef void* HandleType; -#endif - - // Constructor intentionally hidden. - SharedLibrary(HandleType); - - HandleType mLib; -}; - -// Macro to compose emugl shared library name under various OS and bitness -// eg. -// on x86_64, EMUGL_LIBNAME("foo") --> "lib64foo" - -#if defined(__x86_64__) -# define EMUGL_LIBNAME(name) "lib64" name -#elif defined(__i386__) -# define EMUGL_LIBNAME(name) "lib" name -#else -/* This header is included by target w/o using EMUGL_LIBNAME(). Don't #error, leave it undefined */ -#endif - -} // namespace emugl - -#endif // EMUGL_COMMON_SHARED_LIBRARY_H diff --git a/emulator/opengl/shared/emugl/common/shared_library_unittest.cpp b/emulator/opengl/shared/emugl/common/shared_library_unittest.cpp deleted file mode 100644 index cb74efa..0000000 --- a/emulator/opengl/shared/emugl/common/shared_library_unittest.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/shared_library.h" - -#include <gtest/gtest.h> - -#include <string> - -#include <limits.h> -#include <string.h> - -// Hack to get the current executable's full path. -namespace testing { -namespace internal { - -extern std::string g_executable_path; - -} // namespace internal -} // namespace testing - -namespace emugl { - -namespace { - -// Return the name/path of the test shared library to load. -// Note that this doesn't include a platform-specific extension. -// This assumes that the test shared library is under the lib/ sub-directory -// of the current executable's path! -std::string GetTestLibraryName() { - static const char kSubDir[] = "lib/"; -#ifdef __x86_64__ - static const char kLibraryPrefix[] = "lib64"; -#else - static const char kLibraryPrefix[] = "lib"; -#endif - static const char kTestLibrarySuffix[] = "emugl_test_shared_library"; - - const char* exec_path = testing::internal::g_executable_path.c_str(); - -#ifdef _WIN32 - const char* p = strrchr(exec_path, '/'); - const char* p2 = strrchr(exec_path, '\\'); - if (p2) { - if (!p || p2 > p) { - p = p2; - } - } -#else - const char* p = strrchr(exec_path, '/'); -#endif - - std::string path; - - if (!p) { - path = "./"; - } else { - path = std::string(exec_path, p - exec_path + 1U); - } - path += kSubDir; - path += kLibraryPrefix; - path += kTestLibrarySuffix; - printf("Library path: %s\n", path.c_str()); - return path; -} - -class SharedLibraryTest : public testing::Test { -public: - SharedLibraryTest() { - // Locate the shared library - mLibraryPath = GetTestLibraryName(); - } - - ~SharedLibraryTest() {} - - const char* library_path() const { return mLibraryPath.c_str(); } - -private: - std::string mLibraryPath; -}; - -class ScopedSharedLibrary { -public: - explicit ScopedSharedLibrary(SharedLibrary* lib) : mLib(lib) {} - ~ScopedSharedLibrary() { - delete mLib; - } - SharedLibrary* get() const { return mLib; } - - SharedLibrary* operator->() { return mLib; } - - void release() { - delete mLib; - mLib = NULL; - } - -private: - SharedLibrary* mLib; -}; - -} // namespace - -TEST_F(SharedLibraryTest, Open) { - ScopedSharedLibrary lib(SharedLibrary::open(library_path())); - EXPECT_TRUE(lib.get()); -} - -TEST_F(SharedLibraryTest, OpenLibraryWithExtension) { - std::string path = library_path(); - - // test extension append - ScopedSharedLibrary libNoExtension(SharedLibrary::open(path.c_str())); - EXPECT_TRUE(libNoExtension.get()); - libNoExtension.release(); - -#ifdef _WIN32 - path += ".dll"; -#elif defined(__APPLE__) - // try to open the library without an extension - - path += ".dylib"; -#else - path += ".so"; -#endif - - // test open with prepended extension - ScopedSharedLibrary lib(SharedLibrary::open(path.c_str())); - EXPECT_TRUE(lib.get()); -} - -#ifdef __APPLE__ -TEST_F(SharedLibraryTest, OpenLibraryWithoutExtension) { - const char* library = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; - ScopedSharedLibrary lib(SharedLibrary::open(library)); - EXPECT_TRUE(lib.get()); -} -#endif - -TEST_F(SharedLibraryTest, FindSymbol) { - ScopedSharedLibrary lib(SharedLibrary::open(library_path())); - EXPECT_TRUE(lib.get()); - - if (lib.get()) { - typedef int (*FooFunction)(void); - - FooFunction foo_func = reinterpret_cast<FooFunction>( - lib->findSymbol("foo_function")); - EXPECT_TRUE(foo_func); - EXPECT_EQ(42, (*foo_func)()); - } -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/smart_ptr.cpp b/emulator/opengl/shared/emugl/common/smart_ptr.cpp deleted file mode 100644 index 703487d..0000000 --- a/emulator/opengl/shared/emugl/common/smart_ptr.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/smart_ptr.h" - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#endif - -namespace emugl { - -// Thread-safe atomic reference-counting type. -class RefCount { -public: - RefCount() : mCount(1) {} - ~RefCount() {} - - // Technically not thread-safe, use only for testing. - int count() const { return (int)mCount; } - - void increment() { -#ifdef _WIN32 - InterlockedIncrement(&mCount); -#else - __sync_fetch_and_add(&mCount, 1); -#endif - } - - bool decrement() { -#ifdef _WIN32 - return InterlockedDecrement(&mCount) == 0; -#else - return __sync_add_and_fetch(&mCount, -1) == 0; -#endif - } - -private: -#ifdef _WIN32 - LONG mCount; -#else - int mCount; -#endif -}; - - -// SmartPtrBase implementation. - -SmartPtrBase::SmartPtrBase(void* ptr) : mPtr(ptr), mRefCount(NULL) { - if (mPtr) - mRefCount = new RefCount(); -} - - -SmartPtrBase::SmartPtrBase(const SmartPtrBase& other) - : mPtr(other.mPtr), mRefCount(other.mRefCount) { - if (mRefCount) - mRefCount->increment(); -} - - -int SmartPtrBase::getRefCount() const { - return mRefCount ? mRefCount->count() : 0; -} - - -void SmartPtrBase::addRef() { - if (mRefCount) - mRefCount->increment(); -} - - -void* SmartPtrBase::copyFrom(const SmartPtrBase& other) { - void* old_ptr = release(); - - mPtr = other.mPtr; - mRefCount = other.mRefCount; - if (mRefCount) - mRefCount->increment(); - - return old_ptr; -} - - -void* SmartPtrBase::release() { - void* old_ptr = mPtr; - RefCount* old_refcount = mRefCount; - - if (old_refcount) { - mPtr = NULL; - mRefCount = NULL; - - if (old_refcount->decrement()) { - delete old_refcount; - return old_ptr; - } - } - - return NULL; -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/smart_ptr.h b/emulator/opengl/shared/emugl/common/smart_ptr.h deleted file mode 100644 index 73efdd6..0000000 --- a/emulator/opengl/shared/emugl/common/smart_ptr.h +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_SMART_PTR_H -#define EMUGL_SMART_PTR_H - -#include <stddef.h> - -namespace emugl { - -// Hidden atomic ref-counting implementation. -class RefCount; - -// Base class for all templated SmartPtr<> instances. Reduces -// template expansion and code. Consider this to be an implementation -// detail of SmartPtr<>, so don't rely on anything here. -class SmartPtrBase { -public: - // Defrault constructor. - SmartPtrBase() : mPtr(NULL), mRefCount(NULL) {} - - // Normal constructor. This takes ownership of |ptr|, though only - // template instances are capable of destroying the object. - explicit SmartPtrBase(void* ptr); - - // Copy-constructor, this increments the reference count. - SmartPtrBase(const SmartPtrBase& other); - - // Assignment operator, also increments the reference count. - SmartPtrBase& operator=(const SmartPtrBase& other); - - // Nothing happens in this destructor, the real work must be performed - // in subclasses. - ~SmartPtrBase() {} - - - // Used to enable 'if (smart_ptr) { ... }' properly. - operator void*() const { - return mPtr; - } - - // Return internal reference count value, only use for unit testing. - int getRefCount() const; - -protected: - // Used internally to increment the reference count. - void addRef(); - - // Copy the |other| into this instance, returns the old pointer value - // if it needs to be destroyed by the caller, or NULL otherwise. - void* copyFrom(const SmartPtrBase& other); - - // Used internally to decrement the reference count, if it reaches 0, - // returns the pointer to be destroyed, NULL otherwise. - void* release(); - - void* mPtr; - RefCount* mRefCount; -}; - - -// The real template class to be used for smart pointers. -// Typical uses: -// -// SmartPtr<Foo> ptr(new Foo()); // takes ownership. -// SmartPtr<Foo> ptr2; // empty pointer. -// ptr2 = ptr; // copies pointer + increment reference count. -// Foo* obj = ptr.Ptr(); // access pointed object. -// ptr->DoStuff(); // operate directly on pointed object. -// (*ptr)->DoStuff(); // same here. -// -// On scope exit, the internal reference count is decremented and the -// object is deleted automatically when it reaches 0, indicating that -// there are no more owners. -// -// IMPORTANT: You need to be sure that only one 'chain' of smart pointers -// own a given object. I.e. the following is incorrect: -// -// Foo* foo = new Foo(); // create new instance. -// SmartPtr<Foo> ptr(foo); // |ptr| takes ownership of |foo|. -// SmartPtr<Foo> ptr2(foo); // |ptr2| takes also ownership of |foo|. -// -// The problem is that |ptr| and |ptr2| don't know anything about each -// other, and will not share the same reference count. Once a smart pointer -// owns an object, only use other smart pointers that are copy-constructed -// or assigned with the initial one to keep everything consistent. -template <class T> -class SmartPtr : public emugl::SmartPtrBase { -public: - // Default constructor. The instance holds a NULL pointer. - SmartPtr() : SmartPtrBase() {} - - // Regular constructor, takes ownership of |ptr|. - explicit SmartPtr(T* ptr) : SmartPtrBase(ptr) {} - - // Copy-constructor, |this| and |other| will share the same internal - // reference count, which is incremented by 1. - SmartPtr(const SmartPtr& other) - : SmartPtrBase(reinterpret_cast<const SmartPtrBase&>(other)) {} - - // Assignment operator, same semantics as copy-constructor. - SmartPtr& operator=(const SmartPtr& other) { - void* old_ptr = copyFrom(static_cast<const SmartPtrBase&>(other)); - if (old_ptr) - delete reinterpret_cast<T*>(old_ptr); - return *this; - } - - // Destructor, decrements reference count and destroys the object - // if it reaches 0 (indicating this was the last owning smart pointer). - ~SmartPtr() { - void* ptr = release(); - if (ptr) - delete reinterpret_cast<T*>(ptr); - } - - // Return owned object instance, or NULL. - T* Ptr() const { - return reinterpret_cast<T*>(mPtr); - } - - // Return owned object instance, or NULL - const T* constPtr() const { - return reinterpret_cast<const T*>(mPtr); - } - - // Operate directly on owned object. - T* operator->() const { - return Ptr(); - } - - // Return reference to owned object. - T& operator*() const { - return *Ptr(); - } -}; - -} // namespace emugl - -#endif // EMUGL_SMART_PTR_H diff --git a/emulator/opengl/shared/emugl/common/smart_ptr_unittest.cpp b/emulator/opengl/shared/emugl/common/smart_ptr_unittest.cpp deleted file mode 100644 index db9e5f2..0000000 --- a/emulator/opengl/shared/emugl/common/smart_ptr_unittest.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/smart_ptr.h" - -#include <gtest/gtest.h> - -namespace emugl { - -// This Test sub-class is used to track allocations and deallocations of -// the MyTestClass instances that are created through newInstance(). -// See below for typical usage. -class SmartPtrTest : public testing::Test { -public: - SmartPtrTest() : mNewCount(0), mDeleteCount(0), mDoCount(0) {} - - ~SmartPtrTest() { - mNewCount = 0; - mDoCount = 0; - mDeleteCount = 0; - } - - class MyClass; - - MyClass* newInstance() { - return new MyClass(this); - } - - class MyClass { - public: - MyClass(SmartPtrTest* test) : mTest(test) { - mTest->mNewCount++; - } - - void doStuff() { - mTest->mDoCount++; - } - - ~MyClass() { - mTest->mDeleteCount++; - } - private: - SmartPtrTest* mTest; - }; - - int mNewCount; - int mDeleteCount; - int mDoCount; -}; - - -TEST_F(SmartPtrTest, Empty) { - SmartPtr<MyClass> ptr; - EXPECT_FALSE(ptr.Ptr()); - - EXPECT_EQ(0, mNewCount); - EXPECT_EQ(0, mDeleteCount); - EXPECT_EQ(0, mDoCount); -} - - -TEST_F(SmartPtrTest, SingleRef) { - MyClass* obj = newInstance(); - EXPECT_EQ(1, mNewCount); - - { - SmartPtr<MyClass> ptr(obj); - EXPECT_EQ(obj, ptr.Ptr()); - - EXPECT_EQ(1, mNewCount); - EXPECT_EQ(0, mDeleteCount); - EXPECT_EQ(0, mDoCount); - } - // Check that the object was deleted. - EXPECT_EQ(1, mDeleteCount); -} - - -TEST_F(SmartPtrTest, CopyConstructor) { - MyClass* obj = newInstance(); - EXPECT_EQ(1, mNewCount); - - { - SmartPtr<MyClass> ptr1(obj); - { - SmartPtr<MyClass> ptr2(ptr1); - EXPECT_EQ(2, ptr1.getRefCount()); - EXPECT_EQ(2, ptr2.getRefCount()); - EXPECT_EQ(1, mNewCount); - EXPECT_EQ(0, mDeleteCount); - EXPECT_EQ(0, mDoCount); - } - EXPECT_EQ(1, mNewCount); - EXPECT_EQ(0, mDeleteCount); - EXPECT_EQ(0, mDoCount); - } - EXPECT_EQ(1, mNewCount); - EXPECT_EQ(1, mDeleteCount); - EXPECT_EQ(0, mDoCount); -} - - -TEST_F(SmartPtrTest, AssignmentOperator) { - SmartPtr<MyClass> ptr1(newInstance()); - SmartPtr<MyClass> ptr2(newInstance()); - EXPECT_EQ(2, mNewCount); - EXPECT_EQ(0, mDeleteCount); - EXPECT_EQ(0, mDoCount); - - ptr2 = ptr1; - EXPECT_EQ(2, mNewCount); - EXPECT_EQ(1, mDeleteCount); - - EXPECT_EQ(ptr1.Ptr(), ptr2.Ptr()); - EXPECT_EQ(2, ptr1.getRefCount()); - EXPECT_EQ(2, ptr2.getRefCount()); -} - - -TEST_F(SmartPtrTest, ArrowOperator) { - SmartPtr<MyClass> ptr(newInstance()); - ptr->doStuff(); - EXPECT_EQ(1, mDoCount); - - (*ptr).doStuff(); - EXPECT_EQ(2, mDoCount); -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/sockets.cpp b/emulator/opengl/shared/emugl/common/sockets.cpp deleted file mode 100644 index 2a13d72..0000000 --- a/emulator/opengl/shared/emugl/common/sockets.cpp +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/sockets.h" - -#include <errno.h> - -#ifdef _WIN32 -#include <winsock2.h> -#include <ws2tcpip.h> -#else -#include <netinet/in.h> -#include <netinet/tcp.h> -#include <sys/un.h> -#include <sys/stat.h> -#endif - -#include <stddef.h> -#include <stdint.h> -#include <string.h> -#include <unistd.h> - -namespace emugl { - -namespace { - -static void socketSetReuseAddress(int s) { -#ifdef _WIN32 - // The default behaviour on Windows is equivalent to SO_REUSEADDR - // so we don't need to set this option. Moreover, one should never - // set this option with WinSock because it's badly implemented and - // generates a huge security issue. See: - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621(v=vs.85).aspx -#else - int val = 1; - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); -#endif -} - -// Helper union to store a socket address. -struct SockAddr { - socklen_t len; - union { - sockaddr generic; - sockaddr_in inet; -#ifndef _WIN32 - sockaddr_un local; -#endif - }; - - int getFamily() const { return generic.sa_family; } - - void initEmpty() { - ::memset(this, 0, sizeof(*this)); - this->len = static_cast<socklen_t>(sizeof(*this)); - } - - int initFromInet(uint32_t ip_address, int port) { - if (port < 0 || port >= 65536) - return -EINVAL; - - ::memset(this, 0, sizeof(*this)); - this->inet.sin_family = AF_INET; - this->inet.sin_port = htons(port); - this->inet.sin_addr.s_addr = htonl(ip_address); - this->len = sizeof(this->inet); - return 0; - } - - int initFromLocalhost(int port) { - return initFromInet(0x7f000001, port); - } - -#ifndef _WIN32 - // Initialize the SockAddr from a Unix path. Returns 0 on success, - // or -errno code on failure. - int initFromUnixPath(const char* path) { - if (!path || !path[0]) - return -EINVAL; - - size_t pathLen = ::strlen(path); - if (pathLen >= sizeof(local.sun_path)) - return -E2BIG; - - ::memset(this, 0, sizeof(*this)); - this->local.sun_family = AF_LOCAL; - ::memcpy(this->local.sun_path, path, pathLen + 1U); - this->len = pathLen + offsetof(sockaddr_un, sun_path); - return 0; - } -#endif -}; - -int socketBindInternal(const SockAddr* addr, int socketType) { - int s = ::socket(addr->getFamily(), socketType, 0); - if (s < 0) - return -errno; - - // Bind to the socket. - if (::bind(s, &addr->generic, addr->len) < 0 || - ::listen(s, 5) < 0) { - int ret = -errno; - ::close(s); - return ret; - } - - socketSetReuseAddress(s); - return s; -} - -int socketConnectInternal(const SockAddr* addr, int socketType) { - int s = ::socket(addr->getFamily(), socketType, 0); - if (s < 0) - return -errno; - - int ret; - do { - ret = ::connect(s, &addr->generic, addr->len); - } while (ret < 0 && errno == EINTR); - - if (ret < 0) { - ret = -errno; - ::close(s); - return ret; - } - - return s; -} - -} // namespace - -void socketTcpDisableNagle(int s) { - // disable Nagle algorithm to improve bandwidth of small - // packets which are quite common in our implementation. -#ifdef _WIN32 - DWORD flag; -#else - int flag; -#endif - flag = 1; - setsockopt(s, IPPROTO_TCP, TCP_NODELAY, - (const char*)&flag, sizeof(flag)); -} - -int socketGetPort(int s) { - SockAddr addr; - addr.initEmpty(); - if (getsockname(s, &addr.generic, &addr.len) < 0) { - return -errno; - } - switch (addr.generic.sa_family) { - case AF_INET: - return ntohs(addr.inet.sin_port); - default: - ; - } - return -EINVAL; -} - -#ifndef _WIN32 -int socketLocalServer(const char* path, int socketType) { - SockAddr addr; - int ret = addr.initFromUnixPath(path); - if (ret < 0) { - return ret; - } - return socketBindInternal(&addr, socketType); -} - -int socketLocalClient(const char* path, int socketType) { - SockAddr addr; - int ret = addr.initFromUnixPath(path); - if (ret < 0) { - return ret; - } - return socketConnectInternal(&addr, socketType); -} -#endif // !_WIN32 - -int socketTcpLoopbackServer(int port, int socketType) { - SockAddr addr; - int ret = addr.initFromLocalhost(port); - if (ret < 0) { - return ret; - } - return socketBindInternal(&addr, socketType); -} - -int socketTcpLoopbackClient(int port, int socketType) { - SockAddr addr; - int ret = addr.initFromLocalhost(port); - if (ret < 0) { - return ret; - } - return socketConnectInternal(&addr, socketType); -} - -int socketTcpClient(const char* hostname, int port, int socketType) { - // TODO(digit): Implement this. - return -ENOSYS; -} - -int socketAccept(int serverSocket) { - int ret; - do { - ret = ::accept(serverSocket, NULL, NULL); - } while (ret < 0 && errno == EINTR); - return ret; -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/sockets.h b/emulator/opengl/shared/emugl/common/sockets.h deleted file mode 100644 index 11e7ac7..0000000 --- a/emulator/opengl/shared/emugl/common/sockets.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_SOCKETS_H -#define EMUGL_COMMON_SOCKETS_H - -// A set of helper functions used to deal with sockets in a portable way. - -namespace emugl { - -// Disable Nagle's algorithm for socket descriptor |s|. This assumes -// that |s| is a TCP socket descriptor. -void socketTcpDisableNagle(int s); - -// Return the port associated with a given IP or IPv6 socket, -// or -errno code on failure. -int socketGetPort(int s); - -// Bind to a local/Unix path, and return its socket descriptor on success, -// or -errno code on failure. -int socketLocalServer(const char* path, int socketType); - -// Connect to a Unix local path, and return a new socket descriptor -// on success, or -errno code on failure. -int socketLocalClient(const char* path, int socketType); - -// Bind to a localhost TCP socket, and return its socket descriptor on -// success, or -errno code on failure. -int socketTcpLoopbackServer(int port, int socketType); - -// Connect to a localhost TCP port, and return a new socket descriptor on -// success, or -errno code on failure. -int socketTcpLoopbackClient(int port, int socketType); - -// Connect to a TCP host, and return a new socket descriptor on -// success, or -errno code on failure. -int socketTcpClient(const char* hostname, int port, int socketType); - -// Accept a new connection. |serverSocket| must be a bound server socket -// descriptor. Returns new socket descriptor on success, or -errno code -// on failure. -int socketAccept(int serverSocket); - -} // namespace emugl - -#endif // EMUGL_COMMON_SOCKETS_H diff --git a/emulator/opengl/shared/emugl/common/testing/test_shared_library.cpp b/emulator/opengl/shared/emugl/common/testing/test_shared_library.cpp deleted file mode 100644 index 598a963..0000000 --- a/emulator/opengl/shared/emugl/common/testing/test_shared_library.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2014 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. - -// This source file must be compiled into a simple shared library which -// will be used by shared_library_unittest.cpp to verify that the -// emugl::SharedLibrary class works properly. - - -extern "C" int foo_function(void) { - return 42; -} diff --git a/emulator/opengl/shared/emugl/common/testing/test_thread.h b/emulator/opengl/shared/emugl/common/testing/test_thread.h deleted file mode 100644 index 2d758b3..0000000 --- a/emulator/opengl/shared/emugl/common/testing/test_thread.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_TESTING_TEST_THREAD_H -#define EMUGL_COMMON_TESTING_TEST_THREAD_H - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN 1 -# include <windows.h> -#else -# include <pthread.h> -#endif - -namespace emugl { - -// Very basic platform thread wrapper that only uses a tiny stack. -// This shall only be used during unit testing, and allows test code -// to not depend on the implementation of emugl::Thread. -class TestThread { -public: - // Main thread function type. - typedef void* (ThreadFunction)(void* param); - - // Constructor actually launches a new platform thread. - TestThread(ThreadFunction* func, void* funcParam) { -#ifdef _WIN32 - mThread = CreateThread(NULL, - 16384, - (DWORD WINAPI (*)(void*))func, - funcParam, - NULL, - NULL); -#else - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, 16384); - pthread_create(&mThread, &attr, func, funcParam); - pthread_attr_destroy(&attr); -#endif - } - - ~TestThread() { -#ifdef _WIN32 - CloseHandle(mThread); -#endif - } - - void join() { -#ifdef _WIN32 - WaitForSingleObject(mThread, INFINITE); -#else - void* ret = NULL; - pthread_join(mThread, &ret); -#endif - } - -private: -#ifdef _WIN32 - HANDLE mThread; -#else - pthread_t mThread; -#endif -}; - -} // namespace emugl - -#endif // EMUGL_COMMON_TESTING_TEST_THREAD_H diff --git a/emulator/opengl/shared/emugl/common/thread.h b/emulator/opengl/shared/emugl/common/thread.h deleted file mode 100644 index d0f7d20..0000000 --- a/emulator/opengl/shared/emugl/common/thread.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_THREAD_H -#define EMUGL_COMMON_THREAD_H - -#ifdef _WIN32 -#include <windows.h> -#else -#include <pthread.h> -#endif - -#include <stdint.h> - -namespace emugl { - -// Wrapper class for platform-specific threads. -// To create your own thread, define a sub-class of emugl::Thread -// and override its main() method. -// -// For example: -// -// class MyThread : public emugl::Thread { -// public: -// MyThread() : Thread() {} -// -// virtual intptr_t main() { -// ... main thread loop implementation -// return 0; -// } -// }; -// -// ... -// -// // Create new instance, but does not start it. -// MyThread* thread = new MyThread(); -// -// // Start the thread. -// thread->start(); -// -// // Wait for thread completion, and gets result into |exitStatus|. -// int exitStatus; -// thread->wait(&exitStatus); -// -class Thread { -public: - // Public constructor. - Thread(); - - // Virtual destructor. - virtual ~Thread(); - - // Override this method in your own thread sub-classes. This will - // be called when start() is invoked on the Thread instance. - virtual intptr_t main() = 0; - - // Start a thread instance. Return true on success, false otherwise - // (e.g. if the thread was already started or terminated). - bool start(); - - // Wait for thread termination and retrieve exist status into - // |*exitStatus|. Return true on success, false otherwise. - // NOTE: |exitStatus| can be NULL. - bool wait(intptr_t *exitStatus); - - // Check whether a thread has terminated. On success, return true - // and sets |*exitStatus|. On failure, return false. - // NOTE: |exitStatus| can be NULL. - bool tryWait(intptr_t *exitStatus); - -private: -#ifdef _WIN32 - static DWORD WINAPI thread_main(void* arg); - - HANDLE mThread; - DWORD mThreadId; - CRITICAL_SECTION mLock; -#else // !WIN32 - static void* thread_main(void* arg); - - pthread_t mThread; - pthread_mutex_t mLock; -#endif - intptr_t mExitStatus; - bool mIsRunning; -}; - -} // namespace emugl - -#endif // EMUGL_COMMON_THREAD_H - diff --git a/emulator/opengl/shared/emugl/common/thread_pthread.cpp b/emulator/opengl/shared/emugl/common/thread_pthread.cpp deleted file mode 100644 index 5dbc3ab..0000000 --- a/emulator/opengl/shared/emugl/common/thread_pthread.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/thread.h" - -#include "emugl/common/thread_store.h" - -#include <stdio.h> - -namespace emugl { - -namespace { - -class ScopedLocker { -public: - ScopedLocker(pthread_mutex_t* mutex) : mMutex(mutex) { - pthread_mutex_lock(mMutex); - } - - ~ScopedLocker() { - pthread_mutex_unlock(mMutex); - } -private: - pthread_mutex_t* mMutex; -}; - -} // namespace - -Thread::Thread() : - mThread((pthread_t)NULL), - mExitStatus(0), - mIsRunning(false) { - pthread_mutex_init(&mLock, NULL); -} - -Thread::~Thread() { - pthread_mutex_destroy(&mLock); -} - -bool Thread::start() { - bool ret = true; - pthread_mutex_lock(&mLock); - mIsRunning = true; - if (pthread_create(&mThread, NULL, thread_main, this)) { - ret = false; - mIsRunning = false; - } - pthread_mutex_unlock(&mLock); - return ret; -} - -bool Thread::wait(intptr_t *exitStatus) { - { - ScopedLocker locker(&mLock); - if (!mIsRunning) { - // Thread already stopped. - if (exitStatus) { - *exitStatus = mExitStatus; - } - return true; - } - } - - // NOTE: Do not hold the lock when waiting for the thread to ensure - // it can update mIsRunning and mExitStatus properly in thread_main - // without blocking. - void *retval; - if (pthread_join(mThread, &retval)) { - return false; - } - if (exitStatus) { - *exitStatus = (intptr_t)retval; - } - return true; -} - -bool Thread::tryWait(intptr_t *exitStatus) { - ScopedLocker locker(&mLock); - if (!mIsRunning) { - return false; - } - if (exitStatus) { - *exitStatus = mExitStatus; - } - return true; -} - -// static -void* Thread::thread_main(void *arg) { - Thread* self = reinterpret_cast<Thread*>(arg); - intptr_t ret = self->main(); - - pthread_mutex_lock(&self->mLock); - self->mIsRunning = false; - self->mExitStatus = ret; - pthread_mutex_unlock(&self->mLock); - - ::emugl::ThreadStore::OnThreadExit(); - - return (void*)ret; -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/thread_store.cpp b/emulator/opengl/shared/emugl/common/thread_store.cpp deleted file mode 100644 index ea64c6f..0000000 --- a/emulator/opengl/shared/emugl/common/thread_store.cpp +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/thread_store.h" - -#ifdef _WIN32 -#include "emugl/common/lazy_instance.h" -#endif - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -// Set to 1 to print debug messages. -#define DEBUG_THREAD_STORE 0 - -#if DEBUG_THREAD_STORE -# define D(...) do { printf("%s:%d: ", __FUNCTION__, __LINE__); printf(__VA_ARGS__); fflush(stdout); } while (0) -#else -# define D(...) ((void)0) -#endif - -namespace emugl { - -#ifdef _WIN32 - -namespace { - -// The ThreadStore implementation on Windows is very tricky, because -// TlsAlloc() doesn't allow one to provide a destructor function. As -// such threads are expected to destroy all TLS values explicitely. -// -// To solve this issue, this source file provides a static method called -// ThreadStore::OnThreadExit() that must be called when a thread exits, -// which will cleanup all values for the current thread. -// -// But this forces us to track thread-specific values ourselves. - -// Maximum amount of thread-specific slots supported by this implementation. -enum { - kMaxTlsSlots = 64 -}; - -// TlsSlotArray is a thread-specific array of values. Instances will -// be stored in a Win32 TLS value controlled by a single master TLS -// key. -// -typedef void* TlsSlotArray[kMaxTlsSlots]; - -// Global state shared by all threads -class GlobalState { -public: - GlobalState() { - D("Entering\n"); - mMasterTls = TlsAlloc(); - D("Master TLS = %d\n", (int)mMasterTls); - InitializeCriticalSection(&mSection); - mLastIndex = 0; - ::memset(mDestructors, 0, sizeof(mDestructors)); - D("Exiting\n"); - } - - // Register a new TLS key, or return -1 on error (too many keys). - // |destroy| is the destructor function for the key. - int registerKey(ThreadStore::Destructor* destroy) { - D("Entering destroy=%p\n", destroy); - int ret = -1; - EnterCriticalSection(&mSection); - if (mLastIndex < kMaxTlsSlots) { - ret = mLastIndex++; - mDestructors[ret] = destroy; - } - LeaveCriticalSection(&mSection); - D("Exiting newKey=%d\n", ret); - return ret; - } - - void unregisterKey(int key) { - D("key=%d\n", key); - if (key < 0 || key >= kMaxTlsSlots) { - D("Invalid key\n"); - return; - } - - // Note: keys are not reusable, but remove the destructor to avoid - // crashes in leaveCurrentThread() when it points to a function that - // is going to be unloaded from the process' address space. - EnterCriticalSection(&mSection); - mDestructors[key] = NULL; - LeaveCriticalSection(&mSection); - D("Exiting\n"); - } - - // Get the current thread-local value for a given |key|. - void* getValue(int key) const { - D("Entering key=%d\n", key); - if (key < 0 || key >= kMaxTlsSlots) { - D("Invalid key, result=NULL\n"); - return NULL; - } - - TlsSlotArray* array = getArray(); - void* ret = (*array)[key]; - D("Exiting keyValue=%p\n", ret); - return ret; - } - - // Set the current thread-local |value| for a given |key|. - void setValue(int key, void* value) { - D("Entering key=%d\n",key); - if (key < 0 || key >= kMaxTlsSlots) { - D("Invalid key, returning\n"); - return; - } - - TlsSlotArray* array = getArray(); - (*array)[key] = value; - D("Exiting\n"); - } - - // Call this when a thread exits to destroy all its thread-local values. - void leaveCurrentThread() { - D("Entering\n"); - TlsSlotArray* array = - reinterpret_cast<TlsSlotArray*>(TlsGetValue(mMasterTls)); - if (!array) { - D("Exiting, no thread-local data in this thread\n"); - return; - } - - for (size_t n = 0; n < kMaxTlsSlots; ++n) { - void* value = array[n]; - if (value) { - (*array)[n] = NULL; - // NOTE: In theory, a destructor could reset the slot to - // a new value, and we would have to loop in this function - // in interesting ways. In practice, ignore the issue. - EnterCriticalSection(&mSection); - ThreadStore::Destructor* destroy = mDestructors[n]; - LeaveCriticalSection(&mSection); - if (destroy) { - D("Calling destructor %p for key=%d, with value=%p\n", - destroy, (int)n, value); - (*destroy)(value); - } - } - } - TlsSetValue(mMasterTls, NULL); - ::free(array); - D("Exiting\n"); - } - -private: - // Return the thread-local array of TLS slots for the current thread. - // Cannot return NULL. - TlsSlotArray* getArray() const { - D("Entering\n"); - TlsSlotArray* array = - reinterpret_cast<TlsSlotArray*>(TlsGetValue(mMasterTls)); - if (!array) { - array = reinterpret_cast<TlsSlotArray*>( - ::calloc(sizeof(*array), 1)); - TlsSetValue(mMasterTls, array); - D("Allocated new array at %p\n", array); - } else { - D("Retrieved array at %p\n", array); - } - return array; - } - - DWORD mMasterTls; - CRITICAL_SECTION mSection; - int mLastIndex; - ThreadStore::Destructor* mDestructors[kMaxTlsSlots]; -}; - -LazyInstance<GlobalState> gGlobalState = LAZY_INSTANCE_INIT; - -} // namespace - -ThreadStore::ThreadStore(Destructor* destroy) { - D("Entering this=%p destroy=%p\n", this, destroy); - mKey = gGlobalState->registerKey(destroy); - D("Exiting this=%p key=%d\n", this, mKey); -} - -ThreadStore::~ThreadStore() { - D("Entering this=%p\n", this); - GlobalState* state = gGlobalState.ptr(); - state->unregisterKey(mKey); - D("Exiting this=%p\n", this); -} - -void* ThreadStore::get() const { - D("Entering this=%p\n", this); - void* ret = gGlobalState->getValue(mKey); - D("Exiting this=%p value=%p\n", this, ret); - return ret; -} - -void ThreadStore::set(void* value) { - D("Entering this=%p value=%p\n", this, value); - gGlobalState->setValue(mKey, value); - D("Exiting this=%p\n", this); -} - -// static -void ThreadStore::OnThreadExit() { - gGlobalState->leaveCurrentThread(); -} - -#else // !_WIN32 - -ThreadStore::ThreadStore(Destructor* destroy) { - int ret = pthread_key_create(&mKey, destroy); - if (ret != 0) { - fprintf(stderr, - "Could not create thread store key: %s\n", - strerror(ret)); - exit(1); - } -} - -ThreadStore::~ThreadStore() { - pthread_key_delete(mKey); -} - -#endif // !_WIN32 - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/thread_store.h b/emulator/opengl/shared/emugl/common/thread_store.h deleted file mode 100644 index 5fd08bd..0000000 --- a/emulator/opengl/shared/emugl/common/thread_store.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_THREAD_STORE_H -#define EMUGL_COMMON_THREAD_STORE_H - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN 1 -# include <windows.h> -#else -# include <pthread.h> -#endif - -namespace emugl { - -// A class to model storage of thread-specific values, that can be -// destroyed on thread exit. -// -// Note that on Windows, a thread must call OnThreadExit() explicitly -// here to ensure that the values are probably discarded. This is an -// unfortunate requirement of the Win32 API, which doesn't support -// destructors at all. -// -// There are various hacks on the web to try to achieve this automatically -// (e.g. [1]) but they rely on using the Microsoft build tools, -// which doesn't work for us. -// -// Note another important issue with ThreadStore instances: if you create -// one instance in a shared library, you need to make sure that it is -// always destroyed before the library is unloaded. Otherwise, future -// thread exit will likely crash, due to calling a destructor function -// that is no longer in the process' address space. -// -// Finally, destroying an instance does _not_ free the corresponding values, -// because doing so properly requires coordinating all participating threads, -// which is impossible to achieve in the most general case. Thus, consider -// that thread-local values are always leaked on library unload, or on -// program exit. -// -// [1] http://stackoverflow.com/questions/14538159/about-tls-callback-in-windows - -class ThreadStore { -public: - // Type of a function used to destroy a thread-specific value that - // was previously assigned by calling set(). - typedef void (Destructor)(void* value); - - // Initialize instance so that is hold keys that must be destroyed - // on thread exit by calling |destroy|. - explicit ThreadStore(Destructor* destroy); - - // NOTE: Destructor don't free the thread-local values, but are required - // to avoid crashes (see note above). - ~ThreadStore(); - - // Retrieve current thread-specific value from store. -#ifdef _WIN32 - void* get() const; -#else - inline void* get() const { - return pthread_getspecific(mKey); - } -#endif - - // Set the new thread-specific value. -#ifdef _WIN32 - void set(void* value); -#else - inline void set(void* value) { - pthread_setspecific(mKey, value); - } -#endif - -#ifdef _WIN32 - // Each thread should call this function on exit to ensure that - // all corresponding TLS values are properly freed. - static void OnThreadExit(); -#else - // Nothing to do on Posix. - static inline void OnThreadExit() {} -#endif - -private: - // Ensure you can't create an empty ThreadStore instance, or simply - // copy it in any way. - ThreadStore(); - ThreadStore(const ThreadStore&); - ThreadStore& operator=(const ThreadStore&); - -#ifdef _WIN32 - int mKey; -#else - pthread_key_t mKey; -#endif -}; - -} // namespace emugl - -#endif // EMUGL_COMMON_THREAD_STORE_H diff --git a/emulator/opengl/shared/emugl/common/thread_store_unittest.cpp b/emulator/opengl/shared/emugl/common/thread_store_unittest.cpp deleted file mode 100644 index 6b5dddb..0000000 --- a/emulator/opengl/shared/emugl/common/thread_store_unittest.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/thread_store.h" - -#include "emugl/common/mutex.h" -#include "emugl/common/testing/test_thread.h" - -#include <gtest/gtest.h> - -namespace emugl { - -namespace { - -// Helper class used to count instance creation and destruction. -class StaticCounter { -public: - enum { - kMaxInstances = 1000, - }; - - StaticCounter() { - Mutex::AutoLock lock(mMutex); - if (mCreationCount < kMaxInstances) - mInstances[mCreationCount] = this; - mCreationCount++; - } - - ~StaticCounter() { - Mutex::AutoLock lock(mMutex); - mDestructionCount++; - } - - static void reset() { - Mutex::AutoLock lock(mMutex); - mCreationCount = 0; - mDestructionCount = 0; - } - - static size_t getCreationCount() { - Mutex::AutoLock lock(mMutex); - return mCreationCount; - } - - static size_t getDestructionCount() { - Mutex::AutoLock lock(mMutex); - return mDestructionCount; - } - - static void freeAll() { - for (size_t n = 0; n < kMaxInstances; ++n) - delete mInstances[n]; - } - -private: - static Mutex mMutex; - static size_t mCreationCount; - static size_t mDestructionCount; - static StaticCounter* mInstances[kMaxInstances]; -}; - -Mutex StaticCounter::mMutex; -size_t StaticCounter::mCreationCount = 0; -size_t StaticCounter::mDestructionCount = 0; -StaticCounter* StaticCounter::mInstances[kMaxInstances]; - -} // namespace - -// Just check that we can create a new ThreadStore with an empty -// destructor, and use it in the current thread. -TEST(ThreadStore, MainThreadWithoutDestructor) { - ThreadStore store(NULL); - static int x = 42; - store.set(&x); - EXPECT_EQ(&x, store.get()); -} - -// The following test checks that exiting a thread correctly deletes -// any thread-local value stored in it. -static void simplyDestroy(void* value) { - delete (StaticCounter*) value; -} - -static void* simpleThreadFunc(void* param) { - ThreadStore* store = static_cast<ThreadStore*>(param); - store->set(new StaticCounter()); - ThreadStore::OnThreadExit(); - return NULL; -} - -TEST(ThreadStore, ThreadsWithDestructor) { - ThreadStore store(simplyDestroy); - const size_t kNumThreads = 1000; - TestThread* threads[kNumThreads]; - StaticCounter::reset(); - - for (size_t n = 0; n < kNumThreads; ++n) { - threads[n] = new TestThread(&simpleThreadFunc, &store); - } - for (size_t n = 0; n < kNumThreads; ++n) { - threads[n]->join(); - } - - EXPECT_EQ(kNumThreads, StaticCounter::getCreationCount()); - EXPECT_EQ(kNumThreads, StaticCounter::getDestructionCount()); - - for (size_t n = 0; n < kNumThreads; ++n) { - delete threads[n]; - } -} - -TEST(ThreadStore, ThreadsWithoutDestructor) { - ThreadStore store(NULL); - const size_t kNumThreads = 1000; - TestThread* threads[kNumThreads]; - StaticCounter::reset(); - - for (size_t n = 0; n < kNumThreads; ++n) { - threads[n] = new TestThread(&simpleThreadFunc, &store); - } - for (size_t n = 0; n < kNumThreads; ++n) { - threads[n]->join(); - } - - EXPECT_EQ(kNumThreads, StaticCounter::getCreationCount()); - EXPECT_EQ(0U, StaticCounter::getDestructionCount()); - - StaticCounter::freeAll(); - - for (size_t n = 0; n < kNumThreads; ++n) { - delete threads[n]; - } -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/thread_unittest.cpp b/emulator/opengl/shared/emugl/common/thread_unittest.cpp deleted file mode 100644 index db1931f..0000000 --- a/emulator/opengl/shared/emugl/common/thread_unittest.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/thread.h" - -#include "emugl/common/mutex.h" - -#include <gtest/gtest.h> - -namespace emugl { - -namespace { - -// A simple thread instance that does nothing at all and exits immediately. -class EmptyThread : public ::emugl::Thread { -public: - intptr_t main() { return 42; } -}; - -class CountingThread : public ::emugl::Thread { -public: - class State { - public: - State() : mLock(), mCount(0) {} - ~State() {} - - void increment() { - mLock.lock(); - mCount++; - mLock.unlock(); - } - - int count() const { - int ret; - mLock.lock(); - ret = mCount; - mLock.unlock(); - return ret; - } - - private: - mutable Mutex mLock; - int mCount; - }; - - CountingThread(State* state) : mState(state) {} - - intptr_t main() { - mState->increment(); - return 0; - } - -private: - State* mState; -}; - -} // namespace - -TEST(ThreadTest, SimpleThread) { - Thread* thread = new EmptyThread(); - EXPECT_TRUE(thread); - EXPECT_TRUE(thread->start()); - intptr_t status; - EXPECT_TRUE(thread->wait(&status)); - EXPECT_EQ(42, status); -} - -TEST(ThreadTest, MultipleThreads) { - CountingThread::State state; - const size_t kMaxThreads = 100; - Thread* threads[kMaxThreads]; - - // Create all threads. - for (size_t n = 0; n < kMaxThreads; ++n) { - threads[n] = new CountingThread(&state); - EXPECT_TRUE(threads[n]) << "thread " << n; - } - - // Start them all. - for (size_t n = 0; n < kMaxThreads; ++n) { - EXPECT_TRUE(threads[n]->start()) << "thread " << n; - } - - // Wait for them all. - for (size_t n = 0; n < kMaxThreads; ++n) { - EXPECT_TRUE(threads[n]->wait(NULL)) << "thread " << n; - } - - // Check state. - EXPECT_EQ((int)kMaxThreads, state.count()); - - // Delete them all. - for (size_t n = 0; n < kMaxThreads; ++n) { - delete threads[n]; - } -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/thread_win32.cpp b/emulator/opengl/shared/emugl/common/thread_win32.cpp deleted file mode 100644 index f348ca8..0000000 --- a/emulator/opengl/shared/emugl/common/thread_win32.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/thread.h" - -#include "emugl/common/thread_store.h" - -namespace emugl { - -namespace { - -class ScopedLocker { -public: - ScopedLocker(CRITICAL_SECTION* section) : mSection(section) { - EnterCriticalSection(mSection); - } - - ~ScopedLocker() { - LeaveCriticalSection(mSection); - } -private: - CRITICAL_SECTION* mSection; -}; - -} // namespace - -Thread::Thread() : - mThread(INVALID_HANDLE_VALUE), - mThreadId(0), - mExitStatus(0), - mIsRunning(false) { - InitializeCriticalSection(&mLock); -} - -Thread::~Thread() { - if(mThread != INVALID_HANDLE_VALUE) { - CloseHandle(mThread); - } - DeleteCriticalSection(&mLock); -} - -bool Thread::start() { - ScopedLocker locker(&mLock); - - bool ret = true; - mIsRunning = true; - mThread = CreateThread(NULL, 0, &Thread::thread_main, this, 0, &mThreadId); - if (!mThread) { - ret = false; - mIsRunning = false; - } - return ret; -} - -bool Thread::wait(intptr_t* exitStatus) { - { - ScopedLocker locker(&mLock); - if (!mIsRunning) { - // Thread already stopped. - if (exitStatus) { - *exitStatus = mExitStatus; - } - return true; - } - } - - // NOTE: Do not hold lock during wait to aloow thread_main to - // properly update mIsRunning and mExitStatus on thread exit. - if (WaitForSingleObject(mThread, INFINITE) == WAIT_FAILED) { - return false; - } - - if (exitStatus) { - ScopedLocker locker(&mLock); - *exitStatus = mExitStatus; - } - return true; -} - -bool Thread::tryWait(intptr_t* exitStatus) { - ScopedLocker locker(&mLock); - - if (!mIsRunning || - WaitForSingleObject(mThread, 0) != WAIT_OBJECT_0) { - return false; - } - - if (exitStatus) { - *exitStatus = mExitStatus; - } - return true; -} - -// static -DWORD WINAPI Thread::thread_main(void *arg) -{ - Thread* self = reinterpret_cast<Thread*>(arg); - intptr_t ret = self->main(); - - EnterCriticalSection(&self->mLock); - self->mIsRunning = false; - self->mExitStatus = ret; - LeaveCriticalSection(&self->mLock); - - // Ensure all thread-local values are released for this thread. - ::emugl::ThreadStore::OnThreadExit(); - - return static_cast<DWORD>(ret); -} - -} // namespace emugl diff --git a/emulator/opengl/shared/emugl/common/unique_integer_map.h b/emulator/opengl/shared/emugl/common/unique_integer_map.h deleted file mode 100644 index 720aceb..0000000 --- a/emulator/opengl/shared/emugl/common/unique_integer_map.h +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (C) 2014 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 EMUGL_COMMON_UNIQUE_INTEGER_MAP_H -#define EMUGL_COMMON_UNIQUE_INTEGER_MAP_H - -#include "emugl/common/pod_vector.h" - -#include <stdint.h> - -namespace emugl { - -// Helper template class that implements a bi-directional mapping between -// two integer types |A| and |B|. More specifically: -// -// - The map allocates values of type |B| when a key of type |A| is entered -// in the map. -// -// - keys and values cannot be 0, which is reserved (i.e. means 'invalid'). -// -// This is used in EmuGL to map liberal 'void*' values (e.g. EGLimages ones) -// to unique 32-bit IDs that can be written to / read from the wire protocol. -template <typename A, typename B> -class UniqueIntegerMap { -public: - UniqueIntegerMap() : mForwardPairs(), mBackwardPairs() {} - ~UniqueIntegerMap() {} - - // Return true iff the map is empty. - const bool empty() const { return mForwardPairs.empty(); } - - // Return the number of (key,value) pairs in the map. - size_t size() const { return mForwardPairs.size(); } - - // Find the value associated with |key| in the map. - // Returns 0 in case of failure, or if |key| is 0. - B find(const A key) const; - - // Find the key associated with a given |value| in the map. - // Returns 0 if |value| is 0, or in case of failure. - A findKeyFor(const B value) const; - - // Add |key| to the map and return an automatically-allocated - // unique value for it. Return 0 if |key| is 0. - B add(const A key); - - // Delete the entry associated with a given |key|. The - // corresponding value may be recycled by future calls to add(). - void del(const A key); - -private: - typedef struct { - A first; - B second; - } ForwardPair; - - typedef struct { - B first; - A second; - } BackwardPair; - - size_t findKeyIndexPlusOne(const A key) const; - size_t findValueIndexPlusOne(const B value) const; - - B allocValue(); - void freeValue(B value); - - PodVector<ForwardPair> mForwardPairs; - PodVector<BackwardPair> mBackwardPairs; - - B mLastValue; - PodVector<B> mFreeValues; -}; - -template <typename A, typename B> -B UniqueIntegerMap<A,B>::find(const A key) const { - size_t keyIndex = findKeyIndexPlusOne(key); - if (!keyIndex) { - return 0; - } - return mForwardPairs[keyIndex - 1U].second; -} - -template <typename A, typename B> -A UniqueIntegerMap<A,B>::findKeyFor(const B value) const { - size_t valueIndex = findValueIndexPlusOne(value); - if (!valueIndex) { - return 0; - } - return mBackwardPairs[valueIndex - 1U].second; -} - -template <typename A, typename B> -B UniqueIntegerMap<A,B>::add(const A key) { - // Binary search to find the proper insertion point for the key. - // Also checks that the key isn't already in the set. - size_t min = 0; - size_t max = mForwardPairs.size(); - while (min < max) { - size_t mid = min + ((max - min) >> 1); - A midKey = mForwardPairs[mid].first; - if (midKey < key) { - min = mid + 1U; - } else if (midKey > key) { - max = mid; - } else { - // Already in the set. - return 0; - } - } - - // Generate new unique value - B value = allocValue(); - - ForwardPair* pair = mForwardPairs.emplace(min); - pair->first = key; - pair->second = value; - - // Binary search to find proper insertion point for the value. - min = 0; - max = mBackwardPairs.size(); - while (min < max) { - size_t mid = min + ((max - min) >> 1); - B midValue = mBackwardPairs[mid].first; - if (midValue < value) { - min = mid + 1U; - } else { - max = mid; - } - } - - BackwardPair* backPair = mBackwardPairs.emplace(min); - backPair->first = value; - backPair->second = key; - - return value; -} - -template <typename A, typename B> -void UniqueIntegerMap<A,B>::del(const A key) { - size_t keyIndex = findKeyIndexPlusOne(key); - if (!keyIndex) { - return; - } - B value = mForwardPairs[keyIndex - 1U].second; - size_t valueIndex = findValueIndexPlusOne(value); - mForwardPairs.remove(keyIndex - 1U); - mBackwardPairs.remove(valueIndex - 1U); - freeValue(value); -} - -template <typename A, typename B> -size_t UniqueIntegerMap<A,B>::findKeyIndexPlusOne(const A key) const { - // Binary search in forward pair array. - size_t min = 0; - size_t max = mForwardPairs.size(); - while (min < max) { - size_t mid = min + ((max - min) >> 1); - A midKey = mForwardPairs[mid].first; - if (midKey < key) { - min = mid + 1U; - } else if (midKey > key) { - max = mid; - } else { - return mid + 1U; - } - } - return 0U; -} - -template <typename A, typename B> -size_t UniqueIntegerMap<A,B>::findValueIndexPlusOne(const B value) const { - // Binary search in revere pair array. - size_t min = 0; - size_t max = mBackwardPairs.size(); - while (min < max) { - size_t mid = min + ((max - min) >> 1); - B midValue = mBackwardPairs[mid].first; - if (midValue < value) { - min = mid + 1U; - } else if (midValue > value) { - max = mid; - } else { - return mid + 1U; - } - } - return 0U; -} - -template <typename A, typename B> -B UniqueIntegerMap<A,B>::allocValue() { - if (!mFreeValues.empty()) { - B result = mFreeValues[0]; - mFreeValues.pop(); - return result; - } - return ++mLastValue; -} - -template <typename A, typename B> -void UniqueIntegerMap<A,B>::freeValue(B value) { - if (!value) { - return; - } - if (value == mLastValue) { - mLastValue--; - return; - } - mFreeValues.append(value); -} - -} // namespace emugl - -#endif // EMUGL_COMMON_INTEGER_MAP_H diff --git a/emulator/opengl/shared/emugl/common/unique_integer_map_unittest.cpp b/emulator/opengl/shared/emugl/common/unique_integer_map_unittest.cpp deleted file mode 100644 index 8aee013..0000000 --- a/emulator/opengl/shared/emugl/common/unique_integer_map_unittest.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2014 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 "emugl/common/unique_integer_map.h" - -#include <gtest/gtest.h> - -#include <stdio.h> - -namespace emugl { - -typedef UniqueIntegerMap<uintptr_t,uint32_t> MyMap; - -TEST(UniqueIntegerMap, Empty) { - MyMap map; - - EXPECT_TRUE(map.empty()); - EXPECT_EQ(0U, map.size()); - EXPECT_EQ(0U, map.find(0U)); - EXPECT_EQ(0U, map.find(1U)); - EXPECT_EQ(0U, map.find(2U)); - EXPECT_EQ(0U, map.find(4U)); -} - -TEST(UniqueIntegerMap, AddOne) { - MyMap map; - uintptr_t key1 = 1U; - uint32_t val1 = map.add(key1); - - EXPECT_NE(0U, val1); - EXPECT_EQ(val1, map.find(key1)); - EXPECT_EQ(key1, map.findKeyFor(val1)); - - EXPECT_FALSE(map.empty()); - EXPECT_EQ(1U, map.size()); - - EXPECT_EQ(0U, map.find(0)); - EXPECT_EQ(0U, map.findKeyFor(0)); - - EXPECT_EQ(0U, map.find(key1 + 1)); - EXPECT_EQ(0U, map.findKeyFor(val1 + 1)); -} - -TEST(UniqueIntegerMap, AddMultiple) { - MyMap map; - const size_t kCount = 100; - const size_t kKeyMultiplier = 3U; // must be >= 2. - uint32_t values[kCount]; - - for (size_t n = 0; n < kCount; ++n) { - uintptr_t key = 1U + n * kKeyMultiplier; - values[n] = map.add(key); - EXPECT_NE(0U, values[n]) << "key #" << n; - } - - EXPECT_EQ(kCount, map.size()); - - for (size_t n = 0; n < kCount; ++n) { - uintptr_t key = 1U + n * kKeyMultiplier; - EXPECT_EQ(values[n], map.find(key)) << "key #" << n; - EXPECT_EQ(0U, map.find(key + 1U)) << "key #" << n; - } - - for (size_t n = 0; n < kCount; ++n) { - uintptr_t key = 1U + n * kKeyMultiplier; - EXPECT_EQ(key, map.findKeyFor(values[n])); - } -} - -TEST(UniqueIntegerMap, Del) { - MyMap map; - const size_t kCount = 100; - const size_t kKeyMultiplier = 3U; // must be >= 2. - uint32_t values[kCount]; - - for (size_t n = 0; n < kCount; ++n) { - uintptr_t key = 1U + n * kKeyMultiplier; - values[n] = map.add(key); - } - - for (size_t n = 0; n < kCount; ++n) { - uintptr_t key = 1U + n * kKeyMultiplier; - map.del(key); - EXPECT_EQ(kCount - 1U - n, map.size()); - EXPECT_EQ(0U, map.find(key)); - EXPECT_EQ(0U, map.findKeyFor(values[n])); - } - - EXPECT_TRUE(map.empty()); -} - -} // namespace emugl |