summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gall <tom.gall@linaro.org>2014-10-05 23:02:12 -0500
committerTom Gall <tom.gall@linaro.org>2014-10-05 23:02:12 -0500
commitffbf61c267a162c3e5d41c9ff310e2c8dae1c3bd (patch)
treeb966b6d1b2c0a6bcb8787e234defcd47ac2a1f0b
Initial commit
This is the reference implementation with the miniEGL code stripped out Tests are simplistic at this point. Windowing uses traditional egl (mesa test) but should work with mali egl too.
-rw-r--r--CMakeLists.txt92
-rw-r--r--include/EGL/egl.h331
-rw-r--r--include/EGL/egl.h.org318
-rw-r--r--include/EGL/eglext.h539
-rw-r--r--include/EGL/eglplatform.h122
-rw-r--r--include/EGL/fbdev_window.h52
-rw-r--r--include/KHR/khrplatform.h273
-rw-r--r--include/VG/openvg.h752
-rw-r--r--include/VG/vgext.h274
-rw-r--r--include/VG/vgplatform.h106
-rw-r--r--include/VG/vgu.h131
-rw-r--r--include/esUtil.h285
-rw-r--r--src/es/esShader.c155
-rw-r--r--src/es/esShapes.c280
-rw-r--r--src/es/esTransform.c213
-rw-r--r--src/es/esUtil.c428
-rw-r--r--src/vg/Api.cpp3672
-rw-r--r--src/vg/Api.cpp.tg37
-rw-r--r--src/vg/Array.h209
-rw-r--r--src/vg/Context.cpp329
-rw-r--r--src/vg/Context.h257
-rw-r--r--src/vg/Defs.h119
-rw-r--r--src/vg/EGLAddOn.cpp868
-rw-r--r--src/vg/Font.cpp203
-rw-r--r--src/vg/Font.h102
-rw-r--r--src/vg/Image.cpp2675
-rw-r--r--src/vg/Image.h371
-rw-r--r--src/vg/Math.cpp75
-rw-r--r--src/vg/Math.h380
-rw-r--r--src/vg/Path.cpp2579
-rw-r--r--src/vg/Path.h177
-rw-r--r--src/vg/PixelPipe.cpp894
-rw-r--r--src/vg/PixelPipe.h150
-rw-r--r--src/vg/Rasterizer.cpp499
-rw-r--r--src/vg/Rasterizer.h165
-rw-r--r--src/vgu/VGU.cpp469
-rw-r--r--tests/Simple_Texture2D/CMakeLists.txt39
-rw-r--r--tests/Simple_Texture2D/main.c216
-rw-r--r--tests/font/CMakeLists.txt39
-rw-r--r--tests/font/Default-568h@2x.pngbin0 -> 18594 bytes
-rw-r--r--tests/font/DejaVuSans.inc937
-rw-r--r--tests/font/DejaVuSansMono.inc965
-rw-r--r--tests/font/DejaVuSerif.inc1110
-rw-r--r--tests/font/arial.fnt202
-rw-r--r--tests/font/arial.pngbin0 -> 184102 bytes
-rw-r--r--tests/font/circle_poly.svg20
-rw-r--r--tests/font/cmake/modules/FindEGL.cmake15
-rw-r--r--tests/font/delorean.pngbin0 -> 25751 bytes
-rw-r--r--tests/font/eglstate.h11
-rw-r--r--tests/font/fontinfo.h19
-rw-r--r--tests/font/inc/EGL/egl.h329
-rw-r--r--tests/font/inc/EGL/eglext.h539
-rw-r--r--tests/font/inc/EGL/eglplatform.h122
-rw-r--r--tests/font/inc/EGL/fbdev_window.h50
-rw-r--r--tests/font/inc/GLES/gl.h770
-rw-r--r--tests/font/inc/GLES/glext.h1278
-rw-r--r--tests/font/inc/GLES/glplatform.h30
-rw-r--r--tests/font/inc/GLES2/gl2.h620
-rw-r--r--tests/font/inc/GLES2/gl2ext.h1809
-rw-r--r--tests/font/inc/GLES2/gl2platform.h30
-rw-r--r--tests/font/inc/GLES3/gl3.h1061
-rw-r--r--tests/font/inc/GLES3/gl3ext.h24
-rw-r--r--tests/font/inc/GLES3/gl3platform.h30
-rw-r--r--tests/font/inc/KHR/khrplatform.h273
-rw-r--r--tests/font/inc/VG/openvg.h746
-rw-r--r--tests/font/inc/VG/vgext.h233
-rw-r--r--tests/font/inc/VG/vgplatform.h106
-rw-r--r--tests/font/inc/VG/vgu.h131
-rw-r--r--tests/font/inc/tiger.h45
-rw-r--r--tests/font/main.c663
-rw-r--r--tests/font/square.svg4
-rw-r--r--tests/font/testfont.fnt99
-rw-r--r--tests/font/testfont.pngbin0 -> 30638 bytes
-rw-r--r--tests/font/zero.pngbin0 -> 35255 bytes
74 files changed, 31146 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..84db850
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,92 @@
+cmake_minimum_required(VERSION 2.8)
+
+# Project Options:
+
+
+set(PROJECT_NAME_STR OpenVG)
+set(VG_LIBRARY_NAME_STR ${PROJECT_NAME_STR})
+set(VGU_LIBRARY_NAME_STR ${PROJECT_NAME_STR}U)
+project($(PROJECT_NAME_STR))
+
+MESSAGE(STATUS "Project : OpenVG Library")
+
+
+SET(DEFAULT_DEV_INSTALL_DIR /usr/local)
+MESSAGE(STATUS "Install path is ${CMAKE_INSTALL_PREFIX}")
+
+# choose target
+if(TARGET)
+ if(${TARGET} STREQUAL "arm")
+ message ("Building for ${TARGET} with fb\n")
+ set(EGL_LIB_PATH "\"/usr/lib/libEGL.so\"")
+# INCLUDE_DIRECTORIES(/root/Mali_OpenGL_ES_SDK_v2.4.0/inc/EGL)
+# INCLUDE_DIRECTORIES(/root/Mali_OpenGL_ES_SDK_v2.4.0/inc)
+ elseif(${TARGET} STREQUAL "x86")
+ message ("Building for ${TARGET}\n")
+ set(EGL_LIB_PATH "\"/usr/lib/x86_64-linux-gnu/mesa-egl/libEGL.so\"")
+ INCLUDE_DIRECTORIES(/usr/include/EGL)
+ set(CMAKE_C_FLAGS "-DMESA_EGL_NO_X11_HEADERS")
+ set(CMAKE_CXX_FLAGS "-DMESA_EGL_NO_X11_HEADERS -fpermissive")
+ else()
+ MESSAGE(FATAL_ERROR "Target ${TARGET} is not valid. Choices are \"x86\" and \"arm\".")
+ endif()
+else(TARGET)
+ message ("TARGET was not set. Choices are \"x86\" and \"arm\".")
+ message ("Example usage: cmake .. -DTARGET=arm")
+ message ("Now using [arm] as default.\n")
+ set (TARGET "arm")
+ message ("Building for ${TARGET}\n")
+ set(EGL_LIB_PATH "\"/usr/lib/libEGL.so\"")
+
+endif(TARGET)
+message ("EGL PATH:${EGL_LIB_PATH} \n")
+add_definitions( -DEGLLIB=${EGL_LIB_PATH} )
+message ("PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}\n")
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
+
+# Set up install permissions for file, directories and binaries.
+# !!! Note that these variables are used by the child cmake files so these
+# variables must be set before the add_subdirectories() commands below
+# File permissions (664)
+set(LIB_FPERMS PERMISSIONS
+ OWNER_READ OWNER_WRITE
+ GROUP_READ GROUP_WRITE
+ WORLD_READ)
+
+#set(CMAKE_CXX_FLAGS "-O3 -mcpu=cortex-a15 -mfpu=neon-vfpv4 -ftree-vectorize -funsafe-math-optimizations -mfloat-abi=hard" CACHE STRING "" FORCE)
+set(CMAKE_CXX_FLAGS "-g -std=c++11 -mcpu=cortex-a15 -mfpu=neon-vfpv4 -ftree-vectorize -funsafe-math-optimizations" CACHE STRING "" FORCE)
+set(CMAKE_C_FLAGS "-g -mcpu=cortex-a15 -mfpu=neon-vfpv4 -ftree-vectorize -funsafe-math-optimizations" CACHE STRING "" FORCE)
+# set(CMAKE_CXX_FLAGS "-g -O3 -std=c++11 -mcpu=cortex-a15 -mfpu=neon-vfpv4 -ftree-vectorize -funsafe-math-optimizations" CACHE STRING "" FORCE)
+#LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
+
+set(VG_SOURCEFILES
+ src/es/esShader.c
+ src/es/esShapes.c
+ src/es/esTransform.c
+ src/es/esUtil.c
+ src/vg/Math.cpp
+ src/vg/Image.cpp
+ src/vg/Context.cpp
+ src/vg/Font.cpp
+ src/vg/Path.cpp
+ src/vg/PixelPipe.cpp
+ src/vg/Rasterizer.cpp
+ src/vg/Api.cpp
+ src/vg/EGLAddOn.cpp
+ )
+
+set(VGU_SOURCEFILES
+ src/vgu/VGU.cpp
+ )
+
+message ("VG_SOURCEFILES = ${VG_SOURCEFILES}\n")
+message ("VGU_SOURCEFILES = ${VGU_SOURCEFILES}\n")
+
+add_library(${VG_LIBRARY_NAME_STR} SHARED ${VG_SOURCEFILES})
+add_library(${VGU_LIBRARY_NAME_STR} SHARED ${VGU_SOURCEFILES})
+
+#target_link_libraries(${PROJECT_NAME_STR})
+
+install(TARGETS ${VG_LIBRARY_NAME_STR} LIBRARY DESTINATION lib ${LIB_FPERMS})
+install(TARGETS ${VGU_LIBRARY_NAME_STR} LIBRARY DESTINATION lib ${LIB_FPERMS})
diff --git a/include/EGL/egl.h b/include/EGL/egl.h
new file mode 100644
index 0000000..18527e9
--- /dev/null
+++ b/include/EGL/egl.h
@@ -0,0 +1,331 @@
+/* -*- 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 void eglOpenVGInit(EGLSurface surface);
+EGLAPI void eglVGDrawFunction(EGLSurface surface);
+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/include/EGL/egl.h.org b/include/EGL/egl.h.org
new file mode 100644
index 0000000..c95dfc9
--- /dev/null
+++ b/include/EGL/egl.h.org
@@ -0,0 +1,318 @@
+#ifndef __egl_h_
+#define __egl_h_
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief EGL 1.3 API.
+ *//*-------------------------------------------------------------------*/
+
+/* All platform-dependent types and macro boilerplate (such as EGLAPI
+ * and EGLAPIENTRY) should go in eglplatform.h.
+ */
+/*#include <EGL/eglplatform.h>*/
+
+/* Platform-specific types and definitions for egl.h */
+
+#ifndef __eglplatform_h_
+#define __eglplatform_h_
+
+#define EGLAPIENTRY /* empty */
+
+#if defined(EGL_STATIC_LIBRARY)
+# define EGLAPI
+#else
+# if defined(_WIN32) || defined(__VC32__) /* Win32 */
+# if defined (OPENVG_DLL_EXPORTS)
+# define EGLAPI __declspec(dllexport)
+# else
+# define EGLAPI __declspec(dllimport)
+# endif
+# elif defined(__APPLE__) /* Mac OS X */
+# define EGLAPI extern
+# endif
+#endif /* defined(EGL_STATIC_LIBRARY) */
+
+typedef struct
+{
+ int format; /*VGImageFormat cast to int*/
+ int width;
+ int height;
+ int stride; /*in bytes*/
+ void* data;
+} NativePixmap;
+
+typedef void* NativeDisplayType;
+typedef void* NativeWindowType;
+typedef NativePixmap* NativePixmapType;
+
+/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
+typedef NativeDisplayType EGLNativeDisplayType;
+typedef NativePixmapType EGLNativePixmapType;
+typedef NativeWindowType EGLNativeWindowType;
+
+#endif /* __eglplatform_h */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* EGL Types */
+typedef int EGLint; /* NOTE: official EGL 1.3 header defines this as int32_t */
+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
+
+/* 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 ((void *)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_PRESERVED_RESOURCES 0x3030
+#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
+#define EGL_CONFORMANT_KHR EGL_CONFORMANT
+
+/* 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_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 */
+
+/* QueryString targets */
+#define EGL_VENDOR 0x3053
+#define EGL_VERSION 0x3054
+#define EGL_EXTENSIONS 0x3055
+#define EGL_CLIENT_APIS 0x308D
+
+/* QuerySurface / 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
+
+/* 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
+
+/* BindAPI/QueryAPI targets */
+#define EGL_OPENGL_ES_API 0x30A0
+#define EGL_OPENVG_API 0x30A1
+
+/* 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 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);
+EGLAPI void (* EGLAPIENTRY eglGetProcAddress(const char *procname))(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __egl_h_ */
diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
new file mode 100644
index 0000000..8e9e610
--- /dev/null
+++ b/include/EGL/eglext.h
@@ -0,0 +1,539 @@
+#ifndef __eglext_h_
+#define __eglext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007-2012 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: 19987 $ on $Date: 2012-12-13 16:46:46 -0800 (Thu, 13 Dec 2012) $ */
+#define EGL_EGLEXT_VERSION 14
+
+#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
+
+#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */
+#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
+#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_KHR_lock_surface2
+#define EGL_KHR_lock_surface2 1
+#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110
+#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
+
+#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */
+#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 khronos_utime_nanoseconds_t EGLTimeNV;
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync);
+EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync);
+EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
+EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
+EGLAPI EGLBoolean EGLAPIENTRY 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
+#endif
+
+#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */
+#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
+#endif
+
+#ifndef EGL_HI_clientpixmap
+#define EGL_HI_clientpixmap 1
+
+/* Surface Attribute */
+#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74
+/*
+ * Structure representing a client pixmap
+ * (pixmap's data is in client-space memory).
+ */
+struct EGLClientPixmapHI
+{
+ void* pData;
+ EGLint iWidth;
+ EGLint iHeight;
+ EGLint iStride;
+};
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
+#endif /* EGL_HI_clientpixmap */
+
+#ifndef EGL_HI_colorformats
+#define EGL_HI_colorformats 1
+/* Config Attribute */
+#define EGL_COLOR_FORMAT_HI 0x8F70
+/* Color Formats */
+#define EGL_COLOR_RGB_HI 0x8F71
+#define EGL_COLOR_RGBA_HI 0x8F72
+#define EGL_COLOR_ARGB_HI 0x8F73
+#endif /* EGL_HI_colorformats */
+
+#ifndef EGL_MESA_drm_image
+#define EGL_MESA_drm_image 1
+#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */
+#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */
+#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */
+#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */
+#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4
+#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */
+#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
+#endif
+
+#ifndef EGL_NV_post_sub_buffer
+#define EGL_NV_post_sub_buffer 1
+#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
+#endif
+
+#ifndef EGL_ANGLE_query_surface_pointer
+#define EGL_ANGLE_query_surface_pointer 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
+#endif
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
+#endif
+
+#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
+#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
+#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
+#endif
+
+#ifndef EGL_NV_coverage_sample_resolve
+#define EGL_NV_coverage_sample_resolve 1
+#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131
+#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
+#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133
+#endif
+
+#if KHRONOS_SUPPORT_INT64 /* EGLuint64NV requires 64-bit uint support */
+#ifndef EGL_NV_system_time
+#define EGL_NV_system_time 1
+typedef khronos_utime_nanoseconds_t EGLuint64NV;
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
+EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
+typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
+#endif
+#endif
+
+#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */
+#ifndef EGL_KHR_stream
+#define EGL_KHR_stream 1
+typedef void* EGLStreamKHR;
+typedef khronos_uint64_t EGLuint64KHR;
+#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0)
+#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210
+#define EGL_PRODUCER_FRAME_KHR 0x3212
+#define EGL_CONSUMER_FRAME_KHR 0x3213
+#define EGL_STREAM_STATE_KHR 0x3214
+#define EGL_STREAM_STATE_CREATED_KHR 0x3215
+#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216
+#define EGL_STREAM_STATE_EMPTY_KHR 0x3217
+#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218
+#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219
+#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A
+#define EGL_BAD_STREAM_KHR 0x321B
+#define EGL_BAD_STATE_KHR 0x321C
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_consumer_gltexture
+#define EGL_KHR_stream_consumer_gltexture 1
+#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_producer_eglsurface
+#define EGL_KHR_stream_producer_eglsurface 1
+#define EGL_STREAM_BIT_KHR 0x0800
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_producer_aldatalocator
+#define EGL_KHR_stream_producer_aldatalocator 1
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_fifo
+#define EGL_KHR_stream_fifo 1
+/* reuse EGLTimeKHR */
+#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC
+#define EGL_STREAM_TIME_NOW_KHR 0x31FD
+#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE
+#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
+#endif
+#endif
+
+#ifndef EGL_EXT_create_context_robustness
+#define EGL_EXT_create_context_robustness 1
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
+#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE
+#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF
+#endif
+
+#ifndef EGL_ANGLE_d3d_share_handle_client_buffer
+#define EGL_ANGLE_d3d_share_handle_client_buffer 1
+/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */
+#endif
+
+#ifndef EGL_KHR_create_context
+#define EGL_KHR_create_context 1
+#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
+#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
+#define EGL_CONTEXT_FLAGS_KHR 0x30FC
+#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD
+#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE
+#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF
+#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
+#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
+#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
+#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
+#define EGL_OPENGL_ES3_BIT_KHR 0x00000040
+#endif
+
+#ifndef EGL_KHR_surfaceless_context
+#define EGL_KHR_surfaceless_context 1
+/* No tokens/entry points, just relaxes an error condition */
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_cross_process_fd
+#define EGL_KHR_stream_cross_process_fd 1
+typedef int EGLNativeFileDescriptorKHR;
+#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1))
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
+#endif
+#endif
+
+#ifndef EGL_EXT_multiview_window
+#define EGL_EXT_multiview_window 1
+#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134
+#endif
+
+#ifndef EGL_KHR_wait_sync
+#define EGL_KHR_wait_sync 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+#endif
+
+#ifndef EGL_NV_post_convert_rounding
+#define EGL_NV_post_convert_rounding 1
+/* No tokens or entry points, just relaxes behavior of SwapBuffers */
+#endif
+
+#ifndef EGL_NV_native_query
+#define EGL_NV_native_query 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV( EGLDisplay dpy, EGLNativeDisplayType* display_id);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV( EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType* window);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV( EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType* pixmap);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)(EGLDisplay dpy, EGLNativeDisplayType *display_id);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap);
+#endif
+
+#ifndef EGL_NV_3dvision_surface
+#define EGL_NV_3dvision_surface 1
+#define EGL_AUTO_STEREO_NV 0x3136
+#endif
+
+#ifndef EGL_ANDROID_framebuffer_target
+#define EGL_ANDROID_framebuffer_target 1
+#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147
+#endif
+
+#ifndef EGL_ANDROID_blob_cache
+#define EGL_ANDROID_blob_cache 1
+typedef khronos_ssize_t EGLsizeiANDROID;
+typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);
+typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
+#endif
+
+#ifndef EGL_ANDROID_image_native_buffer
+#define EGL_ANDROID_image_native_buffer 1
+#define EGL_NATIVE_BUFFER_ANDROID 0x3140
+#endif
+
+#ifndef EGL_ANDROID_native_fence_sync
+#define EGL_ANDROID_native_fence_sync 1
+#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
+#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
+#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146
+#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, EGLSyncKHR);
+#endif
+
+#ifndef EGL_ANDROID_recordable
+#define EGL_ANDROID_recordable 1
+#define EGL_RECORDABLE_ANDROID 0x3142
+#endif
+
+#ifndef EGL_EXT_buffer_age
+#define EGL_EXT_buffer_age 1
+#define EGL_BUFFER_AGE_EXT 0x313D
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __eglext_h_ */
diff --git a/include/EGL/eglplatform.h b/include/EGL/eglplatform.h
new file mode 100644
index 0000000..6d04553
--- /dev/null
+++ b/include/EGL/eglplatform.h
@@ -0,0 +1,122 @@
+#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: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $
+ *
+ * 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".
+ *
+ * Khronos STRONGLY RECOMMENDS that you use the default definitions
+ * provided below, since these changes affect both binary and source
+ * portability of applications using EGL running on different EGL
+ * implementations.
+ */
+
+#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(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
+
+typedef int EGLNativeDisplayType;
+typedef void *EGLNativeWindowType;
+typedef void *EGLNativePixmapType;
+
+#elif defined(__arm__) && defined(__gnu_linux__) /* ARM Linux Mali */
+#include <EGL/fbdev_window.h>
+
+typedef void* EGLNativeDisplayType;
+typedef fbdev_pixmap* EGLNativePixmapType;
+typedef fbdev_window* 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/include/EGL/fbdev_window.h b/include/EGL/fbdev_window.h
new file mode 100644
index 0000000..caa35f2
--- /dev/null
+++ b/include/EGL/fbdev_window.h
@@ -0,0 +1,52 @@
+/* vim:set sts=4 ts=4 noexpandtab: */
+/*
+ * This confidential and proprietary software may be used only as
+ * authorised by a licensing agreement from ARM Limited
+ * (C) COPYRIGHT 2008,2009 ARM Limited
+ * ALL RIGHTS RESERVED
+ * The entire notice above must be reproduced on all authorised
+ * copies and copies may only be made to the extent permitted
+ * by a licensing agreement from ARM Limited.
+ */
+
+#ifndef _FBDEV_WINDOW_H_
+#define _FBDEV_WINDOW_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum
+{
+ FBDEV_PIXMAP_SUPPORTS_UMP = (1<<0)
+} fbdev_pixmap_flags;
+
+typedef struct fbdev_window
+{
+ unsigned short width;
+ unsigned short height;
+} fbdev_window;
+
+typedef struct fbdev_pixmap
+{
+ unsigned int height;
+ unsigned int width;
+ unsigned int format;
+ unsigned int stride;
+ unsigned int bytes_per_pixel;
+ unsigned char buffer_size;
+ unsigned char red_size;
+ unsigned char green_size;
+ unsigned char blue_size;
+ unsigned char alpha_size;
+ unsigned char luminance_size;
+ fbdev_pixmap_flags flags;
+ unsigned short *data;
+} fbdev_pixmap;
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/include/KHR/khrplatform.h b/include/KHR/khrplatform.h
new file mode 100644
index 0000000..11e873e
--- /dev/null
+++ b/include/KHR/khrplatform.h
@@ -0,0 +1,273 @@
+#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: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
+ *
+ * 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__)
+# if defined (_DLL_EXPORTS)
+# define KHRONOS_APICALL __declspec(dllexport)
+# else
+# define KHRONOS_APICALL __declspec(dllimport)
+# endif
+#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;
+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;
+
+#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/include/VG/openvg.h b/include/VG/openvg.h
new file mode 100644
index 0000000..a6a43a0
--- /dev/null
+++ b/include/VG/openvg.h
@@ -0,0 +1,752 @@
+/* $Revision: 6838 $ on $Date:: 2008-11-04 12:46:08 +0100 #$ */
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -------------------------------------
+ *
+ * Copyright (c) 2008 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.
+ *
+ *//**
+ * \file
+ * \brief OpenVG 1.1 API.
+ *//*-------------------------------------------------------------------*/
+
+#ifndef _OPENVG_H
+#define _OPENVG_H
+
+#include <VG/vgplatform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OPENVG_VERSION_1_0 1
+#define OPENVG_VERSION_1_0_1 1
+#define OPENVG_VERSION_1_1 2
+
+#ifndef VG_MAXSHORT
+#define VG_MAXSHORT 0x7FFF
+#endif
+
+#ifndef VG_MAXINT
+#define VG_MAXINT 0x7FFFFFFF
+#endif
+
+#ifndef VG_MAX_ENUM
+#define VG_MAX_ENUM 0x7FFFFFFF
+#endif
+
+typedef VGuint VGHandle;
+
+typedef VGHandle VGPath;
+typedef VGHandle VGImage;
+typedef VGHandle VGMaskLayer;
+typedef VGHandle VGFont;
+typedef VGHandle VGPaint;
+
+#define VG_INVALID_HANDLE ((VGHandle)0)
+
+typedef enum {
+ VG_FALSE = 0,
+ VG_TRUE = 1,
+
+ VG_BOOLEAN_FORCE_SIZE = VG_MAX_ENUM
+} VGboolean;
+
+typedef enum {
+ VG_NO_ERROR = 0,
+ VG_BAD_HANDLE_ERROR = 0x1000,
+ VG_ILLEGAL_ARGUMENT_ERROR = 0x1001,
+ VG_OUT_OF_MEMORY_ERROR = 0x1002,
+ VG_PATH_CAPABILITY_ERROR = 0x1003,
+ VG_UNSUPPORTED_IMAGE_FORMAT_ERROR = 0x1004,
+ VG_UNSUPPORTED_PATH_FORMAT_ERROR = 0x1005,
+ VG_IMAGE_IN_USE_ERROR = 0x1006,
+ VG_NO_CONTEXT_ERROR = 0x1007,
+
+ VG_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM
+} VGErrorCode;
+
+typedef enum {
+ /* Mode settings */
+ VG_MATRIX_MODE = 0x1100,
+ VG_FILL_RULE = 0x1101,
+ VG_IMAGE_QUALITY = 0x1102,
+ VG_RENDERING_QUALITY = 0x1103,
+ VG_BLEND_MODE = 0x1104,
+ VG_IMAGE_MODE = 0x1105,
+
+ /* Scissoring rectangles */
+ VG_SCISSOR_RECTS = 0x1106,
+
+ /* Color Transformation */
+ VG_COLOR_TRANSFORM = 0x1170,
+ VG_COLOR_TRANSFORM_VALUES = 0x1171,
+
+ /* Stroke parameters */
+ VG_STROKE_LINE_WIDTH = 0x1110,
+ VG_STROKE_CAP_STYLE = 0x1111,
+ VG_STROKE_JOIN_STYLE = 0x1112,
+ VG_STROKE_MITER_LIMIT = 0x1113,
+ VG_STROKE_DASH_PATTERN = 0x1114,
+ VG_STROKE_DASH_PHASE = 0x1115,
+ VG_STROKE_DASH_PHASE_RESET = 0x1116,
+
+ /* Edge fill color for VG_TILE_FILL tiling mode */
+ VG_TILE_FILL_COLOR = 0x1120,
+
+ /* Color for vgClear */
+ VG_CLEAR_COLOR = 0x1121,
+
+ /* Glyph origin */
+ VG_GLYPH_ORIGIN = 0x1122,
+
+ /* Enable/disable alpha masking and scissoring */
+ VG_MASKING = 0x1130,
+ VG_SCISSORING = 0x1131,
+
+ /* Pixel layout information */
+ VG_PIXEL_LAYOUT = 0x1140,
+ VG_SCREEN_LAYOUT = 0x1141,
+
+ /* Source format selection for image filters */
+ VG_FILTER_FORMAT_LINEAR = 0x1150,
+ VG_FILTER_FORMAT_PREMULTIPLIED = 0x1151,
+
+ /* Destination write enable mask for image filters */
+ VG_FILTER_CHANNEL_MASK = 0x1152,
+
+ /* Implementation limits (read-only) */
+ VG_MAX_SCISSOR_RECTS = 0x1160,
+ VG_MAX_DASH_COUNT = 0x1161,
+ VG_MAX_KERNEL_SIZE = 0x1162,
+ VG_MAX_SEPARABLE_KERNEL_SIZE = 0x1163,
+ VG_MAX_COLOR_RAMP_STOPS = 0x1164,
+ VG_MAX_IMAGE_WIDTH = 0x1165,
+ VG_MAX_IMAGE_HEIGHT = 0x1166,
+ VG_MAX_IMAGE_PIXELS = 0x1167,
+ VG_MAX_IMAGE_BYTES = 0x1168,
+ VG_MAX_FLOAT = 0x1169,
+ VG_MAX_GAUSSIAN_STD_DEVIATION = 0x116A,
+
+ VG_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGParamType;
+
+typedef enum {
+ VG_RENDERING_QUALITY_NONANTIALIASED = 0x1200,
+ VG_RENDERING_QUALITY_FASTER = 0x1201,
+ VG_RENDERING_QUALITY_BETTER = 0x1202, /* Default */
+
+ VG_RENDERING_QUALITY_FORCE_SIZE = VG_MAX_ENUM
+} VGRenderingQuality;
+
+typedef enum {
+ VG_PIXEL_LAYOUT_UNKNOWN = 0x1300,
+ VG_PIXEL_LAYOUT_RGB_VERTICAL = 0x1301,
+ VG_PIXEL_LAYOUT_BGR_VERTICAL = 0x1302,
+ VG_PIXEL_LAYOUT_RGB_HORIZONTAL = 0x1303,
+ VG_PIXEL_LAYOUT_BGR_HORIZONTAL = 0x1304,
+
+ VG_PIXEL_LAYOUT_FORCE_SIZE = VG_MAX_ENUM
+} VGPixelLayout;
+
+typedef enum {
+ VG_MATRIX_PATH_USER_TO_SURFACE = 0x1400,
+ VG_MATRIX_IMAGE_USER_TO_SURFACE = 0x1401,
+ VG_MATRIX_FILL_PAINT_TO_USER = 0x1402,
+ VG_MATRIX_STROKE_PAINT_TO_USER = 0x1403,
+ VG_MATRIX_GLYPH_USER_TO_SURFACE = 0x1404,
+
+ VG_MATRIX_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGMatrixMode;
+
+typedef enum {
+ VG_CLEAR_MASK = 0x1500,
+ VG_FILL_MASK = 0x1501,
+ VG_SET_MASK = 0x1502,
+ VG_UNION_MASK = 0x1503,
+ VG_INTERSECT_MASK = 0x1504,
+ VG_SUBTRACT_MASK = 0x1505,
+
+ VG_MASK_OPERATION_FORCE_SIZE = VG_MAX_ENUM
+} VGMaskOperation;
+
+#define VG_PATH_FORMAT_STANDARD 0
+
+typedef enum {
+ VG_PATH_DATATYPE_S_8 = 0,
+ VG_PATH_DATATYPE_S_16 = 1,
+ VG_PATH_DATATYPE_S_32 = 2,
+ VG_PATH_DATATYPE_F = 3,
+
+ VG_PATH_DATATYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGPathDatatype;
+
+typedef enum {
+ VG_ABSOLUTE = 0,
+ VG_RELATIVE = 1,
+
+ VG_PATH_ABS_REL_FORCE_SIZE = VG_MAX_ENUM
+} VGPathAbsRel;
+
+typedef enum {
+ VG_CLOSE_PATH = ( 0 << 1),
+ VG_MOVE_TO = ( 1 << 1),
+ VG_LINE_TO = ( 2 << 1),
+ VG_HLINE_TO = ( 3 << 1),
+ VG_VLINE_TO = ( 4 << 1),
+ VG_QUAD_TO = ( 5 << 1),
+ VG_CUBIC_TO = ( 6 << 1),
+ VG_SQUAD_TO = ( 7 << 1),
+ VG_SCUBIC_TO = ( 8 << 1),
+ VG_SCCWARC_TO = ( 9 << 1),
+ VG_SCWARC_TO = (10 << 1),
+ VG_LCCWARC_TO = (11 << 1),
+ VG_LCWARC_TO = (12 << 1),
+
+ VG_PATH_SEGMENT_FORCE_SIZE = VG_MAX_ENUM
+} VGPathSegment;
+
+typedef enum {
+ VG_MOVE_TO_ABS = VG_MOVE_TO | VG_ABSOLUTE,
+ VG_MOVE_TO_REL = VG_MOVE_TO | VG_RELATIVE,
+ VG_LINE_TO_ABS = VG_LINE_TO | VG_ABSOLUTE,
+ VG_LINE_TO_REL = VG_LINE_TO | VG_RELATIVE,
+ VG_HLINE_TO_ABS = VG_HLINE_TO | VG_ABSOLUTE,
+ VG_HLINE_TO_REL = VG_HLINE_TO | VG_RELATIVE,
+ VG_VLINE_TO_ABS = VG_VLINE_TO | VG_ABSOLUTE,
+ VG_VLINE_TO_REL = VG_VLINE_TO | VG_RELATIVE,
+ VG_QUAD_TO_ABS = VG_QUAD_TO | VG_ABSOLUTE,
+ VG_QUAD_TO_REL = VG_QUAD_TO | VG_RELATIVE,
+ VG_CUBIC_TO_ABS = VG_CUBIC_TO | VG_ABSOLUTE,
+ VG_CUBIC_TO_REL = VG_CUBIC_TO | VG_RELATIVE,
+ VG_SQUAD_TO_ABS = VG_SQUAD_TO | VG_ABSOLUTE,
+ VG_SQUAD_TO_REL = VG_SQUAD_TO | VG_RELATIVE,
+ VG_SCUBIC_TO_ABS = VG_SCUBIC_TO | VG_ABSOLUTE,
+ VG_SCUBIC_TO_REL = VG_SCUBIC_TO | VG_RELATIVE,
+ VG_SCCWARC_TO_ABS = VG_SCCWARC_TO | VG_ABSOLUTE,
+ VG_SCCWARC_TO_REL = VG_SCCWARC_TO | VG_RELATIVE,
+ VG_SCWARC_TO_ABS = VG_SCWARC_TO | VG_ABSOLUTE,
+ VG_SCWARC_TO_REL = VG_SCWARC_TO | VG_RELATIVE,
+ VG_LCCWARC_TO_ABS = VG_LCCWARC_TO | VG_ABSOLUTE,
+ VG_LCCWARC_TO_REL = VG_LCCWARC_TO | VG_RELATIVE,
+ VG_LCWARC_TO_ABS = VG_LCWARC_TO | VG_ABSOLUTE,
+ VG_LCWARC_TO_REL = VG_LCWARC_TO | VG_RELATIVE,
+
+ VG_PATH_COMMAND_FORCE_SIZE = VG_MAX_ENUM
+} VGPathCommand;
+
+typedef enum {
+ VG_PATH_CAPABILITY_APPEND_FROM = (1 << 0),
+ VG_PATH_CAPABILITY_APPEND_TO = (1 << 1),
+ VG_PATH_CAPABILITY_MODIFY = (1 << 2),
+ VG_PATH_CAPABILITY_TRANSFORM_FROM = (1 << 3),
+ VG_PATH_CAPABILITY_TRANSFORM_TO = (1 << 4),
+ VG_PATH_CAPABILITY_INTERPOLATE_FROM = (1 << 5),
+ VG_PATH_CAPABILITY_INTERPOLATE_TO = (1 << 6),
+ VG_PATH_CAPABILITY_PATH_LENGTH = (1 << 7),
+ VG_PATH_CAPABILITY_POINT_ALONG_PATH = (1 << 8),
+ VG_PATH_CAPABILITY_TANGENT_ALONG_PATH = (1 << 9),
+ VG_PATH_CAPABILITY_PATH_BOUNDS = (1 << 10),
+ VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS = (1 << 11),
+ VG_PATH_CAPABILITY_ALL = (1 << 12) - 1,
+
+ VG_PATH_CAPABILITIES_FORCE_SIZE = VG_MAX_ENUM
+} VGPathCapabilities;
+
+typedef enum {
+ VG_PATH_FORMAT = 0x1600,
+ VG_PATH_DATATYPE = 0x1601,
+ VG_PATH_SCALE = 0x1602,
+ VG_PATH_BIAS = 0x1603,
+ VG_PATH_NUM_SEGMENTS = 0x1604,
+ VG_PATH_NUM_COORDS = 0x1605,
+
+ VG_PATH_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGPathParamType;
+
+typedef enum {
+ VG_CAP_BUTT = 0x1700,
+ VG_CAP_ROUND = 0x1701,
+ VG_CAP_SQUARE = 0x1702,
+
+ VG_CAP_STYLE_FORCE_SIZE = VG_MAX_ENUM
+} VGCapStyle;
+
+typedef enum {
+ VG_JOIN_MITER = 0x1800,
+ VG_JOIN_ROUND = 0x1801,
+ VG_JOIN_BEVEL = 0x1802,
+
+ VG_JOIN_STYLE_FORCE_SIZE = VG_MAX_ENUM
+} VGJoinStyle;
+
+typedef enum {
+ VG_EVEN_ODD = 0x1900,
+ VG_NON_ZERO = 0x1901,
+
+ VG_FILL_RULE_FORCE_SIZE = VG_MAX_ENUM
+} VGFillRule;
+
+typedef enum {
+ VG_STROKE_PATH = (1 << 0),
+ VG_FILL_PATH = (1 << 1),
+
+ VG_PAINT_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGPaintMode;
+
+typedef enum {
+ /* Color paint parameters */
+ VG_PAINT_TYPE = 0x1A00,
+ VG_PAINT_COLOR = 0x1A01,
+ VG_PAINT_COLOR_RAMP_SPREAD_MODE = 0x1A02,
+ VG_PAINT_COLOR_RAMP_PREMULTIPLIED = 0x1A07,
+ VG_PAINT_COLOR_RAMP_STOPS = 0x1A03,
+
+ /* Linear gradient paint parameters */
+ VG_PAINT_LINEAR_GRADIENT = 0x1A04,
+
+ /* Radial gradient paint parameters */
+ VG_PAINT_RADIAL_GRADIENT = 0x1A05,
+
+ /* Pattern paint parameters */
+ VG_PAINT_PATTERN_TILING_MODE = 0x1A06,
+
+ VG_PAINT_2x3_GRADIENT = 0x1A08,
+
+ VG_PAINT_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGPaintParamType;
+
+typedef enum {
+ VG_PAINT_TYPE_COLOR = 0x1B00,
+ VG_PAINT_TYPE_LINEAR_GRADIENT = 0x1B01,
+ VG_PAINT_TYPE_RADIAL_GRADIENT = 0x1B02,
+ VG_PAINT_TYPE_PATTERN = 0x1B03,
+
+ /* 2x3 matrix gradients */
+ VG_PAINT_TYPE_LINEAR_2x3_GRADIENT = 0x1B04,
+ VG_PAINT_TYPE_RADIAL_2x3_GRADIENT = 0x1B05,
+
+ VG_PAINT_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGPaintType;
+
+typedef enum {
+ VG_COLOR_RAMP_SPREAD_PAD = 0x1C00,
+ VG_COLOR_RAMP_SPREAD_REPEAT = 0x1C01,
+ VG_COLOR_RAMP_SPREAD_REFLECT = 0x1C02,
+
+ VG_COLOR_RAMP_SPREAD_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGColorRampSpreadMode;
+
+typedef enum {
+ VG_TILE_FILL = 0x1D00,
+ VG_TILE_PAD = 0x1D01,
+ VG_TILE_REPEAT = 0x1D02,
+ VG_TILE_REFLECT = 0x1D03,
+
+ VG_TILING_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGTilingMode;
+
+typedef enum {
+ /* RGB{A,X} channel ordering */
+ VG_sRGBX_8888 = 0,
+ VG_sRGBA_8888 = 1,
+ VG_sRGBA_8888_PRE = 2,
+ VG_sRGB_565 = 3,
+ VG_sRGBA_5551 = 4,
+ VG_sRGBA_4444 = 5,
+ VG_sL_8 = 6,
+ VG_lRGBX_8888 = 7,
+ VG_lRGBA_8888 = 8,
+ VG_lRGBA_8888_PRE = 9,
+ VG_lL_8 = 10,
+ VG_A_8 = 11,
+ VG_BW_1 = 12,
+ VG_A_1 = 13,
+ VG_A_4 = 14,
+
+ /* {A,X}RGB channel ordering */
+ VG_sXRGB_8888 = 0 | (1 << 6),
+ VG_sARGB_8888 = 1 | (1 << 6),
+ VG_sARGB_8888_PRE = 2 | (1 << 6),
+ VG_sARGB_1555 = 4 | (1 << 6),
+ VG_sARGB_4444 = 5 | (1 << 6),
+ VG_lXRGB_8888 = 7 | (1 << 6),
+ VG_lARGB_8888 = 8 | (1 << 6),
+ VG_lARGB_8888_PRE = 9 | (1 << 6),
+
+ /* BGR{A,X} channel ordering */
+ VG_sBGRX_8888 = 0 | (1 << 7),
+ VG_sBGRA_8888 = 1 | (1 << 7),
+ VG_sBGRA_8888_PRE = 2 | (1 << 7),
+ VG_sBGR_565 = 3 | (1 << 7),
+ VG_sBGRA_5551 = 4 | (1 << 7),
+ VG_sBGRA_4444 = 5 | (1 << 7),
+ VG_lBGRX_8888 = 7 | (1 << 7),
+ VG_lBGRA_8888 = 8 | (1 << 7),
+ VG_lBGRA_8888_PRE = 9 | (1 << 7),
+
+ /* {A,X}BGR channel ordering */
+ VG_sXBGR_8888 = 0 | (1 << 6) | (1 << 7),
+ VG_sABGR_8888 = 1 | (1 << 6) | (1 << 7),
+ VG_sABGR_8888_PRE = 2 | (1 << 6) | (1 << 7),
+ VG_sABGR_1555 = 4 | (1 << 6) | (1 << 7),
+ VG_sABGR_4444 = 5 | (1 << 6) | (1 << 7),
+ VG_lXBGR_8888 = 7 | (1 << 6) | (1 << 7),
+ VG_lABGR_8888 = 8 | (1 << 6) | (1 << 7),
+ VG_lABGR_8888_PRE = 9 | (1 << 6) | (1 << 7),
+
+ VG_IMAGE_FORMAT_FORCE_SIZE = VG_MAX_ENUM
+} VGImageFormat;
+
+typedef enum {
+ VG_IMAGE_QUALITY_NONANTIALIASED = (1 << 0),
+ VG_IMAGE_QUALITY_FASTER = (1 << 1),
+ VG_IMAGE_QUALITY_BETTER = (1 << 2),
+
+ VG_IMAGE_QUALITY_FORCE_SIZE = VG_MAX_ENUM
+} VGImageQuality;
+
+typedef enum {
+ VG_IMAGE_FORMAT = 0x1E00,
+ VG_IMAGE_WIDTH = 0x1E01,
+ VG_IMAGE_HEIGHT = 0x1E02,
+
+ VG_IMAGE_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGImageParamType;
+
+typedef enum {
+ VG_DRAW_IMAGE_NORMAL = 0x1F00,
+ VG_DRAW_IMAGE_MULTIPLY = 0x1F01,
+ VG_DRAW_IMAGE_STENCIL = 0x1F02,
+
+ VG_IMAGE_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGImageMode;
+
+typedef enum {
+ VG_RED = (1 << 3),
+ VG_GREEN = (1 << 2),
+ VG_BLUE = (1 << 1),
+ VG_ALPHA = (1 << 0),
+
+ VG_IMAGE_CHANNEL_FORCE_SIZE = VG_MAX_ENUM
+} VGImageChannel;
+
+typedef enum {
+ VG_BLEND_SRC = 0x2000,
+ VG_BLEND_SRC_OVER = 0x2001,
+ VG_BLEND_DST_OVER = 0x2002,
+ VG_BLEND_SRC_IN = 0x2003,
+ VG_BLEND_DST_IN = 0x2004,
+ VG_BLEND_MULTIPLY = 0x2005,
+ VG_BLEND_SCREEN = 0x2006,
+ VG_BLEND_DARKEN = 0x2007,
+ VG_BLEND_LIGHTEN = 0x2008,
+ VG_BLEND_ADDITIVE = 0x2009,
+
+ VG_BLEND_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGBlendMode;
+
+typedef enum {
+ VG_FONT_NUM_GLYPHS = 0x2F00,
+
+ VG_FONT_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGFontParamType;
+
+typedef enum {
+ VG_IMAGE_FORMAT_QUERY = 0x2100,
+ VG_PATH_DATATYPE_QUERY = 0x2101,
+
+ VG_HARDWARE_QUERY_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGHardwareQueryType;
+
+typedef enum {
+ VG_HARDWARE_ACCELERATED = 0x2200,
+ VG_HARDWARE_UNACCELERATED = 0x2201,
+
+ VG_HARDWARE_QUERY_RESULT_FORCE_SIZE = VG_MAX_ENUM
+} VGHardwareQueryResult;
+
+typedef enum {
+ VG_VENDOR = 0x2300,
+ VG_RENDERER = 0x2301,
+ VG_VERSION = 0x2302,
+ VG_EXTENSIONS = 0x2303,
+
+ VG_STRING_ID_FORCE_SIZE = VG_MAX_ENUM
+} VGStringID;
+
+/* Function Prototypes */
+
+#ifndef VG_API_CALL
+# error VG_API_CALL must be defined
+#endif
+
+#ifndef VG_API_ENTRY
+# error VG_API_ENTRY must be defined
+#endif
+
+#ifndef VG_API_EXIT
+# error VG_API_EXIT must be defined
+#endif
+
+VG_API_CALL VGErrorCode VG_API_ENTRY vgGetError(void) VG_API_EXIT;
+
+VG_API_CALL void VG_API_ENTRY vgFlush(void) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgFinish(void) VG_API_EXIT;
+
+/* Getters and Setters */
+VG_API_CALL void VG_API_ENTRY vgSetf (VGParamType type, VGfloat value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSeti (VGParamType type, VGint value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetfv(VGParamType type, VGint count,
+ const VGfloat * values) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetiv(VGParamType type, VGint count,
+ const VGint * values) VG_API_EXIT;
+
+VG_API_CALL VGfloat VG_API_ENTRY vgGetf(VGParamType type) VG_API_EXIT;
+VG_API_CALL VGint VG_API_ENTRY vgGeti(VGParamType type) VG_API_EXIT;
+VG_API_CALL VGint VG_API_ENTRY vgGetVectorSize(VGParamType type) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetfv(VGParamType type, VGint count, VGfloat * values) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetiv(VGParamType type, VGint count, VGint * values) VG_API_EXIT;
+
+VG_API_CALL void VG_API_ENTRY vgSetParameterf(VGHandle object,
+ VGint paramType,
+ VGfloat value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetParameteri(VGHandle object,
+ VGint paramType,
+ VGint value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetParameterfv(VGHandle object,
+ VGint paramType,
+ VGint count, const VGfloat * values) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetParameteriv(VGHandle object,
+ VGint paramType,
+ VGint count, const VGint * values) VG_API_EXIT;
+
+VG_API_CALL VGfloat VG_API_ENTRY vgGetParameterf(VGHandle object,
+ VGint paramType) VG_API_EXIT;
+VG_API_CALL VGint VG_API_ENTRY vgGetParameteri(VGHandle object,
+ VGint paramType);
+VG_API_CALL VGint VG_API_ENTRY vgGetParameterVectorSize(VGHandle object,
+ VGint paramType) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetParameterfv(VGHandle object,
+ VGint paramType,
+ VGint count, VGfloat * values) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetParameteriv(VGHandle object,
+ VGint paramType,
+ VGint count, VGint * values) VG_API_EXIT;
+
+/* Matrix Manipulation */
+VG_API_CALL void VG_API_ENTRY vgLoadIdentity(void) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgLoadMatrix(const VGfloat * m) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetMatrix(VGfloat * m) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgMultMatrix(const VGfloat * m) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgTranslate(VGfloat tx, VGfloat ty) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgScale(VGfloat sx, VGfloat sy) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgShear(VGfloat shx, VGfloat shy) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgRotate(VGfloat angle) VG_API_EXIT;
+
+/* Masking and Clearing */
+VG_API_CALL void VG_API_ENTRY vgMask(VGHandle mask, VGMaskOperation operation,
+ VGint x, VGint y,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgRenderToMask(VGPath path,
+ VGbitfield paintModes,
+ VGMaskOperation operation) VG_API_EXIT;
+VG_API_CALL VGMaskLayer VG_API_ENTRY vgCreateMaskLayer(VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyMaskLayer(VGMaskLayer maskLayer) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgFillMaskLayer(VGMaskLayer maskLayer,
+ VGint x, VGint y,
+ VGint width, VGint height,
+ VGfloat value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgCopyMask(VGMaskLayer maskLayer,
+ VGint dx, VGint dy,
+ VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgClear(VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
+
+/* Paths */
+VG_API_CALL VGPath VG_API_ENTRY vgCreatePath(VGint pathFormat,
+ VGPathDatatype datatype,
+ VGfloat scale, VGfloat bias,
+ VGint segmentCapacityHint,
+ VGint coordCapacityHint,
+ VGbitfield capabilities) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgClearPath(VGPath path, VGbitfield capabilities) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyPath(VGPath path) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgRemovePathCapabilities(VGPath path,
+ VGbitfield capabilities) VG_API_EXIT;
+VG_API_CALL VGbitfield VG_API_ENTRY vgGetPathCapabilities(VGPath path) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgAppendPath(VGPath dstPath, VGPath srcPath) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgAppendPathData(VGPath dstPath,
+ VGint numSegments,
+ const VGubyte * pathSegments,
+ const void * pathData) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgModifyPathCoords(VGPath dstPath, VGint startIndex,
+ VGint numSegments,
+ const void * pathData) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgTransformPath(VGPath dstPath, VGPath srcPath) VG_API_EXIT;
+VG_API_CALL VGboolean VG_API_ENTRY vgInterpolatePath(VGPath dstPath,
+ VGPath startPath,
+ VGPath endPath,
+ VGfloat amount) VG_API_EXIT;
+VG_API_CALL VGfloat VG_API_ENTRY vgPathLength(VGPath path,
+ VGint startSegment, VGint numSegments) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgPointAlongPath(VGPath path,
+ VGint startSegment, VGint numSegments,
+ VGfloat distance,
+ VGfloat * x, VGfloat * y,
+ VGfloat * tangentX, VGfloat * tangentY) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgPathBounds(VGPath path,
+ VGfloat * minX, VGfloat * minY,
+ VGfloat * width, VGfloat * height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgPathTransformedBounds(VGPath path,
+ VGfloat * minX, VGfloat * minY,
+ VGfloat * width, VGfloat * height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDrawPath(VGPath path, VGbitfield paintModes) VG_API_EXIT;
+
+/* Paint */
+VG_API_CALL VGPaint VG_API_ENTRY vgCreatePaint(void) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyPaint(VGPaint paint) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetPaint(VGPaint paint, VGbitfield paintModes) VG_API_EXIT;
+VG_API_CALL VGPaint VG_API_ENTRY vgGetPaint(VGPaintMode paintMode) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetColor(VGPaint paint, VGuint rgba) VG_API_EXIT;
+VG_API_CALL VGuint VG_API_ENTRY vgGetColor(VGPaint paint) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgPaintPattern(VGPaint paint, VGImage pattern) VG_API_EXIT;
+
+/* Images */
+VG_API_CALL VGImage VG_API_ENTRY vgCreateImage(VGImageFormat format,
+ VGint width, VGint height,
+ VGbitfield allowedQuality) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyImage(VGImage image) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgClearImage(VGImage image,
+ VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgImageSubData(VGImage image,
+ const void * data, VGint dataStride,
+ VGImageFormat dataFormat,
+ VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetImageSubData(VGImage image,
+ void * data, VGint dataStride,
+ VGImageFormat dataFormat,
+ VGint x, VGint y,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL VGImage VG_API_ENTRY vgChildImage(VGImage parent,
+ VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL VGImage VG_API_ENTRY vgGetParent(VGImage image) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgCopyImage(VGImage dst, VGint dx, VGint dy,
+ VGImage src, VGint sx, VGint sy,
+ VGint width, VGint height,
+ VGboolean dither) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDrawImage(VGImage image) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetPixels(VGint dx, VGint dy,
+ VGImage src, VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgWritePixels(const void * data, VGint dataStride,
+ VGImageFormat dataFormat,
+ VGint dx, VGint dy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetPixels(VGImage dst, VGint dx, VGint dy,
+ VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgReadPixels(void * data, VGint dataStride,
+ VGImageFormat dataFormat,
+ VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgCopyPixels(VGint dx, VGint dy,
+ VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+
+/* Text */
+VG_API_CALL VGFont VG_API_ENTRY vgCreateFont(VGint glyphCapacityHint) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyFont(VGFont font) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetGlyphToPath(VGFont font,
+ VGuint glyphIndex,
+ VGPath path,
+ VGboolean isHinted,
+ VGfloat glyphOrigin [2],
+ VGfloat escapement[2]) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetGlyphToImage(VGFont font,
+ VGuint glyphIndex,
+ VGImage image,
+ VGfloat glyphOrigin [2],
+ VGfloat escapement[2]) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgClearGlyph(VGFont font,VGuint glyphIndex) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDrawGlyph(VGFont font,
+ VGuint glyphIndex,
+ VGbitfield paintModes,
+ VGboolean allowAutoHinting) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDrawGlyphs(VGFont font,
+ VGint glyphCount,
+ VGuint *glyphIndices,
+ VGfloat *adjustments_x,
+ VGfloat *adjustments_y,
+ VGbitfield paintModes,
+ VGboolean allowAutoHinting) VG_API_EXIT;
+
+/* Image Filters */
+VG_API_CALL void VG_API_ENTRY vgColorMatrix(VGImage dst, VGImage src,
+ const VGfloat * matrix) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgConvolve(VGImage dst, VGImage src,
+ VGint kernelWidth, VGint kernelHeight,
+ VGint shiftX, VGint shiftY,
+ const VGshort * kernel,
+ VGfloat scale,
+ VGfloat bias,
+ VGTilingMode tilingMode) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSeparableConvolve(VGImage dst, VGImage src,
+ VGint kernelWidth,
+ VGint kernelHeight,
+ VGint shiftX, VGint shiftY,
+ const VGshort * kernelX,
+ const VGshort * kernelY,
+ VGfloat scale,
+ VGfloat bias,
+ VGTilingMode tilingMode) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGaussianBlur(VGImage dst, VGImage src,
+ VGfloat stdDeviationX,
+ VGfloat stdDeviationY,
+ VGTilingMode tilingMode) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgLookup(VGImage dst, VGImage src,
+ const VGubyte * redLUT,
+ const VGubyte * greenLUT,
+ const VGubyte * blueLUT,
+ const VGubyte * alphaLUT,
+ VGboolean outputLinear,
+ VGboolean outputPremultiplied) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgLookupSingle(VGImage dst, VGImage src,
+ const VGuint * lookupTable,
+ VGImageChannel sourceChannel,
+ VGboolean outputLinear,
+ VGboolean outputPremultiplied) VG_API_EXIT;
+
+/* Hardware Queries */
+VG_API_CALL VGHardwareQueryResult VG_API_ENTRY vgHardwareQuery(VGHardwareQueryType key,
+ VGint setting) VG_API_EXIT;
+
+/* Renderer and Extension Information */
+VG_API_CALL const VGubyte * VG_API_ENTRY vgGetString(VGStringID name) VG_API_EXIT;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _OPENVG_H */
diff --git a/include/VG/vgext.h b/include/VG/vgext.h
new file mode 100644
index 0000000..ac05994
--- /dev/null
+++ b/include/VG/vgext.h
@@ -0,0 +1,274 @@
+/* $Revision: 6810 $ on $Date:: 2008-10-29 15:31:37 +0100 #$ */
+
+/*------------------------------------------------------------------------
+ *
+ * VG extensions Reference Implementation
+ * -------------------------------------
+ *
+ * Copyright (c) 2008 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.
+ *
+ *//**
+ * \file
+ * \brief VG extensions
+ *//*-------------------------------------------------------------------*/
+
+
+
+#ifndef _VGEXT_H
+#define _VGEXT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+#include <VG/openvg.h>
+#include <VG/vgu.h>
+
+#ifndef VG_API_ENTRYP
+# define VG_API_ENTRYP VG_API_ENTRY*
+#endif
+
+#ifndef VGU_API_ENTRYP
+# define VGU_API_ENTRYP VGU_API_ENTRY*
+#endif
+
+/*-------------------------------------------------------------------------------
+ * KHR extensions
+ *------------------------------------------------------------------------------*/
+
+typedef enum {
+
+#ifndef VG_KHR_iterative_average_blur
+ VG_MAX_AVERAGE_BLUR_DIMENSION_KHR = 0x116B,
+ VG_AVERAGE_BLUR_DIMENSION_RESOLUTION_KHR = 0x116C,
+ VG_MAX_AVERAGE_BLUR_ITERATIONS_KHR = 0x116D,
+#endif
+
+ VG_PARAM_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
+} VGParamTypeKHR;
+
+#ifndef VG_KHR_EGL_image
+#define VG_KHR_EGL_image 1
+/* VGEGLImageKHR is an opaque handle to an EGLImage */
+typedef void* VGeglImageKHR;
+
+#ifdef VG_VGEXT_PROTOTYPES
+VG_API_CALL VGImage VG_API_ENTRY vgCreateEGLImageTargetKHR(VGeglImageKHR image);
+#endif
+typedef VGImage (VG_API_ENTRYP PFNVGCREATEEGLIMAGETARGETKHRPROC) (VGeglImageKHR image);
+
+#endif
+
+
+#ifndef VG_KHR_iterative_average_blur
+#define VG_KHR_iterative_average_blur 1
+
+#ifdef VG_VGEXT_PROTOTYPES
+VG_API_CALL void vgIterativeAverageBlurKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
+#endif
+typedef void (VG_API_ENTRYP PFNVGITERATIVEAVERAGEBLURKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
+
+#endif
+
+
+#ifndef VG_KHR_advanced_blending
+#define VG_KHR_advanced_blending 1
+
+typedef enum {
+ VG_BLEND_OVERLAY_KHR = 0x2010,
+ VG_BLEND_HARDLIGHT_KHR = 0x2011,
+ VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012,
+ VG_BLEND_SOFTLIGHT_KHR = 0x2013,
+ VG_BLEND_COLORDODGE_KHR = 0x2014,
+ VG_BLEND_COLORBURN_KHR = 0x2015,
+ VG_BLEND_DIFFERENCE_KHR = 0x2016,
+ VG_BLEND_SUBTRACT_KHR = 0x2017,
+ VG_BLEND_INVERT_KHR = 0x2018,
+ VG_BLEND_EXCLUSION_KHR = 0x2019,
+ VG_BLEND_LINEARDODGE_KHR = 0x201a,
+ VG_BLEND_LINEARBURN_KHR = 0x201b,
+ VG_BLEND_VIVIDLIGHT_KHR = 0x201c,
+ VG_BLEND_LINEARLIGHT_KHR = 0x201d,
+ VG_BLEND_PINLIGHT_KHR = 0x201e,
+ VG_BLEND_HARDMIX_KHR = 0x201f,
+ VG_BLEND_CLEAR_KHR = 0x2020,
+ VG_BLEND_DST_KHR = 0x2021,
+ VG_BLEND_SRC_OUT_KHR = 0x2022,
+ VG_BLEND_DST_OUT_KHR = 0x2023,
+ VG_BLEND_SRC_ATOP_KHR = 0x2024,
+ VG_BLEND_DST_ATOP_KHR = 0x2025,
+ VG_BLEND_XOR_KHR = 0x2026,
+
+ VG_BLEND_MODE_KHR_FORCE_SIZE= VG_MAX_ENUM
+} VGBlendModeKHR;
+#endif
+
+#ifndef VG_KHR_parametric_filter
+#define VG_KHR_parametric_filter 1
+
+typedef enum {
+ VG_PF_OBJECT_VISIBLE_FLAG_KHR = (1 << 0),
+ VG_PF_KNOCKOUT_FLAG_KHR = (1 << 1),
+ VG_PF_OUTER_FLAG_KHR = (1 << 2),
+ VG_PF_INNER_FLAG_KHR = (1 << 3),
+
+ VG_PF_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
+} VGPfTypeKHR;
+
+typedef enum {
+ VGU_IMAGE_IN_USE_ERROR = 0xF010,
+
+ VGU_ERROR_CODE_KHR_FORCE_SIZE = VG_MAX_ENUM
+} VGUErrorCodeKHR;
+
+#ifdef VG_VGEXT_PROTOTYPES
+VG_API_CALL void VG_API_ENTRY vgParametricFilterKHR(VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguDropShadowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA) ;
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
+#endif
+typedef void (VG_API_ENTRYP PFNVGPARAMETRICFILTERKHRPROC) (VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUDROPSHADOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
+
+#endif
+
+
+/*-------------------------------------------------------------------------------
+ * NDS extensions
+ *------------------------------------------------------------------------------*/
+
+#ifndef VG_NDS_paint_generation
+#define VG_NDS_paint_generation 1
+
+typedef enum {
+ VG_PAINT_COLOR_RAMP_LINEAR_NDS = 0x1A10,
+ VG_COLOR_MATRIX_NDS = 0x1A11,
+ VG_PAINT_COLOR_TRANSFORM_LINEAR_NDS = 0x1A12,
+
+ VG_PAINT_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGPaintParamTypeNds;
+
+typedef enum {
+ VG_DRAW_IMAGE_COLOR_MATRIX_NDS = 0x1F10,
+
+ VG_IMAGE_MODE_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGImageModeNds;
+#endif
+
+
+#ifndef VG_NDS_projective_geometry
+#define VG_NDS_projective_geometry 1
+
+typedef enum {
+ VG_CLIP_MODE_NDS = 0x1180,
+ VG_CLIP_LINES_NDS = 0x1181,
+ VG_MAX_CLIP_LINES_NDS = 0x1182,
+
+ VG_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGParamTypeNds;
+
+typedef enum {
+ VG_CLIPMODE_NONE_NDS = 0x3000,
+ VG_CLIPMODE_CLIP_CLOSED_NDS = 0x3001,
+ VG_CLIPMODE_CLIP_OPEN_NDS = 0x3002,
+ VG_CLIPMODE_CULL_NDS = 0x3003,
+
+ VG_CLIPMODE_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGClipModeNds;
+
+typedef enum {
+ VG_RQUAD_TO_NDS = ( 13 << 1 ),
+ VG_RCUBIC_TO_NDS = ( 14 << 1 ),
+
+ VG_PATH_SEGMENT_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGPathSegmentNds;
+
+typedef enum {
+ VG_RQUAD_TO_ABS_NDS = (VG_RQUAD_TO_NDS | VG_ABSOLUTE),
+ VG_RQUAD_TO_REL_NDS = (VG_RQUAD_TO_NDS | VG_RELATIVE),
+ VG_RCUBIC_TO_ABS_NDS = (VG_RCUBIC_TO_NDS | VG_ABSOLUTE),
+ VG_RCUBIC_TO_REL_NDS = (VG_RCUBIC_TO_NDS | VG_RELATIVE),
+
+ VG_PATH_COMMAND_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGPathCommandNds;
+
+#ifdef VG_VGEXT_PROTOTYPES
+VG_API_CALL void VG_API_ENTRY vgProjectiveMatrixNDS(VGboolean enable) ;
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguTransformClipLineNDS(const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
+#endif
+typedef void (VG_API_ENTRYP PFNVGPROJECTIVEMATRIXNDSPROC) (VGboolean enable) ;
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUTRANSFORMCLIPLINENDSPROC) (const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
+
+#endif
+
+/*-------------------------------------------------------------------------------
+ * * MonkVG extensions
+ * *------------------------------------------------------------------------------*/
+
+ /* set the number of iterations for tesselating curves. a low number will generate
+ * * less polygons but rougher looking rendering -- and vice versa.
+ * */
+ typedef enum {
+ VG_TESSELLATION_ITERATIONS_MNK = 0x1170,
+
+ /* the rendering buffer dimensions */
+ VG_SURFACE_WIDTH_MNK = 0x1171,
+ VG_SURFACE_HEIGHT_MNK = 0x1172,
+
+ VG_PARAM_TYPE_MNK_FORCE_SIZE = VG_MAX_ENUM
+ } VGParamTypeMNK;
+
+ typedef enum {
+ VG_RENDERING_BACKEND_TYPE_OPENGLES11 = 0,
+ VG_RENDERING_BACKEND_TYPE_OPENGLES20 = 1,
+ VG_RENDERING_BACKEND_TYPE_FORCE_SIZE = VG_MAX_ENUM
+ } VGRenderingBackendTypeMNK;
+
+ /* batches are a method for significantly speeding up rendering of collections of static paths
+ * */
+ typedef VGHandle VGBatchMNK;
+
+ VG_API_CALL VGBatchMNK VG_API_ENTRY vgCreateBatchMNK() VG_API_EXIT;
+ VG_API_CALL void VG_API_ENTRY vgDestroyBatchMNK( VGBatchMNK batch ) VG_API_EXIT;
+ VG_API_CALL void VG_API_ENTRY vgBeginBatchMNK( VGBatchMNK batch ) VG_API_EXIT;
+ VG_API_CALL void VG_API_ENTRY vgEndBatchMNK( VGBatchMNK batch ) VG_API_EXIT;
+ VG_API_CALL void VG_API_ENTRY vgDrawBatchMNK( VGBatchMNK batch ) VG_API_EXIT;
+ VG_API_CALL void VG_API_ENTRY vgDumpBatchMNK( VGBatchMNK batch, void **vertices, size_t *size ) VG_API_EXIT;
+
+ /* context MonkVG */
+ VG_API_CALL VGboolean vgCreateContextMNK( VGint width, VGint height, VGRenderingBackendTypeMNK backend );
+ VG_API_CALL void vgResizeSurfaceMNK( VGint width, VGint height );
+ VG_API_CALL void vgDestroyContextMNK( void );
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _VGEXT_H */
diff --git a/include/VG/vgplatform.h b/include/VG/vgplatform.h
new file mode 100644
index 0000000..aa9896e
--- /dev/null
+++ b/include/VG/vgplatform.h
@@ -0,0 +1,106 @@
+/* $Revision: 6810 $ on $Date:: 2008-10-29 15:31:37 +0100 #$ */
+
+/*------------------------------------------------------------------------
+ *
+ * VG platform specific header Reference Implementation
+ * ----------------------------------------------------
+ *
+ * Copyright (c) 2008 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.
+ *
+ *//**
+ * \file
+ * \brief VG platform specific header
+ *//*-------------------------------------------------------------------*/
+
+#ifndef _VGPLATFORM_H
+#define _VGPLATFORM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef VG_API_CALL
+#if defined(OPENVG_STATIC_LIBRARY)
+# define VG_API_CALL
+#else
+# if defined(_WIN32) || defined(__VC32__) /* Win32 */
+# if defined (OPENVG_DLL_EXPORTS)
+# define VG_API_CALL __declspec(dllexport)
+# else
+# define VG_API_CALL __declspec(dllimport)
+# endif
+# else
+# define VG_API_CALL extern
+# endif /* defined(_WIN32) ||... */
+#endif /* defined OPENVG_STATIC_LIBRARY */
+#endif /* ifndef VG_API_CALL */
+
+#ifndef VGU_API_CALL
+#if defined(OPENVG_STATIC_LIBRARY)
+# define VGU_API_CALL
+#else
+# if defined(_WIN32) || defined(__VC32__) /* Win32 */
+# if defined (OPENVG_DLL_EXPORTS)
+# define VGU_API_CALL __declspec(dllexport)
+# else
+# define VGU_API_CALL __declspec(dllimport)
+# endif
+# else
+# define VGU_API_CALL extern
+# endif /* defined(_WIN32) ||... */
+#endif /* defined OPENVG_STATIC_LIBRARY */
+#endif /* ifndef VGU_API_CALL */
+
+
+#ifndef VG_API_ENTRY
+#define VG_API_ENTRY
+#endif
+
+#ifndef VG_API_EXIT
+#define VG_API_EXIT
+#endif
+
+#ifndef VGU_API_ENTRY
+#define VGU_API_ENTRY
+#endif
+
+#ifndef VGU_API_EXIT
+#define VGU_API_EXIT
+#endif
+
+typedef float VGfloat;
+typedef signed char VGbyte;
+typedef unsigned char VGubyte;
+typedef signed short VGshort;
+typedef signed int VGint;
+typedef unsigned int VGuint;
+typedef unsigned int VGbitfield;
+
+#ifndef VG_VGEXT_PROTOTYPES
+#define VG_VGEXT_PROTOTYPES
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _VGPLATFORM_H */
diff --git a/include/VG/vgu.h b/include/VG/vgu.h
new file mode 100644
index 0000000..7c814f7
--- /dev/null
+++ b/include/VG/vgu.h
@@ -0,0 +1,131 @@
+/* $Revision: 6810 $ on $Date:: 2008-10-29 15:31:37 +0100 #$ */
+
+/*------------------------------------------------------------------------
+ *
+ * VGU 1.1 Reference Implementation
+ * -------------------------------------
+ *
+ * Copyright (c) 2008 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.
+ *
+ *//**
+ * \file
+ * \brief VGU 1.1 API.
+ *//*-------------------------------------------------------------------*/
+
+#ifndef _VGU_H
+#define _VGU_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <VG/openvg.h>
+
+#define VGU_VERSION_1_0 1
+#define VGU_VERSION_1_1 2
+
+#ifndef VGU_API_CALL
+# error VGU_API_CALL must be defined
+#endif
+
+#ifndef VGU_API_ENTRY
+# error VGU_API_ENTRY must be defined
+#endif
+
+#ifndef VGU_API_EXIT
+# error VGU_API_EXIT must be defined
+#endif
+
+
+typedef enum {
+ VGU_NO_ERROR = 0,
+ VGU_BAD_HANDLE_ERROR = 0xF000,
+ VGU_ILLEGAL_ARGUMENT_ERROR = 0xF001,
+ VGU_OUT_OF_MEMORY_ERROR = 0xF002,
+ VGU_PATH_CAPABILITY_ERROR = 0xF003,
+ VGU_BAD_WARP_ERROR = 0xF004,
+
+ VGU_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM
+} VGUErrorCode;
+
+typedef enum {
+ VGU_ARC_OPEN = 0xF100,
+ VGU_ARC_CHORD = 0xF101,
+ VGU_ARC_PIE = 0xF102,
+
+ VGU_ARC_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGUArcType;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguLine(VGPath path,
+ VGfloat x0, VGfloat y0,
+ VGfloat x1, VGfloat y1) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguPolygon(VGPath path,
+ const VGfloat * points, VGint count,
+ VGboolean closed) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRect(VGPath path,
+ VGfloat x, VGfloat y,
+ VGfloat width, VGfloat height) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRoundRect(VGPath path,
+ VGfloat x, VGfloat y,
+ VGfloat width, VGfloat height,
+ VGfloat arcWidth, VGfloat arcHeight) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguEllipse(VGPath path,
+ VGfloat cx, VGfloat cy,
+ VGfloat width, VGfloat height) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguArc(VGPath path,
+ VGfloat x, VGfloat y,
+ VGfloat width, VGfloat height,
+ VGfloat startAngle, VGfloat angleExtent,
+ VGUArcType arcType) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0,
+ VGfloat sx1, VGfloat sy1,
+ VGfloat sx2, VGfloat sy2,
+ VGfloat sx3, VGfloat sy3,
+ VGfloat * matrix) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0,
+ VGfloat dx1, VGfloat dy1,
+ VGfloat dx2, VGfloat dy2,
+ VGfloat dx3, VGfloat dy3,
+ VGfloat * matrix) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0,
+ VGfloat dx1, VGfloat dy1,
+ VGfloat dx2, VGfloat dy2,
+ VGfloat dx3, VGfloat dy3,
+ VGfloat sx0, VGfloat sy0,
+ VGfloat sx1, VGfloat sy1,
+ VGfloat sx2, VGfloat sy2,
+ VGfloat sx3, VGfloat sy3,
+ VGfloat * matrix) VGU_API_EXIT;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _VGU_H */
diff --git a/include/esUtil.h b/include/esUtil.h
new file mode 100644
index 0000000..c41a599
--- /dev/null
+++ b/include/esUtil.h
@@ -0,0 +1,285 @@
+//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+//
+/// \file ESUtil.h
+/// \brief A utility library for OpenGL ES. This library provides a
+/// basic common framework for the example applications in the
+/// OpenGL ES 2.0 Programming Guide.
+//
+#ifndef ESUTIL_H
+#define ESUTIL_H
+
+///
+// Includes
+//
+#include <GLES2/gl2.h>
+#include <EGL/egl.h>
+
+#ifdef __cplusplus
+
+extern "C" {
+#endif
+
+
+///
+// Macros
+//
+#define ESUTIL_API
+#define ESCALLBACK
+
+
+/// esCreateWindow flag - RGB color buffer
+#define ES_WINDOW_RGB 0
+/// esCreateWindow flag - ALPHA color buffer
+#define ES_WINDOW_ALPHA 1
+/// esCreateWindow flag - depth buffer
+#define ES_WINDOW_DEPTH 2
+/// esCreateWindow flag - stencil buffer
+#define ES_WINDOW_STENCIL 4
+/// esCreateWindow flat - multi-sample buffer
+#define ES_WINDOW_MULTISAMPLE 8
+
+
+///
+// Types
+//
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+typedef struct
+{
+ GLfloat m[4][4];
+} ESMatrix;
+
+typedef struct _escontext
+{
+ /// Put your user data here...
+ void* userData;
+
+ /// Window width
+ GLint width;
+
+ /// Window height
+ GLint height;
+
+ /// Window handle
+ EGLNativeWindowType hWnd;
+
+ /// EGL display
+ EGLDisplay eglDisplay;
+
+ /// EGL context
+ EGLContext eglContext;
+
+ /// EGL surface
+ EGLSurface eglSurface;
+
+ EGLConfig eglConfig;
+
+ void *vgContext;
+
+ /// Callbacks
+ void (ESCALLBACK *drawFunc) ( struct _escontext * );
+ void (ESCALLBACK *keyFunc) ( struct _escontext *, unsigned char, int, int );
+ void (ESCALLBACK *updateFunc) ( struct _escontext *, float deltaTime );
+} ESContext;
+
+
+///
+// Public Functions
+//
+
+//
+///
+/// \brief Initialize ES framework context. This must be called before calling any other functions.
+/// \param esContext Application context
+//
+void ESUTIL_API esInitContext ( ESContext *esContext );
+
+//
+/// \brief Create a window with the specified parameters
+/// \param esContext Application context
+/// \param title Name for title bar of window
+/// \param width Width in pixels of window to create
+/// \param height Height in pixels of window to create
+/// \param flags Bitfield for the window creation flags
+/// ES_WINDOW_RGB - specifies that the color buffer should have R,G,B channels
+/// ES_WINDOW_ALPHA - specifies that the color buffer should have alpha
+/// ES_WINDOW_DEPTH - specifies that a depth buffer should be created
+/// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created
+/// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created
+/// \return GL_TRUE if window creation is succesful, GL_FALSE otherwise
+GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, const char *title, GLint width, GLint height, GLuint flags );
+
+//
+/// \brief Start the main loop for the OpenGL ES application
+/// \param esContext Application context
+//
+void ESUTIL_API esMainLoop ( ESContext *esContext );
+
+//
+/// \brief Register a draw callback function to be used to render each frame
+/// \param esContext Application context
+/// \param drawFunc Draw callback function that will be used to render the scene
+//
+void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) ( ESContext* ) );
+
+//
+/// \brief Register an update callback function to be used to update on each time step
+/// \param esContext Application context
+/// \param updateFunc Update callback function that will be used to render the scene
+//
+void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) );
+
+//
+/// \brief Register an keyboard input processing callback function
+/// \param esContext Application context
+/// \param keyFunc Key callback function for application processing of keyboard input
+//
+void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext,
+ void (ESCALLBACK *drawFunc) ( ESContext*, unsigned char, int, int ) );
+//
+/// \brief Log a message to the debug output for the platform
+/// \param formatStr Format string for error log.
+//
+void ESUTIL_API esLogMessage ( const char *formatStr, ... );
+
+//
+///
+/// \brief Load a shader, check for compile errors, print error messages to output log
+/// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER)
+/// \param shaderSrc Shader source string
+/// \return A new shader object on success, 0 on failure
+//
+GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc );
+
+//
+///
+/// \brief Load a vertex and fragment shader, create a program object, link program.
+/// Errors output to log.
+/// \param vertShaderSrc Vertex shader source code
+/// \param fragShaderSrc Fragment shader source code
+/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure
+//
+GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc );
+
+
+//
+/// \brief Generates geometry for a sphere. Allocates memory for the vertex data and stores
+/// the results in the arrays. Generate index list for a TRIANGLE_STRIP
+/// \param numSlices The number of slices in the sphere
+/// \param vertices If not NULL, will contain array of float3 positions
+/// \param normals If not NULL, will contain array of float3 normals
+/// \param texCoords If not NULL, will contain array of float2 texCoords
+/// \param indices If not NULL, will contain the array of indices for the triangle strip
+/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
+/// if it is not NULL ) as a GL_TRIANGLE_STRIP
+//
+int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals,
+ GLfloat **texCoords, GLuint **indices );
+
+//
+/// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores
+/// the results in the arrays. Generate index list for a TRIANGLES
+/// \param scale The size of the cube, use 1.0 for a unit cube.
+/// \param vertices If not NULL, will contain array of float3 positions
+/// \param normals If not NULL, will contain array of float3 normals
+/// \param texCoords If not NULL, will contain array of float2 texCoords
+/// \param indices If not NULL, will contain the array of indices for the triangle strip
+/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
+/// if it is not NULL ) as a GL_TRIANGLES
+//
+int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
+ GLfloat **texCoords, GLuint **indices );
+
+//
+/// \brief Loads a 24-bit TGA image from a file
+/// \param fileName Name of the file on disk
+/// \param width Width of loaded image in pixels
+/// \param height Height of loaded image in pixels
+/// \return Pointer to loaded image. NULL on failure.
+//
+char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height );
+
+
+//
+/// \brief multiply matrix specified by result with a scaling matrix and return new matrix in result
+/// \param result Specifies the input matrix. Scaled matrix is returned in result.
+/// \param sx, sy, sz Scale factors along the x, y and z axes respectively
+//
+void ESUTIL_API esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz);
+
+//
+/// \brief multiply matrix specified by result with a translation matrix and return new matrix in result
+/// \param result Specifies the input matrix. Translated matrix is returned in result.
+/// \param tx, ty, tz Scale factors along the x, y and z axes respectively
+//
+void ESUTIL_API esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz);
+
+//
+/// \brief multiply matrix specified by result with a rotation matrix and return new matrix in result
+/// \param result Specifies the input matrix. Rotated matrix is returned in result.
+/// \param angle Specifies the angle of rotation, in degrees.
+/// \param x, y, z Specify the x, y and z coordinates of a vector, respectively
+//
+void ESUTIL_API esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+
+//
+// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
+/// \param result Specifies the input matrix. new matrix is returned in result.
+/// \param left, right Coordinates for the left and right vertical clipping planes
+/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes
+/// \param nearZ, farZ Distances to the near and far depth clipping planes. Both distances must be positive.
+//
+void ESUTIL_API esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
+
+//
+/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
+/// \param result Specifies the input matrix. new matrix is returned in result.
+/// \param fovy Field of view y angle in degrees
+/// \param aspect Aspect ratio of screen
+/// \param nearZ Near plane distance
+/// \param farZ Far plane distance
+//
+void ESUTIL_API esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ);
+
+//
+/// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
+/// \param result Specifies the input matrix. new matrix is returned in result.
+/// \param left, right Coordinates for the left and right vertical clipping planes
+/// \param bottom, top Coordinates for the bottom and top horizontal clipping planes
+/// \param nearZ, farZ Distances to the near and far depth clipping planes. These values are negative if plane is behind the viewer
+//
+void ESUTIL_API esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
+
+//
+/// \brief perform the following operation - result matrix = srcA matrix * srcB matrix
+/// \param result Returns multiplied matrix
+/// \param srcA, srcB Input matrices to be multiplied
+//
+void ESUTIL_API esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB);
+
+//
+//// \brief return an indentity matrix
+//// \param result returns identity matrix
+//
+void ESUTIL_API esMatrixLoadIdentity(ESMatrix *result);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ESUTIL_H
diff --git a/src/es/esShader.c b/src/es/esShader.c
new file mode 100644
index 0000000..4ea2cbc
--- /dev/null
+++ b/src/es/esShader.c
@@ -0,0 +1,155 @@
+//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+// ESShader.c
+//
+// Utility functions for loading shaders and creating program objects.
+//
+
+///
+// Includes
+//
+#include "esUtil.h"
+#include <stdlib.h>
+
+//////////////////////////////////////////////////////////////////
+//
+// Private Functions
+//
+//
+
+
+
+//////////////////////////////////////////////////////////////////
+//
+// Public Functions
+//
+//
+
+//
+///
+/// \brief Load a shader, check for compile errors, print error messages to output log
+/// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER)
+/// \param shaderSrc Shader source string
+/// \return A new shader object on success, 0 on failure
+//
+GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc )
+{
+ GLuint shader;
+ GLint compiled;
+
+ // Create the shader object
+ shader = glCreateShader ( type );
+
+ if ( shader == 0 )
+ return 0;
+
+ // Load the shader source
+ glShaderSource ( shader, 1, &shaderSrc, NULL );
+
+ // Compile the shader
+ glCompileShader ( shader );
+
+ // Check the compile status
+ glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled );
+
+ if ( !compiled )
+ {
+ GLint infoLen = 0;
+
+ glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen );
+
+ if ( infoLen > 1 )
+ {
+ char* infoLog = malloc (sizeof(char) * infoLen );
+
+ glGetShaderInfoLog ( shader, infoLen, NULL, infoLog );
+ esLogMessage ( "Error compiling shader:\n%s\n", infoLog );
+
+ free ( infoLog );
+ }
+
+ glDeleteShader ( shader );
+ return 0;
+ }
+
+ return shader;
+
+}
+
+
+//
+///
+/// \brief Load a vertex and fragment shader, create a program object, link program.
+// Errors output to log.
+/// \param vertShaderSrc Vertex shader source code
+/// \param fragShaderSrc Fragment shader source code
+/// \return A new program object linked with the vertex/fragment shader pair, 0 on failure
+//
+GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc )
+{
+ GLuint vertexShader;
+ GLuint fragmentShader;
+ GLuint programObject;
+ GLint linked;
+
+ // Load the vertex/fragment shaders
+ vertexShader = esLoadShader ( GL_VERTEX_SHADER, vertShaderSrc );
+ if ( vertexShader == 0 )
+ return 0;
+
+ fragmentShader = esLoadShader ( GL_FRAGMENT_SHADER, fragShaderSrc );
+ if ( fragmentShader == 0 )
+ {
+ glDeleteShader( vertexShader );
+ return 0;
+ }
+
+ // Create the program object
+ programObject = glCreateProgram ( );
+
+ if ( programObject == 0 )
+ return 0;
+
+ glAttachShader ( programObject, vertexShader );
+ glAttachShader ( programObject, fragmentShader );
+
+ // Link the program
+ glLinkProgram ( programObject );
+
+ // Check the link status
+ glGetProgramiv ( programObject, GL_LINK_STATUS, &linked );
+
+ if ( !linked )
+ {
+ GLint infoLen = 0;
+
+ glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen );
+
+ if ( infoLen > 1 )
+ {
+ char* infoLog = malloc (sizeof(char) * infoLen );
+
+ glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog );
+ esLogMessage ( "Error linking program:\n%s\n", infoLog );
+
+ free ( infoLog );
+ }
+
+ glDeleteProgram ( programObject );
+ return 0;
+ }
+
+ // Free up no longer needed shader resources
+ glDeleteShader ( vertexShader );
+ glDeleteShader ( fragmentShader );
+
+ return programObject;
+} \ No newline at end of file
diff --git a/src/es/esShapes.c b/src/es/esShapes.c
new file mode 100644
index 0000000..0fa6505
--- /dev/null
+++ b/src/es/esShapes.c
@@ -0,0 +1,280 @@
+//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+// ESShapes.c
+//
+// Utility functions for generating shapes
+//
+
+///
+// Includes
+//
+#include "esUtil.h"
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+///
+// Defines
+//
+#define ES_PI (3.14159265f)
+
+//////////////////////////////////////////////////////////////////
+//
+// Private Functions
+//
+//
+
+
+
+//////////////////////////////////////////////////////////////////
+//
+// Public Functions
+//
+//
+
+//
+/// \brief Generates geometry for a sphere. Allocates memory for the vertex data and stores
+/// the results in the arrays. Generate index list for a TRIANGLE_STRIP
+/// \param numSlices The number of slices in the sphere
+/// \param vertices If not NULL, will contain array of float3 positions
+/// \param normals If not NULL, will contain array of float3 normals
+/// \param texCoords If not NULL, will contain array of float2 texCoords
+/// \param indices If not NULL, will contain the array of indices for the triangle strip
+/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
+/// if it is not NULL ) as a GL_TRIANGLE_STRIP
+//
+int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **normals,
+ GLfloat **texCoords, GLuint **indices )
+{
+ int i;
+ int j;
+ int numParallels = numSlices / 2;
+ int numVertices = ( numParallels + 1 ) * ( numSlices + 1 );
+ int numIndices = numParallels * numSlices * 6;
+ float angleStep = (2.0f * ES_PI) / ((float) numSlices);
+
+ // Allocate memory for buffers
+ if ( vertices != NULL )
+ *vertices = malloc ( sizeof(GLfloat) * 3 * numVertices );
+
+ if ( normals != NULL )
+ *normals = malloc ( sizeof(GLfloat) * 3 * numVertices );
+
+ if ( texCoords != NULL )
+ *texCoords = malloc ( sizeof(GLfloat) * 2 * numVertices );
+
+ if ( indices != NULL )
+ *indices = malloc ( sizeof(GLuint) * numIndices );
+
+ for ( i = 0; i < numParallels + 1; i++ )
+ {
+ for ( j = 0; j < numSlices + 1; j++ )
+ {
+ int vertex = ( i * (numSlices + 1) + j ) * 3;
+
+ if ( vertices )
+ {
+ (*vertices)[vertex + 0] = radius * sinf ( angleStep * (float)i ) *
+ sinf ( angleStep * (float)j );
+ (*vertices)[vertex + 1] = radius * cosf ( angleStep * (float)i );
+ (*vertices)[vertex + 2] = radius * sinf ( angleStep * (float)i ) *
+ cosf ( angleStep * (float)j );
+ }
+
+ if ( normals )
+ {
+ (*normals)[vertex + 0] = (*vertices)[vertex + 0] / radius;
+ (*normals)[vertex + 1] = (*vertices)[vertex + 1] / radius;
+ (*normals)[vertex + 2] = (*vertices)[vertex + 2] / radius;
+ }
+
+ if ( texCoords )
+ {
+ int texIndex = ( i * (numSlices + 1) + j ) * 2;
+ (*texCoords)[texIndex + 0] = (float) j / (float) numSlices;
+ (*texCoords)[texIndex + 1] = ( 1.0f - (float) i ) / (float) (numParallels - 1 );
+ }
+ }
+ }
+
+ // Generate the indices
+ if ( indices != NULL )
+ {
+ GLuint *indexBuf = (*indices);
+ for ( i = 0; i < numParallels ; i++ )
+ {
+ for ( j = 0; j < numSlices; j++ )
+ {
+ *indexBuf++ = i * ( numSlices + 1 ) + j;
+ *indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + j;
+ *indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + ( j + 1 );
+
+ *indexBuf++ = i * ( numSlices + 1 ) + j;
+ *indexBuf++ = ( i + 1 ) * ( numSlices + 1 ) + ( j + 1 );
+ *indexBuf++ = i * ( numSlices + 1 ) + ( j + 1 );
+ }
+ }
+ }
+
+ return numIndices;
+}
+
+//
+/// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores
+/// the results in the arrays. Generate index list for a TRIANGLES
+/// \param scale The size of the cube, use 1.0 for a unit cube.
+/// \param vertices If not NULL, will contain array of float3 positions
+/// \param normals If not NULL, will contain array of float3 normals
+/// \param texCoords If not NULL, will contain array of float2 texCoords
+/// \param indices If not NULL, will contain the array of indices for the triangle strip
+/// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
+/// if it is not NULL ) as a GL_TRIANGLE_STRIP
+//
+int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
+ GLfloat **texCoords, GLuint **indices )
+{
+ int i;
+ int numVertices = 24;
+ int numIndices = 36;
+
+ GLfloat cubeVerts[] =
+ {
+ -0.5f, -0.5f, -0.5f,
+ -0.5f, -0.5f, 0.5f,
+ 0.5f, -0.5f, 0.5f,
+ 0.5f, -0.5f, -0.5f,
+ -0.5f, 0.5f, -0.5f,
+ -0.5f, 0.5f, 0.5f,
+ 0.5f, 0.5f, 0.5f,
+ 0.5f, 0.5f, -0.5f,
+ -0.5f, -0.5f, -0.5f,
+ -0.5f, 0.5f, -0.5f,
+ 0.5f, 0.5f, -0.5f,
+ 0.5f, -0.5f, -0.5f,
+ -0.5f, -0.5f, 0.5f,
+ -0.5f, 0.5f, 0.5f,
+ 0.5f, 0.5f, 0.5f,
+ 0.5f, -0.5f, 0.5f,
+ -0.5f, -0.5f, -0.5f,
+ -0.5f, -0.5f, 0.5f,
+ -0.5f, 0.5f, 0.5f,
+ -0.5f, 0.5f, -0.5f,
+ 0.5f, -0.5f, -0.5f,
+ 0.5f, -0.5f, 0.5f,
+ 0.5f, 0.5f, 0.5f,
+ 0.5f, 0.5f, -0.5f,
+ };
+
+ GLfloat cubeNormals[] =
+ {
+ 0.0f, -1.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, -1.0f,
+ 0.0f, 0.0f, -1.0f,
+ 0.0f, 0.0f, -1.0f,
+ 0.0f, 0.0f, -1.0f,
+ 0.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f,
+ -1.0f, 0.0f, 0.0f,
+ -1.0f, 0.0f, 0.0f,
+ -1.0f, 0.0f, 0.0f,
+ -1.0f, 0.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f,
+ };
+
+ GLfloat cubeTex[] =
+ {
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ 1.0f, 0.0f,
+ 1.0f, 1.0f,
+ 0.0f, 1.0f,
+ 0.0f, 0.0f,
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ };
+
+ // Allocate memory for buffers
+ if ( vertices != NULL )
+ {
+ *vertices = malloc ( sizeof(GLfloat) * 3 * numVertices );
+ memcpy( *vertices, cubeVerts, sizeof( cubeVerts ) );
+ for ( i = 0; i < numVertices * 3; i++ )
+ {
+ (*vertices)[i] *= scale;
+ }
+ }
+
+ if ( normals != NULL )
+ {
+ *normals = malloc ( sizeof(GLfloat) * 3 * numVertices );
+ memcpy( *normals, cubeNormals, sizeof( cubeNormals ) );
+ }
+
+ if ( texCoords != NULL )
+ {
+ *texCoords = malloc ( sizeof(GLfloat) * 2 * numVertices );
+ memcpy( *texCoords, cubeTex, sizeof( cubeTex ) ) ;
+ }
+
+
+ // Generate the indices
+ if ( indices != NULL )
+ {
+ GLuint cubeIndices[] =
+ {
+ 0, 2, 1,
+ 0, 3, 2,
+ 4, 5, 6,
+ 4, 6, 7,
+ 8, 9, 10,
+ 8, 10, 11,
+ 12, 15, 14,
+ 12, 14, 13,
+ 16, 17, 18,
+ 16, 18, 19,
+ 20, 23, 22,
+ 20, 22, 21
+ };
+
+ *indices = malloc ( sizeof(GLuint) * numIndices );
+ memcpy( *indices, cubeIndices, sizeof( cubeIndices ) );
+ }
+
+ return numIndices;
+}
diff --git a/src/es/esTransform.c b/src/es/esTransform.c
new file mode 100644
index 0000000..5182218
--- /dev/null
+++ b/src/es/esTransform.c
@@ -0,0 +1,213 @@
+//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+// ESUtil.c
+//
+// A utility library for OpenGL ES. This library provides a
+// basic common framework for the example applications in the
+// OpenGL ES 2.0 Programming Guide.
+//
+
+///
+// Includes
+//
+#include "esUtil.h"
+#include <math.h>
+#include <string.h>
+
+#define PI 3.1415926535897932384626433832795f
+
+void ESUTIL_API
+esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz)
+{
+ result->m[0][0] *= sx;
+ result->m[0][1] *= sx;
+ result->m[0][2] *= sx;
+ result->m[0][3] *= sx;
+
+ result->m[1][0] *= sy;
+ result->m[1][1] *= sy;
+ result->m[1][2] *= sy;
+ result->m[1][3] *= sy;
+
+ result->m[2][0] *= sz;
+ result->m[2][1] *= sz;
+ result->m[2][2] *= sz;
+ result->m[2][3] *= sz;
+}
+
+void ESUTIL_API
+esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz)
+{
+ result->m[3][0] += (result->m[0][0] * tx + result->m[1][0] * ty + result->m[2][0] * tz);
+ result->m[3][1] += (result->m[0][1] * tx + result->m[1][1] * ty + result->m[2][1] * tz);
+ result->m[3][2] += (result->m[0][2] * tx + result->m[1][2] * ty + result->m[2][2] * tz);
+ result->m[3][3] += (result->m[0][3] * tx + result->m[1][3] * ty + result->m[2][3] * tz);
+}
+
+void ESUTIL_API
+esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+{
+ GLfloat sinAngle, cosAngle;
+ GLfloat mag = sqrtf(x * x + y * y + z * z);
+
+ sinAngle = sinf ( angle * PI / 180.0f );
+ cosAngle = cosf ( angle * PI / 180.0f );
+ if ( mag > 0.0f )
+ {
+ GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs;
+ GLfloat oneMinusCos;
+ ESMatrix rotMat;
+
+ x /= mag;
+ y /= mag;
+ z /= mag;
+
+ xx = x * x;
+ yy = y * y;
+ zz = z * z;
+ xy = x * y;
+ yz = y * z;
+ zx = z * x;
+ xs = x * sinAngle;
+ ys = y * sinAngle;
+ zs = z * sinAngle;
+ oneMinusCos = 1.0f - cosAngle;
+
+ rotMat.m[0][0] = (oneMinusCos * xx) + cosAngle;
+ rotMat.m[0][1] = (oneMinusCos * xy) - zs;
+ rotMat.m[0][2] = (oneMinusCos * zx) + ys;
+ rotMat.m[0][3] = 0.0F;
+
+ rotMat.m[1][0] = (oneMinusCos * xy) + zs;
+ rotMat.m[1][1] = (oneMinusCos * yy) + cosAngle;
+ rotMat.m[1][2] = (oneMinusCos * yz) - xs;
+ rotMat.m[1][3] = 0.0F;
+
+ rotMat.m[2][0] = (oneMinusCos * zx) - ys;
+ rotMat.m[2][1] = (oneMinusCos * yz) + xs;
+ rotMat.m[2][2] = (oneMinusCos * zz) + cosAngle;
+ rotMat.m[2][3] = 0.0F;
+
+ rotMat.m[3][0] = 0.0F;
+ rotMat.m[3][1] = 0.0F;
+ rotMat.m[3][2] = 0.0F;
+ rotMat.m[3][3] = 1.0F;
+
+ esMatrixMultiply( result, &rotMat, result );
+ }
+}
+
+void ESUTIL_API
+esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ)
+{
+ float deltaX = right - left;
+ float deltaY = top - bottom;
+ float deltaZ = farZ - nearZ;
+ ESMatrix frust;
+
+ if ( (nearZ <= 0.0f) || (farZ <= 0.0f) ||
+ (deltaX <= 0.0f) || (deltaY <= 0.0f) || (deltaZ <= 0.0f) )
+ return;
+
+ frust.m[0][0] = 2.0f * nearZ / deltaX;
+ frust.m[0][1] = frust.m[0][2] = frust.m[0][3] = 0.0f;
+
+ frust.m[1][1] = 2.0f * nearZ / deltaY;
+ frust.m[1][0] = frust.m[1][2] = frust.m[1][3] = 0.0f;
+
+ frust.m[2][0] = (right + left) / deltaX;
+ frust.m[2][1] = (top + bottom) / deltaY;
+ frust.m[2][2] = -(nearZ + farZ) / deltaZ;
+ frust.m[2][3] = -1.0f;
+
+ frust.m[3][2] = -2.0f * nearZ * farZ / deltaZ;
+ frust.m[3][0] = frust.m[3][1] = frust.m[3][3] = 0.0f;
+
+ esMatrixMultiply(result, &frust, result);
+}
+
+
+void ESUTIL_API
+esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ)
+{
+ GLfloat frustumW, frustumH;
+
+ frustumH = tanf( fovy / 360.0f * PI ) * nearZ;
+ frustumW = frustumH * aspect;
+
+ esFrustum( result, -frustumW, frustumW, -frustumH, frustumH, nearZ, farZ );
+}
+
+void ESUTIL_API
+esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ)
+{
+ float deltaX = right - left;
+ float deltaY = top - bottom;
+ float deltaZ = farZ - nearZ;
+ ESMatrix ortho;
+
+ if ( (deltaX == 0.0f) || (deltaY == 0.0f) || (deltaZ == 0.0f) )
+ return;
+
+ esMatrixLoadIdentity(&ortho);
+ ortho.m[0][0] = 2.0f / deltaX;
+ ortho.m[3][0] = -(right + left) / deltaX;
+ ortho.m[1][1] = 2.0f / deltaY;
+ ortho.m[3][1] = -(top + bottom) / deltaY;
+ ortho.m[2][2] = -2.0f / deltaZ;
+ ortho.m[3][2] = -(nearZ + farZ) / deltaZ;
+
+ esMatrixMultiply(result, &ortho, result);
+}
+
+
+void ESUTIL_API
+esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB)
+{
+ ESMatrix tmp;
+ int i;
+
+ for (i=0; i<4; i++)
+ {
+ tmp.m[i][0] = (srcA->m[i][0] * srcB->m[0][0]) +
+ (srcA->m[i][1] * srcB->m[1][0]) +
+ (srcA->m[i][2] * srcB->m[2][0]) +
+ (srcA->m[i][3] * srcB->m[3][0]) ;
+
+ tmp.m[i][1] = (srcA->m[i][0] * srcB->m[0][1]) +
+ (srcA->m[i][1] * srcB->m[1][1]) +
+ (srcA->m[i][2] * srcB->m[2][1]) +
+ (srcA->m[i][3] * srcB->m[3][1]) ;
+
+ tmp.m[i][2] = (srcA->m[i][0] * srcB->m[0][2]) +
+ (srcA->m[i][1] * srcB->m[1][2]) +
+ (srcA->m[i][2] * srcB->m[2][2]) +
+ (srcA->m[i][3] * srcB->m[3][2]) ;
+
+ tmp.m[i][3] = (srcA->m[i][0] * srcB->m[0][3]) +
+ (srcA->m[i][1] * srcB->m[1][3]) +
+ (srcA->m[i][2] * srcB->m[2][3]) +
+ (srcA->m[i][3] * srcB->m[3][3]) ;
+ }
+ memcpy(result, &tmp, sizeof(ESMatrix));
+}
+
+
+void ESUTIL_API
+esMatrixLoadIdentity(ESMatrix *result)
+{
+ memset(result, 0x0, sizeof(ESMatrix));
+ result->m[0][0] = 1.0f;
+ result->m[1][1] = 1.0f;
+ result->m[2][2] = 1.0f;
+ result->m[3][3] = 1.0f;
+}
+
diff --git a/src/es/esUtil.c b/src/es/esUtil.c
new file mode 100644
index 0000000..4b0898c
--- /dev/null
+++ b/src/es/esUtil.c
@@ -0,0 +1,428 @@
+//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+// ESUtil.c
+//
+// A utility library for OpenGL ES. This library provides a
+// basic common framework for the example applications in the
+// OpenGL ES 2.0 Programming Guide.
+//
+
+///
+// Includes
+//
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <sys/time.h>
+#include <GLES2/gl2.h>
+#include <EGL/egl.h>
+#include "esUtil.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+// X11 related local variables
+static Display *x_display = NULL;
+
+void tgOpenVGCreateContext(ESContext *esContext);
+
+///
+// CreateEGLContext()
+//
+// Creates an EGL rendering context and all associated elements
+//
+EGLBoolean CreateEGLContext ( EGLNativeWindowType hWnd, EGLDisplay* eglDisplay,
+ EGLContext* eglContext, EGLSurface* eglSurface,
+ EGLConfig *eglConfig,
+ EGLint attribList[])
+{
+ EGLint numConfigs;
+ EGLint majorVersion;
+ EGLint minorVersion;
+ EGLDisplay display;
+ EGLContext context;
+ EGLSurface surface;
+ EGLConfig config;
+ EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
+
+ // Get Display
+ display = eglGetDisplay((EGLNativeDisplayType)x_display);
+ if ( display == EGL_NO_DISPLAY )
+ {
+ return EGL_FALSE;
+ }
+
+ // Initialize EGL
+ if ( !eglInitialize(display, &majorVersion, &minorVersion) )
+ {
+ return EGL_FALSE;
+ }
+
+ // Get configs
+ if ( !eglGetConfigs(display, NULL, 0, &numConfigs) )
+ {
+ return EGL_FALSE;
+ }
+
+ // Choose config
+ if ( !eglChooseConfig(display, attribList, &config, 1, &numConfigs) )
+ {
+ return EGL_FALSE;
+ }
+
+ // Create a surface
+ surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, NULL);
+ if ( surface == EGL_NO_SURFACE )
+ {
+ return EGL_FALSE;
+ }
+
+ // Create a GL context
+ context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs );
+ if ( context == EGL_NO_CONTEXT )
+ {
+ return EGL_FALSE;
+ }
+
+ // Make the context current
+ if ( !eglMakeCurrent(display, surface, surface, context) )
+ {
+ return EGL_FALSE;
+ }
+
+ *eglDisplay = display;
+ *eglSurface = surface;
+ *eglContext = context;
+ *eglConfig = config;
+ return EGL_TRUE;
+}
+
+
+///
+// WinCreate()
+//
+// This function initialized the native X11 display and window for EGL
+//
+EGLBoolean WinCreate(ESContext *esContext, const char *title)
+{
+ Window root;
+ XSetWindowAttributes swa;
+ XSetWindowAttributes xattr;
+ Atom wm_state;
+ XWMHints hints;
+ XEvent xev;
+ EGLConfig ecfg;
+ EGLint num_config;
+ Window win;
+
+ /*
+ * X11 native display initialization
+ */
+
+ x_display = XOpenDisplay(NULL);
+ if ( x_display == NULL )
+ {
+ return EGL_FALSE;
+ }
+
+ root = DefaultRootWindow(x_display);
+
+ swa.event_mask = ExposureMask | PointerMotionMask | KeyPressMask;
+ win = XCreateWindow(
+ x_display, root,
+ 0, 0, esContext->width, esContext->height, 0,
+ CopyFromParent, InputOutput,
+ CopyFromParent, CWEventMask,
+ &swa );
+
+ xattr.override_redirect = FALSE;
+ XChangeWindowAttributes ( x_display, win, CWOverrideRedirect, &xattr );
+
+ hints.input = TRUE;
+ hints.flags = InputHint;
+ XSetWMHints(x_display, win, &hints);
+
+ // make the window visible on the screen
+ XMapWindow (x_display, win);
+ XStoreName (x_display, win, title);
+
+ // get identifiers for the provided atom name strings
+ wm_state = XInternAtom (x_display, "_NET_WM_STATE", FALSE);
+
+ memset ( &xev, 0, sizeof(xev) );
+ xev.type = ClientMessage;
+ xev.xclient.window = win;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1;
+ xev.xclient.data.l[1] = FALSE;
+ XSendEvent (
+ x_display,
+ DefaultRootWindow ( x_display ),
+ FALSE,
+ SubstructureNotifyMask,
+ &xev );
+
+ esContext->hWnd = (EGLNativeWindowType) win;
+ return EGL_TRUE;
+}
+
+
+///
+// userInterrupt()
+//
+// Reads from X11 event loop and interrupt program if there is a keypress, or
+// window close action.
+//
+GLboolean userInterrupt(ESContext *esContext)
+{
+ XEvent xev;
+ KeySym key;
+ GLboolean userinterrupt = GL_FALSE;
+ char text;
+
+ // Pump all messages from X server. Keypresses are directed to keyfunc (if defined)
+ while ( XPending ( x_display ) )
+ {
+ XNextEvent( x_display, &xev );
+ if ( xev.type == KeyPress )
+ {
+ if (XLookupString(&xev.xkey,&text,1,&key,0)==1)
+ {
+ if (esContext->keyFunc != NULL)
+ esContext->keyFunc(esContext, text, 0, 0);
+ }
+ }
+ if ( xev.type == DestroyNotify )
+ userinterrupt = GL_TRUE;
+ }
+ return userinterrupt;
+}
+
+
+//////////////////////////////////////////////////////////////////
+//
+// Public Functions
+//
+//
+
+///
+// esInitContext()
+//
+// Initialize ES utility context. This must be called before calling any other
+// functions.
+//
+void ESUTIL_API esInitContext ( ESContext *esContext )
+{
+ if ( esContext != NULL )
+ {
+ memset( esContext, 0, sizeof( ESContext) );
+ }
+}
+
+
+///
+// esCreateWindow()
+//
+// title - name for title bar of window
+// width - width of window to create
+// height - height of window to create
+// flags - bitwise or of window creation flags
+// ES_WINDOW_ALPHA - specifies that the framebuffer should have alpha
+// ES_WINDOW_DEPTH - specifies that a depth buffer should be created
+// ES_WINDOW_STENCIL - specifies that a stencil buffer should be created
+// ES_WINDOW_MULTISAMPLE - specifies that a multi-sample buffer should be created
+//
+GLboolean ESUTIL_API esCreateWindow ( ESContext *esContext, const char* title, GLint width, GLint height, GLuint flags )
+{
+ EGLint attribList[] =
+ {
+ EGL_RED_SIZE, 5,
+ EGL_GREEN_SIZE, 6,
+ EGL_BLUE_SIZE, 5,
+ EGL_ALPHA_SIZE, (flags & ES_WINDOW_ALPHA) ? 8 : EGL_DONT_CARE,
+ EGL_DEPTH_SIZE, (flags & ES_WINDOW_DEPTH) ? 8 : EGL_DONT_CARE,
+ EGL_STENCIL_SIZE, (flags & ES_WINDOW_STENCIL) ? 8 : EGL_DONT_CARE,
+ EGL_SAMPLE_BUFFERS, (flags & ES_WINDOW_MULTISAMPLE) ? 1 : 0,
+ EGL_NONE
+ };
+
+ if ( esContext == NULL )
+ {
+ return GL_FALSE;
+ }
+
+ esContext->width = width;
+ esContext->height = height;
+
+ if ( !WinCreate ( esContext, title) )
+ {
+ return GL_FALSE;
+ }
+
+
+ if ( !CreateEGLContext ( esContext->hWnd,
+ &esContext->eglDisplay,
+ &esContext->eglContext,
+ &esContext->eglSurface,
+ &esContext->eglConfig,
+ attribList) )
+ {
+ return GL_FALSE;
+ }
+
+
+ // create VG side of the context
+ tgOpenVGCreateContext(esContext);
+
+ return GL_TRUE;
+}
+
+
+///
+// esMainLoop()
+//
+// Start the main loop for the OpenGL ES application
+//
+
+void ESUTIL_API esMainLoop ( ESContext *esContext )
+{
+ struct timeval t1, t2;
+ struct timezone tz;
+ float deltatime;
+ float totaltime = 0.0f;
+ unsigned int frames = 0;
+
+ gettimeofday ( &t1 , &tz );
+
+ while(userInterrupt(esContext) == GL_FALSE)
+ {
+ gettimeofday(&t2, &tz);
+ deltatime = (float)(t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) * 1e-6);
+ t1 = t2;
+
+ if (esContext->updateFunc != NULL)
+ esContext->updateFunc(esContext, deltatime);
+ if (esContext->drawFunc != NULL)
+ esContext->drawFunc(esContext);
+
+ eglSwapBuffers(esContext->eglDisplay, esContext->eglSurface);
+
+ totaltime += deltatime;
+ frames++;
+ if (totaltime > 2.0f)
+ {
+ printf("%4d frames rendered in %1.4f seconds -> FPS=%3.4f\n", frames, totaltime, frames/totaltime);
+ totaltime -= 2.0f;
+ frames = 0;
+ }
+ }
+}
+
+
+///
+// esRegisterDrawFunc()
+//
+void ESUTIL_API esRegisterDrawFunc ( ESContext *esContext, void (ESCALLBACK *drawFunc) (ESContext* ) )
+{
+ esContext->drawFunc = drawFunc;
+}
+
+
+///
+// esRegisterUpdateFunc()
+//
+void ESUTIL_API esRegisterUpdateFunc ( ESContext *esContext, void (ESCALLBACK *updateFunc) ( ESContext*, float ) )
+{
+ esContext->updateFunc = updateFunc;
+}
+
+
+///
+// esRegisterKeyFunc()
+//
+void ESUTIL_API esRegisterKeyFunc ( ESContext *esContext,
+ void (ESCALLBACK *keyFunc) (ESContext*, unsigned char, int, int ) )
+{
+ esContext->keyFunc = keyFunc;
+}
+
+
+///
+// esLogMessage()
+//
+// Log an error message to the debug output for the platform
+//
+void ESUTIL_API esLogMessage ( const char *formatStr, ... )
+{
+ va_list params;
+ char buf[BUFSIZ];
+
+ va_start ( params, formatStr );
+ vsprintf ( buf, formatStr, params );
+
+ printf ( "%s", buf );
+
+ va_end ( params );
+}
+
+
+///
+// esLoadTGA()
+//
+// Loads a 24-bit TGA image from a file. This is probably the simplest TGA loader ever.
+// Does not support loading of compressed TGAs nor TGAa with alpha channel. But for the
+// sake of the examples, this is sufficient.
+//
+
+char* ESUTIL_API esLoadTGA ( char *fileName, int *width, int *height )
+{
+ char *buffer = NULL;
+ FILE *f;
+ unsigned char tgaheader[12];
+ unsigned char attributes[6];
+ unsigned int imagesize;
+
+ f = fopen(fileName, "rb");
+ if(f == NULL) return NULL;
+
+ if(fread(&tgaheader, sizeof(tgaheader), 1, f) == 0)
+ {
+ fclose(f);
+ return NULL;
+ }
+
+ if(fread(attributes, sizeof(attributes), 1, f) == 0)
+ {
+ fclose(f);
+ return 0;
+ }
+
+ *width = attributes[1] * 256 + attributes[0];
+ *height = attributes[3] * 256 + attributes[2];
+ imagesize = attributes[4] / 8 * *width * *height;
+ buffer = malloc(imagesize);
+ if (buffer == NULL)
+ {
+ fclose(f);
+ return 0;
+ }
+
+ if(fread(buffer, 1, imagesize, f) != imagesize)
+ {
+ free(buffer);
+ return NULL;
+ }
+ fclose(f);
+ return buffer;
+}
diff --git a/src/vg/Api.cpp b/src/vg/Api.cpp
new file mode 100644
index 0000000..5b97a50
--- /dev/null
+++ b/src/vg/Api.cpp
@@ -0,0 +1,3672 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Implementations of OpenVG API functions.
+ * \note The actual processing is done in Path, Image, Rasterizer and PixelPipe classes.
+ *//*-------------------------------------------------------------------*/
+
+#include "VG/openvg.h"
+#include "EGL/egl.h"
+#include "Context.h"
+#include "Rasterizer.h"
+#include "PixelPipe.h"
+#include "Path.h"
+#include <stdio.h>
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+/* EGL&OS functions for use in an OpenVG implementation */
+void* eglvgGetCurrentVGContext(void);
+bool eglvgIsInUse(void* image);
+void OSAcquireMutex(void);
+void OSReleaseMutex(void);
+
+
+#define RI_NO_RETVAL
+
+//this must be the first line in an API function
+#define RI_GET_CONTEXT(RETVAL) \
+ OSAcquireMutex(); \
+ VGContext* context = (VGContext*)eglvgGetCurrentVGContext(); \
+ if(!context) \
+ { \
+ OSReleaseMutex(); \
+ return RETVAL;\
+ }
+
+#define RI_IF_ERROR(COND, ERRORCODE, RETVAL) \
+ if(COND) { context->setError(ERRORCODE); OSReleaseMutex(); return RETVAL; }
+
+//all API functions must call this as their last operation (also functions that don't return values)
+//NOTE: don't evaluate anything or read state in RETVAL (it'll be executed after the mutex has been released)
+#define RI_RETURN(RETVAL) \
+ { OSReleaseMutex(); \
+ return RETVAL; }
+
+static bool isAligned(const void* ptr, int alignment)
+{
+ RI_ASSERT(alignment == 1 || alignment == 2 || alignment == 4);
+ if(((RIuintptr)ptr) & (alignment-1))
+ return false;
+ return true;
+}
+
+static bool isAligned(const void* ptr, VGImageFormat format)
+{
+ RI_ASSERT(isValidImageFormat(format));
+ int alignment = Color::formatToDescriptor(format).bitsPerPixel >> 3;
+ if(alignment <= 1)
+ return true; //one bit or byte per pixel
+ return isAligned(ptr, alignment);
+}
+
+bool isValidImageFormat(int f)
+{
+ if(f < VG_sRGBX_8888 || f > VG_lABGR_8888_PRE)
+ return false;
+ return true;
+}
+
+} //namespace OpenVGRI
+
+using namespace tgOpenVG;
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgFlush(void)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ //the RI doesn't cache anything, so this is a no-op
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgFinish(void)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ //the RI doesn't cache anything, so this is a no-op
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGErrorCode RI_APIENTRY vgGetError(void)
+{
+ RI_GET_CONTEXT(VG_NO_CONTEXT_ERROR);
+ VGErrorCode error = context->m_error;
+ context->m_error = VG_NO_ERROR;
+ RI_RETURN(error);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+namespace tgOpenVG
+{
+
+RIfloat inputFloat(VGfloat f)
+{
+ //this function is used for all floating point input values
+ if(RI_ISNAN(f)) return 0.0f; //convert NaN to zero
+ return RI_CLAMP(f, -RI_FLOAT_MAX, RI_FLOAT_MAX); //clamp +-inf to +-RIfloat max
+}
+
+Vector2 inputVector2(const Vector2& v)
+{
+ return Vector2(inputFloat(v.x), inputFloat(v.y));
+}
+
+Color inputColor(const Color& c)
+{
+ Color r = c;
+ r.r = inputFloat(r.r);
+ r.g = inputFloat(r.g);
+ r.b = inputFloat(r.b);
+ r.a = inputFloat(r.a);
+ return r;
+}
+
+static int inputFloatToInt(VGfloat value)
+{
+ double v = (double)floor(value);
+ v = v > (double)RI_INT32_MAX ? (double)RI_INT32_MAX : v;
+ v = v < (double)RI_INT32_MIN ? (double)RI_INT32_MIN : v;
+ return (int)v;
+}
+
+static int paramToInt(const void* values, bool floats, int count, int i)
+{
+ RI_ASSERT(i >= 0);
+ if(i >= count || !values)
+ return 0;
+ if(floats)
+ return inputFloatToInt(((const VGfloat*)values)[i]);
+ return (int)((const VGint*)values)[i];
+}
+
+static RIfloat paramToFloat(const void* values, bool floats, int count, int i)
+{
+ RI_ASSERT(i >= 0);
+ if(i >= count || !values)
+ return 0.0f;
+ if(floats)
+ return ((const VGfloat*)values)[i];
+ return (RIfloat)((const VGint*)values)[i];
+}
+
+static void floatToParam(void* output, bool outputFloats, int count, int i, VGfloat value)
+{
+ RI_ASSERT(i >= 0);
+ RI_ASSERT(output);
+ if(i >= count)
+ return;
+ if(outputFloats)
+ ((VGfloat*)output)[i] = value;
+ else
+ ((VGint*)output)[i] = (VGint)inputFloatToInt(value);
+}
+
+static void intToParam(void* output, bool outputFloats, int count, int i, VGint value)
+{
+ RI_ASSERT(i >= 0);
+ RI_ASSERT(output);
+ if(i >= count)
+ return;
+ if(outputFloats)
+ ((VGfloat*)output)[i] = (VGfloat)value;
+ else
+ ((VGint*)output)[i] = value;
+}
+
+} //namespace OpenVGRI
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static void setifv(VGContext* context, VGParamType type, VGint count, const void* values, bool floats)
+{
+ RI_ASSERT(context);
+ RI_ASSERT(!count || (count && values));
+
+ int ivalue = paramToInt(values, floats, count, 0);
+ RIfloat fvalue = paramToFloat(values, floats, count, 0);
+
+ switch(type)
+ {
+ case VG_MATRIX_MODE:
+ if(count != 1 || ivalue < VG_MATRIX_PATH_USER_TO_SURFACE || ivalue > VG_MATRIX_GLYPH_USER_TO_SURFACE) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_matrixMode = (VGMatrixMode)ivalue;
+ break;
+
+ case VG_FILL_RULE:
+ if(count != 1 || ivalue < VG_EVEN_ODD || ivalue > VG_NON_ZERO) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_fillRule = (VGFillRule)ivalue;
+ break;
+
+ case VG_IMAGE_QUALITY:
+ if(count != 1 || ivalue < VG_IMAGE_QUALITY_NONANTIALIASED || ivalue > VG_IMAGE_QUALITY_BETTER) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_imageQuality = (VGImageQuality)ivalue;
+ break;
+
+ case VG_RENDERING_QUALITY:
+ if(count != 1 || ivalue < VG_RENDERING_QUALITY_NONANTIALIASED || ivalue > VG_RENDERING_QUALITY_BETTER) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_renderingQuality = (VGRenderingQuality)ivalue;
+ break;
+
+ case VG_BLEND_MODE:
+ if(count != 1 || ivalue < VG_BLEND_SRC || ivalue > VG_BLEND_ADDITIVE) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_blendMode = (VGBlendMode)ivalue;
+ break;
+
+ case VG_IMAGE_MODE:
+ if(count != 1 || ivalue < VG_DRAW_IMAGE_NORMAL || ivalue > VG_DRAW_IMAGE_STENCIL) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_imageMode = (VGImageMode)ivalue;
+ break;
+
+ case VG_SCISSOR_RECTS:
+ {
+ if(count & 3) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; } //count must be a multiple of four
+ try
+ {
+ Array<Rectangle> scissor;
+ for(int i=0;i<RI_INT_MIN(count, RI_MAX_SCISSOR_RECTANGLES*4);i+=4)
+ {
+ Rectangle s;
+ s.x = paramToInt(values, floats, count, i+0);
+ s.y = paramToInt(values, floats, count, i+1);
+ s.width = paramToInt(values, floats, count, i+2);
+ s.height = paramToInt(values, floats, count, i+3);
+ scissor.push_back(s); //throws bad_alloc
+ }
+ context->m_scissor.swap(scissor); //replace context data
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ break;
+ }
+
+ case VG_COLOR_TRANSFORM:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_colorTransform = ivalue ? VG_TRUE : VG_FALSE;
+ break;
+
+ case VG_COLOR_TRANSFORM_VALUES:
+ if(count != 8 || !values) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ {
+ for(int i=0;i<8;i++)
+ {
+ context->m_inputColorTransformValues[i] = paramToFloat(values, floats, count, i);
+ context->m_colorTransformValues[i] = inputFloat(context->m_inputColorTransformValues[i]);
+ }
+ }
+ break;
+
+ case VG_STROKE_LINE_WIDTH:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_inputStrokeLineWidth = fvalue;
+ context->m_strokeLineWidth = inputFloat(fvalue);
+ break;
+
+ case VG_STROKE_CAP_STYLE:
+ if(count != 1 || ivalue < VG_CAP_BUTT || ivalue > VG_CAP_SQUARE) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_strokeCapStyle = (VGCapStyle)ivalue;
+ break;
+
+ case VG_STROKE_JOIN_STYLE:
+ if(count != 1 || ivalue < VG_JOIN_MITER || ivalue > VG_JOIN_BEVEL) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_strokeJoinStyle = (VGJoinStyle)ivalue;
+ break;
+
+ case VG_STROKE_MITER_LIMIT:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_inputStrokeMiterLimit = fvalue;
+ context->m_strokeMiterLimit = inputFloat(fvalue);
+ break;
+
+ case VG_STROKE_DASH_PATTERN:
+ {
+ try
+ {
+ Array<RIfloat> inputStrokeDashPattern;
+ Array<RIfloat> strokeDashPattern;
+ for(int i=0;i<RI_INT_MIN(count, RI_MAX_DASH_COUNT);i++)
+ {
+ RIfloat v = paramToFloat(values, floats, count, i);
+ inputStrokeDashPattern.push_back(v); //throws bad_alloc
+ strokeDashPattern.push_back(inputFloat(v)); //throws bad_alloc
+ }
+ context->m_inputStrokeDashPattern.swap(inputStrokeDashPattern); //replace context data
+ context->m_strokeDashPattern.swap(strokeDashPattern); //replace context data
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ break;
+ }
+
+ case VG_STROKE_DASH_PHASE:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_inputStrokeDashPhase = fvalue;
+ context->m_strokeDashPhase = inputFloat(fvalue);
+ break;
+
+ case VG_STROKE_DASH_PHASE_RESET:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_strokeDashPhaseReset = ivalue ? VG_TRUE : VG_FALSE;
+ break;
+
+ case VG_TILE_FILL_COLOR:
+ if(count != 4 || !values) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_inputTileFillColor.set(paramToFloat(values, floats, count, 0),
+ paramToFloat(values, floats, count, 1),
+ paramToFloat(values, floats, count, 2),
+ paramToFloat(values, floats, count, 3),
+ Color::sRGBA);
+ context->m_tileFillColor = inputColor(context->m_inputTileFillColor);
+ break;
+
+ case VG_GLYPH_ORIGIN:
+ if(count != 2 || !values) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_inputGlyphOrigin.x = paramToFloat(values, floats, count, 0);
+ context->m_inputGlyphOrigin.y = paramToFloat(values, floats, count, 1);
+ context->m_glyphOrigin = inputVector2(context->m_inputGlyphOrigin);
+ break;
+
+ case VG_CLEAR_COLOR:
+ if(count != 4 || !values) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_inputClearColor.set(paramToFloat(values, floats, count, 0),
+ paramToFloat(values, floats, count, 1),
+ paramToFloat(values, floats, count, 2),
+ paramToFloat(values, floats, count, 3),
+ Color::sRGBA);
+ context->m_clearColor = inputColor(context->m_inputClearColor);
+ break;
+
+ case VG_MASKING:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_masking = ivalue ? VG_TRUE : VG_FALSE;
+ break;
+
+ case VG_SCISSORING:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_scissoring = ivalue ? VG_TRUE : VG_FALSE;
+ break;
+
+ case VG_PIXEL_LAYOUT:
+ if(count != 1 || ivalue < VG_PIXEL_LAYOUT_UNKNOWN || ivalue > VG_PIXEL_LAYOUT_BGR_HORIZONTAL) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_pixelLayout = (VGPixelLayout)ivalue;
+ break;
+
+ case VG_SCREEN_LAYOUT:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ break; //setting read-only values has no effect
+
+ case VG_FILTER_FORMAT_LINEAR:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_filterFormatLinear = ivalue ? VG_TRUE : VG_FALSE;
+ break;
+
+ case VG_FILTER_FORMAT_PREMULTIPLIED:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ context->m_filterFormatPremultiplied = ivalue ? VG_TRUE : VG_FALSE;
+ break;
+
+ case VG_FILTER_CHANNEL_MASK:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ //undefined bits are ignored
+ context->m_filterChannelMask = (VGbitfield)ivalue;
+ break;
+
+ case VG_MAX_SCISSOR_RECTS:
+ case VG_MAX_DASH_COUNT:
+ case VG_MAX_KERNEL_SIZE:
+ case VG_MAX_SEPARABLE_KERNEL_SIZE:
+ case VG_MAX_COLOR_RAMP_STOPS:
+ case VG_MAX_IMAGE_WIDTH:
+ case VG_MAX_IMAGE_HEIGHT:
+ case VG_MAX_IMAGE_PIXELS:
+ case VG_MAX_IMAGE_BYTES:
+ case VG_MAX_FLOAT:
+ case VG_MAX_GAUSSIAN_STD_DEVIATION:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ break; //setting read-only values has no effect
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ break;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetf(VGParamType type, VGfloat value)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(type == VG_SCISSOR_RECTS || type == VG_STROKE_DASH_PATTERN || type == VG_TILE_FILL_COLOR ||
+ type == VG_CLEAR_COLOR, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //vector type value
+ VGfloat values[1] = {value};
+ setifv(context, type, 1, values, true);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSeti(VGParamType type, VGint value)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(type == VG_SCISSOR_RECTS || type == VG_STROKE_DASH_PATTERN || type == VG_TILE_FILL_COLOR ||
+ type == VG_CLEAR_COLOR, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //vector type value
+ VGint values[1] = {value};
+ setifv(context, type, 1, values, false);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetiv(VGParamType type, VGint count, const VGint * values)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(count < 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR((!values && count > 0) || (values && !isAligned(values,4)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ setifv(context, type, count, values, false);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetfv(VGParamType type, VGint count, const VGfloat * values)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(count < 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR((!values && count > 0) || (values && !isAligned(values,4)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ setifv(context, type, count, values, true);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static void getifv(VGContext* context, VGParamType type, VGint count, void* values, bool floats)
+{
+ switch(type)
+ {
+ case VG_MATRIX_MODE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_matrixMode);
+ break;
+
+ case VG_FILL_RULE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_fillRule);
+ break;
+
+ case VG_IMAGE_QUALITY:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_imageQuality);
+ break;
+
+ case VG_RENDERING_QUALITY:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_renderingQuality);
+ break;
+
+ case VG_BLEND_MODE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_blendMode);
+ break;
+
+ case VG_IMAGE_MODE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_imageMode);
+ break;
+
+ case VG_SCISSOR_RECTS:
+ {
+ if(count > context->m_scissor.size()*4) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ for(int i=0;i<context->m_scissor.size();i++)
+ {
+ intToParam(values, floats, count, i*4+0, context->m_scissor[i].x);
+ intToParam(values, floats, count, i*4+1, context->m_scissor[i].y);
+ intToParam(values, floats, count, i*4+2, context->m_scissor[i].width);
+ intToParam(values, floats, count, i*4+3, context->m_scissor[i].height);
+ }
+ break;
+ }
+
+ case VG_COLOR_TRANSFORM:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_colorTransform);
+ break;
+
+ case VG_COLOR_TRANSFORM_VALUES:
+ if(count > 8) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ {
+ for(int i=0;i<count;i++)
+ {
+ floatToParam(values, floats, count, i, context->m_inputColorTransformValues[i]);
+ }
+ }
+ break;
+
+ case VG_STROKE_LINE_WIDTH:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, context->m_inputStrokeLineWidth);
+ break;
+
+ case VG_STROKE_CAP_STYLE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_strokeCapStyle);
+ break;
+
+ case VG_STROKE_JOIN_STYLE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_strokeJoinStyle);
+ break;
+
+ case VG_STROKE_MITER_LIMIT:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, context->m_inputStrokeMiterLimit);
+ break;
+
+ case VG_STROKE_DASH_PATTERN:
+ {
+ if(count > context->m_inputStrokeDashPattern.size()) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ for(int i=0;i<context->m_inputStrokeDashPattern.size();i++)
+ floatToParam(values, floats, count, i, context->m_inputStrokeDashPattern[i]);
+ break;
+ }
+
+ case VG_STROKE_DASH_PHASE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, context->m_inputStrokeDashPhase);
+ break;
+
+ case VG_STROKE_DASH_PHASE_RESET:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_strokeDashPhaseReset);
+ break;
+
+ case VG_TILE_FILL_COLOR:
+ if(count > 4) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, context->m_inputTileFillColor.r);
+ floatToParam(values, floats, count, 1, context->m_inputTileFillColor.g);
+ floatToParam(values, floats, count, 2, context->m_inputTileFillColor.b);
+ floatToParam(values, floats, count, 3, context->m_inputTileFillColor.a);
+ break;
+
+ case VG_CLEAR_COLOR:
+ if(count > 4) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, context->m_inputClearColor.r);
+ floatToParam(values, floats, count, 1, context->m_inputClearColor.g);
+ floatToParam(values, floats, count, 2, context->m_inputClearColor.b);
+ floatToParam(values, floats, count, 3, context->m_inputClearColor.a);
+ break;
+
+ case VG_GLYPH_ORIGIN:
+ if(count > 2) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, context->m_inputGlyphOrigin.x);
+ floatToParam(values, floats, count, 1, context->m_inputGlyphOrigin.y);
+ break;
+
+ case VG_MASKING:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_masking);
+ break;
+
+ case VG_SCISSORING:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_scissoring);
+ break;
+
+ case VG_PIXEL_LAYOUT:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_pixelLayout);
+ break;
+
+ case VG_SCREEN_LAYOUT:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, VG_PIXEL_LAYOUT_UNKNOWN);
+ break;
+
+ case VG_FILTER_FORMAT_LINEAR:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_filterFormatLinear);
+ break;
+
+ case VG_FILTER_FORMAT_PREMULTIPLIED:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_filterFormatPremultiplied);
+ break;
+
+ case VG_FILTER_CHANNEL_MASK:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, context->m_filterChannelMask);
+ break;
+
+ case VG_MAX_SCISSOR_RECTS:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, RI_MAX_SCISSOR_RECTANGLES);
+ break;
+
+ case VG_MAX_DASH_COUNT:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, RI_MAX_DASH_COUNT);
+ break;
+
+ case VG_MAX_KERNEL_SIZE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, RI_MAX_KERNEL_SIZE);
+ break;
+
+ case VG_MAX_SEPARABLE_KERNEL_SIZE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, RI_MAX_SEPARABLE_KERNEL_SIZE);
+ break;
+
+ case VG_MAX_COLOR_RAMP_STOPS:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, RI_MAX_COLOR_RAMP_STOPS);
+ break;
+
+ case VG_MAX_IMAGE_WIDTH:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, RI_MAX_IMAGE_WIDTH);
+ break;
+
+ case VG_MAX_IMAGE_HEIGHT:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, RI_MAX_IMAGE_HEIGHT);
+ break;
+
+ case VG_MAX_IMAGE_PIXELS:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, RI_MAX_IMAGE_PIXELS);
+ break;
+
+ case VG_MAX_IMAGE_BYTES:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, RI_MAX_IMAGE_BYTES);
+ break;
+
+ case VG_MAX_FLOAT:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, RI_FLOAT_MAX);
+ break;
+
+ case VG_MAX_GAUSSIAN_STD_DEVIATION:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, RI_MAX_GAUSSIAN_STD_DEVIATION);
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ break;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGfloat RI_APIENTRY vgGetf(VGParamType type)
+{
+ RI_GET_CONTEXT(0.0f);
+ RI_IF_ERROR(type == VG_SCISSOR_RECTS || type == VG_STROKE_DASH_PATTERN || type == VG_TILE_FILL_COLOR ||
+ type == VG_CLEAR_COLOR, VG_ILLEGAL_ARGUMENT_ERROR, 0.0f); //vector type value
+ RIfloat ret = 0.0f;
+ getifv(context, type, 1, &ret, true);
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGint RI_APIENTRY vgGeti(VGParamType type)
+{
+ RI_GET_CONTEXT(0);
+ RI_IF_ERROR(type == VG_SCISSOR_RECTS || type == VG_STROKE_DASH_PATTERN || type == VG_TILE_FILL_COLOR ||
+ type == VG_CLEAR_COLOR, VG_ILLEGAL_ARGUMENT_ERROR, 0); //vector type value
+ VGint ret = 0;
+ getifv(context, type, 1, &ret, false);
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgGetiv(VGParamType type, VGint count, VGint * values)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(count <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!values || !isAligned(values,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ getifv(context, type, count, values, false);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgGetfv(VGParamType type, VGint count, VGfloat * values)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(count <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!values || !isAligned(values,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ getifv(context, type, count, values, true);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGint RI_APIENTRY vgGetVectorSize(VGParamType type)
+{
+ RI_GET_CONTEXT(0);
+ VGint ret = 0;
+ switch(type)
+ {
+ case VG_MATRIX_MODE:
+ case VG_FILL_RULE:
+ case VG_IMAGE_QUALITY:
+ case VG_RENDERING_QUALITY:
+ case VG_BLEND_MODE:
+ case VG_IMAGE_MODE:
+ ret = 1;
+ break;
+
+ case VG_SCISSOR_RECTS:
+ ret = 4*context->m_scissor.size();
+ break;
+
+ case VG_COLOR_TRANSFORM:
+ ret = 1;
+ break;
+
+ case VG_COLOR_TRANSFORM_VALUES:
+ ret = 8;
+ break;
+
+ case VG_STROKE_LINE_WIDTH:
+ case VG_STROKE_CAP_STYLE:
+ case VG_STROKE_JOIN_STYLE:
+ case VG_STROKE_MITER_LIMIT:
+ ret = 1;
+ break;
+
+ case VG_STROKE_DASH_PATTERN:
+ ret = context->m_inputStrokeDashPattern.size();
+ break;
+
+ case VG_STROKE_DASH_PHASE:
+ case VG_STROKE_DASH_PHASE_RESET:
+ ret = 1;
+ break;
+
+ case VG_TILE_FILL_COLOR:
+ case VG_CLEAR_COLOR:
+ ret = 4;
+ break;
+
+ case VG_GLYPH_ORIGIN:
+ ret = 2;
+ break;
+
+ case VG_MASKING:
+ case VG_SCISSORING:
+ case VG_PIXEL_LAYOUT:
+ case VG_SCREEN_LAYOUT:
+ case VG_FILTER_FORMAT_LINEAR:
+ case VG_FILTER_FORMAT_PREMULTIPLIED:
+ case VG_FILTER_CHANNEL_MASK:
+ case VG_MAX_SCISSOR_RECTS:
+ case VG_MAX_DASH_COUNT:
+ case VG_MAX_KERNEL_SIZE:
+ case VG_MAX_SEPARABLE_KERNEL_SIZE:
+ case VG_MAX_COLOR_RAMP_STOPS:
+ case VG_MAX_IMAGE_WIDTH:
+ case VG_MAX_IMAGE_HEIGHT:
+ case VG_MAX_IMAGE_PIXELS:
+ case VG_MAX_IMAGE_BYTES:
+ case VG_MAX_FLOAT:
+ case VG_MAX_GAUSSIAN_STD_DEVIATION:
+ ret = 1;
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ break;
+ }
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static void setPaintParameterifv(VGContext* context, Paint* paint, VGPaintParamType paramType, VGint count, const void* values, bool floats)
+{
+ RI_ASSERT(context);
+ RI_ASSERT(paint);
+
+ int ivalue = paramToInt(values, floats, count, 0);
+
+ switch(paramType)
+ {
+ case VG_PAINT_TYPE:
+ if(count != 1 || ivalue < VG_PAINT_TYPE_COLOR || ivalue > VG_PAINT_TYPE_PATTERN) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ paint->m_paintType = (VGPaintType)ivalue;
+ break;
+
+ case VG_PAINT_COLOR:
+ if(count != 4) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ paint->m_inputPaintColor.set(paramToFloat(values, floats, count, 0),
+ paramToFloat(values, floats, count, 1),
+ paramToFloat(values, floats, count, 2),
+ paramToFloat(values, floats, count, 3),
+ Color::sRGBA);
+ paint->m_paintColor = inputColor(paint->m_inputPaintColor);
+ paint->m_paintColor.clamp();
+ paint->m_paintColor.premultiply();
+ break;
+
+ case VG_PAINT_COLOR_RAMP_SPREAD_MODE:
+ if(count != 1 || ivalue < VG_COLOR_RAMP_SPREAD_PAD || ivalue > VG_COLOR_RAMP_SPREAD_REFLECT) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ paint->m_colorRampSpreadMode = (VGColorRampSpreadMode)ivalue;
+ break;
+
+ case VG_PAINT_COLOR_RAMP_STOPS:
+ {
+ int numStops = count/5;
+ if(count != numStops*5) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; } //count must be a multiple of five
+ try
+ {
+ Array<Paint::GradientStop> colorRampStops;
+ Array<Paint::GradientStop> inputColorRampStops;
+ RIfloat prevOffset = -RI_FLOAT_MAX;
+ bool valid = true;
+ for(int i=0;i<RI_INT_MIN(numStops, RI_MAX_COLOR_RAMP_STOPS);i++) //NOTE: ignores the final stop if there is not enough parameters
+ {
+ Paint::GradientStop gs;
+ gs.offset = paramToFloat(values, floats, count, i*5);
+ gs.color.set(paramToFloat(values, floats, count, i*5+1),
+ paramToFloat(values, floats, count, i*5+2),
+ paramToFloat(values, floats, count, i*5+3),
+ paramToFloat(values, floats, count, i*5+4),
+ Color::sRGBA);
+ inputColorRampStops.push_back(gs);
+
+ if(gs.offset < prevOffset)
+ valid = false; //decreasing sequence, ignore it
+
+ if(gs.offset >= 0.0f && gs.offset <= 1.0f)
+ {
+ gs.color.clamp();
+
+ if(!colorRampStops.size() && gs.offset > 0.0f)
+ { //the first valid stop is not at 0, replicate the first one
+ RIfloat tmp = gs.offset;
+ gs.offset = 0.0f;
+ colorRampStops.push_back(gs); //throws bad_alloc
+ gs.offset = tmp;
+ }
+ colorRampStops.push_back(gs); //throws bad_alloc
+ }
+ prevOffset = gs.offset;
+ }
+ if(valid && colorRampStops.size() && colorRampStops[colorRampStops.size()-1].offset < 1.0f)
+ { //there is at least one stop, but the last one is not at 1, replicate the last one
+ Paint::GradientStop gs = colorRampStops[colorRampStops.size()-1];
+ gs.offset = 1.0f;
+ colorRampStops.push_back(gs); //throws bad_alloc
+ }
+ if(!valid || !colorRampStops.size())
+ { //there are no valid stops, add implicit stops
+ colorRampStops.clear();
+ Paint::GradientStop gs;
+ gs.offset = 0.0f;
+ gs.color.set(0,0,0,1,Color::sRGBA);
+ colorRampStops.push_back(gs); //throws bad_alloc
+ gs.offset = 1.0f;
+ gs.color.set(1,1,1,1,Color::sRGBA);
+ colorRampStops.push_back(gs); //throws bad_alloc
+ }
+ RI_ASSERT(colorRampStops.size() >= 2 && colorRampStops.size() <= RI_MAX_COLOR_RAMP_STOPS);
+ paint->m_colorRampStops.swap(colorRampStops); //set paint array
+ paint->m_inputColorRampStops.swap(inputColorRampStops); //set paint array
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ break;
+ }
+
+ case VG_PAINT_COLOR_RAMP_PREMULTIPLIED:
+ if(count != 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ paint->m_colorRampPremultiplied = ivalue ? VG_TRUE : VG_FALSE;
+ break;
+
+ case VG_PAINT_LINEAR_GRADIENT:
+ if(count != 4) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ paint->m_inputLinearGradientPoint0.set(paramToFloat(values, floats, count, 0),
+ paramToFloat(values, floats, count, 1));
+ paint->m_inputLinearGradientPoint1.set(paramToFloat(values, floats, count, 2),
+ paramToFloat(values, floats, count, 3));
+ paint->m_linearGradientPoint0 = inputVector2(paint->m_inputLinearGradientPoint0);
+ paint->m_linearGradientPoint1 = inputVector2(paint->m_inputLinearGradientPoint1);
+ break;
+
+ case VG_PAINT_RADIAL_GRADIENT:
+ if(count != 5) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ paint->m_inputRadialGradientCenter.set(paramToFloat(values, floats, count, 0),
+ paramToFloat(values, floats, count, 1));
+ paint->m_inputRadialGradientFocalPoint.set(paramToFloat(values, floats, count, 2),
+ paramToFloat(values, floats, count, 3));
+ paint->m_inputRadialGradientRadius = paramToFloat(values, floats, count, 4);
+ paint->m_radialGradientCenter = inputVector2(paint->m_inputRadialGradientCenter);
+ paint->m_radialGradientFocalPoint = inputVector2(paint->m_inputRadialGradientFocalPoint);
+ paint->m_radialGradientRadius = inputFloat(paint->m_inputRadialGradientRadius);
+ break;
+
+ case VG_PAINT_PATTERN_TILING_MODE:
+ if(count != 1 || ivalue < VG_TILE_FILL || ivalue > VG_TILE_REFLECT) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ paint->m_patternTilingMode = (VGTilingMode)ivalue;
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ break;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetParameterf(VGHandle object, VGint paramType, VGfloat value)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ bool isImage = context->isValidImage(object);
+ bool isPath = context->isValidPath(object);
+ bool isPaint = context->isValidPaint(object);
+ bool isMaskLayer = context->isValidMaskLayer(object);
+ bool isFont = context->isValidFont(object);
+ RI_IF_ERROR(!isImage && !isPath && !isPaint && !isMaskLayer && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+ RI_IF_ERROR(paramType == VG_PAINT_COLOR || paramType == VG_PAINT_COLOR_RAMP_STOPS || paramType == VG_PAINT_LINEAR_GRADIENT ||
+ paramType == VG_PAINT_RADIAL_GRADIENT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //vector valued parameter
+ VGfloat values[1] = {value};
+ if(isImage)
+ { //read only, the function does nothing
+ RI_ASSERT(!isPath && !isPaint && !isMaskLayer && !isFont);
+ if(paramType < VG_IMAGE_FORMAT || paramType > VG_IMAGE_HEIGHT)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else if(isPath)
+ { //read only, the function does nothing
+ RI_ASSERT(!isImage && !isPaint && !isMaskLayer && !isFont);
+ if(paramType < VG_PATH_FORMAT || paramType > VG_PATH_NUM_COORDS)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else if(isPaint)
+ {
+ RI_ASSERT(!isImage && !isPath && !isMaskLayer && !isFont);
+ setPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, 1, values, true);
+ }
+ else if(isMaskLayer)
+ {
+ RI_ASSERT(!isImage && !isPath && !isPaint && !isFont);
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else
+ { //read only, the function does nothing
+ RI_ASSERT(!isImage && !isPath && !isPaint && !isMaskLayer && isFont);
+ if (paramType != VG_FONT_NUM_GLYPHS)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetParameteri(VGHandle object, VGint paramType, VGint value)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ bool isImage = context->isValidImage(object);
+ bool isPath = context->isValidPath(object);
+ bool isPaint = context->isValidPaint(object);
+ bool isMaskLayer = context->isValidMaskLayer(object);
+ bool isFont = context->isValidFont(object);
+ RI_IF_ERROR(!isImage && !isPath && !isPaint && !isMaskLayer && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+ RI_IF_ERROR(paramType == VG_PAINT_COLOR || paramType == VG_PAINT_COLOR_RAMP_STOPS || paramType == VG_PAINT_LINEAR_GRADIENT ||
+ paramType == VG_PAINT_RADIAL_GRADIENT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //vector valued parameter
+ VGint values[1] = {value};
+ if(isImage)
+ { //read only, the function does nothing
+ RI_ASSERT(!isPath && !isPaint && !isMaskLayer && !isFont);
+ if(paramType < VG_IMAGE_FORMAT || paramType > VG_IMAGE_HEIGHT)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else if(isPath)
+ { //read only, the function does nothing
+ RI_ASSERT(!isImage && !isPaint && !isMaskLayer && !isFont);
+ if(paramType < VG_PATH_FORMAT || paramType > VG_PATH_NUM_COORDS)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else if(isPaint)
+ {
+ RI_ASSERT(!isImage && !isPath && !isMaskLayer && !isFont);
+ setPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, 1, values, false);
+ }
+ else if(isMaskLayer)
+ {
+ RI_ASSERT(!isImage && !isPath && !isPaint && !isFont);
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else
+ { //read only, the function does nothing
+ RI_ASSERT(!isImage && !isPath && !isPaint && !isMaskLayer && isFont);
+ if (paramType != VG_FONT_NUM_GLYPHS)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetParameterfv(VGHandle object, VGint paramType, VGint count, const VGfloat * values)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(count < 0 || (!values && count > 0) || (values && !isAligned(values,4)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ bool isImage = context->isValidImage(object);
+ bool isPath = context->isValidPath(object);
+ bool isPaint = context->isValidPaint(object);
+ bool isMaskLayer = context->isValidMaskLayer(object);
+ bool isFont = context->isValidFont(object);
+ RI_IF_ERROR(!isImage && !isPath && !isPaint && !isMaskLayer && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+ if(isImage)
+ { //read only, the function does nothing
+ RI_ASSERT(!isPath && !isPaint && !isMaskLayer && !isFont);
+ if(paramType < VG_IMAGE_FORMAT || paramType > VG_IMAGE_HEIGHT)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else if(isPath)
+ { //read only, the function does nothing
+ RI_ASSERT(!isImage && !isPaint && !isMaskLayer && !isFont);
+ if(paramType < VG_PATH_FORMAT || paramType > VG_PATH_NUM_COORDS)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else if(isPaint)
+ {
+ RI_ASSERT(!isImage && !isPath && !isMaskLayer && !isFont);
+ setPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, count, values, true);
+ }
+ else if(isMaskLayer)
+ {
+ RI_ASSERT(!isImage && !isPath && !isPaint && !isFont);
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else
+ { //read only, the function does nothing
+ RI_ASSERT(!isImage && !isPath && !isPaint && !isMaskLayer && isFont);
+ if (paramType != VG_FONT_NUM_GLYPHS)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetParameteriv(VGHandle object, VGint paramType, VGint count, const VGint * values)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(count < 0 || (!values && count > 0) || (values && !isAligned(values,4)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ bool isImage = context->isValidImage(object);
+ bool isPath = context->isValidPath(object);
+ bool isPaint = context->isValidPaint(object);
+ bool isMaskLayer = context->isValidMaskLayer(object);
+ bool isFont = context->isValidFont(object);
+ RI_IF_ERROR(!isImage && !isPath && !isPaint && !isMaskLayer && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+ if(isImage)
+ { //read only, the function does nothing
+ RI_ASSERT(!isPath && !isPaint && !isMaskLayer && !isFont);
+ if(paramType < VG_IMAGE_FORMAT || paramType > VG_IMAGE_HEIGHT)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else if(isPath)
+ { //read only, the function does nothing
+ RI_ASSERT(!isImage && !isPaint && !isMaskLayer && !isFont);
+ if(paramType < VG_PATH_FORMAT || paramType > VG_PATH_NUM_COORDS)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else if(isPaint)
+ {
+ RI_ASSERT(!isImage && !isPath && !isMaskLayer && !isFont);
+ setPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, count, values, false);
+ }
+ else if(isMaskLayer)
+ {
+ RI_ASSERT(!isImage && !isPath && !isPaint && !isFont);
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ else
+ { //read only, the function does nothing
+ RI_ASSERT(!isImage && !isPath && !isPaint && !isMaskLayer && isFont);
+ if (paramType != VG_FONT_NUM_GLYPHS)
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static void getPaintParameterifv(VGContext* context, Paint* paint, VGPaintParamType type, VGint count, void* values, bool floats)
+{
+ switch(type)
+ {
+ case VG_PAINT_TYPE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, paint->m_paintType);
+ break;
+
+ case VG_PAINT_COLOR:
+ if(count > 4) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, paint->m_inputPaintColor.r);
+ floatToParam(values, floats, count, 1, paint->m_inputPaintColor.g);
+ floatToParam(values, floats, count, 2, paint->m_inputPaintColor.b);
+ floatToParam(values, floats, count, 3, paint->m_inputPaintColor.a);
+ break;
+
+ case VG_PAINT_COLOR_RAMP_SPREAD_MODE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, paint->m_colorRampSpreadMode);
+ break;
+
+ case VG_PAINT_COLOR_RAMP_STOPS:
+ {
+ if(count > paint->m_inputColorRampStops.size()*5) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ int j = 0;
+ for(int i=0;i<paint->m_inputColorRampStops.size();i++)
+ {
+ floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].offset);
+ floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].color.r);
+ floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].color.g);
+ floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].color.b);
+ floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].color.a);
+ }
+ break;
+ }
+
+ case VG_PAINT_COLOR_RAMP_PREMULTIPLIED:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, paint->m_colorRampPremultiplied);
+ break;
+
+ case VG_PAINT_LINEAR_GRADIENT:
+ if(count > 4) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, paint->m_inputLinearGradientPoint0.x);
+ floatToParam(values, floats, count, 1, paint->m_inputLinearGradientPoint0.y);
+ floatToParam(values, floats, count, 2, paint->m_inputLinearGradientPoint1.x);
+ floatToParam(values, floats, count, 3, paint->m_inputLinearGradientPoint1.y);
+ break;
+
+ case VG_PAINT_RADIAL_GRADIENT:
+ if(count > 5) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, paint->m_inputRadialGradientCenter.x);
+ floatToParam(values, floats, count, 1, paint->m_inputRadialGradientCenter.y);
+ floatToParam(values, floats, count, 2, paint->m_inputRadialGradientFocalPoint.x);
+ floatToParam(values, floats, count, 3, paint->m_inputRadialGradientFocalPoint.y);
+ floatToParam(values, floats, count, 4, paint->m_inputRadialGradientRadius);
+ break;
+
+ case VG_PAINT_PATTERN_TILING_MODE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, paint->m_patternTilingMode);
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ break;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static void getPathParameterifv(VGContext* context, Path* path, VGPathParamType type, VGint count, void* values, bool floats)
+{
+ switch(type)
+ {
+ case VG_PATH_FORMAT:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, path->getFormat());
+ break;
+
+ case VG_PATH_DATATYPE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, path->getDatatype());
+ break;
+
+ case VG_PATH_SCALE:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, path->getScale());
+ break;
+
+ case VG_PATH_BIAS:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ floatToParam(values, floats, count, 0, path->getBias());
+ break;
+
+ case VG_PATH_NUM_SEGMENTS:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, path->getNumSegments());
+ break;
+
+ case VG_PATH_NUM_COORDS:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, path->getNumCoordinates());
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ break;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static void getImageParameterifv(VGContext* context, Image* image, VGImageParamType type, VGint count, void* values, bool floats)
+{
+ switch(type)
+ {
+ case VG_IMAGE_FORMAT:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ RI_ASSERT(isValidImageFormat(image->getDescriptor().format));
+ intToParam(values, floats, count, 0, image->getDescriptor().format);
+ break;
+
+ case VG_IMAGE_WIDTH:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, image->getWidth());
+ break;
+
+ case VG_IMAGE_HEIGHT:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, image->getHeight());
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ break;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static void getFontParameterifv(VGContext* context, Font* font, VGFontParamType type, VGint count, void* values, bool floats)
+{
+ switch(type)
+ {
+ case VG_FONT_NUM_GLYPHS:
+ if(count > 1) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+ intToParam(values, floats, count, 0, font->getNumGlyphs());
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid VGParamType
+ break;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGfloat RI_APIENTRY vgGetParameterf(VGHandle object, VGint paramType)
+{
+ RI_GET_CONTEXT(0.0f);
+ RI_IF_ERROR(paramType == VG_PAINT_COLOR || paramType == VG_PAINT_COLOR_RAMP_STOPS || paramType == VG_PAINT_LINEAR_GRADIENT ||
+ paramType == VG_PAINT_RADIAL_GRADIENT, VG_ILLEGAL_ARGUMENT_ERROR, 0.0f); //vector valued parameter
+ bool isImage = context->isValidImage(object);
+ bool isPath = context->isValidPath(object);
+ bool isPaint = context->isValidPaint(object);
+ bool isFont = context->isValidFont(object);
+ RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, 0.0f); //invalid object handle
+ VGfloat ret = 0.0f;
+ if(isImage)
+ {
+ RI_ASSERT(!isPath && !isPaint && !isFont);
+ getImageParameterifv(context, (Image*)object, (VGImageParamType)paramType, 1, &ret, true);
+ }
+ else if(isPath)
+ {
+ RI_ASSERT(!isImage && !isPaint && !isFont);
+ getPathParameterifv(context, (Path*)object, (VGPathParamType)paramType, 1, &ret, true);
+ }
+ else if(isPaint)
+ {
+ RI_ASSERT(!isImage && !isPath && !isFont);
+ getPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, 1, &ret, true);
+ }
+ else
+ {
+ RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+ getFontParameterifv(context, (Font*)object, (VGFontParamType)paramType, 1, &ret, true);
+ }
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGint RI_APIENTRY vgGetParameteri(VGHandle object, VGint paramType)
+{
+ RI_GET_CONTEXT(0);
+ RI_IF_ERROR(paramType == VG_PAINT_COLOR || paramType == VG_PAINT_COLOR_RAMP_STOPS || paramType == VG_PAINT_LINEAR_GRADIENT ||
+ paramType == VG_PAINT_RADIAL_GRADIENT, VG_ILLEGAL_ARGUMENT_ERROR, 0); //vector valued parameter
+ bool isImage = context->isValidImage(object);
+ bool isPath = context->isValidPath(object);
+ bool isPaint = context->isValidPaint(object);
+ bool isFont = context->isValidFont(object);
+ RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, 0); //invalid object handle
+ VGint ret = 0;
+ if(isImage)
+ {
+ RI_ASSERT(!isPath && !isPaint && !isFont);
+ getImageParameterifv(context, (Image*)object, (VGImageParamType)paramType, 1, &ret, false);
+ }
+ else if(isPath)
+ {
+ RI_ASSERT(!isImage && !isPaint && !isFont);
+ getPathParameterifv(context, (Path*)object, (VGPathParamType)paramType, 1, &ret, false);
+ }
+ else if(isPaint)
+ {
+ RI_ASSERT(!isImage && !isPath && !isFont);
+ getPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, 1, &ret, false);
+ }
+ else
+ {
+ RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+ getFontParameterifv(context, (Font*)object, (VGFontParamType)paramType, 1, &ret, false);
+ }
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgGetParameterfv(VGHandle object, VGint paramType, VGint count, VGfloat * values)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(count <= 0 || !values || !isAligned(values,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ bool isImage = context->isValidImage(object);
+ bool isPath = context->isValidPath(object);
+ bool isPaint = context->isValidPaint(object);
+ bool isFont = context->isValidFont(object);
+ RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+ if(isImage)
+ {
+ RI_ASSERT(!isPath && !isPaint && !isFont);
+ getImageParameterifv(context, (Image*)object, (VGImageParamType)paramType, count, values, true);
+ }
+ else if(isPath)
+ {
+ RI_ASSERT(!isImage && !isPaint && !isFont);
+ getPathParameterifv(context, (Path*)object, (VGPathParamType)paramType, count, values, true);
+ }
+ else if(isPaint)
+ {
+ RI_ASSERT(!isImage && !isPath && !isFont);
+ getPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, count, values, true);
+ }
+ else
+ {
+ RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+ getFontParameterifv(context, (Font*)object, (VGFontParamType)paramType, count, values, true);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgGetParameteriv(VGHandle object, VGint paramType, VGint count, VGint * values)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(count <= 0 || !values || !isAligned(values,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ bool isImage = context->isValidImage(object);
+ bool isPath = context->isValidPath(object);
+ bool isPaint = context->isValidPaint(object);
+ bool isFont = context->isValidFont(object);
+ RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+ if(isImage)
+ {
+ RI_ASSERT(!isPath && !isPaint && !isFont);
+ getImageParameterifv(context, (Image*)object, (VGImageParamType)paramType, count, values, false);
+ }
+ else if(isPath)
+ {
+ RI_ASSERT(!isImage && !isPaint && !isFont);
+ getPathParameterifv(context, (Path*)object, (VGPathParamType)paramType, count, values, false);
+ }
+ else if(isPaint)
+ {
+ RI_ASSERT(!isImage && !isPath && !isFont);
+ getPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, count, values, false);
+ }
+ else
+ {
+ RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+ getFontParameterifv(context, (Font*)object, (VGFontParamType)paramType, count, values, false);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGint RI_APIENTRY vgGetParameterVectorSize(VGHandle object, VGint paramType)
+{
+ RI_GET_CONTEXT(0);
+ bool isImage = context->isValidImage(object);
+ bool isPath = context->isValidPath(object);
+ bool isPaint = context->isValidPaint(object);
+ bool isFont = context->isValidFont(object);
+ RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, 0); //invalid object handle
+ int ret = 0;
+ if(isImage)
+ {
+ RI_ASSERT(!isPath && !isPaint && !isFont);
+ switch(paramType)
+ {
+ case VG_IMAGE_FORMAT:
+ case VG_IMAGE_WIDTH:
+ case VG_IMAGE_HEIGHT:
+ ret = 1;
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid paramType
+ break;
+ }
+ }
+ else if(isPath)
+ {
+ RI_ASSERT(!isImage && !isPaint && !isFont);
+ switch(paramType)
+ {
+ case VG_PATH_FORMAT:
+ case VG_PATH_DATATYPE:
+ case VG_PATH_SCALE:
+ case VG_PATH_BIAS:
+ case VG_PATH_NUM_SEGMENTS:
+ case VG_PATH_NUM_COORDS:
+ ret = 1;
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid paramType
+ break;
+ }
+ }
+ else if(isPaint)
+ {
+ RI_ASSERT(!isImage && !isPath && !isFont);
+ switch(paramType)
+ {
+ case VG_PAINT_TYPE:
+ case VG_PAINT_COLOR_RAMP_SPREAD_MODE:
+ case VG_PAINT_PATTERN_TILING_MODE:
+ ret = 1;
+ break;
+
+ case VG_PAINT_COLOR:
+ case VG_PAINT_LINEAR_GRADIENT:
+ ret = 4;
+ break;
+
+ case VG_PAINT_COLOR_RAMP_STOPS:
+ ret = ((Paint*)object)->m_inputColorRampStops.size() * 5;
+ break;
+
+ case VG_PAINT_COLOR_RAMP_PREMULTIPLIED:
+ ret = 1;
+ break;
+
+ case VG_PAINT_RADIAL_GRADIENT:
+ ret = 5;
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid paramType
+ break;
+ }
+ }
+ else
+ {
+ RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+ switch(paramType)
+ {
+ case VG_FONT_NUM_GLYPHS:
+ ret = 1;
+ break;
+
+ default:
+ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); //invalid paramType
+ break;
+ }
+ }
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static Matrix3x3* getCurrentMatrix(VGContext* context)
+{
+ RI_ASSERT(context);
+ switch(context->m_matrixMode)
+ {
+ case VG_MATRIX_PATH_USER_TO_SURFACE:
+ return &context->m_pathUserToSurface;
+
+ case VG_MATRIX_IMAGE_USER_TO_SURFACE:
+ return &context->m_imageUserToSurface;
+
+ case VG_MATRIX_FILL_PAINT_TO_USER:
+ return &context->m_fillPaintToUser;
+
+ case VG_MATRIX_STROKE_PAINT_TO_USER:
+ return &context->m_strokePaintToUser;
+
+ default:
+ RI_ASSERT(context->m_matrixMode == VG_MATRIX_GLYPH_USER_TO_SURFACE);
+ return &context->m_glyphUserToSurface;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgLoadIdentity(void)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ Matrix3x3* d = getCurrentMatrix(context);
+ d->identity();
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgLoadMatrix(const VGfloat * m)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!m || !isAligned(m,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Matrix3x3* d = getCurrentMatrix(context);
+ d->set(inputFloat(m[0]), inputFloat(m[3]), inputFloat(m[6]),
+ inputFloat(m[1]), inputFloat(m[4]), inputFloat(m[7]),
+ inputFloat(m[2]), inputFloat(m[5]), inputFloat(m[8]));
+ if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+ {
+ (*d)[2].set(0,0,1);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgGetMatrix(VGfloat * m)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!m || !isAligned(m,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Matrix3x3* d = getCurrentMatrix(context);
+ m[0] = (*d)[0][0];
+ m[1] = (*d)[1][0];
+ m[2] = (*d)[2][0];
+ m[3] = (*d)[0][1];
+ m[4] = (*d)[1][1];
+ m[5] = (*d)[2][1];
+ m[6] = (*d)[0][2];
+ m[7] = (*d)[1][2];
+ m[8] = (*d)[2][2];
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgMultMatrix(const VGfloat * m)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!m || !isAligned(m,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Matrix3x3 n(inputFloat(m[0]), inputFloat(m[3]), inputFloat(m[6]),
+ inputFloat(m[1]), inputFloat(m[4]), inputFloat(m[7]),
+ inputFloat(m[2]), inputFloat(m[5]), inputFloat(m[8]));
+ if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+ n[2].set(0,0,1);
+
+ Matrix3x3* d = getCurrentMatrix(context);
+ *d *= n;
+ if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+ {
+ (*d)[2].set(0,0,1); //force affinity
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgTranslate(VGfloat tx, VGfloat ty)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ Matrix3x3 n(1, 0, inputFloat(tx),
+ 0, 1, inputFloat(ty),
+ 0, 0, 1 );
+ Matrix3x3* d = getCurrentMatrix(context);
+ *d *= n;
+ if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+ {
+ (*d)[2].set(0,0,1); //force affinity
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgScale(VGfloat sx, VGfloat sy)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ Matrix3x3 n(inputFloat(sx), 0, 0,
+ 0, inputFloat(sy), 0,
+ 0, 0, 1 );
+ Matrix3x3* d = getCurrentMatrix(context);
+ *d *= n;
+ if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+ {
+ (*d)[2].set(0,0,1); //force affinity
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgShear(VGfloat shx, VGfloat shy)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ Matrix3x3 n(1, inputFloat(shx), 0,
+ inputFloat(shy), 1, 0,
+ 0, 0, 1);
+ Matrix3x3* d = getCurrentMatrix(context);
+ *d *= n;
+ if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+ {
+ (*d)[2].set(0,0,1); //force affinity
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgRotate(VGfloat angle)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RIfloat a = RI_DEG_TO_RAD(inputFloat(angle));
+ Matrix3x3 n((RIfloat)cos(a), -(RIfloat)sin(a), 0,
+ (RIfloat)sin(a), (RIfloat)cos(a), 0,
+ 0, 0, 1 );
+ Matrix3x3* d = getCurrentMatrix(context);
+ *d *= n;
+ if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+ {
+ (*d)[2].set(0,0,1); //force affinity
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgMask(VGHandle mask, VGMaskOperation operation, VGint x, VGint y, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ bool isImage = context->isValidImage(mask);
+ bool isMaskLayer = context->isValidMaskLayer(mask);
+ RI_IF_ERROR(operation != VG_CLEAR_MASK && operation != VG_FILL_MASK && !isImage && !isMaskLayer, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(operation != VG_CLEAR_MASK && operation != VG_FILL_MASK && isImage && eglvgIsInUse((Image*)mask), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(operation < VG_CLEAR_MASK || operation > VG_SUBTRACT_MASK, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Drawable* drawable = context->getCurrentDrawable();
+ RI_IF_ERROR(isMaskLayer && drawable->getNumSamples() != ((Surface*)mask)->getNumSamples(), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ if(!drawable || !drawable->getMaskBuffer())
+ {
+ RI_RETURN(RI_NO_RETVAL); //no EGL surface is current at the moment or context has no mask buffer
+ }
+ if(isImage)
+ drawable->getMaskBuffer()->mask((Image*)mask, operation, x, y, width, height);
+ else
+ drawable->getMaskBuffer()->mask((Surface*)mask, operation, x, y, width, height);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static void renderStroke(const VGContext* context, int w, int h, int numSamples, Path* path, Rasterizer& rasterizer, const PixelPipe* pixelPipe, const Matrix3x3& userToSurface)
+{
+ RI_ASSERT(context);
+ RI_ASSERT(w > 0 && h > 0 && numSamples >= 1 && numSamples <= 32);
+
+ RIuint32* covBuffer = RI_NEW_ARRAY(RIuint32, w*h);
+ memset(covBuffer, 0, w*h*sizeof(RIuint32));
+
+ rasterizer.setup(0, 0, w, h, VG_NON_ZERO, NULL, covBuffer);
+ path->stroke(userToSurface, rasterizer, context->m_strokeDashPattern, context->m_strokeDashPhase, context->m_strokeDashPhaseReset ? true : false,
+ context->m_strokeLineWidth, context->m_strokeCapStyle, context->m_strokeJoinStyle, RI_MAX(context->m_strokeMiterLimit, 1.0f)); //throws bad_alloc
+
+ int sx,sy,ex,ey;
+ rasterizer.getBBox(sx,sy,ex,ey);
+ RI_ASSERT(sx >= 0 && sx <= w);
+ RI_ASSERT(sy >= 0 && sy <= h);
+ RI_ASSERT(ex >= 0 && ex <= w);
+ RI_ASSERT(ey >= 0 && ey <= h);
+
+ for(int j=sy;j<ey;j++)
+ {
+ for(int i=sx;i<ex;i++)
+ {
+ unsigned int c = covBuffer[j*w+i];
+ if(c)
+ {
+ int coverage = 0;
+ for(int k=0;k<numSamples;k++)
+ {
+ if(c & (1<<k))
+ coverage++;
+ }
+ pixelPipe->pixelPipe(i, j, (RIfloat)coverage/(RIfloat)numSamples, c);
+ }
+ }
+ }
+ RI_DELETE_ARRAY(covBuffer);
+}
+
+void RI_APIENTRY vgRenderToMask(VGPath path, VGbitfield paintModes, VGMaskOperation operation)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ RI_IF_ERROR(!paintModes || (paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //invalid paint mode
+ RI_IF_ERROR(operation < VG_CLEAR_MASK || operation > VG_SUBTRACT_MASK, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Drawable* curr = context->getCurrentDrawable();
+ if(!curr || !curr->getMaskBuffer())
+ {
+ RI_RETURN(RI_NO_RETVAL); //no EGL surface is current at the moment or context has no mask buffer
+ }
+
+ if(operation == VG_CLEAR_MASK || operation == VG_FILL_MASK)
+ {
+ Surface* dummy = NULL;
+ curr->getMaskBuffer()->mask(dummy, operation, 0, 0, curr->getWidth(), curr->getHeight());
+ RI_RETURN(RI_NO_RETVAL);
+ }
+
+ try
+ {
+ Drawable drawable(Color::formatToDescriptor(VG_A_8), curr->getWidth(), curr->getHeight(), curr->getNumSamples(), 1); //TODO 0 mask bits (mask buffer is not used)
+
+ Rasterizer rasterizer;
+ if(context->m_scissoring)
+ rasterizer.setScissor(context->m_scissor); //throws bad_alloc
+ int numSamples = rasterizer.setupSamplingPattern(context->m_renderingQuality, drawable.getNumSamples());
+
+ PixelPipe pixelPipe;
+ pixelPipe.setDrawable(&drawable);
+ pixelPipe.setMask(false);
+ pixelPipe.setPaint(NULL); //use default paint (solid color alpha = 1)
+ pixelPipe.setBlendMode(VG_BLEND_SRC); //write solid color * coverage to dest
+
+ Matrix3x3 userToSurface = context->m_pathUserToSurface;
+ userToSurface[2].set(0,0,1); //force affinity
+
+ if(paintModes & VG_FILL_PATH)
+ {
+ drawable.getColorBuffer()->clear(Color(0,0,0,0,drawable.getColorBuffer()->getDescriptor().internalFormat), 0, 0, drawable.getWidth(), drawable.getHeight());
+ ((Path*)path)->fill(userToSurface, rasterizer); //throws bad_alloc
+ rasterizer.setup(0, 0, drawable.getWidth(), drawable.getHeight(), context->m_fillRule, &pixelPipe, NULL);
+ rasterizer.fill(); //throws bad_alloc
+ curr->getMaskBuffer()->mask(drawable.getColorBuffer(), operation, 0, 0, drawable.getWidth(), drawable.getHeight());
+ }
+
+ if(paintModes & VG_STROKE_PATH && context->m_strokeLineWidth > 0.0f)
+ {
+ drawable.getColorBuffer()->clear(Color(0,0,0,0,drawable.getColorBuffer()->getDescriptor().internalFormat), 0, 0, drawable.getWidth(), drawable.getHeight());
+ renderStroke(context, drawable.getWidth(), drawable.getHeight(), numSamples, (Path*)path, rasterizer, &pixelPipe, userToSurface);
+ curr->getMaskBuffer()->mask(drawable.getColorBuffer(), operation, 0, 0, drawable.getWidth(), drawable.getHeight());
+ }
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGMaskLayer RI_APIENTRY vgCreateMaskLayer(VGint width, VGint height)
+{
+ RI_GET_CONTEXT(VG_INVALID_HANDLE);
+ RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+ RI_IF_ERROR(width > RI_MAX_IMAGE_WIDTH || height > RI_MAX_IMAGE_HEIGHT || width*height > RI_MAX_IMAGE_PIXELS ||
+ width*height > RI_MAX_IMAGE_BYTES, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+ Drawable* curr = context->getCurrentDrawable();
+ if(!curr || !curr->getMaskBuffer())
+ RI_RETURN(VG_INVALID_HANDLE); //no current drawing surface
+
+ Surface* layer = NULL;
+ try
+ {
+ layer = RI_NEW(Surface, (Color::formatToDescriptor(VG_A_8), width, height, curr->getNumSamples())); //throws bad_alloc
+ RI_ASSERT(layer);
+ context->m_maskLayerManager->addResource(layer, context); //throws bad_alloc
+ layer->clear(Color(1,1,1,1,Color::sRGBA), 0, 0, width, height);
+ RI_RETURN((VGMaskLayer)layer);
+ }
+ catch(std::bad_alloc)
+ {
+ RI_DELETE(layer);
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ RI_RETURN(VG_INVALID_HANDLE);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgDestroyMaskLayer(VGMaskLayer maskLayer)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidMaskLayer(maskLayer), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid handle
+
+ context->m_maskLayerManager->removeResource((Surface*)maskLayer);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgFillMaskLayer(VGMaskLayer maskLayer, VGint x, VGint y, VGint width, VGint height, VGfloat value)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidMaskLayer(maskLayer), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid handle
+ RI_IF_ERROR(value < 0.0f || value > 1.0f, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Surface* layer = (Surface*)maskLayer;
+ RI_IF_ERROR(width <= 0 || height <= 0 || x < 0 || y < 0 || x > layer->getWidth()-width || y > layer->getHeight()-height, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ layer->clear(Color(1,1,1,value,Color::sRGBA), x, y, width, height);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgCopyMask(VGMaskLayer maskLayer, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidMaskLayer(maskLayer), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid handle
+ Drawable* drawable = context->getCurrentDrawable();
+ if(!drawable || !drawable->getMaskBuffer())
+ {
+ RI_RETURN(RI_NO_RETVAL); //no EGL surface is current at the moment or context has no mask buffer
+ }
+ Surface* layer = (Surface*)maskLayer;
+ RI_IF_ERROR(width <= 0 || height <= 0 || drawable->getNumSamples() != layer->getNumSamples(), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ try
+ { //copy drawing surface mask to mask layer
+ layer->blit(drawable->getMaskBuffer(), sx, sy, dx, dy, width, height); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgClear(VGint x, VGint y, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Drawable* drawable = context->getCurrentDrawable();
+ if(!drawable)
+ {
+ RI_RETURN(RI_NO_RETVAL); //no EGL surface is current at the moment
+ }
+
+ try
+ {
+ if(context->m_scissoring)
+ drawable->getColorBuffer()->clear(context->m_clearColor, x, y, width, height, context->m_scissor); //throws bad_alloc
+ else
+ drawable->getColorBuffer()->clear(context->m_clearColor, x, y, width, height);
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGPath RI_APIENTRY vgCreatePath(VGint pathFormat, VGPathDatatype datatype, VGfloat scale, VGfloat bias, VGint segmentCapacityHint, VGint coordCapacityHint, VGbitfield capabilities)
+{
+ RI_GET_CONTEXT(VG_INVALID_HANDLE);
+ RI_IF_ERROR(pathFormat != VG_PATH_FORMAT_STANDARD, VG_UNSUPPORTED_PATH_FORMAT_ERROR, VG_INVALID_HANDLE);
+ RI_IF_ERROR(datatype < VG_PATH_DATATYPE_S_8 || datatype > VG_PATH_DATATYPE_F, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+ RIfloat s = inputFloat(scale);
+ RIfloat b = inputFloat(bias);
+ RI_IF_ERROR(s == 0.0f, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+ capabilities &= VG_PATH_CAPABILITY_ALL; //undefined bits are ignored
+
+ Path* path = NULL;
+ try
+ {
+ path = RI_NEW(Path, (pathFormat, datatype, s, b, segmentCapacityHint, coordCapacityHint, capabilities)); //throws bad_alloc
+ RI_ASSERT(path);
+ context->m_pathManager->addResource(path, context); //throws bad_alloc
+ RI_RETURN((VGPath)path);
+ }
+ catch(std::bad_alloc)
+ {
+ RI_DELETE(path);
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ RI_RETURN(VG_INVALID_HANDLE);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgClearPath(VGPath path, VGbitfield capabilities)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ capabilities &= VG_PATH_CAPABILITY_ALL; //undefined bits are ignored
+ ((Path*)path)->clear(capabilities);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgDestroyPath(VGPath path)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+
+ context->m_pathManager->removeResource((Path*)path);
+
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgRemovePathCapabilities(VGPath path, VGbitfield capabilities)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ capabilities &= VG_PATH_CAPABILITY_ALL; //undefined bits are ignored
+
+ VGbitfield caps = ((Path*)path)->getCapabilities();
+ caps &= ~capabilities;
+ ((Path*)path)->setCapabilities(caps);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGbitfield RI_APIENTRY vgGetPathCapabilities(VGPath path)
+{
+ RI_GET_CONTEXT(0);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, 0); //invalid path handle
+ VGbitfield ret = ((Path*)path)->getCapabilities();
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgAppendPathData(VGPath dstPath, VGint numSegments, const VGubyte * pathSegments, const void * pathData)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(dstPath), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ Path* p = (Path*)dstPath;
+ RI_IF_ERROR(!(p->getCapabilities() & VG_PATH_CAPABILITY_APPEND_TO), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL); //no append cap
+ RI_IF_ERROR(numSegments <= 0 || !pathSegments || !pathData, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //no segments or data
+ RI_IF_ERROR((p->getDatatype() == VG_PATH_DATATYPE_S_16 && !isAligned(pathData,2)) ||
+ ((p->getDatatype() == VG_PATH_DATATYPE_S_32 || p->getDatatype() == VG_PATH_DATATYPE_F) && !isAligned(pathData,4)),
+ VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //invalid alignment
+ for(int i=0;i<numSegments;i++)
+ {
+ VGPathSegment c = (VGPathSegment)(pathSegments[i] & 0x1e);
+ RI_IF_ERROR(c < VG_CLOSE_PATH || c > VG_LCWARC_TO, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //invalid segment
+ RI_IF_ERROR(c & ~0x1f, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //reserved bits are nonzero
+ }
+
+ try
+ {
+ p->appendData((const RIuint8*)pathSegments, numSegments, (const RIuint8*)pathData); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgModifyPathCoords(VGPath dstPath, VGint startIndex, VGint numSegments, const void * pathData)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(dstPath), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ Path* p = (Path*)dstPath;
+ RI_IF_ERROR(!(p->getCapabilities() & VG_PATH_CAPABILITY_MODIFY), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL); //no modify cap
+ RI_IF_ERROR(!pathData || startIndex < 0 || numSegments <= 0 || RI_INT_ADDSATURATE(startIndex, numSegments) > p->getNumSegments(), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //no segments
+ RI_IF_ERROR((p->getDatatype() == VG_PATH_DATATYPE_S_16 && !isAligned(pathData,2)) ||
+ ((p->getDatatype() == VG_PATH_DATATYPE_S_32 || p->getDatatype() == VG_PATH_DATATYPE_F) && !isAligned(pathData,4)),
+ VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //invalid alignment
+ p->modifyCoords(startIndex, numSegments, (const RIuint8*)pathData);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgAppendPath(VGPath dstPath, VGPath srcPath)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(dstPath) || !context->isValidPath(srcPath), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ RI_IF_ERROR(!(((Path*)dstPath)->getCapabilities() & VG_PATH_CAPABILITY_APPEND_TO) ||
+ !(((Path*)srcPath)->getCapabilities() & VG_PATH_CAPABILITY_APPEND_FROM), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL); //invalid caps
+
+ try
+ {
+ ((Path*)dstPath)->append((Path*)srcPath); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgTransformPath(VGPath dstPath, VGPath srcPath)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(dstPath) || !context->isValidPath(srcPath), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ RI_IF_ERROR(!(((Path*)dstPath)->getCapabilities() & VG_PATH_CAPABILITY_TRANSFORM_TO) ||
+ !(((Path*)srcPath)->getCapabilities() & VG_PATH_CAPABILITY_TRANSFORM_FROM), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL); //invalid caps
+ try
+ {
+ ((Path*)dstPath)->transform((Path*)srcPath, context->m_pathUserToSurface); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static bool drawPath(VGContext* context, VGPath path, const Matrix3x3& userToSurfaceMatrix, VGbitfield paintModes)
+{
+ //set up rendering surface and mask buffer
+ Drawable* drawable = context->getCurrentDrawable();
+ if(!drawable)
+ return false; //no EGL surface is current at the moment
+
+ Rasterizer rasterizer;
+ if(context->m_scissoring)
+ rasterizer.setScissor(context->m_scissor); //throws bad_alloc
+ int numSamples = rasterizer.setupSamplingPattern(context->m_renderingQuality, drawable->getNumSamples());
+
+ PixelPipe pixelPipe;
+ pixelPipe.setDrawable(drawable);
+ pixelPipe.setMask(context->m_masking ? true : false);
+ pixelPipe.setBlendMode(context->m_blendMode);
+ pixelPipe.setTileFillColor(context->m_tileFillColor);
+ pixelPipe.setImageQuality(context->m_imageQuality);
+ pixelPipe.setColorTransform(context->m_colorTransform ? true : false, context->m_colorTransformValues);
+
+ Matrix3x3 userToSurface = userToSurfaceMatrix;
+ userToSurface[2].set(0,0,1); //force affinity
+
+ if(paintModes & VG_FILL_PATH)
+ {
+ pixelPipe.setPaint((Paint*)context->m_fillPaint);
+
+ Matrix3x3 surfaceToPaintMatrix = userToSurface * context->m_fillPaintToUser;
+ if(surfaceToPaintMatrix.invert())
+ {
+ surfaceToPaintMatrix[2].set(0,0,1); //force affinity
+ pixelPipe.setSurfaceToPaintMatrix(surfaceToPaintMatrix);
+
+ rasterizer.setup(0, 0, drawable->getWidth(), drawable->getHeight(), context->m_fillRule, &pixelPipe, NULL);
+ ((Path*)path)->fill(userToSurface, rasterizer); //throws bad_alloc
+ rasterizer.fill(); //throws bad_alloc
+ }
+ }
+
+ if(paintModes & VG_STROKE_PATH && context->m_strokeLineWidth > 0.0f)
+ {
+ pixelPipe.setPaint((Paint*)context->m_strokePaint);
+
+ Matrix3x3 surfaceToPaintMatrix = userToSurface * context->m_strokePaintToUser;
+ if(surfaceToPaintMatrix.invert())
+ {
+ surfaceToPaintMatrix[2].set(0,0,1); //force affinity
+ pixelPipe.setSurfaceToPaintMatrix(surfaceToPaintMatrix);
+
+ renderStroke(context, drawable->getWidth(), drawable->getHeight(), numSamples, (Path*)path, rasterizer, &pixelPipe, userToSurface);
+ }
+ }
+ return true;
+}
+
+void RI_APIENTRY vgDrawPath(VGPath path, VGbitfield paintModes)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ RI_IF_ERROR(!paintModes || (paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //invalid paint mode
+
+ try
+ {
+ if(!drawPath(context, path, context->m_pathUserToSurface, paintModes))
+ {
+ RI_RETURN(RI_NO_RETVAL);
+ }
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGfloat RI_APIENTRY vgPathLength(VGPath path, VGint startSegment, VGint numSegments)
+{
+ RI_GET_CONTEXT(-1.0f);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, -1.0f); //invalid path handle
+ Path* p = (Path*)path;
+ RI_IF_ERROR(!(p->getCapabilities() & VG_PATH_CAPABILITY_PATH_LENGTH), VG_PATH_CAPABILITY_ERROR, -1.0f); //invalid caps
+ RI_IF_ERROR(startSegment < 0 || numSegments <= 0 || RI_INT_ADDSATURATE(startSegment, numSegments) > p->getNumSegments(), VG_ILLEGAL_ARGUMENT_ERROR, -1.0f);
+ RIfloat pathLength = -1.0f;
+ try
+ {
+ pathLength = p->getPathLength(startSegment, numSegments); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(pathLength);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgPointAlongPath(VGPath path, VGint startSegment, VGint numSegments, VGfloat distance, VGfloat * x, VGfloat * y, VGfloat * tangentX, VGfloat * tangentY)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ Path* p = (Path*)path;
+ RI_IF_ERROR((x && y && !(p->getCapabilities() & VG_PATH_CAPABILITY_POINT_ALONG_PATH)) ||
+ (tangentX && tangentY && !(p->getCapabilities() & VG_PATH_CAPABILITY_TANGENT_ALONG_PATH)), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL); //invalid caps
+ RI_IF_ERROR(startSegment < 0 || numSegments <= 0 || RI_INT_ADDSATURATE(startSegment, numSegments) > p->getNumSegments(), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!isAligned(x,4) || !isAligned(y,4) || !isAligned(tangentX,4) || !isAligned(tangentY,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ try
+ {
+ Vector2 point, tangent;
+ p->getPointAlong(startSegment, numSegments, distance, point, tangent); //throws bad_alloc
+ if(x && y)
+ {
+ *x = point.x;
+ *y = point.y;
+ }
+ if(tangentX && tangentY)
+ {
+ tangent.normalize();
+ *tangentX = tangent.x;
+ *tangentY = tangent.y;
+ }
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgPathBounds(VGPath path, VGfloat * minx, VGfloat * miny, VGfloat * width, VGfloat * height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ RI_IF_ERROR(!(((Path*)path)->getCapabilities() & VG_PATH_CAPABILITY_PATH_BOUNDS), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL); //invalid caps
+ RI_IF_ERROR(!minx || !miny || !width || !height, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!isAligned(minx,4) || !isAligned(miny,4) || !isAligned(width,4) || !isAligned(height,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ try
+ {
+ RIfloat pminx,pminy,pmaxx,pmaxy;
+ ((Path*)path)->getPathBounds(pminx, pminy, pmaxx, pmaxy); //throws bad_alloc
+ *minx = pminx;
+ *miny = pminy;
+ *width = pmaxx - pminx;
+ *height = pmaxy - pminy;
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgPathTransformedBounds(VGPath path, VGfloat * minx, VGfloat * miny, VGfloat * width, VGfloat * height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ RI_IF_ERROR(!(((Path*)path)->getCapabilities() & VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL); //invalid caps
+ RI_IF_ERROR(!minx || !miny || !width || !height, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!isAligned(minx,4) || !isAligned(miny,4) || !isAligned(width,4) || !isAligned(height,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ try
+ {
+ RIfloat pminx, pminy, pmaxx, pmaxy;
+ ((Path*)path)->getPathTransformedBounds(context->m_pathUserToSurface, pminx, pminy, pmaxx, pmaxy); //throws bad_alloc
+ *minx = pminx;
+ *miny = pminy;
+ *width = pmaxx - pminx;
+ *height = pmaxy - pminy;
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGboolean RI_APIENTRY vgInterpolatePath(VGPath dstPath, VGPath startPath, VGPath endPath, VGfloat amount)
+{
+ RI_GET_CONTEXT(VG_FALSE);
+ RI_IF_ERROR(!context->isValidPath(dstPath) || !context->isValidPath(startPath) || !context->isValidPath(endPath), VG_BAD_HANDLE_ERROR, VG_FALSE); //invalid path handle
+ RI_IF_ERROR(!(((Path*)dstPath)->getCapabilities() & VG_PATH_CAPABILITY_INTERPOLATE_TO) ||
+ !(((Path*)startPath)->getCapabilities() & VG_PATH_CAPABILITY_INTERPOLATE_FROM) ||
+ !(((Path*)endPath)->getCapabilities() & VG_PATH_CAPABILITY_INTERPOLATE_FROM), VG_PATH_CAPABILITY_ERROR, VG_FALSE); //invalid caps
+ VGboolean ret = VG_FALSE;
+ try
+ {
+ if(((Path*)dstPath)->interpolate((const Path*)startPath, (const Path*)endPath, inputFloat(amount))) //throws bad_alloc
+ ret = VG_TRUE;
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGPaint RI_APIENTRY vgCreatePaint(void)
+{
+// RI_GET_CONTEXT(VG_INVALID_HANDLE);
+ OSAcquireMutex();
+ VGContext* context = (VGContext*)eglvgGetCurrentVGContext();
+ if(!context)
+ {
+ OSReleaseMutex();
+ return VG_INVALID_HANDLE;
+ }
+ Paint* paint = NULL;
+ try
+ {
+ paint = RI_NEW(Paint, ()); //throws bad_alloc
+ RI_ASSERT(paint);
+ context->m_paintManager->addResource(paint, context); //throws bad_alloc
+ RI_RETURN((VGPaint)paint);
+ }
+ catch(std::bad_alloc)
+ {
+ RI_DELETE(paint);
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ RI_RETURN(VG_INVALID_HANDLE);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgDestroyPaint(VGPaint paint)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid paint handle
+
+ context->m_paintManager->removeResource((Paint*)paint);
+
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetPaint(VGPaint paint, VGbitfield paintModes)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(paint && !context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid paint handle
+ RI_IF_ERROR(!paintModes || paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //invalid paint mode
+
+ context->releasePaint(paintModes);
+
+ if(paintModes & VG_FILL_PATH)
+ {
+ if(paint)
+ ((Paint*)paint)->addReference();
+ context->m_fillPaint = paint;
+ }
+ if(paintModes & VG_STROKE_PATH)
+ {
+ if(paint)
+ ((Paint*)paint)->addReference();
+ context->m_strokePaint = paint;
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetColor(VGPaint paint, VGuint rgba)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid paint handle
+ Paint* p = (Paint*)paint;
+ p->m_inputPaintColor.unpack(rgba, Color::formatToDescriptor(VG_sRGBA_8888));
+ p->m_paintColor = inputColor(p->m_inputPaintColor);
+ p->m_paintColor.clamp();
+ p->m_paintColor.premultiply();
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGuint RI_APIENTRY vgGetColor(VGPaint paint)
+{
+ RI_GET_CONTEXT(0);
+ RI_IF_ERROR(!context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, 0); //invalid paint handle
+ unsigned int ret = ((Paint*)paint)->m_inputPaintColor.pack(Color::formatToDescriptor(VG_sRGBA_8888));
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGPaint RI_APIENTRY vgGetPaint(VGPaintMode paintMode)
+{
+ RI_GET_CONTEXT(VG_INVALID_HANDLE);
+ RI_IF_ERROR(paintMode != VG_FILL_PATH && paintMode != VG_STROKE_PATH, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE); //invalid paint mode
+
+ if(paintMode == VG_FILL_PATH)
+ {
+ RI_RETURN(context->m_fillPaint);
+ }
+ RI_RETURN(context->m_strokePaint);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgPaintPattern(VGPaint paint, VGImage image)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPaint(paint) || (image != VG_INVALID_HANDLE && !context->isValidImage(image)), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid handle
+ Image* img = (Image*)image;
+ Paint* pnt = (Paint*)paint;
+ RI_IF_ERROR(image != VG_INVALID_HANDLE && eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ Image* pattern = pnt->m_pattern;
+ if(pattern)
+ {
+ pattern->removeInUse();
+ if(!pattern->removeReference())
+ RI_DELETE(pattern);
+ }
+ pnt->m_pattern = img;
+ if(img)
+ {
+ img->addReference();
+ img->addInUse();
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGImage RI_APIENTRY vgCreateImage(VGImageFormat format, VGint width, VGint height, VGbitfield allowedQuality)
+{
+ RI_GET_CONTEXT(VG_INVALID_HANDLE);
+ RI_IF_ERROR(!isValidImageFormat(format), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, VG_INVALID_HANDLE);
+ RI_IF_ERROR(width <= 0 || height <= 0 || !allowedQuality ||
+ (allowedQuality & ~(VG_IMAGE_QUALITY_NONANTIALIASED | VG_IMAGE_QUALITY_FASTER | VG_IMAGE_QUALITY_BETTER)), VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+ RI_IF_ERROR(width > RI_MAX_IMAGE_WIDTH || height > RI_MAX_IMAGE_HEIGHT || width*height > RI_MAX_IMAGE_PIXELS ||
+ ((width*Color::formatToDescriptor(format).bitsPerPixel+7)/8)*height > RI_MAX_IMAGE_BYTES, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+
+ Image* image = NULL;
+ try
+ {
+ image = RI_NEW(Image, (Color::formatToDescriptor(format), width, height, allowedQuality)); //throws bad_alloc
+ RI_ASSERT(image);
+ context->m_imageManager->addResource(image, context); //throws bad_alloc
+ RI_RETURN((VGImage)image);
+ }
+ catch(std::bad_alloc)
+ {
+ RI_DELETE(image);
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ RI_RETURN(VG_INVALID_HANDLE);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgDestroyImage(VGImage image)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid image handle
+
+ context->m_imageManager->removeResource((Image*)image);
+
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgClearImage(VGImage image, VGint x, VGint y, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* img = (Image*)image;
+ RI_IF_ERROR(eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ img->clear(context->m_clearColor, x, y, width, height);
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgImageSubData(VGImage image, const void * data, VGint dataStride, VGImageFormat dataFormat, VGint x, VGint y, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* img = (Image*)image;
+ RI_IF_ERROR(eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!isValidImageFormat(dataFormat), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!data || !isAligned(data, dataFormat) || width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ {
+ Image input(Color::formatToDescriptor(dataFormat), width, height, dataStride, const_cast<RIuint8*>((const RIuint8*)data));
+ input.addReference();
+ try
+ {
+ img->blit(input, 0, 0, x, y, width, height, false); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ input.removeReference();
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgGetImageSubData(VGImage image, void * data, VGint dataStride, VGImageFormat dataFormat, VGint x, VGint y, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* img = (Image*)image;
+ RI_IF_ERROR(eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!isValidImageFormat(dataFormat), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!data || !isAligned(data, dataFormat) || width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ {
+ Image output(Color::formatToDescriptor(dataFormat), width, height, dataStride, (RIuint8*)data);
+ output.addReference();
+ try
+ {
+ output.blit(*img, x, y, 0, 0, width, height, false); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ output.removeReference();
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGImage RI_APIENTRY vgChildImage(VGImage parent, VGint x, VGint y, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(VG_INVALID_HANDLE);
+ RI_IF_ERROR(!context->isValidImage(parent), VG_BAD_HANDLE_ERROR, VG_INVALID_HANDLE);
+ Image* p = (Image*)parent;
+ RI_IF_ERROR(eglvgIsInUse((Image*)parent), VG_IMAGE_IN_USE_ERROR, VG_INVALID_HANDLE);
+ RI_IF_ERROR(x < 0 || x >= p->getWidth() || y < 0 || y >= p->getHeight() ||
+ width <= 0 || height <= 0 || RI_INT_ADDSATURATE(x, width) > p->getWidth() || RI_INT_ADDSATURATE(y, height) > p->getHeight(), VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+
+ Image* child = NULL;
+ try
+ {
+ child = RI_NEW(Image, (p, x, y, width, height)); //throws bad_alloc
+ RI_ASSERT(child);
+ context->m_imageManager->addResource(child, context); //throws bad_alloc
+ RI_RETURN((VGImage)child);
+ }
+ catch(std::bad_alloc)
+ {
+ RI_DELETE(child);
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ RI_RETURN(VG_INVALID_HANDLE);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGImage RI_APIENTRY vgGetParent(VGImage image)
+{
+ RI_GET_CONTEXT(VG_INVALID_HANDLE);
+ RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, VG_INVALID_HANDLE);
+ VGImage ret = image; //if image has no ancestors, image is returned.
+
+ //The vgGetParent function returns the closest valid ancestor (i.e., one that has not been the target of a vgDestroyImage call)
+ // of the given image.
+ Image* im = ((Image*)image)->getParent();
+ for(;im;im = im->getParent())
+ {
+ if(context->isValidImage((VGImage)im))
+ { //the parent is valid and alive
+ ret = (VGImage)im;
+ break;
+ }
+ }
+ RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgCopyImage(VGImage dst, VGint dx, VGint dy, VGImage src, VGint sx, VGint sy, VGint width, VGint height, VGboolean dither)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(eglvgIsInUse((Image*)dst) || eglvgIsInUse((Image*)src), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ try
+ {
+ ((Image*)dst)->blit(*(Image*)src, sx, sy, dx, dy, width, height, dither ? true : false); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static bool drawImage(VGContext* context, VGImage image, const Matrix3x3& userToSurfaceMatrix)
+{
+ Drawable* drawable = context->getCurrentDrawable();
+ if(!drawable)
+ return false; //no EGL surface is current at the moment
+
+ Image* img = (Image*)image;
+ //transform image corners into the surface space
+ Vector3 p0(0, 0, 1);
+ Vector3 p1(0, (RIfloat)img->getHeight(), 1);
+ Vector3 p2((RIfloat)img->getWidth(), (RIfloat)img->getHeight(), 1);
+ Vector3 p3((RIfloat)img->getWidth(), 0, 1);
+ p0 = userToSurfaceMatrix * p0;
+ p1 = userToSurfaceMatrix * p1;
+ p2 = userToSurfaceMatrix * p2;
+ p3 = userToSurfaceMatrix * p3;
+ if(p0.z <= 0.0f || p1.z <= 0.0f || p2.z <= 0.0f || p3.z <= 0.0f)
+ return false;
+
+ //projection
+ p0 *= 1.0f/p0.z;
+ p1 *= 1.0f/p1.z;
+ p2 *= 1.0f/p2.z;
+ p3 *= 1.0f/p3.z;
+
+ Rasterizer rasterizer;
+ if(context->m_scissoring)
+ rasterizer.setScissor(context->m_scissor); //throws bad_alloc
+ rasterizer.setupSamplingPattern(context->m_renderingQuality, drawable->getNumSamples());
+
+ PixelPipe pixelPipe;
+ pixelPipe.setTileFillColor(context->m_tileFillColor);
+ pixelPipe.setPaint((Paint*)context->m_fillPaint);
+ pixelPipe.setImageQuality(context->m_imageQuality);
+ pixelPipe.setBlendMode(context->m_blendMode);
+ pixelPipe.setDrawable(drawable);
+ pixelPipe.setMask(context->m_masking ? true : false);
+ pixelPipe.setColorTransform(context->m_colorTransform ? true : false, context->m_colorTransformValues);
+
+ Matrix3x3 surfaceToImageMatrix = userToSurfaceMatrix;
+ Matrix3x3 surfaceToPaintMatrix = userToSurfaceMatrix * context->m_fillPaintToUser;
+ if(surfaceToImageMatrix.invert() && surfaceToPaintMatrix.invert())
+ {
+ VGImageMode imode = context->m_imageMode;
+ if(!surfaceToPaintMatrix.isAffine())
+ imode = VG_DRAW_IMAGE_NORMAL; //if paint matrix is not affine, always use normal image mode
+ surfaceToPaintMatrix[2].set(0,0,1); //force affine
+
+ pixelPipe.setImage(img, imode);
+ pixelPipe.setSurfaceToPaintMatrix(surfaceToPaintMatrix);
+ pixelPipe.setSurfaceToImageMatrix(surfaceToImageMatrix);
+
+ rasterizer.addEdge(Vector2(p0.x,p0.y), Vector2(p1.x,p1.y)); //throws bad_alloc
+ rasterizer.addEdge(Vector2(p1.x,p1.y), Vector2(p2.x,p2.y)); //throws bad_alloc
+ rasterizer.addEdge(Vector2(p2.x,p2.y), Vector2(p3.x,p3.y)); //throws bad_alloc
+ rasterizer.addEdge(Vector2(p3.x,p3.y), Vector2(p0.x,p0.y)); //throws bad_alloc
+ rasterizer.setup(0, 0, drawable->getWidth(), drawable->getHeight(), VG_EVEN_ODD, &pixelPipe, NULL);
+ rasterizer.fill(); //throws bad_alloc
+ }
+ return true;
+}
+
+void RI_APIENTRY vgDrawImage(VGImage image)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* img = (Image*)image;
+ RI_IF_ERROR(eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+
+ try
+ {
+ if(!drawImage(context, image, context->m_imageUserToSurface))
+ {
+ RI_RETURN(RI_NO_RETVAL);
+ }
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetPixels(VGint dx, VGint dy, VGImage src, VGint sx, VGint sy, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(eglvgIsInUse((Image*)src), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Drawable* drawable = context->getCurrentDrawable();
+ if(!drawable)
+ {
+ RI_RETURN(RI_NO_RETVAL); //no EGL surface is current at the moment
+ }
+ try
+ {
+ if(context->m_scissoring)
+ drawable->getColorBuffer()->blit(*(Image*)src, sx, sy, dx, dy, width, height, context->m_scissor); //throws bad_alloc
+ else
+ drawable->getColorBuffer()->blit(*(Image*)src, sx, sy, dx, dy, width, height); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgWritePixels(const void * data, VGint dataStride, VGImageFormat dataFormat, VGint dx, VGint dy, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!isValidImageFormat(dataFormat), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!data || !isAligned(data, dataFormat) || width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Drawable* drawable = context->getCurrentDrawable();
+ if(!drawable)
+ {
+ RI_RETURN(RI_NO_RETVAL); //no EGL surface is current at the moment
+ }
+ {
+ Image input(Color::formatToDescriptor(dataFormat), width, height, dataStride, const_cast<RIuint8*>((const RIuint8*)data));
+ input.addReference();
+ try
+ {
+ if(context->m_scissoring)
+ drawable->getColorBuffer()->blit(input, 0, 0, dx, dy, width, height, context->m_scissor); //throws bad_alloc
+ else
+ drawable->getColorBuffer()->blit(input, 0, 0, dx, dy, width, height); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ input.removeReference();
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgGetPixels(VGImage dst, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(dst), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(eglvgIsInUse((Image*)dst), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Drawable* drawable = context->getCurrentDrawable();
+ if(!drawable)
+ {
+ RI_RETURN(RI_NO_RETVAL); //no EGL surface is current at the moment
+ }
+ try
+ {
+ ((Image*)dst)->blit(drawable->getColorBuffer(), sx, sy, dx, dy, width, height); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgReadPixels(void* data, VGint dataStride, VGImageFormat dataFormat, VGint sx, VGint sy, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!isValidImageFormat(dataFormat), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!data || !isAligned(data, dataFormat) || width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Drawable* drawable = context->getCurrentDrawable();
+ if(!drawable)
+ {
+ RI_RETURN(RI_NO_RETVAL); //no EGL surface is current at the moment
+ }
+ {
+ Image output(Color::formatToDescriptor(dataFormat), width, height, dataStride, (RIuint8*)data);
+ output.addReference();
+ try
+ {
+ output.blit(drawable->getColorBuffer(), sx, sy, 0, 0, width, height); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ output.removeReference();
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgCopyPixels(VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Drawable* drawable = context->getCurrentDrawable();
+ if(!drawable)
+ {
+ RI_RETURN(RI_NO_RETVAL); //no EGL surface is current at the moment
+ }
+ try
+ {
+ if(context->m_scissoring)
+ drawable->getColorBuffer()->blit(drawable->getColorBuffer(), sx, sy, dx, dy, width, height, context->m_scissor); //throws bad_alloc
+ else
+ drawable->getColorBuffer()->blit(drawable->getColorBuffer(), sx, sy, dx, dy, width, height); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgColorMatrix(VGImage dst, VGImage src, const VGfloat * matrix)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* d = (Image*)dst;
+ Image* s = (Image*)src;
+ RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!matrix || !isAligned(matrix,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA); //undefined bits are ignored
+
+ RIfloat m[20];
+ for(int i=0;i<20;i++)
+ {
+ m[i] = inputFloat(matrix[i]);
+ }
+ try
+ {
+ d->colorMatrix(*s, m, context->m_filterFormatLinear ? true : false, context->m_filterFormatPremultiplied ? true : false, channelMask);
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgConvolve(VGImage dst, VGImage src, VGint kernelWidth, VGint kernelHeight, VGint shiftX, VGint shiftY, const VGshort * kernel, VGfloat scale, VGfloat bias, VGTilingMode tilingMode)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* d = (Image*)dst;
+ Image* s = (Image*)src;
+ RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!kernel || !isAligned(kernel,2) || kernelWidth <= 0 || kernelHeight <= 0 || kernelWidth > RI_MAX_KERNEL_SIZE || kernelHeight > RI_MAX_KERNEL_SIZE, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(tilingMode < VG_TILE_FILL || tilingMode > VG_TILE_REFLECT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA); //undefined bits are ignored
+ try
+ {
+ d->convolve(*s, kernelWidth, kernelHeight, shiftX, shiftY, (const RIint16*)kernel, inputFloat(scale), inputFloat(bias), tilingMode, context->m_tileFillColor, context->m_filterFormatLinear ? true : false, context->m_filterFormatPremultiplied ? true : false, channelMask);
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSeparableConvolve(VGImage dst, VGImage src, VGint kernelWidth, VGint kernelHeight, VGint shiftX, VGint shiftY, const VGshort * kernelX, const VGshort * kernelY, VGfloat scale, VGfloat bias, VGTilingMode tilingMode)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* d = (Image*)dst;
+ Image* s = (Image*)src;
+ RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!kernelX || !kernelY || !isAligned(kernelX,2) || !isAligned(kernelY,2) || kernelWidth <= 0 || kernelHeight <= 0 || kernelWidth > RI_MAX_SEPARABLE_KERNEL_SIZE || kernelHeight > RI_MAX_SEPARABLE_KERNEL_SIZE, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(tilingMode < VG_TILE_FILL || tilingMode > VG_TILE_REFLECT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA); //undefined bits are ignored
+ try
+ {
+ d->separableConvolve(*s, kernelWidth, kernelHeight, shiftX, shiftY, (const RIint16*)kernelX, (const RIint16*)kernelY,
+ inputFloat(scale), inputFloat(bias), tilingMode, context->m_tileFillColor, context->m_filterFormatLinear ? true : false,
+ context->m_filterFormatPremultiplied ? true : false, channelMask);
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgGaussianBlur(VGImage dst, VGImage src, VGfloat stdDeviationX, VGfloat stdDeviationY, VGTilingMode tilingMode)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* d = (Image*)dst;
+ Image* s = (Image*)src;
+ RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RIfloat sx = inputFloat(stdDeviationX);
+ RIfloat sy = inputFloat(stdDeviationY);
+ RI_IF_ERROR(sx <= 0.0f || sy <= 0.0f || sx > (RIfloat)RI_MAX_GAUSSIAN_STD_DEVIATION || sy > (RIfloat)RI_MAX_GAUSSIAN_STD_DEVIATION, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(tilingMode < VG_TILE_FILL || tilingMode > VG_TILE_REFLECT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA); //undefined bits are ignored
+ try
+ {
+ d->gaussianBlur(*s, sx, sy, tilingMode, context->m_tileFillColor, context->m_filterFormatLinear ? true : false,
+ context->m_filterFormatPremultiplied ? true : false, channelMask);
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgLookup(VGImage dst, VGImage src, const VGubyte * redLUT, const VGubyte * greenLUT, const VGubyte * blueLUT, const VGubyte * alphaLUT, VGboolean outputLinear, VGboolean outputPremultiplied)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* d = (Image*)dst;
+ Image* s = (Image*)src;
+ RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!redLUT || !greenLUT || !blueLUT || !alphaLUT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA); //undefined bits are ignored
+ try
+ {
+ d->lookup(*s, (const RIuint8*)redLUT, (const RIuint8*)greenLUT, (const RIuint8*)blueLUT, (const RIuint8*)alphaLUT,
+ outputLinear ? true : false, outputPremultiplied ? true : false, context->m_filterFormatLinear ? true : false,
+ context->m_filterFormatPremultiplied ? true : false, channelMask);
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgLookupSingle(VGImage dst, VGImage src, const VGuint * lookupTable, VGImageChannel sourceChannel, VGboolean outputLinear, VGboolean outputPremultiplied)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+ Image* d = (Image*)dst;
+ Image* s = (Image*)src;
+ RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(!lookupTable || !isAligned(lookupTable,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ const Color::Descriptor& desc = s->getDescriptor();
+ RI_ASSERT(Color::isValidDescriptor(desc));
+ //give an error if src is in rgb format and the source channel is not valid
+ RI_IF_ERROR((!desc.isLuminance() && !desc.isAlphaOnly()) && (sourceChannel != VG_RED && sourceChannel != VG_GREEN && sourceChannel != VG_BLUE && sourceChannel != VG_ALPHA), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA); //undefined bits are ignored
+ try
+ {
+ d->lookupSingle(*s, (const RIuint32*)lookupTable, sourceChannel, outputLinear ? true : false, outputPremultiplied ? true : false,
+ context->m_filterFormatLinear ? true : false, context->m_filterFormatPremultiplied ? true : false, channelMask);
+ }
+ catch(std::bad_alloc)
+ {
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGHardwareQueryResult RI_APIENTRY vgHardwareQuery(VGHardwareQueryType key, VGint setting)
+{
+ RI_GET_CONTEXT(VG_HARDWARE_UNACCELERATED);
+ RI_IF_ERROR(key != VG_IMAGE_FORMAT_QUERY && key != VG_PATH_DATATYPE_QUERY, VG_ILLEGAL_ARGUMENT_ERROR, VG_HARDWARE_UNACCELERATED);
+ RI_IF_ERROR(key == VG_IMAGE_FORMAT_QUERY && !isValidImageFormat(setting), VG_ILLEGAL_ARGUMENT_ERROR, VG_HARDWARE_UNACCELERATED);
+ RI_IF_ERROR(key == VG_PATH_DATATYPE_QUERY && (setting < VG_PATH_DATATYPE_S_8 || setting > VG_PATH_DATATYPE_F), VG_ILLEGAL_ARGUMENT_ERROR, VG_HARDWARE_UNACCELERATED);
+ RI_RETURN(VG_HARDWARE_UNACCELERATED);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+const VGubyte * RI_APIENTRY vgGetString(VGStringID name)
+{
+ static const VGubyte vendor[] = "Khronos Group";
+ static const VGubyte renderer[] = {"OpenVG 1.1 Reference Implementation May 13 2008"};
+ static const VGubyte version[] = "1.1";
+ static const VGubyte extensions[] = "";
+ const VGubyte* r = NULL;
+ RI_GET_CONTEXT(NULL);
+ switch(name)
+ {
+ case VG_VENDOR:
+ r = vendor;
+ break;
+ case VG_RENDERER:
+ r = renderer;
+ break;
+ case VG_VERSION:
+ r = version;
+ break;
+ case VG_EXTENSIONS:
+ r = extensions;
+ break;
+ default:
+ break;
+ }
+ RI_RETURN(r);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGFont RI_APIENTRY vgCreateFont(VGint glyphCapacityHint)
+{
+ RI_GET_CONTEXT(VG_INVALID_HANDLE);
+ RI_IF_ERROR(glyphCapacityHint < 0, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+
+ Font* font = NULL;
+ try
+ {
+ font = RI_NEW(Font, (glyphCapacityHint)); //throws bad_alloc
+ RI_ASSERT(font);
+ context->m_fontManager->addResource(font, context); //throws bad_alloc
+ RI_RETURN((VGFont)font);
+ }
+ catch(std::bad_alloc)
+ {
+ RI_DELETE(font);
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ RI_RETURN(VG_INVALID_HANDLE);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgDestroyFont(VGFont font)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid font handle
+
+ context->m_fontManager->removeResource((Font*)font);
+
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetGlyphToPath(VGFont font, VGuint glyphIndex, VGPath path, VGboolean isHinted, VGfloat glyphOrigin[2], VGfloat escapement[2])
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid font handle
+ RI_IF_ERROR(path != VG_INVALID_HANDLE && !context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid path handle
+ RI_IF_ERROR(!glyphOrigin || !escapement || !isAligned(glyphOrigin,sizeof(VGfloat)) || !isAligned(escapement,sizeof(VGfloat)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Font* f = (Font*)font;
+
+ try
+ {
+ f->setGlyphToPath(glyphIndex, path, isHinted ? true : false, Vector2(inputFloat(glyphOrigin[0]), inputFloat(glyphOrigin[1])), Vector2(inputFloat(escapement[0]), inputFloat(escapement[1])));
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgSetGlyphToImage(VGFont font, VGuint glyphIndex, VGImage image, VGfloat glyphOrigin[2], VGfloat escapement[2])
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid font handle
+ if(image != VG_INVALID_HANDLE)
+ {
+ RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid image handle
+ RI_IF_ERROR(eglvgIsInUse((Image*)image), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL); //image in use
+ }
+ RI_IF_ERROR(!glyphOrigin || !escapement || !isAligned(glyphOrigin,sizeof(VGfloat)) || !isAligned(escapement,sizeof(VGfloat)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ Font* f = (Font*)font;
+
+ try
+ {
+ f->setGlyphToImage(glyphIndex, image, Vector2(inputFloat(glyphOrigin[0]), inputFloat(glyphOrigin[1])), Vector2(inputFloat(escapement[0]), inputFloat(escapement[1])));
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgClearGlyph(VGFont font, VGuint glyphIndex)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid font handle
+ Font* f = (Font*)font;
+ Font::Glyph* g = f->findGlyph(glyphIndex);
+ RI_IF_ERROR(!g, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //glyphIndex not defined
+
+ f->clearGlyph(g);
+
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgDrawGlyph(VGFont font, VGuint glyphIndex, VGbitfield paintModes, VGboolean allowAutoHinting)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid font handle
+ RI_IF_ERROR(paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //invalid paint mode
+ Font* f = (Font*)font;
+ Font::Glyph* g = f->findGlyph(glyphIndex);
+ RI_IF_ERROR(!g, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //glyphIndex not defined
+ RI_UNREF(allowAutoHinting); //RI doesn't implement autohinting
+
+ try
+ {
+ if(paintModes)
+ {
+ Matrix3x3 userToSurfaceMatrix = context->m_glyphUserToSurface;
+ Vector2 t = context->m_glyphOrigin - g->m_origin;
+ Matrix3x3 n(1, 0, t.x,
+ 0, 1, t.y,
+ 0, 0, 1 );
+ userToSurfaceMatrix *= n;
+ userToSurfaceMatrix[2].set(0,0,1); //force affinity
+
+ bool ret = true;
+ if(g->m_image != VG_INVALID_HANDLE)
+ ret = drawImage(context, g->m_image, userToSurfaceMatrix);
+ else if(g->m_path != VG_INVALID_HANDLE)
+ ret = drawPath(context, g->m_path, userToSurfaceMatrix, paintModes);
+ if(!ret)
+ {
+ RI_RETURN(RI_NO_RETVAL);
+ }
+ }
+
+ context->m_glyphOrigin += g->m_escapement;
+ context->m_inputGlyphOrigin = context->m_glyphOrigin;
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void RI_APIENTRY vgDrawGlyphs(VGFont font, VGint glyphCount, VGuint *glyphIndices, VGfloat *adjustments_x, VGfloat *adjustments_y, VGbitfield paintModes, VGboolean allowAutoHinting)
+{
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid font handle
+ RI_IF_ERROR(!glyphIndices || !isAligned(glyphIndices, sizeof(VGuint)) || glyphCount <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR((adjustments_x && !isAligned(adjustments_x, sizeof(VGfloat))) || (adjustments_y && !isAligned(adjustments_y, sizeof(VGfloat))), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+ RI_IF_ERROR(paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //invalid paint mode
+ Font* f = (Font*)font;
+ for(int i=0;i<glyphCount;i++)
+ {
+ Font::Glyph* g = f->findGlyph(glyphIndices[i]);
+ RI_IF_ERROR(!g, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //glyphIndex not defined
+ }
+ RI_UNREF(allowAutoHinting); //RI doesn't implement autohinting
+
+ try
+ {
+ for(int i=0;i<glyphCount;i++)
+ {
+ Font::Glyph* g = f->findGlyph(glyphIndices[i]);
+
+ if(paintModes)
+ {
+ Matrix3x3 userToSurfaceMatrix = context->m_glyphUserToSurface;
+ Vector2 t = context->m_glyphOrigin - g->m_origin;
+ Matrix3x3 n(1, 0, t.x,
+ 0, 1, t.y,
+ 0, 0, 1 );
+ userToSurfaceMatrix *= n;
+ userToSurfaceMatrix[2].set(0,0,1); //force affinity
+
+ bool ret = true;
+ if(g->m_image != VG_INVALID_HANDLE)
+ ret = drawImage(context, g->m_image, userToSurfaceMatrix);
+ else if(g->m_path != VG_INVALID_HANDLE)
+ ret = drawPath(context, g->m_path, userToSurfaceMatrix, paintModes);
+ if(!ret)
+ {
+ RI_RETURN(RI_NO_RETVAL);
+ }
+ }
+
+ context->m_glyphOrigin += g->m_escapement;
+ if(adjustments_x)
+ context->m_glyphOrigin.x += inputFloat(adjustments_x[i]);
+ if(adjustments_y)
+ context->m_glyphOrigin.y += inputFloat(adjustments_y[i]);
+ context->m_inputGlyphOrigin = context->m_glyphOrigin;
+ }
+ }
+ catch(std::bad_alloc)
+ {
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ }
+
+ RI_RETURN(RI_NO_RETVAL);
+}
diff --git a/src/vg/Api.cpp.tg b/src/vg/Api.cpp.tg
new file mode 100644
index 0000000..4f8a94f
--- /dev/null
+++ b/src/vg/Api.cpp.tg
@@ -0,0 +1,37 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "egl.h"
+#include "openvg.h"
+
+namespace tgOpenVG {
+
+VGPaint RI_APIENTRY vgCreatePaint(void) {
+
+ RI_GET_CONTEXT(VG_INVALID_HANDLE);
+ Paint* paint = NULL;
+ try
+ {
+ paint = RI_NEW(Paint, ()); //throws bad_alloc
+ RI_ASSERT(paint);
+ context->m_paintManager->addResource(paint, context); //throws bad_alloc
+ RI_RETURN((VGPaint)paint);
+ }
+ catch(std::bad_alloc)
+ {
+ RI_DELETE(paint);
+ context->setError(VG_OUT_OF_MEMORY_ERROR);
+ RI_RETURN(VG_INVALID_HANDLE);
+ }
+}
+
+void RI_APIENTRY vgDestroyPaint(VGPaint paint) {
+ RI_GET_CONTEXT(RI_NO_RETVAL);
+ RI_IF_ERROR(!context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid paint handle
+
+ context->m_paintManager->removeResource((Paint*)paint);
+
+ RI_RETURN(RI_NO_RETVAL);
+}
+
+}
diff --git a/src/vg/Array.h b/src/vg/Array.h
new file mode 100644
index 0000000..3d10a6f
--- /dev/null
+++ b/src/vg/Array.h
@@ -0,0 +1,209 @@
+#ifndef __ARRAY_H
+#define __ARRAY_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Array class.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Defs.h"
+
+#include <string.h> //for memcpy
+
+namespace tgOpenVG
+{
+
+//=======================================================================
+
+/*-------------------------------------------------------------------*//*!
+* \brief An array class similar to std::vector.
+* \param
+* \return
+* \note Follows std::vector's naming convention (except resizeAndReallocate).
+*//*-------------------------------------------------------------------*/
+
+template <class Item> class Array
+{
+public:
+ Array() : m_array(NULL), m_size(0), m_allocated(0) {} //throws bad_alloc
+ ~Array()
+ {
+ RI_DELETE_ARRAY(m_array);
+ }
+
+ void swap(Array& s)
+ {
+ Item* tarray = m_array;
+ m_array = s.m_array;
+ s.m_array = tarray;
+
+ int tsize = m_size;
+ m_size = s.m_size;
+ s.m_size = tsize;
+
+ int tallocated = m_allocated;
+ m_allocated = s.m_allocated;
+ s.m_allocated = tallocated;
+ }
+
+ //if more room is needed, reallocate, otherwise return
+ void reserve( int items ) //throws bad_alloc
+ {
+ RI_ASSERT( items >= 0 );
+ if( items <= m_allocated )
+ return; //if there is room already, return
+
+ RI_ASSERT( items > m_allocated );
+
+ Item* newa = RI_NEW_ARRAY(Item, items); //throws bad_alloc if runs out of memory
+ for(int i=0;i<m_size;i++)
+ newa[i] = m_array[i];
+ RI_DELETE_ARRAY(m_array);
+ m_array = newa;
+ m_allocated = items;
+ //doesn't change size
+ }
+
+ //reserve and change size
+ void resize( int items ) //throws bad_alloc
+ {
+ reserve( items ); //throws bad_alloc if runs out of memory
+ m_size = items;
+ }
+
+ //resize and allocate exactly the correct amount of memory
+ void resizeAndReallocate( int items ) //throws bad_alloc
+ {
+ RI_ASSERT( items >= 0 );
+ if( items == m_allocated )
+ {
+ m_size = items;
+ return;
+ }
+
+ if( items == 0 )
+ {
+ RI_DELETE_ARRAY(m_array);
+ m_size = 0;
+ m_allocated = 0;
+ return;
+ }
+
+ Item* newa = RI_NEW_ARRAY(Item, items); //throws bad_alloc if runs out of memory
+ int copySize = (m_size < items) ? m_size : items; //min(m_size,items)
+ for(int i=0;i<copySize;i++)
+ newa[i] = m_array[i];
+ RI_DELETE_ARRAY(m_array);
+ m_array = newa;
+ m_allocated = items;
+ m_size = items; //changes also size
+ }
+ void clear()
+ {
+ m_size = 0;
+ }
+
+ //sort array (needs operator< defined for Item. Define it with < for increasing order and > for decreasing.)
+ void sort()
+ {
+ if(m_size <= 1)
+ return;
+ quicksort(0, m_size - 1);
+ }
+
+ //remove the first occurrence of an item from the array
+ bool remove(const Item& item)
+ {
+ int i=0;
+ for(;i<m_size;i++)
+ {
+ if(m_array[i] == item)
+ break;
+ }
+ if(i >= m_size)
+ return false; //not found
+ for(;i<m_size-1;i++)
+ {
+ m_array[i] = m_array[i+1];
+ }
+ m_size--;
+ return true;
+ }
+
+ inline void push_back( const Item& item ) //throws bad_alloc
+ {
+ if( m_size >= m_allocated )
+ reserve( (!m_allocated) ? 8 : m_allocated * 2 ); //by default, reserve 8. throws bad_alloc if runs out of memory
+ m_array[m_size++] = item;
+ }
+ inline int size() const { return m_size; }
+ inline Item& operator[](int i) { RI_ASSERT(i >= 0 && i < m_size); return m_array[i]; }
+ inline const Item& operator[](int i) const { RI_ASSERT(i >= 0 && i < m_size); return m_array[i]; }
+
+private:
+ Array(const Array& s); //!< Not allowed.
+ void operator=(const Array& s); //!< Not allowed.
+
+ void quicksort(int left, int right)
+ {
+ int i = left, j = right;
+ Item x = m_array[(left+right)>>1];
+
+ do
+ {
+ while (m_array[i] < x)
+ i++;
+ while (x < m_array[j])
+ j--;
+ if (i<=j)
+ {
+ Item tmp = m_array[i];
+ m_array[i] = m_array[j];
+ m_array[j] = tmp;
+ i++;
+ j--;
+ }
+ } while (i<=j);
+
+ if(left < j) quicksort(left, j);
+ if(i < right) quicksort(i, right);
+ }
+
+
+ Item* m_array;
+ int m_size;
+ int m_allocated;
+};
+
+//=======================================================================
+
+} //namespace tgOpenVG
+
+#endif /* __ARRAY_H */
diff --git a/src/vg/Context.cpp b/src/vg/Context.cpp
new file mode 100644
index 0000000..f1fee49
--- /dev/null
+++ b/src/vg/Context.cpp
@@ -0,0 +1,329 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Implementation of VGContext functions.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Context.h"
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief VGContext constructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGContext::VGContext(VGContext* shareContext) :
+ // Mode settings
+ m_matrixMode(VG_MATRIX_PATH_USER_TO_SURFACE),
+ m_fillRule(VG_EVEN_ODD),
+ m_imageQuality(VG_IMAGE_QUALITY_FASTER),
+ m_renderingQuality(VG_RENDERING_QUALITY_BETTER),
+ m_blendMode(VG_BLEND_SRC_OVER),
+ m_imageMode(VG_DRAW_IMAGE_NORMAL),
+
+ // Scissor rectangles
+ m_scissor(),
+
+ // Stroke parameters
+ m_strokeLineWidth(1.0f),
+ m_inputStrokeLineWidth(1.0f),
+ m_strokeCapStyle(VG_CAP_BUTT),
+ m_strokeJoinStyle(VG_JOIN_MITER),
+ m_strokeMiterLimit(4.0f),
+ m_inputStrokeMiterLimit(4.0f),
+ m_strokeDashPattern(),
+ m_inputStrokeDashPattern(),
+ m_strokeDashPhase(0.0f),
+ m_inputStrokeDashPhase(0.0f),
+ m_strokeDashPhaseReset(VG_FALSE),
+
+ // Edge fill color for vgConvolve and pattern paint
+ m_tileFillColor(0,0,0,0, Color::sRGBA),
+ m_inputTileFillColor(0,0,0,0, Color::sRGBA),
+
+ // Color for vgClear
+ m_clearColor(0,0,0,0, Color::sRGBA),
+ m_inputClearColor(0,0,0,0, Color::sRGBA),
+
+ m_glyphOrigin(0.0f, 0.0f),
+ m_inputGlyphOrigin(0.0f, 0.0f),
+
+ m_masking(VG_FALSE),
+ m_scissoring(VG_FALSE),
+
+ m_pixelLayout(VG_PIXEL_LAYOUT_UNKNOWN),
+
+ m_filterFormatLinear(VG_FALSE),
+ m_filterFormatPremultiplied(VG_FALSE),
+ m_filterChannelMask(VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA),
+
+ // Matrices
+ m_pathUserToSurface(),
+ m_imageUserToSurface(),
+ m_glyphUserToSurface(),
+ m_fillPaintToUser(),
+ m_strokePaintToUser(),
+
+ m_fillPaint(VG_INVALID_HANDLE),
+ m_strokePaint(VG_INVALID_HANDLE),
+
+ m_colorTransform(VG_FALSE),
+ m_colorTransformValues(),
+ m_inputColorTransformValues(),
+
+ m_error(VG_NO_ERROR),
+
+ m_imageManager(NULL),
+ m_pathManager(NULL),
+ m_paintManager(NULL),
+ m_fontManager(NULL),
+ m_maskLayerManager(NULL),
+
+ m_eglDrawable(NULL)
+{
+ if(shareContext)
+ {
+ m_imageManager = shareContext->m_imageManager;
+ m_pathManager = shareContext->m_pathManager;
+ m_paintManager = shareContext->m_paintManager;
+ m_fontManager = shareContext->m_fontManager;
+ m_maskLayerManager = shareContext->m_maskLayerManager;
+ }
+ else
+ {
+ try
+ {
+ m_imageManager = RI_NEW(tgOpenVG::ResourceManager<Image>, ()); //throws bad_alloc
+ m_pathManager = RI_NEW(tgOpenVG::ResourceManager<Path>, ()); //throws bad_alloc
+ m_paintManager = RI_NEW(tgOpenVG::ResourceManager<Paint>, ()); //throws bad_alloc
+ m_fontManager = RI_NEW(tgOpenVG::ResourceManager<Font>, ()); //throws bad_alloc
+ m_maskLayerManager = RI_NEW(tgOpenVG::ResourceManager<Surface>, ()); //throws bad_alloc
+ }
+ catch(std::bad_alloc)
+ {
+ RI_DELETE(m_imageManager);
+ RI_DELETE(m_pathManager);
+ RI_DELETE(m_paintManager);
+ RI_DELETE(m_fontManager);
+ RI_DELETE(m_maskLayerManager);
+ throw;
+ }
+ }
+ RI_ASSERT(m_imageManager);
+ RI_ASSERT(m_pathManager);
+ RI_ASSERT(m_paintManager);
+ RI_ASSERT(m_fontManager);
+ RI_ASSERT(m_maskLayerManager);
+ m_imageManager->addReference();
+ m_pathManager->addReference();
+ m_paintManager->addReference();
+ m_fontManager->addReference();
+ m_maskLayerManager->addReference();
+
+ m_inputColorTransformValues[0] = 1.0f;
+ m_inputColorTransformValues[1] = 1.0f;
+ m_inputColorTransformValues[2] = 1.0f;
+ m_inputColorTransformValues[3] = 1.0f;
+ m_inputColorTransformValues[4] = 0.0f;
+ m_inputColorTransformValues[5] = 0.0f;
+ m_inputColorTransformValues[6] = 0.0f;
+ m_inputColorTransformValues[7] = 0.0f;
+ m_colorTransformValues[0] = 1.0f;
+ m_colorTransformValues[1] = 1.0f;
+ m_colorTransformValues[2] = 1.0f;
+ m_colorTransformValues[3] = 1.0f;
+ m_colorTransformValues[4] = 0.0f;
+ m_colorTransformValues[5] = 0.0f;
+ m_colorTransformValues[6] = 0.0f;
+ m_colorTransformValues[7] = 0.0f;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief VGContext destructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGContext::~VGContext()
+{
+ releasePaint(VG_FILL_PATH | VG_STROKE_PATH);
+ setDefaultDrawable(NULL);
+
+ //destroy own images, paths and paints
+ while(Image* i = m_imageManager->getFirstResource(this))
+ m_imageManager->removeResource(i);
+ while(Path* p = m_pathManager->getFirstResource(this))
+ m_pathManager->removeResource(p);
+ while(Paint* t = m_paintManager->getFirstResource(this))
+ m_paintManager->removeResource(t);
+ while(Font* t = m_fontManager->getFirstResource(this))
+ m_fontManager->removeResource(t);
+ while(Surface* t = m_maskLayerManager->getFirstResource(this))
+ m_maskLayerManager->removeResource(t);
+
+ //decrease the reference count of resource managers
+ if(!m_imageManager->removeReference())
+ RI_DELETE(m_imageManager);
+ if(!m_pathManager->removeReference())
+ RI_DELETE(m_pathManager);
+ if(!m_paintManager->removeReference())
+ RI_DELETE(m_paintManager);
+ if(!m_fontManager->removeReference())
+ RI_DELETE(m_fontManager);
+ if(!m_maskLayerManager->removeReference())
+ RI_DELETE(m_maskLayerManager);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets new default drawable.
+* \param drawable New drawable or NULL when context is unbound
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void VGContext::setDefaultDrawable(Drawable* drawable)
+{
+ if(m_eglDrawable)
+ {
+ if(!m_eglDrawable->removeReference())
+ RI_DELETE(m_eglDrawable);
+ }
+ m_eglDrawable = drawable;
+ if(m_eglDrawable)
+ {
+ m_eglDrawable->addReference();
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns true if the given image is generated through any
+* context that is shared with this one.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidImage(VGImage image)
+{
+ return m_imageManager->isValid((Image*)image);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns true if the given path is generated through any
+* context that is shared with this one.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidPath(VGPath path)
+{
+ return m_pathManager->isValid((Path*)path);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns true if the given paint is generated through any
+* context that is shared with this one.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidPaint(VGPaint paint)
+{
+ return m_paintManager->isValid((Paint*)paint);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns true if the given font is generated through any
+* context that is shared with this one.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidFont(VGFont font)
+{
+ return m_fontManager->isValid((Font*)font);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns true if the given mask layer is generated through any
+* context that is shared with this one.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidMaskLayer(VGMaskLayer layer)
+{
+ return m_maskLayerManager->isValid((Surface*)layer);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Releases the given paint objects of the context.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void VGContext::releasePaint(VGbitfield paintModes)
+{
+ if(paintModes & VG_FILL_PATH)
+ {
+ //release previous paint
+ Paint* prev = (Paint*)m_fillPaint;
+ if(prev)
+ {
+ if(!prev->removeReference())
+ RI_DELETE(prev);
+ }
+ m_fillPaint = VG_INVALID_HANDLE;
+ }
+ if(paintModes & VG_STROKE_PATH)
+ {
+ //release previous paint
+ Paint* prev = (Paint*)m_strokePaint;
+ if(prev)
+ {
+ if(!prev->removeReference())
+ RI_DELETE(prev);
+ }
+ m_strokePaint = VG_INVALID_HANDLE;
+ }
+}
+
+//==============================================================================================
+
+} //namespace tgOpenVG
diff --git a/src/vg/Context.h b/src/vg/Context.h
new file mode 100644
index 0000000..05aad3a
--- /dev/null
+++ b/src/vg/Context.h
@@ -0,0 +1,257 @@
+#ifndef __CONTEXT_H
+#define __CONTEXT_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief VGContext class. Used for storing OpenVG state.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include <VG/openvg.h>
+#include "Defs.h"
+#include "Math.h"
+#include "Image.h"
+#include "Path.h"
+#include "Font.h"
+#include "Array.h"
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+class VGContext;
+
+/*-------------------------------------------------------------------*//*!
+* \brief A list of resources (Images, Paths, or Paints) shared by a
+* set of contexts.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+template <class Resource> class ResourceManager
+{
+public:
+ ResourceManager() :
+ m_referenceCount(0),
+ m_resources()
+ {
+ }
+
+ ~ResourceManager()
+ {
+ RI_ASSERT(m_referenceCount == 0);
+ RI_ASSERT(m_resources.size() == 0);
+ }
+
+ void addReference()
+ {
+ m_referenceCount++;
+ }
+
+ int removeReference()
+ {
+ m_referenceCount--;
+ RI_ASSERT(m_referenceCount >= 0);
+ return m_referenceCount;
+ }
+
+ void addResource(Resource* resource, VGContext* context)
+ {
+ Entry r;
+ r.resource = resource;
+ r.context = context;
+ m_resources.push_back(r); //throws bad_alloc
+ resource->addReference();
+ }
+
+ void removeResource(Resource* resource)
+ {
+ if(!resource->removeReference())
+ RI_DELETE(resource);
+
+ int i=0;
+ bool found = false;
+ for(;i<m_resources.size();i++)
+ {
+ if(m_resources[i].resource == resource)
+ {
+ found = true;
+ break;
+ }
+ }
+ RI_ASSERT(found);
+
+ for(;i<m_resources.size()-1;i++)
+ {
+ m_resources[i] = m_resources[i+1];
+ }
+ m_resources.resize(m_resources.size()-1);
+ }
+
+ bool isValid(Resource* resource)
+ {
+ for(int i=0;i<m_resources.size();i++)
+ {
+ if(m_resources[i].resource == resource)
+ return true;
+ }
+ return false;
+ }
+
+ Resource* getFirstResource(VGContext* context)
+ {
+ for(int i=0;i<m_resources.size();i++)
+ {
+ if(m_resources[i].context == context)
+ return m_resources[i].resource;
+ }
+ return NULL;
+ }
+
+private:
+ ResourceManager(const ResourceManager&);
+ ResourceManager operator=(const ResourceManager&);
+
+ struct Entry
+ {
+ Resource* resource;
+ VGContext* context;
+ };
+
+ int m_referenceCount;
+ Array<Entry> m_resources;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class VGContext
+{
+public:
+ VGContext(VGContext* shareContext); //throws bad_alloc
+ ~VGContext();
+
+ void setDefaultDrawable(Drawable* drawable); //called from EGL
+ Drawable* getCurrentDrawable() { return m_eglDrawable; }
+
+ bool isValidImage(VGImage image);
+ bool isValidPath(VGPath path);
+ bool isValidPaint(VGPaint paint);
+ bool isValidFont(VGFont font);
+ bool isValidMaskLayer(VGMaskLayer layer);
+
+ void releasePaint(VGbitfield paintModes);
+
+ void setError(VGErrorCode error) { if(m_error == VG_NO_ERROR) m_error = error; }
+
+ // Mode settings
+ VGMatrixMode m_matrixMode;
+ VGFillRule m_fillRule;
+ VGImageQuality m_imageQuality;
+ VGRenderingQuality m_renderingQuality;
+ VGBlendMode m_blendMode;
+ VGImageMode m_imageMode;
+
+ // Scissor rectangles
+ Array<Rectangle> m_scissor;
+
+ // Stroke parameters
+ RIfloat m_strokeLineWidth;
+ RIfloat m_inputStrokeLineWidth;
+ VGCapStyle m_strokeCapStyle;
+ VGJoinStyle m_strokeJoinStyle;
+ RIfloat m_strokeMiterLimit;
+ RIfloat m_inputStrokeMiterLimit;
+ Array<RIfloat> m_strokeDashPattern;
+ Array<RIfloat> m_inputStrokeDashPattern;
+ RIfloat m_strokeDashPhase;
+ RIfloat m_inputStrokeDashPhase;
+ VGboolean m_strokeDashPhaseReset;
+
+ // Edge fill color for vgConvolve and pattern paint
+ Color m_tileFillColor;
+ Color m_inputTileFillColor;
+
+ // Color for vgClear
+ Color m_clearColor;
+ Color m_inputClearColor;
+
+ Vector2 m_glyphOrigin;
+ Vector2 m_inputGlyphOrigin;
+
+ VGboolean m_masking;
+ VGboolean m_scissoring;
+
+ VGPixelLayout m_pixelLayout;
+
+ VGboolean m_filterFormatLinear;
+ VGboolean m_filterFormatPremultiplied;
+ VGbitfield m_filterChannelMask;
+
+ // Matrices
+ Matrix3x3 m_pathUserToSurface;
+ Matrix3x3 m_imageUserToSurface;
+ Matrix3x3 m_glyphUserToSurface;
+ Matrix3x3 m_fillPaintToUser;
+ Matrix3x3 m_strokePaintToUser;
+
+ VGPaint m_fillPaint;
+ VGPaint m_strokePaint;
+
+ VGboolean m_colorTransform;
+ RIfloat m_colorTransformValues[8];
+ RIfloat m_inputColorTransformValues[8];
+
+ VGErrorCode m_error;
+
+ ResourceManager<Image>* m_imageManager;
+ ResourceManager<Path>* m_pathManager;
+ ResourceManager<Paint>* m_paintManager;
+ ResourceManager<Font>* m_fontManager;
+ ResourceManager<Surface>* m_maskLayerManager;
+private:
+ Drawable* m_eglDrawable;
+
+ VGContext(const VGContext&); //!< Not allowed.
+ void operator=(const VGContext&); //!< Not allowed.
+};
+
+//==============================================================================================
+
+} //namespace tgOpenVG
+
+//==============================================================================================
+
+#endif /* __CONTEXT_H */
diff --git a/src/vg/Defs.h b/src/vg/Defs.h
new file mode 100644
index 0000000..4ef264e
--- /dev/null
+++ b/src/vg/Defs.h
@@ -0,0 +1,119 @@
+#ifndef __DEFS_H
+#define __DEFS_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Platform- and compiler-dependent type and macro definitions.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include <float.h>
+#include <math.h>
+#include <assert.h>
+#include <new> //for bad_alloc
+#include <cinttypes>
+
+namespace tgOpenVG
+{
+
+//=======================================================================
+
+typedef int RIint32;
+typedef unsigned int RIuint32;
+typedef short RIint16;
+typedef unsigned short RIuint16;
+typedef signed char RIint8;
+typedef unsigned char RIuint8;
+typedef float RIfloat32;
+
+
+typedef unsigned long RIuintptr;
+typedef signed long RIintptr;
+
+#define RI_UINT32_MAX (0xffffffffu)
+#define RI_INT32_MAX (0x7fffffff)
+#define RI_INT32_MIN (-0x7fffffff-1)
+
+/* maximum mantissa is 23 */
+#define RI_MANTISSA_BITS 23
+
+/* maximum exponent is 8 */
+#define RI_EXPONENT_BITS 8
+
+typedef union
+{
+ RIfloat32 f;
+ RIuint32 i;
+} RIfloatInt;
+
+inline float getFloatMax()
+{
+ RIfloatInt v;
+ v.i = (((1<<(RI_EXPONENT_BITS-1))-1+127) << 23) | (((1<<RI_MANTISSA_BITS)-1) << (23-RI_MANTISSA_BITS));
+ return v.f;
+}
+#define RI_FLOAT_MAX getFloatMax()
+
+#define RI_MAX_IMAGE_WIDTH 16384
+#define RI_MAX_IMAGE_HEIGHT 16384
+#define RI_MAX_IMAGE_PIXELS (RI_MAX_IMAGE_WIDTH*RI_MAX_IMAGE_HEIGHT)
+#define RI_MAX_IMAGE_BYTES (4*RI_MAX_IMAGE_WIDTH*RI_MAX_IMAGE_HEIGHT)
+#define RI_MAX_DASH_COUNT 256
+#define RI_MAX_COLOR_RAMP_STOPS 256
+#define RI_MAX_KERNEL_SIZE 256
+#define RI_MAX_SEPARABLE_KERNEL_SIZE 256
+#define RI_MAX_GAUSSIAN_STD_DEVIATION 16.0f
+#define RI_MAX_SCISSOR_RECTANGLES 256
+#define RI_MAX_EDGES 262144
+#define RI_MAX_SAMPLES 32
+#define RI_NUM_TESSELLATED_SEGMENTS 256
+
+#define RI_DEBUG
+
+#ifdef RI_DEBUG
+# define RI_ASSERT assert
+#else
+# define RI_ASSERT
+#endif
+
+#define RI_UNREF(X) ((void)(X))
+#define RI_APIENTRY
+
+#define RI_NEW(TYPE, PARAMS) (new TYPE PARAMS)
+#define RI_NEW_ARRAY(TYPE, ITEMS) (new TYPE[ITEMS])
+#define RI_DELETE(PARAMS) (delete (PARAMS))
+#define RI_DELETE_ARRAY(PARAMS) (delete[] (PARAMS))
+
+bool isValidImageFormat(int format);
+
+//=======================================================================
+
+} //namespace tgOpenVG
+
+#endif /* __DEFS_H */
diff --git a/src/vg/EGLAddOn.cpp b/src/vg/EGLAddOn.cpp
new file mode 100644
index 0000000..e8da666
--- /dev/null
+++ b/src/vg/EGLAddOn.cpp
@@ -0,0 +1,868 @@
+/*------------------------------------------------------------------------
+ *
+ * EGL 1.3
+ * -------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Simple implementation of EGL 1.3
+ * \note caveats:
+ - always renders into the backbuffer and blits it to window (no single buffered rendering)
+ - no native Windows or Mac OS X pixmap support
+ - no power management events
+ - no support for swap interval
+ * \todo what happens in egl functions when eglTerminate has been called but the context and surface are still in use?
+ * \todo OSDeinitMutex should be called in case getEGL fails.
+ *//*-------------------------------------------------------------------*/
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <EGL/egl.h>
+#include "VG/openvg.h"
+#include "Array.h"
+#include "Math.h"
+#include "Context.h"
+#include "Image.h"
+#include "esUtil.h"
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+void* OSGetCurrentThreadID(void);
+void OSAcquireMutex(void);
+void OSReleaseMutex(void);
+void OSDeinitMutex(void);
+
+EGLDisplay OSGetDisplay(EGLNativeDisplayType display_id);
+void* OSCreateWindowContext(EGLNativeWindowType window);
+void OSDestroyWindowContext(void* context);
+bool OSIsWindow(const void* context);
+void OSGetWindowSize(const void* context, int& width, int& height);
+void OSBlitToWindow(void* context, const Drawable* drawable);
+
+static pthread_mutex_t mutex;
+static int mutexRefCount = 0;
+static bool mutexInitialized = false;
+
+class RIEGLThread;
+
+void* OSGetCurrentThreadID(void)
+{
+ return (void*)pthread_self(); //TODO this is not safe
+}
+
+void OSAcquireMutex(void)
+{
+ if(!mutexInitialized)
+ {
+ int ret;
+ pthread_mutexattr_t attr;
+ ret = pthread_mutexattr_init(&attr); //initially not locked
+ RI_ASSERT(!ret); //check that there aren't any errors
+ ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); //count the number of recursive locks
+ RI_ASSERT(!ret); //check that there aren't any errors
+ ret = pthread_mutex_init(&mutex, &attr);
+ pthread_mutexattr_destroy(&attr);
+ RI_ASSERT(!ret); //check that there aren't more errors
+ RI_UNREF(ret);
+ mutexInitialized = true;
+ }
+ int ret = pthread_mutex_lock(&mutex);
+ RI_ASSERT(ret != EINVAL); //assert that the mutex has been initialized
+ RI_ASSERT(ret != EAGAIN); //assert that the maximum number of recursive locks hasn't been exceeded
+ RI_ASSERT(ret != EDEADLK); //recursive mutexes shouldn't return this
+ RI_ASSERT(!ret); //check that there aren't other errors
+ RI_UNREF(ret);
+ mutexRefCount++;
+}
+
+void OSReleaseMutex(void)
+{
+ RI_ASSERT(mutexInitialized);
+ mutexRefCount--;
+ RI_ASSERT(mutexRefCount >= 0);
+ int ret = pthread_mutex_unlock(&mutex);
+ RI_ASSERT(ret != EPERM); //assert that the current thread owns the mutex
+ RI_ASSERT(!ret); //check that there aren't more errors
+ RI_UNREF(ret);
+}
+
+
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class RIEGLConfig
+{
+public:
+ RIEGLConfig() : m_desc(Color::formatToDescriptor(VG_sRGBA_8888)), m_configID(0) {}
+ ~RIEGLConfig() {}
+ void set(int r, int g, int b, int a, int l, int bpp, int samples, int maskBits, int ID)
+ {
+ m_desc.redBits = r;
+ m_desc.greenBits = g;
+ m_desc.blueBits = b;
+ m_desc.alphaBits = a;
+ m_desc.luminanceBits = l;
+ m_desc.alphaShift = 0;
+ m_desc.luminanceShift = 0;
+ m_desc.blueShift = b ? a : 0;
+ m_desc.greenShift = g ? a + b : 0;
+ m_desc.redShift = r ? a + b + g : 0;
+ m_desc.format = (VGImageFormat)-1;
+ m_desc.internalFormat = l ? Color::sLA : Color::sRGBA;
+ m_desc.bitsPerPixel = bpp;
+ RI_ASSERT(Color::isValidDescriptor(m_desc));
+ m_samples = samples;
+ m_maskBits = maskBits;
+ m_configID = ID;
+ m_config = (EGLConfig)ID;
+ }
+
+ Color::Descriptor configToDescriptor(bool sRGB, bool premultiplied) const
+ {
+ Color::Descriptor desc = m_desc;
+ unsigned int f = m_desc.luminanceBits ? Color::LUMINANCE : 0;
+ f |= sRGB ? Color::NONLINEAR : 0;
+ f |= premultiplied ? Color::PREMULTIPLIED : 0;
+ desc.internalFormat = (Color::InternalFormat)f;
+ return desc;
+ }
+
+ //EGL RED SIZE bits of Red in the color buffer
+ //EGL GREEN SIZE bits of Green in the color buffer
+ //EGL BLUE SIZE bits of Blue in the color buffer
+ //EGL ALPHA SIZE bits of Alpha in the color buffer
+ //EGL LUMINANCE SIZE bits of Luminance in the color buffer
+ Color::Descriptor m_desc;
+ int m_samples;
+ int m_maskBits;
+ EGLint m_configID; //EGL CONFIG ID unique EGLConfig identifier
+ EGLConfig m_config;
+ //EGL BUFFER SIZE depth of the color buffer (sum of channel bits)
+ //EGL ALPHA MASK SIZE number alpha mask bits (always 8)
+ //EGL BIND TO TEXTURE RGB boolean True if bindable to RGB textures. (always EGL_FALSE)
+ //EGL BIND TO TEXTURE RGBA boolean True if bindable to RGBA textures. (always EGL_FALSE)
+ //EGL COLOR BUFFER TYPE enum color buffer type (EGL_RGB_BUFFER, EGL_LUMINANCE_BUFFER)
+ //EGL CONFIG CAVEAT enum any caveats for the configuration (always EGL_NONE)
+ //EGL DEPTH SIZE integer bits of Z in the depth buffer (always 0)
+ //EGL LEVEL integer frame buffer level (always 0)
+ //EGL MAX PBUFFER WIDTH integer maximum width of pbuffer (always INT_MAX)
+ //EGL MAX PBUFFER HEIGHT integer maximum height of pbuffer (always INT_MAX)
+ //EGL MAX PBUFFER PIXELS integer maximum size of pbuffer (always INT_MAX)
+ //EGL MAX SWAP INTERVAL integer maximum swap interval (always 1)
+ //EGL MIN SWAP INTERVAL integer minimum swap interval (always 1)
+ //EGL NATIVE RENDERABLE boolean EGL TRUE if native rendering APIs can render to surface (always EGL_FALSE)
+ //EGL NATIVE VISUAL ID integer handle of corresponding native visual (always 0)
+ //EGL NATIVE VISUAL TYPE integer native visual type of the associated visual (always EGL_NONE)
+ //EGL RENDERABLE TYPE bitmask which client rendering APIs are supported. (always EGL_OPENVG_BIT)
+ //EGL SAMPLE BUFFERS integer number of multisample buffers (always 0)
+ //EGL SAMPLES integer number of samples per pixel (always 0)
+ //EGL STENCIL SIZE integer bits of Stencil in the stencil buffer (always 0)
+ //EGL SURFACE TYPE bitmask which types of EGL surfaces are supported. (always EGL WINDOW BIT | EGL PIXMAP BIT | EGL PBUFFER BIT)
+ //EGL TRANSPARENT TYPE enum type of transparency supported (always EGL_NONE)
+ //EGL TRANSPARENT RED VALUE integer transparent red value (undefined)
+ //EGL TRANSPARENT GREEN VALUE integer transparent green value (undefined)
+ //EGL TRANSPARENT BLUE VALUE integer transparent blue value (undefined)
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class RIEGLContext
+{
+public:
+ RIEGLContext(VGContext* vgctx, const EGLConfig config);
+ ~RIEGLContext();
+ void addReference() { m_referenceCount++; }
+ int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+ VGContext* getVGContext() const { return m_vgContext; }
+ const EGLConfig getConfig() const { return m_config; }
+private:
+ RIEGLContext(const RIEGLContext&);
+ RIEGLContext& operator=(const RIEGLContext&);
+ VGContext* m_vgContext;
+ const EGLConfig m_config;
+ int m_referenceCount;
+};
+
+RIEGLContext::RIEGLContext(VGContext* vgctx, const EGLConfig config) :
+ m_vgContext(vgctx),
+ m_config(config),
+ m_referenceCount(0)
+{
+}
+RIEGLContext::~RIEGLContext()
+{
+ RI_ASSERT(m_referenceCount == 0);
+ RI_DELETE(m_vgContext);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class RIEGLSurface
+{
+public:
+ RIEGLSurface(void* OSWindowContext, const EGLConfig config, Drawable* drawable, bool largestPbuffer, int renderBuffer);
+ ~RIEGLSurface();
+ void addReference() { m_referenceCount++; }
+ int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+ void* getOSWindowContext() const { return m_OSWindowContext; }
+ const EGLConfig getConfig() const { return m_config; }
+ Drawable* getDrawable() const { return m_drawable; }
+ bool isLargestPbuffer() const { return m_largestPbuffer; }
+ int getRenderBuffer() const { return m_renderBuffer; }
+
+private:
+ RIEGLSurface(const RIEGLSurface&);
+ RIEGLSurface& operator=(const RIEGLSurface&);
+ void* m_OSWindowContext;
+ const EGLConfig m_config;
+ Drawable* m_drawable;
+ bool m_largestPbuffer;
+ int m_renderBuffer; //EGL_BACK_BUFFER or EGL_SINGLE_BUFFER
+ int m_referenceCount;
+};
+
+RIEGLSurface::RIEGLSurface(void* OSWindowContext, const EGLConfig config, Drawable* drawable, bool largestPbuffer, int renderBuffer) :
+ m_OSWindowContext(OSWindowContext),
+ m_config(config),
+ m_drawable(drawable),
+ m_largestPbuffer(largestPbuffer),
+ m_renderBuffer(renderBuffer),
+ m_referenceCount(0)
+{
+ RI_ASSERT(m_renderBuffer == EGL_BACK_BUFFER); //only back buffer rendering is supported
+ m_drawable->addReference();
+}
+
+RIEGLSurface::~RIEGLSurface()
+{
+ RI_ASSERT(m_referenceCount == 0);
+ // TAG FIX ME OSDestroyWindowContext(m_OSWindowContext);
+ if(m_drawable)
+ {
+ if(!m_drawable->removeReference())
+ RI_DELETE(m_drawable);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+#define EGL_NUMCONFIGS 60
+
+class RIEGLDisplay
+{
+public:
+ RIEGLDisplay(EGLDisplay id);
+ ~RIEGLDisplay();
+
+ int getNumConfigs() const { return EGL_NUMCONFIGS; }
+ const RIEGLConfig& getConfig(int i) const { RI_ASSERT(i >= 0 && i < EGL_NUMCONFIGS); return m_configs[i]; }
+ const RIEGLConfig& getConfig(const EGLConfig config) const { for(int i=0;i<EGL_NUMCONFIGS;i++) { if(m_configs[i].m_config == config) return m_configs[i]; } RI_ASSERT(0); return m_configs[0]; }
+
+ const EGLDisplay getID() const { return m_id; }
+
+ void addContext(RIEGLContext* ctx) { RI_ASSERT(ctx); m_contexts.push_back(ctx); } //throws bad_alloc
+ void removeContext(RIEGLContext* ctx) { RI_ASSERT(ctx); bool res = m_contexts.remove(ctx); RI_ASSERT(res); RI_UNREF(res); }
+
+ void addSurface(RIEGLSurface* srf) { RI_ASSERT(srf); m_surfaces.push_back(srf); } //throws bad_alloc
+ void removeSurface(RIEGLSurface* srf) { RI_ASSERT(srf); bool res = m_surfaces.remove(srf); RI_ASSERT(res); RI_UNREF(res); }
+
+ EGLBoolean contextExists(const EGLContext ctx) const;
+ EGLBoolean surfaceExists(const EGLSurface srf) const;
+ EGLBoolean configExists(const EGLConfig cfg) const;
+
+private:
+ RIEGLDisplay(const RIEGLDisplay& t);
+ RIEGLDisplay& operator=(const RIEGLDisplay&t);
+
+ EGLDisplay m_id;
+
+ Array<RIEGLContext*> m_contexts;
+ Array<RIEGLSurface*> m_surfaces;
+
+ RIEGLConfig m_configs[EGL_NUMCONFIGS];
+};
+
+RIEGLDisplay::RIEGLDisplay(EGLDisplay id) :
+ m_id(id),
+ m_contexts(),
+ m_surfaces()
+{
+ RI_ASSERT(EGL_NUMCONFIGS == 60);
+
+ //sorted by RGB/LUMINANCE (exact), larger total number of color bits (at least), buffer size (at least), config ID (exact)
+ //NOTE: 16 bit configs need to be sorted on the fly if the request ignores some channels
+ //NOTE: config IDs start from 1
+ // R B G A L bpp samples maskBits ID
+ m_configs[0].set(8, 8, 8, 8, 0, 32, 1, 8, 1); //EGL_RGB_BUFFER, buffer size = 32
+ m_configs[1].set(8, 8, 8, 0, 0, 32, 1, 8, 2); //EGL_RGB_BUFFER, buffer size = 24
+ m_configs[2].set(5, 5, 5, 1, 0, 16, 1, 4, 3); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[3].set(5, 6, 5, 0, 0, 16, 1, 4, 4); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[4].set(4, 4, 4, 4, 0, 16, 1, 4, 5); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[5].set(0, 0, 0, 8, 0, 8, 1, 8, 6); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[6].set(0, 0, 0, 4, 0, 4, 1, 4, 7); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[7].set(0, 0, 0, 1, 0, 1, 1, 1, 8); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[8].set(0, 0, 0, 0, 8, 8, 1, 8, 9); //EGL_LUMINANCE_BUFFER, buffer size = 8
+ m_configs[9].set(0, 0, 0, 0, 1, 1, 1, 1, 10); //EGL_LUMINANCE_BUFFER, buffer size = 1
+
+ m_configs[10].set(8, 8, 8, 8, 0, 32, 4, 1, 11); //EGL_RGB_BUFFER, buffer size = 32
+ m_configs[11].set(8, 8, 8, 0, 0, 32, 4, 1, 12); //EGL_RGB_BUFFER, buffer size = 24
+ m_configs[12].set(5, 5, 5, 1, 0, 16, 4, 1, 13); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[13].set(5, 6, 5, 0, 0, 16, 4, 1, 14); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[14].set(4, 4, 4, 4, 0, 16, 4, 1, 15); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[15].set(0, 0, 0, 8, 0, 8, 4, 1, 16); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[16].set(0, 0, 0, 4, 0, 4, 4, 1, 17); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[17].set(0, 0, 0, 1, 0, 1, 4, 1, 18); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[18].set(0, 0, 0, 0, 8, 8, 4, 1, 19); //EGL_LUMINANCE_BUFFER, buffer size = 8
+ m_configs[19].set(0, 0, 0, 0, 1, 1, 4, 1, 20); //EGL_LUMINANCE_BUFFER, buffer size = 1
+
+ m_configs[20].set(8, 8, 8, 8, 0, 32, 32, 1, 21); //EGL_RGB_BUFFER, buffer size = 32
+ m_configs[21].set(8, 8, 8, 0, 0, 32, 32, 1, 22); //EGL_RGB_BUFFER, buffer size = 24
+ m_configs[22].set(5, 5, 5, 1, 0, 16, 32, 1, 23); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[23].set(5, 6, 5, 0, 0, 16, 32, 1, 24); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[24].set(4, 4, 4, 4, 0, 16, 32, 1, 25); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[25].set(0, 0, 0, 8, 0, 8, 32, 1, 26); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[26].set(0, 0, 0, 4, 0, 4, 32, 1, 27); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[27].set(0, 0, 0, 1, 0, 1, 32, 1, 28); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[28].set(0, 0, 0, 0, 8, 8, 32, 1, 29); //EGL_LUMINANCE_BUFFER, buffer size = 8
+ m_configs[29].set(0, 0, 0, 0, 1, 1, 32, 1, 30); //EGL_LUMINANCE_BUFFER, buffer size = 1
+
+ //configs without mask
+ m_configs[30].set(8, 8, 8, 8, 0, 32, 1, 0, 31); //EGL_RGB_BUFFER, buffer size = 32
+ m_configs[31].set(8, 8, 8, 0, 0, 32, 1, 0, 32); //EGL_RGB_BUFFER, buffer size = 24
+ m_configs[32].set(5, 5, 5, 1, 0, 16, 1, 0, 33); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[33].set(5, 6, 5, 0, 0, 16, 1, 0, 34); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[34].set(4, 4, 4, 4, 0, 16, 1, 0, 35); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[35].set(0, 0, 0, 8, 0, 8, 1, 0, 36); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[36].set(0, 0, 0, 4, 0, 4, 1, 0, 37); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[37].set(0, 0, 0, 1, 0, 1, 1, 0, 38); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[38].set(0, 0, 0, 0, 8, 8, 1, 0, 39); //EGL_LUMINANCE_BUFFER, buffer size = 8
+ m_configs[39].set(0, 0, 0, 0, 1, 1, 1, 0, 40); //EGL_LUMINANCE_BUFFER, buffer size = 1
+
+ m_configs[40].set(8, 8, 8, 8, 0, 32, 4, 0, 41); //EGL_RGB_BUFFER, buffer size = 32
+ m_configs[41].set(8, 8, 8, 0, 0, 32, 4, 0, 42); //EGL_RGB_BUFFER, buffer size = 24
+ m_configs[42].set(5, 5, 5, 1, 0, 16, 4, 0, 43); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[43].set(5, 6, 5, 0, 0, 16, 4, 0, 44); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[44].set(4, 4, 4, 4, 0, 16, 4, 0, 45); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[45].set(0, 0, 0, 8, 0, 8, 4, 0, 46); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[46].set(0, 0, 0, 4, 0, 4, 4, 0, 47); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[47].set(0, 0, 0, 1, 0, 1, 4, 0, 48); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[48].set(0, 0, 0, 0, 8, 8, 4, 0, 49); //EGL_LUMINANCE_BUFFER, buffer size = 8
+ m_configs[49].set(0, 0, 0, 0, 1, 1, 4, 0, 50); //EGL_LUMINANCE_BUFFER, buffer size = 1
+
+ m_configs[50].set(8, 8, 8, 8, 0, 32, 32, 0, 51); //EGL_RGB_BUFFER, buffer size = 32
+ m_configs[51].set(8, 8, 8, 0, 0, 32, 32, 0, 52); //EGL_RGB_BUFFER, buffer size = 24
+ m_configs[52].set(5, 5, 5, 1, 0, 16, 32, 0, 53); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[53].set(5, 6, 5, 0, 0, 16, 32, 0, 54); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[54].set(4, 4, 4, 4, 0, 16, 32, 0, 55); //EGL_RGB_BUFFER, buffer size = 16
+ m_configs[55].set(0, 0, 0, 8, 0, 8, 32, 0, 56); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[56].set(0, 0, 0, 4, 0, 4, 32, 0, 57); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[57].set(0, 0, 0, 1, 0, 1, 32, 0, 58); //EGL_RGB_BUFFER, buffer size = 8
+ m_configs[58].set(0, 0, 0, 0, 8, 8, 32, 0, 59); //EGL_LUMINANCE_BUFFER, buffer size = 8
+ m_configs[59].set(0, 0, 0, 0, 1, 1, 32, 0, 60); //EGL_LUMINANCE_BUFFER, buffer size = 1
+/*
+attrib default criteria order priority
+--------------------------------------------------------------
+EGL_COLOR_BUFFER_TYPE EGL_RGB_BUFFER Exact None 2
+EGL_RED_SIZE 0 AtLeast Special 3
+EGL_GREEN_SIZE 0 AtLeast Special 3
+EGL_BLUE_SIZE 0 AtLeast Special 3
+EGL_LUMINANCE_SIZE 0 AtLeast Special 3
+EGL_ALPHA_SIZE 0 AtLeast Special 3
+EGL_BUFFER_SIZE 0 AtLeast Smaller 4
+EGL_CONFIG_ID EGL_DONT_CARE Exact Smaller 11
+*/
+}
+
+RIEGLDisplay::~RIEGLDisplay()
+{
+ //mark everything for deletion, but don't delete the current context and surface
+ for(int i=0;i<m_contexts.size();i++)
+ {
+ if(!m_contexts[i]->removeReference())
+ RI_DELETE(m_contexts[i]);
+ }
+ m_contexts.clear(); //remove all contexts from the list (makes further references to the current contexts invalid)
+
+ for(int i=0;i<m_surfaces.size();i++)
+ {
+ if(!m_surfaces[i]->removeReference())
+ RI_DELETE(m_surfaces[i]);
+ }
+ m_surfaces.clear(); //remove all surfaces from the list (makes further references to the current surfaces invalid)
+}
+
+EGLBoolean RIEGLDisplay::contextExists(const EGLContext ctx) const
+{
+ for(int i=0;i<m_contexts.size();i++)
+ {
+ if(m_contexts[i] == ctx)
+ return EGL_TRUE;
+ }
+ return EGL_FALSE;
+}
+
+EGLBoolean RIEGLDisplay::surfaceExists(const EGLSurface surf) const
+{
+ for(int i=0;i<m_surfaces.size();i++)
+ {
+ if(m_surfaces[i] == surf)
+ return EGL_TRUE;
+ }
+ return EGL_FALSE;
+}
+
+EGLBoolean RIEGLDisplay::configExists(const EGLConfig config) const
+{
+ for(int i=0;i<EGL_NUMCONFIGS;i++)
+ {
+ if(m_configs[i].m_config == config)
+ return EGL_TRUE;
+ }
+ return EGL_FALSE;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class RIEGLThread
+{
+public:
+ RIEGLThread(void* currentThreadID);
+ ~RIEGLThread();
+
+ void* getThreadID() const { return m_threadID; }
+
+ void makeCurrent(RIEGLContext* c, RIEGLSurface* s) { m_context = c; m_surface = s; }
+ RIEGLContext* getCurrentContext() const { return m_context; }
+ RIEGLSurface* getCurrentSurface() const { return m_surface; }
+
+ void setError(EGLint error) { m_error = error; }
+ EGLint getError() const { return m_error; }
+
+ void bindAPI(EGLint api) { m_boundAPI = api; }
+ EGLint getBoundAPI() const { return m_boundAPI; }
+
+private:
+ RIEGLThread(const RIEGLThread&);
+ RIEGLThread operator=(const RIEGLThread&);
+
+ RIEGLContext* m_context;
+ RIEGLSurface* m_surface;
+ EGLint m_error;
+ void* m_threadID;
+ EGLint m_boundAPI;
+};
+
+RIEGLThread::RIEGLThread(void* currentThreadID) :
+ m_context(NULL),
+ m_surface(NULL),
+ m_error(EGL_SUCCESS),
+ m_threadID(currentThreadID),
+ m_boundAPI(EGL_NONE)
+{
+}
+
+RIEGLThread::~RIEGLThread()
+{
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class EGL
+{
+public:
+ EGL();
+ ~EGL();
+
+ void addReference() { m_referenceCount++; }
+ int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+ void addDisplay(RIEGLDisplay* display) { RI_ASSERT(display); m_displays.push_back(display); } //throws bad alloc
+ void removeDisplay(RIEGLDisplay* display) { RI_ASSERT(display); bool res = m_displays.remove(display); RI_ASSERT(res); RI_UNREF(res); }
+ RIEGLDisplay* getDisplay(const EGLDisplay displayID) const;
+ const EGLDisplay findDisplay(const EGLContext ctx) const;
+
+ void addCurrentThread(RIEGLThread* thread) { RI_ASSERT(thread); m_currentThreads.push_back(thread); } //throws bad alloc
+ void removeCurrentThread(RIEGLThread* thread) { RI_ASSERT(thread); bool res = m_currentThreads.remove(thread); RI_ASSERT(res); RI_UNREF(res); }
+ RIEGLThread* getCurrentThread() const;
+
+ RIEGLThread* getThread();
+ void destroyThread();
+
+ bool isInUse(const void* image) const;
+
+private:
+ EGL(const EGL&); // Not allowed.
+ const EGL& operator=(const EGL&); // Not allowed.
+
+ Array<RIEGLThread*> m_threads; //threads that have called EGL
+ Array<RIEGLThread*> m_currentThreads; //threads that have a bound context
+ Array<RIEGLDisplay*> m_displays;
+
+ int m_referenceCount;
+};
+
+EGL::EGL() :
+ m_displays(),
+ m_threads(),
+ m_currentThreads(),
+ m_referenceCount(0)
+{
+}
+EGL::~EGL()
+{
+ for(int i=0;i<m_displays.size();i++)
+ {
+ RI_DELETE(m_displays[i]);
+ }
+ for(int i=0;i<m_threads.size();i++)
+ {
+ RI_DELETE(m_threads[i]);
+ }
+ //currentThreads contain just pointers to threads we just deleted
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static EGL* g_egl = NULL; //never use this directly
+static EGL* getEGL()
+{
+ if(!g_egl)
+ {
+ try
+ {
+ g_egl = RI_NEW(EGL, ()); //throws bad_alloc
+ g_egl->addReference();
+ }
+ catch(std::bad_alloc)
+ {
+ g_egl = NULL;
+ }
+ }
+ return g_egl;
+}
+static void releaseEGL()
+{
+ if(g_egl)
+ {
+ if(!g_egl->removeReference())
+ {
+ RI_DELETE(g_egl);
+ g_egl = NULL;
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Given a display ID, return the corresponding object, or NULL
+* if the ID hasn't been initialized.
+* \param
+* \return
+* \note if egl has been initialized for this display, the display ID can
+* be found from egl->m_displays
+*//*-------------------------------------------------------------------*/
+
+RIEGLDisplay* EGL::getDisplay(EGLDisplay displayID) const
+{
+ for(int i=0;i<m_displays.size();i++)
+ {
+ if(displayID == m_displays[i]->getID())
+ return m_displays[i];
+ }
+ return NULL; //error: the display hasn't been eglInitialized
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief return EGLDisplay for the current context
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+const EGLDisplay EGL::findDisplay(EGLContext ctx) const
+{
+ for(int i=0;i<m_displays.size();i++)
+ {
+ if(m_displays[i]->contextExists(ctx))
+ return m_displays[i]->getID();
+ }
+ return EGL_NO_DISPLAY;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief return an EGL thread struct for the thread made current, or
+* NULL if there's no current context.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+RIEGLThread* EGL::getCurrentThread() const
+{
+ void* currentThreadID = OSGetCurrentThreadID();
+ for(int i=0;i<m_currentThreads.size();i++)
+ {
+ if(currentThreadID == m_currentThreads[i]->getThreadID())
+ return m_currentThreads[i];
+ }
+ return NULL; //thread is not current
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief return an EGL thread struct corresponding to current OS thread.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+RIEGLThread* EGL::getThread()
+{
+ void* currentThreadID = OSGetCurrentThreadID();
+ for(int i=0;i<m_threads.size();i++)
+ {
+ if(currentThreadID == m_threads[i]->getThreadID())
+ return m_threads[i];
+ }
+
+ //EGL doesn't have a struct for the thread yet, add it to EGL's list
+ RIEGLThread* newThread = NULL;
+ try
+ {
+ newThread = RI_NEW(RIEGLThread, (OSGetCurrentThreadID())); //throws bad_alloc
+ m_threads.push_back(newThread); //throws bad_alloc
+ return newThread;
+ }
+ catch(std::bad_alloc)
+ {
+ RI_DELETE(newThread);
+ return NULL;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief destroy an EGL thread struct
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void EGL::destroyThread()
+{
+ void* currentThreadID = OSGetCurrentThreadID();
+ for(int i=0;i<m_threads.size();i++)
+ {
+ if(currentThreadID == m_threads[i]->getThreadID())
+ {
+ RIEGLThread* thread = m_threads[i];
+ bool res = m_threads.remove(thread);
+ RI_ASSERT(res);
+ RI_UNREF(res);
+ RI_DELETE(thread);
+ break;
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool EGL::isInUse(const void* image) const
+{
+ for(int i=0;i<m_currentThreads.size();i++)
+ {
+ RIEGLSurface* s = m_currentThreads[i]->getCurrentSurface();
+ if(s && s->getDrawable() && s->getDrawable()->isInUse((Image*)image))
+ return true;
+ }
+ return false;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+#define EGL_GET_DISPLAY(DISPLAY, RETVAL) \
+ OSAcquireMutex(); \
+ EGL* egl = getEGL(); \
+ if(!egl) \
+ { \
+ OSReleaseMutex(); \
+ return RETVAL; \
+ } \
+ RIEGLDisplay* display = egl->getDisplay(DISPLAY); \
+
+#define EGL_GET_EGL(RETVAL) \
+ OSAcquireMutex(); \
+ EGL* egl = getEGL(); \
+ if(!egl) \
+ { \
+ OSReleaseMutex(); \
+ return RETVAL; \
+ } \
+
+#define EGL_IF_ERROR(COND, ERRORCODE, RETVAL) \
+ if(COND) { eglSetError(egl, ERRORCODE); OSReleaseMutex(); return RETVAL; } \
+
+#define EGL_RETURN(ERRORCODE, RETVAL) \
+ { \
+ eglSetError(egl, ERRORCODE); \
+ OSReleaseMutex(); \
+ return RETVAL; \
+ }
+
+// Note: egl error handling model differs from OpenVG. The latest error is stored instead of the oldest one.
+static void eglSetError(EGL* egl, EGLint error)
+{
+ RIEGLThread* thread = egl->getThread();
+ if(thread)
+ thread->setError(error);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns the OpenVG context current to the calling thread.
+* \param
+* \return
+* \note This function is always called from a mutexed API function
+*//*-------------------------------------------------------------------*/
+
+void* eglvgGetCurrentVGContext(void)
+{
+ EGL* egl = getEGL();
+ if(egl)
+ {
+ RIEGLThread* thread = egl->getCurrentThread();
+ if(thread)
+ {
+ RI_ASSERT(thread->getCurrentContext() && thread->getCurrentSurface());
+ return thread->getCurrentContext()->getVGContext();
+ }
+ }
+ return NULL; //not initialized or made current
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Check if the image is current in any of the displays
+* \param
+* \return
+* \note This function is always called from a mutexed API function
+*//*-------------------------------------------------------------------*/
+
+bool eglvgIsInUse(void* image)
+{
+ EGL* egl = getEGL();
+ if(egl)
+ {
+ return egl->isInUse(image);
+ }
+ return false;
+}
+
+//==============================================================================================
+
+} //namespace tgOpenVG
+
+using namespace tgOpenVG;
+
+extern "C"
+void tgOpenVGCreateContext(ESContext *esContext) {
+
+ EGL* egl = getEGL();
+
+ RIEGLThread* thread = egl->getThread();
+ tgOpenVG::VGContext* vgctx = NULL;
+ RIEGLContext* c = NULL;
+
+ try {
+ vgctx = RI_NEW(tgOpenVG::VGContext, (NULL)); //throws bad_alloc
+ c = RI_NEW(RIEGLContext, (vgctx, esContext->eglConfig)); //throws bad_alloc
+ esContext->vgContext = vgctx;
+
+ }
+ catch (std::bad_alloc) {
+ }
+}
+
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static bool smaller(EGLint c, EGLint filter)
+{
+ return (filter != EGL_DONT_CARE) && (c < filter);
+}
+
diff --git a/src/vg/Font.cpp b/src/vg/Font.cpp
new file mode 100644
index 0000000..c63c129
--- /dev/null
+++ b/src/vg/Font.cpp
@@ -0,0 +1,203 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Implementation of Font class.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Font.h"
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief Font constructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Font::Font(int capacityHint) :
+ m_referenceCount(0),
+ m_glyphs()
+{
+ RI_ASSERT(capacityHint >= 0);
+ m_glyphs.reserve(capacityHint);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Font destructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Font::~Font()
+{
+ //remove references to paths and images
+ for(int i=0;i<m_glyphs.size();i++)
+ clearGlyph(&m_glyphs[i]);
+ RI_ASSERT(m_referenceCount == 0);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Find a glyph based on glyphIndex.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Font::Glyph* Font::findGlyph(unsigned int index)
+{
+ for(int i=0;i<m_glyphs.size();i++)
+ {
+ if(m_glyphs[i].m_state != Glyph::GLYPH_UNINITIALIZED && m_glyphs[i].m_index == index)
+ return &m_glyphs[i];
+ }
+ return NULL;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Find a free glyph or allocate a new one.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Font::Glyph* Font::newGlyph()
+{
+ for(int i=0;i<m_glyphs.size();i++)
+ {
+ if(m_glyphs[i].m_state == Glyph::GLYPH_UNINITIALIZED)
+ return &m_glyphs[i];
+ }
+ m_glyphs.resize(m_glyphs.size()+1);
+ return &m_glyphs[m_glyphs.size()-1];
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Free glyph and its data.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Font::clearGlyph(Glyph* g)
+{
+ RI_ASSERT(g);
+ if(g->m_path != VG_INVALID_HANDLE)
+ {
+ Path* p = (Path*)g->m_path;
+ if(!p->removeReference())
+ RI_DELETE(p);
+ }
+ if(g->m_image != VG_INVALID_HANDLE)
+ {
+ Image* p = (Image*)g->m_image;
+ p->removeInUse();
+ if(!p->removeReference())
+ RI_DELETE(p);
+ }
+ Glyph a;
+ *g = a;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Font::setGlyphToPath(unsigned int index, VGPath path, bool isHinted, const Vector2& origin, const Vector2& escapement)
+{
+ Glyph* g = findGlyph(index);
+ if(g)
+ { //glyph exists, replace
+ clearGlyph(g);
+ }
+ else
+ { //glyph doesn't exist, allocate a new one
+ g = newGlyph();
+ }
+
+ g->m_index = index;
+ g->m_state = Glyph::GLYPH_PATH;
+ g->m_path = path;
+ g->m_image = VG_INVALID_HANDLE;
+ g->m_isHinted = isHinted;
+ g->m_origin = origin;
+ g->m_escapement = escapement;
+
+ if(path != VG_INVALID_HANDLE)
+ {
+ Path* p = (Path*)path;
+ p->addReference();
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Font::setGlyphToImage(unsigned int index, VGImage image, const Vector2& origin, const Vector2& escapement)
+{
+ Glyph* g = findGlyph(index);
+ if(g)
+ { //glyph exists, replace
+ clearGlyph(g);
+ }
+ else
+ { //glyph doesn't exist, allocate a new one
+ g = newGlyph();
+ }
+
+ g->m_index = index;
+ g->m_state = Glyph::GLYPH_IMAGE;
+ g->m_path = VG_INVALID_HANDLE;
+ g->m_image = image;
+ g->m_isHinted = false;
+ g->m_origin = origin;
+ g->m_escapement = escapement;
+
+ if(image != VG_INVALID_HANDLE)
+ {
+ Image* p = (Image*)image;
+ p->addReference();
+ p->addInUse();
+ }
+}
+
+//=======================================================================
+
+} //namespace tgOpenVG
diff --git a/src/vg/Font.h b/src/vg/Font.h
new file mode 100644
index 0000000..ca29cb7
--- /dev/null
+++ b/src/vg/Font.h
@@ -0,0 +1,102 @@
+#ifndef __FONT_H
+#define __FONT_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief VGContext class. Used for storing OpenVG state.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "VG/openvg.h"
+#include "Math.h"
+#include "Array.h"
+#include "Path.h"
+#include "Image.h"
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief Storage and operations for VGFont.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class Font
+{
+public:
+ struct Glyph
+ {
+ enum State
+ {
+ GLYPH_UNINITIALIZED = 0,
+ GLYPH_PATH = 1,
+ GLYPH_IMAGE = 2
+ };
+ Glyph() { m_state = GLYPH_UNINITIALIZED; m_path = m_image = VG_INVALID_HANDLE; m_isHinted = false; m_origin.set(0.0f, 0.0f); m_escapement.set(0.0f, 0.0f); }
+ unsigned int m_index;
+ State m_state;
+ VGPath m_path;
+ VGImage m_image;
+ bool m_isHinted;
+ Vector2 m_origin;
+ Vector2 m_escapement;
+ };
+
+ Font(int capacityHint); //throws bad_alloc
+ ~Font();
+
+ int getNumGlyphs() const { int n=0; for(int i=0;i<m_glyphs.size();i++) { if(m_glyphs[i].m_state != Glyph::GLYPH_UNINITIALIZED) n++; } return n; }
+ void addReference() { m_referenceCount++; }
+ int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+ void setGlyphToPath(unsigned int index, VGPath path, bool isHinted, const Vector2& origin, const Vector2& escapement); //throws bad_alloc
+ void setGlyphToImage(unsigned int index, VGImage image, const Vector2& origin, const Vector2& escapement); //throws bad_alloc
+ Glyph* findGlyph(unsigned int index);
+ void clearGlyph(Glyph* g);
+private:
+ Font(const Font&); //!< Not allowed.
+ void operator=(const Font&); //!< Not allowed.
+
+ Glyph* newGlyph(); //throws bad_alloc
+
+ int m_referenceCount;
+ Array<Glyph> m_glyphs;
+};
+
+//=======================================================================
+
+} //namespace tgOpenVG
+
+//=======================================================================
+
+#endif /* __FONT_H */
diff --git a/src/vg/Image.cpp b/src/vg/Image.cpp
new file mode 100644
index 0000000..1d3c407
--- /dev/null
+++ b/src/vg/Image.cpp
@@ -0,0 +1,2675 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Implementation of Color and Image functions.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Image.h"
+#include "Rasterizer.h"
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+
+/*-------------------------------------------------------------------*//*!
+* \brief Converts from numBits into a shifted mask
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static unsigned int bitsToMask(unsigned int bits, unsigned int shift)
+{
+ return ((1<<bits)-1) << shift;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Converts from color (RIfloat) to an int with 1.0f mapped to the
+* given maximum with round-to-nearest semantics.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static unsigned int colorToInt(RIfloat c, int maxc)
+{
+ return RI_INT_MIN(RI_INT_MAX((int)floor(c * (RIfloat)maxc + 0.5f), 0), maxc);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Converts from int to color (RIfloat) with the given maximum
+* mapped to 1.0f.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static inline RIfloat intToColor(unsigned int i, unsigned int maxi)
+{
+ return (RIfloat)(i & maxi) / (RIfloat)maxi;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Converts from packed integer in a given format to a Color.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Color::unpack(unsigned int inputData, const Color::Descriptor& inputDesc)
+{
+ int rb = inputDesc.redBits;
+ int gb = inputDesc.greenBits;
+ int bb = inputDesc.blueBits;
+ int ab = inputDesc.alphaBits;
+ int lb = inputDesc.luminanceBits;
+ int rs = inputDesc.redShift;
+ int gs = inputDesc.greenShift;
+ int bs = inputDesc.blueShift;
+ int as = inputDesc.alphaShift;
+ int ls = inputDesc.luminanceShift;
+
+ m_format = inputDesc.internalFormat;
+ if(lb)
+ { //luminance
+ r = g = b = intToColor(inputData >> ls, (1<<lb)-1);
+ a = 1.0f;
+ }
+ else
+ { //rgba
+ r = rb ? intToColor(inputData >> rs, (1<<rb)-1) : (RIfloat)1.0f;
+ g = gb ? intToColor(inputData >> gs, (1<<gb)-1) : (RIfloat)1.0f;
+ b = bb ? intToColor(inputData >> bs, (1<<bb)-1) : (RIfloat)1.0f;
+ a = ab ? intToColor(inputData >> as, (1<<ab)-1) : (RIfloat)1.0f;
+
+ if(isPremultiplied())
+ { //clamp premultiplied color to alpha to enforce consistency
+ r = RI_MIN(r, a);
+ g = RI_MIN(g, a);
+ b = RI_MIN(b, a);
+ }
+ }
+
+ assertConsistency();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Converts from Color to a packed integer in a given format.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+unsigned int Color::pack(const Color::Descriptor& outputDesc) const
+{
+ assertConsistency();
+
+ int rb = outputDesc.redBits;
+ int gb = outputDesc.greenBits;
+ int bb = outputDesc.blueBits;
+ int ab = outputDesc.alphaBits;
+ int lb = outputDesc.luminanceBits;
+ int rs = outputDesc.redShift;
+ int gs = outputDesc.greenShift;
+ int bs = outputDesc.blueShift;
+ int as = outputDesc.alphaShift;
+ int ls = outputDesc.luminanceShift;
+
+ if(lb)
+ { //luminance
+ RI_ASSERT(isLuminance());
+ return colorToInt(r, (1<<lb)-1) << ls;
+ }
+ else
+ { //rgb
+ RI_ASSERT(!isLuminance());
+ unsigned int cr = rb ? colorToInt(r, (1<<rb)-1) : 0;
+ unsigned int cg = gb ? colorToInt(g, (1<<gb)-1) : 0;
+ unsigned int cb = bb ? colorToInt(b, (1<<bb)-1) : 0;
+ unsigned int ca = ab ? colorToInt(a, (1<<ab)-1) : 0;
+ return (cr << rs) | (cg << gs) | (cb << bs) | (ca << as);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Converts from the current internal format to another.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static RIfloat gamma(RIfloat c)
+{
+ if( c <= 0.00304f )
+ c *= 12.92f;
+ else
+ c = 1.0556f * (RIfloat)pow(c, 1.0f/2.4f) - 0.0556f;
+ return c;
+}
+
+static RIfloat invgamma(RIfloat c)
+{
+ if( c <= 0.03928f )
+ c /= 12.92f;
+ else
+ c = (RIfloat)pow((c + 0.0556f)/1.0556f, 2.4f);
+ return c;
+}
+
+static RIfloat lRGBtoL(RIfloat r, RIfloat g, RIfloat b)
+{
+ return 0.2126f*r + 0.7152f*g + 0.0722f*b;
+}
+
+void Color::convert(InternalFormat outputFormat)
+{
+ assertConsistency();
+
+ if( m_format == outputFormat )
+ return;
+
+ if(isPremultiplied())
+ { //unpremultiply
+ RIfloat ooa = (a != 0.0f) ? 1.0f / a : (RIfloat)0.0f;
+ r *= ooa;
+ g *= ooa;
+ b *= ooa;
+ }
+
+ //From Section 3.4.2 of OpenVG spec
+ //1: sRGB = gamma(lRGB)
+ //2: lRGB = invgamma(sRGB)
+ //3: lL = 0.2126 lR + 0.7152 lG + 0.0722 lB
+ //4: lRGB = lL
+ //5: sL = gamma(lL)
+ //6: lL = invgamma(sL)
+ //7: sRGB = sL
+
+ //Source/Dest lRGB sRGB lL sL
+ //lRGB - 1 3 3,5
+ //sRGB 2 - 2,3 2,3,5
+ //lL 4 4,1 - 5
+ //sL 7,2 7 6 -
+
+ const unsigned int shift = 3;
+ unsigned int conversion = (m_format & (NONLINEAR | LUMINANCE)) | ((outputFormat & (NONLINEAR | LUMINANCE)) << shift);
+
+ switch(conversion)
+ {
+ case lRGBA | (sRGBA << shift): r = gamma(r); g = gamma(g); b = gamma(b); break; //1
+ case lRGBA | (lLA << shift) : r = g = b = lRGBtoL(r, g, b); break; //3
+ case lRGBA | (sLA << shift) : r = g = b = gamma(lRGBtoL(r, g, b)); break; //3,5
+ case sRGBA | (lRGBA << shift): r = invgamma(r); g = invgamma(g); b = invgamma(b); break; //2
+ case sRGBA | (lLA << shift) : r = g = b = lRGBtoL(invgamma(r), invgamma(g), invgamma(b)); break; //2,3
+ case sRGBA | (sLA << shift) : r = g = b = gamma(lRGBtoL(invgamma(r), invgamma(g), invgamma(b))); break;//2,3,5
+ case lLA | (lRGBA << shift): break; //4
+ case lLA | (sRGBA << shift): r = g = b = gamma(r); break; //4,1
+ case lLA | (sLA << shift) : r = g = b = gamma(r); break; //5
+ case sLA | (lRGBA << shift): r = g = b = invgamma(r); break; //7,2
+ case sLA | (sRGBA << shift): break; //7
+ case sLA | (lLA << shift) : r = g = b = invgamma(r); break; //6
+ default: RI_ASSERT((m_format & (LUMINANCE | NONLINEAR)) == (outputFormat & (LUMINANCE | NONLINEAR))); break; //nop
+ }
+
+ if(outputFormat & PREMULTIPLIED)
+ { //premultiply
+ r *= a;
+ g *= a;
+ b *= a;
+ }
+ m_format = outputFormat;
+
+ assertConsistency();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Creates a pixel format descriptor out of VGImageFormat
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Color::Descriptor Color::formatToDescriptor(VGImageFormat format)
+{
+ Descriptor desc;
+ memset(&desc, 0, sizeof(Descriptor));
+ RI_ASSERT(isValidImageFormat(format));
+
+ int baseFormat = (int)format & 15;
+ const int numBaseFormats = 15;
+ RI_ASSERT(baseFormat >= 0 && baseFormat < numBaseFormats);
+ int swizzleBits = ((int)format >> 6) & 3;
+
+ /* base formats
+ VG_sRGBX_8888 = 0,
+ VG_sRGBA_8888 = 1,
+ VG_sRGBA_8888_PRE = 2,
+ VG_sRGB_565 = 3,
+ VG_sRGBA_5551 = 4,
+ VG_sRGBA_4444 = 5,
+ VG_sL_8 = 6,
+ VG_lRGBX_8888 = 7,
+ VG_lRGBA_8888 = 8,
+ VG_lRGBA_8888_PRE = 9,
+ VG_lL_8 = 10,
+ VG_A_8 = 11,
+ VG_BW_1 = 12,
+ VG_A_1 = 13,
+ VG_A_4 = 14,
+ */
+
+ static const int redBits[numBaseFormats] = {8, 8, 8, 5, 5, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0};
+ static const int greenBits[numBaseFormats] = {8, 8, 8, 6, 5, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0};
+ static const int blueBits[numBaseFormats] = {8, 8, 8, 5, 5, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0};
+ static const int alphaBits[numBaseFormats] = {0, 8, 8, 0, 1, 4, 0, 0, 8, 8, 0, 8, 0, 1, 4};
+ static const int luminanceBits[numBaseFormats] = {0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 8, 0, 1, 0, 0};
+
+ static const int redShifts[4*numBaseFormats] = {24, 24, 24, 11, 11, 12, 0, 24, 24, 24, 0, 0, 0, 0, 0, //RGBA
+ 16, 16, 16, 11, 10, 8, 0, 16, 16, 16, 0, 0, 0, 0, 0, //ARGB
+ 8, 8, 8, 0, 1, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0, //BGRA
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //ABGR
+
+ static const int greenShifts[4*numBaseFormats] = {16, 16, 16, 5, 6, 8, 0, 16, 16, 16, 0, 0, 0, 0, 0, //RGBA
+ 8, 8, 8, 5, 5, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0, //ARGB
+ 16, 16, 16, 5, 6, 8, 0, 16, 16, 16, 0, 0, 0, 0, 0, //BGRA
+ 8, 8, 8, 5, 5, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0};//ABGR
+
+ static const int blueShifts[4*numBaseFormats] = {8, 8, 8, 0, 1, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0, //RGBA
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //ARGB
+ 24, 24, 24, 11, 11, 12, 0, 24, 24, 24, 0, 0, 0, 0, 0, //BGRA
+ 16, 16, 16, 11, 10, 8, 0, 16, 16, 16, 0, 0, 0, 0, 0};//ABGR
+
+ static const int alphaShifts[4*numBaseFormats] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //RGBA
+ 0, 24, 24, 0, 15, 12, 0, 0, 24, 24, 0, 0, 0, 0, 0, //ARGB
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //BGRA
+ 0, 24, 24, 0, 15, 12, 0, 0, 24, 24, 0, 0, 0, 0, 0};//ABGR
+
+ static const int bpps[numBaseFormats] = {32, 32, 32, 16, 16, 16, 8, 32, 32, 32, 8, 8, 1, 1, 4};
+
+ static const InternalFormat internalFormats[numBaseFormats] = {sRGBA, sRGBA, sRGBA_PRE, sRGBA, sRGBA, sRGBA, sLA, lRGBA, lRGBA, lRGBA_PRE, lLA, lRGBA, lLA, lRGBA, lRGBA};
+
+ desc.redBits = redBits[baseFormat];
+ desc.greenBits = greenBits[baseFormat];
+ desc.blueBits = blueBits[baseFormat];
+ desc.alphaBits = alphaBits[baseFormat];
+ desc.luminanceBits = luminanceBits[baseFormat];
+
+ desc.redShift = redShifts[swizzleBits * numBaseFormats + baseFormat];
+ desc.greenShift = greenShifts[swizzleBits * numBaseFormats + baseFormat];
+ desc.blueShift = blueShifts[swizzleBits * numBaseFormats + baseFormat];
+ desc.alphaShift = alphaShifts[swizzleBits * numBaseFormats + baseFormat];
+ desc.luminanceShift = 0; //always zero
+
+ desc.format = format;
+ desc.bitsPerPixel = bpps[baseFormat];
+ desc.internalFormat = internalFormats[baseFormat];
+
+ return desc;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Checks if the pixel format descriptor is valid (i.e. all the
+* values are supported by the RI)
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool Color::isValidDescriptor(const Color::Descriptor& desc)
+{
+ //A valid descriptor has 1, 2, 4, 8, 16, or 32 bits per pixel, and either luminance or rgba channels, but not both.
+ //Any of the rgba channels can be missing, and not all bits need to be used. Maximum channel bit depth is 8.
+ int rb = desc.redBits;
+ int gb = desc.greenBits;
+ int bb = desc.blueBits;
+ int ab = desc.alphaBits;
+ int lb = desc.luminanceBits;
+ int rs = desc.redShift;
+ int gs = desc.greenShift;
+ int bs = desc.blueShift;
+ int as = desc.alphaShift;
+ int ls = desc.luminanceShift;
+ int bpp = desc.bitsPerPixel;
+
+ int rgbaBits = rb + gb + bb + ab;
+ if(rb < 0 || rb > 8 || rs < 0 || rs + rb > bpp || !(rb || !rs))
+ return false; //invalid channel description
+ if(gb < 0 || gb > 8 || gs < 0 || gs + gb > bpp || !(gb || !gs))
+ return false; //invalid channel description
+ if(bb < 0 || bb > 8 || bs < 0 || bs + bb > bpp || !(bb || !bs))
+ return false; //invalid channel description
+ if(ab < 0 || ab > 8 || as < 0 || as + ab > bpp || !(ab || !as))
+ return false; //invalid channel description
+ if(lb < 0 || lb > 8 || ls < 0 || ls + lb > bpp || !(lb || !ls))
+ return false; //invalid channel description
+
+ if(rgbaBits && lb)
+ return false; //can't have both rgba and luminance
+ if(!rgbaBits && !lb)
+ return false; //must have either rgba or luminance
+ if(rgbaBits)
+ { //rgba
+ if(rb+gb+bb == 0)
+ { //alpha only
+ if(rs || gs || bs || as || ls)
+ return false; //wrong shifts (even alpha shift must be zero)
+ if((ab != 1 && ab != 2 && ab != 4 && ab != 8) || bpp != ab)
+ return false; //alpha size must be 1, 2, 4, or, 8, bpp must match
+ }
+ else
+ { //rgba
+ if(rgbaBits > bpp)
+ return false; //bpp must be greater than or equal to the sum of rgba bits
+ if(!(bpp == 32 || bpp == 16 || bpp == 8))
+ return false; //only 1, 2, and 4 byte formats are supported for rgba
+
+ unsigned int rm = bitsToMask((unsigned int)rb, (unsigned int)rs);
+ unsigned int gm = bitsToMask((unsigned int)gb, (unsigned int)gs);
+ unsigned int bm = bitsToMask((unsigned int)bb, (unsigned int)bs);
+ unsigned int am = bitsToMask((unsigned int)ab, (unsigned int)as);
+ if((rm & gm) || (rm & bm) || (rm & am) || (gm & bm) || (gm & am) || (bm & am))
+ return false; //channels overlap
+ }
+ }
+ else
+ { //luminance
+ if(rs || gs || bs || as || ls)
+ return false; //wrong shifts (even luminance shift must be zero)
+ if(!(lb == 1 || lb == 8) || bpp != lb)
+ return false; //luminance size must be either 1 or 8, bpp must match
+ }
+
+ if(desc.format != -1)
+ {
+ if(!isValidImageFormat(desc.format))
+ return false; //invalid image format
+
+ Descriptor d = formatToDescriptor(desc.format);
+ if(d.redBits != rb || d.greenBits != gb || d.blueBits != bb || d.alphaBits != ab || d.luminanceBits != lb ||
+ d.redShift != rs || d.greenShift != gs || d.blueShift != bs || d.alphaShift != as || d.luminanceShift != ls ||
+ d.bitsPerPixel != bpp)
+ return false; //if the descriptor has a VGImageFormat, it must match the bits, shifts, and bpp
+ }
+
+ if((unsigned int)desc.internalFormat & ~(Color::PREMULTIPLIED | Color::NONLINEAR | Color::LUMINANCE))
+ return false; //invalid internal format
+
+ return true;
+}
+
+//==============================================================================================
+
+
+
+
+//==============================================================================================
+
+/*-------------------------------------------------------------------*//*!
+* \brief Constructs a blank image.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Image::Image(const Color::Descriptor& desc, int width, int height, VGbitfield allowedQuality) :
+ m_desc(desc),
+ m_width(width),
+ m_height(height),
+ m_allowedQuality(allowedQuality),
+ m_inUse(0),
+ m_stride(0),
+ m_data(NULL),
+ m_referenceCount(0),
+ m_ownsData(true),
+ m_parent(NULL),
+ m_storageOffsetX(0),
+ m_storageOffsetY(0),
+ m_mipmapsValid(false),
+ m_mipmaps()
+{
+ RI_ASSERT(Color::isValidDescriptor(m_desc));
+ RI_ASSERT(width > 0 && height > 0);
+
+ m_stride = (m_width*m_desc.bitsPerPixel+7)/8;
+
+ m_data = RI_NEW_ARRAY(RIuint8, m_stride*m_height); //throws bad_alloc
+ memset(m_data, 0, m_stride*m_height); //clear image
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Constructs an image that uses an external array for its data
+* storage.
+* \param
+* \return
+* \note this is meant for internal use to make blitting easier
+*//*-------------------------------------------------------------------*/
+
+Image::Image(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data) :
+ m_desc(desc),
+ m_width(width),
+ m_height(height),
+ m_allowedQuality(0),
+ m_inUse(0),
+ m_stride(stride),
+ m_data(data),
+ m_referenceCount(0),
+ m_ownsData(false),
+ m_parent(NULL),
+ m_storageOffsetX(0),
+ m_storageOffsetY(0),
+ m_mipmapsValid(false),
+ m_mipmaps()
+{
+ RI_ASSERT(Color::isValidDescriptor(m_desc));
+ RI_ASSERT(width > 0 && height > 0);
+ RI_ASSERT(data);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Construcs a child image.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Image::Image(Image* parent, int x, int y, int width, int height) :
+ m_desc(Color::formatToDescriptor(VG_sRGBA_8888)), //dummy initialization, will be overwritten below (can't read from parent->m_desc before knowing the pointer is valid)
+ m_width(width),
+ m_height(height),
+ m_allowedQuality(0),
+ m_inUse(0),
+ m_stride(0),
+ m_data(NULL),
+ m_referenceCount(0),
+ m_ownsData(false),
+ m_parent(parent),
+ m_storageOffsetX(0),
+ m_storageOffsetY(0),
+ m_mipmapsValid(false),
+ m_mipmaps()
+{
+ RI_ASSERT(parent);
+ RI_ASSERT(x >= 0 && y >= 0 && width > 0 && height > 0);
+ RI_ASSERT(RI_INT_ADDSATURATE(x,width) <= parent->m_width && RI_INT_ADDSATURATE(y,height) <= parent->m_height); //child image must be contained in parent
+
+ m_desc = parent->m_desc;
+ RI_ASSERT(Color::isValidDescriptor(m_desc));
+ m_allowedQuality = parent->m_allowedQuality;
+ m_stride = parent->m_stride;
+ m_data = parent->m_data;
+ m_storageOffsetX = parent->m_storageOffsetX + x;
+ m_storageOffsetY = parent->m_storageOffsetY + y;
+
+ //increase the reference and use count of the parent
+ addInUse();
+ parent->addInUse();
+ parent->addReference();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Image destructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Image::~Image()
+{
+ RI_ASSERT(m_referenceCount == 0);
+
+ if(m_parent)
+ {
+ //decrease the reference and use count of the parent
+ removeInUse();
+ m_parent->removeInUse();
+ if(!m_parent->removeReference())
+ RI_DELETE(m_parent);
+ }
+ RI_ASSERT(m_inUse == 0);
+
+ for(int i=0;i<m_mipmaps.size();i++)
+ {
+ if(!m_mipmaps[i]->removeReference())
+ RI_DELETE(m_mipmaps[i]);
+ else
+ {
+ RI_ASSERT(0); //there can't be any other references to the mipmap levels
+ }
+ }
+ m_mipmaps.clear();
+
+ if(m_ownsData)
+ {
+ RI_ASSERT(!m_parent); //can't have parent if owns the data
+ RI_DELETE_ARRAY(m_data); //delete image data if we own it
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns true if the two images share pixels.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool Image::overlaps(const Image* src) const
+{
+ RI_ASSERT(src);
+
+ if(m_data != src->m_data)
+ return false; //images don't share data
+
+ //check if the image storage regions overlap
+ Rectangle r(m_storageOffsetX, m_storageOffsetY, m_width, m_height);
+ r.intersect(Rectangle(src->m_storageOffsetX, src->m_storageOffsetY, src->m_width, src->m_height));
+ if(!r.width || !r.height)
+ return false; //intersection is empty, images don't overlap
+
+ return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Clears a rectangular portion of an image with the given clear color.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::clear(const Color& clearColor, int x, int y, int w, int h)
+{
+ RI_ASSERT(m_data);
+ RI_ASSERT(m_referenceCount > 0);
+
+ //intersect clear region with image bounds
+ Rectangle r(0,0,m_width,m_height);
+ r.intersect(Rectangle(x,y,w,h));
+ if(!r.width || !r.height)
+ return; //intersection is empty or one of the rectangles is invalid
+
+ Color col = clearColor;
+ col.clamp();
+ col.convert(m_desc.internalFormat);
+
+ for(int j=r.y;j<r.y + r.height;j++)
+ {
+ for(int i=r.x;i<r.x + r.width;i++)
+ {
+ writePixel(i, j, col);
+ }
+ }
+
+ m_mipmapsValid = false;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Blits a source region to destination. Source and destination
+* can overlap.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static RIfloat ditherChannel(RIfloat c, int bits, RIfloat m)
+{
+ RIfloat fc = c * (RIfloat)((1<<bits)-1);
+ RIfloat ic = (RIfloat)floor(fc);
+ if(fc - ic > m) ic += 1.0f;
+ return RI_MIN(ic / (RIfloat)((1<<bits)-1), 1.0f);
+}
+
+static void computeBlitRegion(int& sx, int& sy, int& dx, int& dy, int& w, int& h, int srcWidth, int srcHeight, int dstWidth, int dstHeight)
+{
+ RI_ASSERT(w > 0 && h > 0);
+ sx = RI_INT_MIN(RI_INT_MAX(sx, (int)(RI_INT32_MIN>>2)), (int)(RI_INT32_MAX>>2));
+ sy = RI_INT_MIN(RI_INT_MAX(sy, (int)(RI_INT32_MIN>>2)), (int)(RI_INT32_MAX>>2));
+ dx = RI_INT_MIN(RI_INT_MAX(dx, (int)(RI_INT32_MIN>>2)), (int)(RI_INT32_MAX>>2));
+ dy = RI_INT_MIN(RI_INT_MAX(dy, (int)(RI_INT32_MIN>>2)), (int)(RI_INT32_MAX>>2));
+ w = RI_INT_MIN(w, (int)(RI_INT32_MAX>>2));
+ h = RI_INT_MIN(h, (int)(RI_INT32_MAX>>2));
+ int srcsx = sx, srcex = sx + w, dstsx = dx, dstex = dx + w;
+ if(srcsx < 0)
+ {
+ dstsx -= srcsx;
+ srcsx = 0;
+ }
+ if(srcex > srcWidth)
+ {
+ dstex -= srcex - srcWidth;
+ srcex = srcWidth;
+ }
+ if(dstsx < 0)
+ {
+ srcsx -= dstsx;
+ dstsx = 0;
+ }
+ if(dstex > dstWidth)
+ {
+ srcex -= dstex - dstWidth;
+ dstex = dstWidth;
+ }
+ RI_ASSERT(srcsx >= 0 && dstsx >= 0 && srcex <= srcWidth && dstex <= dstWidth);
+ w = srcex - srcsx;
+ RI_ASSERT(w == dstex - dstsx);
+
+ int srcsy = sy, srcey = sy + h, dstsy = dy, dstey = dy + h;
+ if(srcsy < 0)
+ {
+ dstsy -= srcsy;
+ srcsy = 0;
+ }
+ if(srcey > srcHeight)
+ {
+ dstey -= srcey - srcHeight;
+ srcey = srcHeight;
+ }
+ if(dstsy < 0)
+ {
+ srcsy -= dstsy;
+ dstsy = 0;
+ }
+ if(dstey > dstHeight)
+ {
+ srcey -= dstey - dstHeight;
+ dstey = dstHeight;
+ }
+ RI_ASSERT(srcsy >= 0 && dstsy >= 0 && srcey <= srcHeight && dstey <= dstHeight);
+ h = srcey - srcsy;
+ RI_ASSERT(h == dstey - dstsy);
+ sx = srcsx;
+ sy = srcsy;
+ dx = dstsx;
+ dy = dstsy;
+}
+
+void Image::blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h, bool dither)
+{
+ //img=>img: vgCopyImage
+ //img=>user: vgGetImageSubData
+ //user=>img: vgImageSubData
+ RI_ASSERT(src.m_data); //source exists
+ RI_ASSERT(m_data); //destination exists
+ RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+ computeBlitRegion(sx, sy, dx, dy, w, h, src.m_width, src.m_height, m_width, m_height);
+ if(w <= 0 || h <= 0)
+ return; //zero area
+
+ Array<Color> tmp;
+ tmp.resize(w*h); //throws bad_alloc
+
+ //copy source region to tmp
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color c = src.readPixel(sx + i, sy + j);
+ c.convert(m_desc.internalFormat);
+ tmp[j*w+i] = c;
+ }
+ }
+
+ int rbits = m_desc.redBits, gbits = m_desc.greenBits, bbits = m_desc.blueBits, abits = m_desc.alphaBits;
+ if(m_desc.isLuminance())
+ {
+ rbits = gbits = bbits = m_desc.luminanceBits;
+ abits = 0;
+ }
+
+ //write tmp to destination region
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color col = tmp[j*w+i];
+
+ if(dither)
+ {
+ static const int matrix[16] = {
+ 0, 8, 2, 10,
+ 12, 4, 14, 6,
+ 3, 11, 1, 9,
+ 15, 7, 13, 5};
+ int x = i & 3;
+ int y = j & 3;
+ RIfloat m = matrix[y*4+x] / 16.0f;
+
+ if(rbits) col.r = ditherChannel(col.r, rbits, m);
+ if(gbits) col.g = ditherChannel(col.g, gbits, m);
+ if(bbits) col.b = ditherChannel(col.b, bbits, m);
+ if(abits) col.a = ditherChannel(col.a, abits, m);
+ }
+
+ writePixel(dx + i, dy + j, col);
+ }
+ }
+ m_mipmapsValid = false;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Converts from multisampled format to display format.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h)
+{
+ //fb=>img: vgGetPixels
+ //fb=>user: vgReadPixels
+ RI_ASSERT(!src->isInUse(this));
+
+ computeBlitRegion(sx, sy, dx, dy, w, h, src->getWidth(), src->getHeight(), m_width, m_height);
+ if(w <= 0 || h <= 0)
+ return; //zero area
+
+ for(int y=0;y<h;y++)
+ {
+ for(int x=0;x<w;x++)
+ {
+ Color r = src->FSAAResolve(sx + x, sy + y);
+ r.convert(getDescriptor().internalFormat);
+ writePixel(dx + x, dy + y, r);
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns the color at pixel (x,y).
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Color Image::readPixel(int x, int y) const
+{
+ RI_ASSERT(m_data);
+ RI_ASSERT(x >= 0 && x < m_width);
+ RI_ASSERT(y >= 0 && y < m_height);
+ RI_ASSERT(m_referenceCount > 0);
+ x += m_storageOffsetX;
+ y += m_storageOffsetY;
+
+ unsigned int p = 0;
+ RIuint8* scanline = m_data + y * m_stride;
+ switch(m_desc.bitsPerPixel)
+ {
+ case 32:
+ {
+ RIuint32* s = (((RIuint32*)scanline) + x);
+ p = (unsigned int)*s;
+ break;
+ }
+
+ case 16:
+ {
+ RIuint16* s = ((RIuint16*)scanline) + x;
+ p = (unsigned int)*s;
+ break;
+ }
+
+ case 8:
+ {
+ RIuint8* s = ((RIuint8*)scanline) + x;
+ p = (unsigned int)*s;
+ break;
+ }
+
+ case 4:
+ {
+ RIuint8* s = ((RIuint8*)scanline) + (x>>1);
+ p = (unsigned int)(*s >> ((x&1)<<2)) & 0xf;
+ break;
+ }
+
+ case 2:
+ {
+ RIuint8* s = ((RIuint8*)scanline) + (x>>2);
+ p = (unsigned int)(*s >> ((x&3)<<1)) & 0x3;
+ break;
+ }
+
+ default:
+ {
+ RI_ASSERT(m_desc.bitsPerPixel == 1);
+ RIuint8* s = ((RIuint8*)scanline) + (x>>3);
+ p = (unsigned int)(*s >> (x&7)) & 0x1;
+ break;
+ }
+ }
+ Color c;
+ c.unpack(p, m_desc);
+ return c;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Writes the color to pixel (x,y). Internal color formats must
+* match.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::writePixel(int x, int y, const Color& c)
+{
+ RI_ASSERT(m_data);
+ RI_ASSERT(x >= 0 && x < m_width);
+ RI_ASSERT(y >= 0 && y < m_height);
+ RI_ASSERT(m_referenceCount > 0);
+ RI_ASSERT(c.getInternalFormat() == m_desc.internalFormat);
+ x += m_storageOffsetX;
+ y += m_storageOffsetY;
+
+ unsigned int p = c.pack(m_desc);
+ RIuint8* scanline = m_data + y * m_stride;
+ switch(m_desc.bitsPerPixel)
+ {
+ case 32:
+ {
+ RIuint32* s = ((RIuint32*)scanline) + x;
+ *s = (RIuint32)p;
+ break;
+ }
+
+ case 16:
+ {
+ RIuint16* s = ((RIuint16*)scanline) + x;
+ *s = (RIuint16)p;
+ break;
+ }
+
+ case 8:
+ {
+ RIuint8* s = ((RIuint8*)scanline) + x;
+ *s = (RIuint8)p;
+ break;
+ }
+ case 4:
+ {
+ RIuint8* s = ((RIuint8*)scanline) + (x>>1);
+ *s = (RIuint8)((p << ((x&1)<<2)) | ((unsigned int)*s & ~(0xf << ((x&1)<<2))));
+ break;
+ }
+
+ case 2:
+ {
+ RIuint8* s = ((RIuint8*)scanline) + (x>>2);
+ *s = (RIuint8)((p << ((x&3)<<1)) | ((unsigned int)*s & ~(0x3 << ((x&3)<<1))));
+ break;
+ }
+
+ default:
+ {
+ RI_ASSERT(m_desc.bitsPerPixel == 1);
+ RIuint8* s = ((RIuint8*)scanline) + (x>>3);
+ *s = (RIuint8)((p << (x&7)) | ((unsigned int)*s & ~(0x1 << (x&7))));
+ break;
+ }
+ }
+ m_mipmapsValid = false;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Writes a filtered color to destination surface
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::writeFilteredPixel(int i, int j, const Color& color, VGbitfield channelMask)
+{
+ //section 3.4.4: before color space conversion, premultiplied colors are
+ //clamped to alpha, and the color is converted to nonpremultiplied format
+ //section 11.2: how to deal with channel mask
+ //step 1
+ Color f = color;
+ f.clamp(); //vgColorMatrix and vgLookups can produce colors that exceed alpha or [0,1] range
+
+ //step 2: color space conversion
+ f.convert((Color::InternalFormat)(m_desc.internalFormat & (Color::NONLINEAR | Color::LUMINANCE)));
+
+ //step 3: read the destination color and convert it to nonpremultiplied
+ Color d = readPixel(i,j);
+ d.unpremultiply();
+ RI_ASSERT(d.getInternalFormat() == f.getInternalFormat());
+
+ //step 4: replace the destination channels specified by the channelMask (channelmask is ignored for luminance formats)
+ if(!m_desc.isLuminance())
+ { //rgba format => use channelmask
+ if(channelMask & VG_RED)
+ d.r = f.r;
+ if(channelMask & VG_GREEN)
+ d.g = f.g;
+ if(channelMask & VG_BLUE)
+ d.b = f.b;
+ if(channelMask & VG_ALPHA)
+ d.a = f.a;
+ }
+ else d = f;
+
+ //step 5: if destination is premultiplied, convert to premultiplied format
+ if(m_desc.isPremultiplied())
+ d.premultiply();
+ //write the color to destination
+ writePixel(i,j,d);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Reads the pixel (x,y) and converts it into an alpha mask value.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+RIfloat Image::readMaskPixel(int x, int y) const
+{
+ RI_ASSERT(m_data);
+ RI_ASSERT(x >= 0 && x < m_width);
+ RI_ASSERT(y >= 0 && y < m_height);
+ RI_ASSERT(m_referenceCount > 0);
+
+ Color c = readPixel(x,y);
+ if(m_desc.isLuminance())
+ {
+ return c.r;
+ }
+ else
+ { //rgba
+ if(m_desc.alphaBits)
+ return c.a;
+ return c.r;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Writes the alpha mask to pixel (x,y).
+* \param
+* \return
+* \note Overwrites color.
+*//*-------------------------------------------------------------------*/
+
+void Image::writeMaskPixel(int x, int y, RIfloat m)
+{
+ RI_ASSERT(m_data);
+ RI_ASSERT(x >= 0 && x < m_width);
+ RI_ASSERT(y >= 0 && y < m_height);
+ RI_ASSERT(m_referenceCount > 0);
+
+ //if luminance or no alpha, red channel will be used, otherwise alpha channel will be used
+ writePixel(x, y, Color(m,m,m,m,m_desc.internalFormat));
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Reads a texel (u,v) at the given mipmap level. Tiling modes and
+* color space conversion are applied. Outputs color in premultiplied
+* format.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Color Image::readTexel(int u, int v, int level, VGTilingMode tilingMode, const Color& tileFillColor) const
+{
+ const Image* image = this;
+ if( level > 0 )
+ {
+ RI_ASSERT(level <= m_mipmaps.size());
+ image = m_mipmaps[level-1];
+ }
+ RI_ASSERT(image);
+
+ Color p;
+ if(tilingMode == VG_TILE_FILL)
+ {
+ if(u < 0 || v < 0 || u >= image->m_width || v >= image->m_height)
+ p = tileFillColor;
+ else
+ p = image->readPixel(u, v);
+ }
+ else if(tilingMode == VG_TILE_PAD)
+ {
+ u = RI_INT_MIN(RI_INT_MAX(u,0),image->m_width-1);
+ v = RI_INT_MIN(RI_INT_MAX(v,0),image->m_height-1);
+ p = image->readPixel(u, v);
+ }
+ else if(tilingMode == VG_TILE_REPEAT)
+ {
+ u = RI_INT_MOD(u, image->m_width);
+ v = RI_INT_MOD(v, image->m_height);
+ p = image->readPixel(u, v);
+ }
+ else
+ {
+ RI_ASSERT(tilingMode == VG_TILE_REFLECT);
+
+ u = RI_INT_MOD(u, image->m_width*2);
+ v = RI_INT_MOD(v, image->m_height*2);
+ if( u >= image->m_width ) u = image->m_width*2-1 - u;
+ if( v >= image->m_height ) v = image->m_height*2-1 - v;
+ p = image->readPixel(u, v);
+ }
+
+ p.premultiply(); //interpolate in premultiplied format
+ return p;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Maps point (x,y) to an image and returns a filtered,
+* premultiplied color value.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Color Image::resample(RIfloat x, RIfloat y, const Matrix3x3& surfaceToImage, VGImageQuality quality, VGTilingMode tilingMode, const Color& tileFillColor) //throws bad_alloc
+{
+ RI_ASSERT(m_referenceCount > 0);
+
+ VGbitfield aq = getAllowedQuality();
+ aq &= (VGbitfield)quality;
+
+ Vector3 uvw(x,y,1.0f);
+ uvw = surfaceToImage * uvw;
+ RIfloat oow = 1.0f / uvw.z;
+ uvw *= oow;
+
+ if(aq & VG_IMAGE_QUALITY_BETTER)
+ { //EWA on mipmaps
+ makeMipMaps(); //throws bad_alloc
+
+ Color::InternalFormat procFormat = (Color::InternalFormat)(m_desc.internalFormat | Color::PREMULTIPLIED);
+
+ RIfloat m_pixelFilterRadius = 1.25f;
+ RIfloat m_resamplingFilterRadius = 1.25f;
+
+ RIfloat Ux = (surfaceToImage[0][0] - uvw.x * surfaceToImage[2][0]) * oow * m_pixelFilterRadius;
+ RIfloat Vx = (surfaceToImage[1][0] - uvw.y * surfaceToImage[2][0]) * oow * m_pixelFilterRadius;
+ RIfloat Uy = (surfaceToImage[0][1] - uvw.x * surfaceToImage[2][1]) * oow * m_pixelFilterRadius;
+ RIfloat Vy = (surfaceToImage[1][1] - uvw.y * surfaceToImage[2][1]) * oow * m_pixelFilterRadius;
+ RIfloat U0 = uvw.x;
+ RIfloat V0 = uvw.y;
+
+ //calculate mip level
+ int level = 0;
+ RIfloat axis1sq = Ux*Ux + Vx*Vx;
+ RIfloat axis2sq = Uy*Uy + Vy*Vy;
+ RIfloat minorAxissq = RI_MIN(axis1sq,axis2sq);
+ while(minorAxissq > 9.0f && level < m_mipmaps.size()) //half the minor axis must be at least three texels
+ {
+ level++;
+ minorAxissq *= 0.25f;
+ }
+
+ RIfloat sx = 1.0f;
+ RIfloat sy = 1.0f;
+ if(level > 0)
+ {
+ sx = (RIfloat)m_mipmaps[level-1]->m_width / (RIfloat)m_width;
+ sy = (RIfloat)m_mipmaps[level-1]->m_height / (RIfloat)m_height;
+ }
+ Ux *= sx;
+ Vx *= sx;
+ U0 *= sx;
+ Uy *= sy;
+ Vy *= sy;
+ V0 *= sy;
+
+ //clamp filter size so that filtering doesn't take excessive amount of time (clamping results in aliasing)
+ RIfloat lim = 100.0f;
+ axis1sq = Ux*Ux + Vx*Vx;
+ axis2sq = Uy*Uy + Vy*Vy;
+ if( axis1sq > lim*lim )
+ {
+ RIfloat s = lim / (RIfloat)sqrt(axis1sq);
+ Ux *= s;
+ Vx *= s;
+ }
+ if( axis2sq > lim*lim )
+ {
+ RIfloat s = lim / (RIfloat)sqrt(axis2sq);
+ Uy *= s;
+ Vy *= s;
+ }
+
+
+ //form elliptic filter by combining texel and pixel filters
+ RIfloat A = Vx*Vx + Vy*Vy + 1.0f;
+ RIfloat B = -2.0f*(Ux*Vx + Uy*Vy);
+ RIfloat C = Ux*Ux + Uy*Uy + 1.0f;
+ //scale by the user-defined size of the kernel
+ A *= m_resamplingFilterRadius;
+ B *= m_resamplingFilterRadius;
+ C *= m_resamplingFilterRadius;
+
+ //calculate bounding box in texture space
+ RIfloat usize = (RIfloat)sqrt(C);
+ RIfloat vsize = (RIfloat)sqrt(A);
+ int u1 = (int)floor(U0 - usize + 0.5f);
+ int u2 = (int)floor(U0 + usize + 0.5f);
+ int v1 = (int)floor(V0 - vsize + 0.5f);
+ int v2 = (int)floor(V0 + vsize + 0.5f);
+ if( u1 == u2 || v1 == v2 )
+ return Color(0,0,0,0,procFormat);
+
+ //scale the filter so that Q = 1 at the cutoff radius
+ RIfloat F = A*C - 0.25f * B*B;
+ if( F <= 0.0f )
+ return Color(0,0,0,0,procFormat); //invalid filter shape due to numerical inaccuracies => return black
+ RIfloat ooF = 1.0f / F;
+ A *= ooF;
+ B *= ooF;
+ C *= ooF;
+
+ //evaluate filter by using forward differences to calculate Q = A*U^2 + B*U*V + C*V^2
+ Color color(0,0,0,0,procFormat);
+ RIfloat sumweight = 0.0f;
+ RIfloat DDQ = 2.0f * A;
+ RIfloat U = (RIfloat)u1 - U0 + 0.5f;
+ for(int v=v1;v<v2;v++)
+ {
+ RIfloat V = (RIfloat)v - V0 + 0.5f;
+ RIfloat DQ = A*(2.0f*U+1.0f) + B*V;
+ RIfloat Q = (C*V+B*U)*V + A*U*U;
+ for(int u=u1;u<u2;u++)
+ {
+ if( Q >= 0.0f && Q < 1.0f )
+ { //Q = r^2, fit gaussian to the range [0,1]
+ RIfloat weight = (RIfloat)exp(-0.5f * 10.0f * Q); //gaussian at radius 10 equals 0.0067
+ color += weight * readTexel(u, v, level, tilingMode, tileFillColor);
+ sumweight += weight;
+ }
+ Q += DQ;
+ DQ += DDQ;
+ }
+ }
+ if( sumweight == 0.0f )
+ return Color(0,0,0,0,procFormat);
+ RI_ASSERT(sumweight > 0.0f);
+ sumweight = 1.0f / sumweight;
+ return color * sumweight;
+ }
+ else if(aq & VG_IMAGE_QUALITY_FASTER)
+ { //bilinear
+ uvw.x -= 0.5f;
+ uvw.y -= 0.5f;
+ int u = (int)floor(uvw.x);
+ int v = (int)floor(uvw.y);
+ Color c00 = readTexel(u,v, 0, tilingMode, tileFillColor);
+ Color c10 = readTexel(u+1,v, 0, tilingMode, tileFillColor);
+ Color c01 = readTexel(u,v+1, 0, tilingMode, tileFillColor);
+ Color c11 = readTexel(u+1,v+1, 0, tilingMode, tileFillColor);
+ RIfloat fu = uvw.x - (RIfloat)u;
+ RIfloat fv = uvw.y - (RIfloat)v;
+ Color c0 = c00 * (1.0f - fu) + c10 * fu;
+ Color c1 = c01 * (1.0f - fu) + c11 * fu;
+ return c0 * (1.0f - fv) + c1 * fv;
+ }
+ else
+ { //point sampling
+ return readTexel((int)floor(uvw.x), (int)floor(uvw.y), 0, tilingMode, tileFillColor);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Generates mip maps for an image.
+* \param
+* \return
+* \note Downsampling is done in the input color space. We use a box
+* filter for downsampling.
+*//*-------------------------------------------------------------------*/
+
+void Image::makeMipMaps()
+{
+ RI_ASSERT(m_data);
+ RI_ASSERT(m_referenceCount > 0);
+
+ if(m_mipmapsValid)
+ return;
+
+ //delete existing mipmaps
+ for(int i=0;i<m_mipmaps.size();i++)
+ {
+ if(!m_mipmaps[i]->removeReference())
+ RI_DELETE(m_mipmaps[i]);
+ else
+ {
+ RI_ASSERT(0); //there can't be any other references to the mipmap levels
+ }
+ }
+ m_mipmaps.clear();
+
+ try
+ {
+ Color::InternalFormat procFormat = m_desc.internalFormat;
+ procFormat = (Color::InternalFormat)(procFormat | Color::PREMULTIPLIED); //premultiplied
+
+ //generate mipmaps until width and height are one
+ Image* prev = this;
+ while( prev->m_width > 1 || prev->m_height > 1 )
+ {
+ int nextw = (int)ceil(prev->m_width*0.5f);
+ int nexth = (int)ceil(prev->m_height*0.5f);
+ RI_ASSERT(nextw >= 1 && nexth >= 1);
+ RI_ASSERT(nextw < prev->m_width || nexth < prev->m_height);
+
+ m_mipmaps.resize(m_mipmaps.size()+1); //throws bad_alloc
+ m_mipmaps[m_mipmaps.size()-1] = NULL;
+
+ Image* next = RI_NEW(Image, (m_desc, nextw, nexth, m_allowedQuality)); //throws bad_alloc
+ next->addReference();
+ for(int j=0;j<next->m_height;j++)
+ {
+ for(int i=0;i<next->m_width;i++)
+ {
+ RIfloat u0 = (RIfloat)i / (RIfloat)next->m_width;
+ RIfloat u1 = (RIfloat)(i+1) / (RIfloat)next->m_width;
+ RIfloat v0 = (RIfloat)j / (RIfloat)next->m_height;
+ RIfloat v1 = (RIfloat)(j+1) / (RIfloat)next->m_height;
+
+ u0 *= prev->m_width;
+ u1 *= prev->m_width;
+ v0 *= prev->m_height;
+ v1 *= prev->m_height;
+
+ int su = (int)floor(u0);
+ int eu = (int)ceil(u1);
+ int sv = (int)floor(v0);
+ int ev = (int)ceil(v1);
+
+ Color c(0,0,0,0,procFormat);
+ int samples = 0;
+ for(int y=sv;y<ev;y++)
+ {
+ for(int x=su;x<eu;x++)
+ {
+ Color p = prev->readPixel(x, y);
+ p.convert(procFormat);
+ c += p;
+ samples++;
+ }
+ }
+ c *= (1.0f/samples);
+ c.convert(m_desc.internalFormat);
+ next->writePixel(i,j,c);
+ }
+ }
+ m_mipmaps[m_mipmaps.size()-1] = next;
+ prev = next;
+ }
+ RI_ASSERT(prev->m_width == 1 && prev->m_height == 1);
+ m_mipmapsValid = true;
+ }
+ catch(std::bad_alloc)
+ {
+ //delete existing mipmaps
+ for(int i=0;i<m_mipmaps.size();i++)
+ {
+ if(m_mipmaps[i])
+ {
+ if(!m_mipmaps[i]->removeReference())
+ RI_DELETE(m_mipmaps[i]);
+ else
+ {
+ RI_ASSERT(0); //there can't be any other references to the mipmap levels
+ }
+ }
+ }
+ m_mipmaps.clear();
+ m_mipmapsValid = false;
+ throw;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Applies color matrix filter.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::colorMatrix(const Image& src, const RIfloat* matrix, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+ RI_ASSERT(src.m_data); //source exists
+ RI_ASSERT(m_data); //destination exists
+ RI_ASSERT(matrix);
+ RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+ int w = RI_INT_MIN(m_width, src.m_width);
+ int h = RI_INT_MIN(m_height, src.m_height);
+ RI_ASSERT(w > 0 && h > 0);
+
+ Color::InternalFormat srcFormat = src.m_desc.internalFormat;
+ Color::InternalFormat procFormat = (Color::InternalFormat)(srcFormat & ~Color::LUMINANCE); //process in RGB, not luminance
+ if(filterFormatLinear)
+ procFormat = (Color::InternalFormat)(procFormat & ~Color::NONLINEAR);
+ else
+ procFormat = (Color::InternalFormat)(procFormat | Color::NONLINEAR);
+
+ if(filterFormatPremultiplied)
+ procFormat = (Color::InternalFormat)(procFormat | Color::PREMULTIPLIED);
+ else
+ procFormat = (Color::InternalFormat)(procFormat & ~Color::PREMULTIPLIED);
+
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color s = src.readPixel(i,j); //convert to RGBA [0,1]
+ s.convert(procFormat);
+
+ Color d(0,0,0,0,procFormat);
+ d.r = matrix[0+4*0] * s.r + matrix[0+4*1] * s.g + matrix[0+4*2] * s.b + matrix[0+4*3] * s.a + matrix[0+4*4];
+ d.g = matrix[1+4*0] * s.r + matrix[1+4*1] * s.g + matrix[1+4*2] * s.b + matrix[1+4*3] * s.a + matrix[1+4*4];
+ d.b = matrix[2+4*0] * s.r + matrix[2+4*1] * s.g + matrix[2+4*2] * s.b + matrix[2+4*3] * s.a + matrix[2+4*4];
+ d.a = matrix[3+4*0] * s.r + matrix[3+4*1] * s.g + matrix[3+4*2] * s.b + matrix[3+4*3] * s.a + matrix[3+4*4];
+
+ writeFilteredPixel(i, j, d, channelMask);
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Reads a pixel from image with tiling mode applied.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static Color readTiledPixel(int x, int y, int w, int h, VGTilingMode tilingMode, const Array<Color>& image, const Color& edge)
+{
+ Color s;
+ if(x < 0 || x >= w || y < 0 || y >= h)
+ { //apply tiling mode
+ switch(tilingMode)
+ {
+ case VG_TILE_FILL:
+ s = edge;
+ break;
+ case VG_TILE_PAD:
+ x = RI_INT_MIN(RI_INT_MAX(x, 0), w-1);
+ y = RI_INT_MIN(RI_INT_MAX(y, 0), h-1);
+ RI_ASSERT(x >= 0 && x < w && y >= 0 && y < h);
+ s = image[y*w+x];
+ break;
+ case VG_TILE_REPEAT:
+ x = RI_INT_MOD(x, w);
+ y = RI_INT_MOD(y, h);
+ RI_ASSERT(x >= 0 && x < w && y >= 0 && y < h);
+ s = image[y*w+x];
+ break;
+ default:
+ RI_ASSERT(tilingMode == VG_TILE_REFLECT);
+ x = RI_INT_MOD(x, w*2);
+ y = RI_INT_MOD(y, h*2);
+ if(x >= w) x = w*2-1-x;
+ if(y >= h) y = h*2-1-y;
+ RI_ASSERT(x >= 0 && x < w && y >= 0 && y < h);
+ s = image[y*w+x];
+ break;
+ }
+ }
+ else
+ {
+ RI_ASSERT(x >= 0 && x < w && y >= 0 && y < h);
+ s = image[y*w+x];
+ }
+ return s;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns processing format for filtering.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static Color::InternalFormat getProcessingFormat(Color::InternalFormat srcFormat, bool filterFormatLinear, bool filterFormatPremultiplied)
+{
+ Color::InternalFormat procFormat = (Color::InternalFormat)(srcFormat & ~Color::LUMINANCE); //process in RGB, not luminance
+ if(filterFormatLinear)
+ procFormat = (Color::InternalFormat)(procFormat & ~Color::NONLINEAR);
+ else
+ procFormat = (Color::InternalFormat)(procFormat | Color::NONLINEAR);
+
+ if(filterFormatPremultiplied)
+ procFormat = (Color::InternalFormat)(procFormat | Color::PREMULTIPLIED);
+ else
+ procFormat = (Color::InternalFormat)(procFormat & ~Color::PREMULTIPLIED);
+ return procFormat;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Applies convolution filter.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::convolve(const Image& src, int kernelWidth, int kernelHeight, int shiftX, int shiftY, const RIint16* kernel, RIfloat scale, RIfloat bias, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+ RI_ASSERT(src.m_data); //source exists
+ RI_ASSERT(m_data); //destination exists
+ RI_ASSERT(kernel && kernelWidth > 0 && kernelHeight > 0);
+ RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+ //the area to be written is an intersection of source and destination image areas.
+ //lower-left corners of the images are aligned.
+ int w = RI_INT_MIN(m_width, src.m_width);
+ int h = RI_INT_MIN(m_height, src.m_height);
+ RI_ASSERT(w > 0 && h > 0);
+
+ Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+
+ Color edge = edgeFillColor;
+ edge.clamp();
+ edge.convert(procFormat);
+
+ Array<Color> tmp;
+ tmp.resize(src.m_width*src.m_height); //throws bad_alloc
+
+ //copy source region to tmp and do conversion
+ for(int j=0;j<src.m_height;j++)
+ {
+ for(int i=0;i<src.m_width;i++)
+ {
+ Color s = src.readPixel(i, j);
+ s.convert(procFormat);
+ tmp[j*src.m_width+i] = s;
+ }
+ }
+
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color sum(0,0,0,0,procFormat);
+
+ for(int kj=0;kj<kernelHeight;kj++)
+ {
+ for(int ki=0;ki<kernelWidth;ki++)
+ {
+ int x = i+ki-shiftX;
+ int y = j+kj-shiftY;
+ Color s = readTiledPixel(x, y, src.m_width, src.m_height, tilingMode, tmp, edge);
+
+ int kx = kernelWidth-ki-1;
+ int ky = kernelHeight-kj-1;
+ RI_ASSERT(kx >= 0 && kx < kernelWidth && ky >= 0 && ky < kernelHeight);
+
+ sum += (RIfloat)kernel[kx*kernelHeight+ky] * s;
+ }
+ }
+
+ sum *= scale;
+ sum.r += bias;
+ sum.g += bias;
+ sum.b += bias;
+ sum.a += bias;
+
+ writeFilteredPixel(i, j, sum, channelMask);
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Applies separable convolution filter.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::separableConvolve(const Image& src, int kernelWidth, int kernelHeight, int shiftX, int shiftY, const RIint16* kernelX, const RIint16* kernelY, RIfloat scale, RIfloat bias, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+ RI_ASSERT(src.m_data); //source exists
+ RI_ASSERT(m_data); //destination exists
+ RI_ASSERT(kernelX && kernelY && kernelWidth > 0 && kernelHeight > 0);
+ RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+ //the area to be written is an intersection of source and destination image areas.
+ //lower-left corners of the images are aligned.
+ int w = RI_INT_MIN(m_width, src.m_width);
+ int h = RI_INT_MIN(m_height, src.m_height);
+ RI_ASSERT(w > 0 && h > 0);
+
+ Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+
+ Color edge = edgeFillColor;
+ edge.clamp();
+ edge.convert(procFormat);
+
+ Array<Color> tmp;
+ tmp.resize(src.m_width*src.m_height); //throws bad_alloc
+
+ //copy source region to tmp and do conversion
+ for(int j=0;j<src.m_height;j++)
+ {
+ for(int i=0;i<src.m_width;i++)
+ {
+ Color s = src.readPixel(i, j);
+ s.convert(procFormat);
+ tmp[j*src.m_width+i] = s;
+ }
+ }
+
+ Array<Color> tmp2;
+ tmp2.resize(w*src.m_height); //throws bad_alloc
+ for(int j=0;j<src.m_height;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color sum(0,0,0,0,procFormat);
+ for(int ki=0;ki<kernelWidth;ki++)
+ {
+ int x = i+ki-shiftX;
+ Color s = readTiledPixel(x, j, src.m_width, src.m_height, tilingMode, tmp, edge);
+
+ int kx = kernelWidth-ki-1;
+ RI_ASSERT(kx >= 0 && kx < kernelWidth);
+
+ sum += (RIfloat)kernelX[kx] * s;
+ }
+ tmp2[j*w+i] = sum;
+ }
+ }
+
+ if(tilingMode == VG_TILE_FILL)
+ { //convolve the edge color
+ Color sum(0,0,0,0,procFormat);
+ for(int ki=0;ki<kernelWidth;ki++)
+ {
+ sum += (RIfloat)kernelX[ki] * edge;
+ }
+ edge = sum;
+ }
+
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color sum(0,0,0,0,procFormat);
+ for(int kj=0;kj<kernelHeight;kj++)
+ {
+ int y = j+kj-shiftY;
+ Color s = readTiledPixel(i, y, w, src.m_height, tilingMode, tmp2, edge);
+
+ int ky = kernelHeight-kj-1;
+ RI_ASSERT(ky >= 0 && ky < kernelHeight);
+
+ sum += (RIfloat)kernelY[ky] * s;
+ }
+
+ sum *= scale;
+ sum.r += bias;
+ sum.g += bias;
+ sum.b += bias;
+ sum.a += bias;
+
+ writeFilteredPixel(i, j, sum, channelMask);
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Applies Gaussian blur filter.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::gaussianBlur(const Image& src, RIfloat stdDeviationX, RIfloat stdDeviationY, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+ RI_ASSERT(src.m_data); //source exists
+ RI_ASSERT(m_data); //destination exists
+ RI_ASSERT(stdDeviationX > 0.0f && stdDeviationY > 0.0f);
+ RI_ASSERT(stdDeviationX <= RI_MAX_GAUSSIAN_STD_DEVIATION && stdDeviationY <= RI_MAX_GAUSSIAN_STD_DEVIATION);
+ RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+ //the area to be written is an intersection of source and destination image areas.
+ //lower-left corners of the images are aligned.
+ int w = RI_INT_MIN(m_width, src.m_width);
+ int h = RI_INT_MIN(m_height, src.m_height);
+ RI_ASSERT(w > 0 && h > 0);
+
+ Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+
+ Color edge = edgeFillColor;
+ edge.clamp();
+ edge.convert(procFormat);
+
+ Array<Color> tmp;
+ tmp.resize(src.m_width*src.m_height); //throws bad_alloc
+
+ //copy source region to tmp and do conversion
+ for(int j=0;j<src.m_height;j++)
+ {
+ for(int i=0;i<src.m_width;i++)
+ {
+ Color s = src.readPixel(i, j);
+ s.convert(procFormat);
+ tmp[j*src.m_width+i] = s;
+ }
+ }
+
+ RIfloat expScaleX = -1.0f / (2.0f*stdDeviationX*stdDeviationX);
+ RIfloat expScaleY = -1.0f / (2.0f*stdDeviationY*stdDeviationY);
+
+ int kernelWidth = (int)(stdDeviationX * 4.0f + 1.0f);
+ int kernelHeight = (int)(stdDeviationY * 4.0f + 1.0f);
+
+ //make a separable kernel
+ Array<RIfloat> kernelX;
+ kernelX.resize(kernelWidth*2+1);
+ int shiftX = kernelWidth;
+ RIfloat scaleX = 0.0f;
+ for(int i=0;i<kernelX.size();i++)
+ {
+ int x = i-shiftX;
+ kernelX[i] = (RIfloat)exp((RIfloat)x*(RIfloat)x * expScaleX);
+ scaleX += kernelX[i];
+ }
+ scaleX = 1.0f / scaleX; //NOTE: using the mathematical definition of the scaling term doesn't work since we cut the filter support early for performance
+
+ Array<RIfloat> kernelY;
+ kernelY.resize(kernelHeight*2+1);
+ int shiftY = kernelHeight;
+ RIfloat scaleY = 0.0f;
+ for(int i=0;i<kernelY.size();i++)
+ {
+ int y = i-shiftY;
+ kernelY[i] = (RIfloat)exp((RIfloat)y*(RIfloat)y * expScaleY);
+ scaleY += kernelY[i];
+ }
+ scaleY = 1.0f / scaleY; //NOTE: using the mathematical definition of the scaling term doesn't work since we cut the filter support early for performance
+
+ Array<Color> tmp2;
+ tmp2.resize(w*src.m_height); //throws bad_alloc
+ //horizontal pass
+ for(int j=0;j<src.m_height;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color sum(0,0,0,0,procFormat);
+ for(int ki=0;ki<kernelX.size();ki++)
+ {
+ int x = i+ki-shiftX;
+ sum += kernelX[ki] * readTiledPixel(x, j, src.m_width, src.m_height, tilingMode, tmp, edge);
+ }
+ tmp2[j*w+i] = sum * scaleX;
+ }
+ }
+ //vertical pass
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color sum(0,0,0,0,procFormat);
+ for(int kj=0;kj<kernelY.size();kj++)
+ {
+ int y = j+kj-shiftY;
+ sum += kernelY[kj] * readTiledPixel(i, y, w, src.m_height, tilingMode, tmp2, edge);
+ }
+ writeFilteredPixel(i, j, sum * scaleY, channelMask);
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns lookup table format for lookup filters.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static Color::InternalFormat getLUTFormat(bool outputLinear, bool outputPremultiplied)
+{
+ Color::InternalFormat lutFormat = Color::lRGBA;
+ if(outputLinear && outputPremultiplied)
+ lutFormat = Color::lRGBA_PRE;
+ else if(!outputLinear && !outputPremultiplied)
+ lutFormat = Color::sRGBA;
+ else if(!outputLinear && outputPremultiplied)
+ lutFormat = Color::sRGBA_PRE;
+ return lutFormat;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Applies multi-channel lookup table filter.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::lookup(const Image& src, const RIuint8 * redLUT, const RIuint8 * greenLUT, const RIuint8 * blueLUT, const RIuint8 * alphaLUT, bool outputLinear, bool outputPremultiplied, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+ RI_ASSERT(src.m_data); //source exists
+ RI_ASSERT(m_data); //destination exists
+ RI_ASSERT(redLUT && greenLUT && blueLUT && alphaLUT);
+ RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+ //the area to be written is an intersection of source and destination image areas.
+ //lower-left corners of the images are aligned.
+ int w = RI_INT_MIN(m_width, src.m_width);
+ int h = RI_INT_MIN(m_height, src.m_height);
+ RI_ASSERT(w > 0 && h > 0);
+
+ Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+ Color::InternalFormat lutFormat = getLUTFormat(outputLinear, outputPremultiplied);
+
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color s = src.readPixel(i,j); //convert to RGBA [0,1]
+ s.convert(procFormat);
+
+ Color d(0,0,0,0,lutFormat);
+ d.r = intToColor( redLUT[colorToInt(s.r, 255)], 255);
+ d.g = intToColor(greenLUT[colorToInt(s.g, 255)], 255);
+ d.b = intToColor( blueLUT[colorToInt(s.b, 255)], 255);
+ d.a = intToColor(alphaLUT[colorToInt(s.a, 255)], 255);
+
+ writeFilteredPixel(i, j, d, channelMask);
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Applies single channel lookup table filter.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::lookupSingle(const Image& src, const RIuint32 * lookupTable, VGImageChannel sourceChannel, bool outputLinear, bool outputPremultiplied, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+ RI_ASSERT(src.m_data); //source exists
+ RI_ASSERT(m_data); //destination exists
+ RI_ASSERT(lookupTable);
+ RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+ //the area to be written is an intersection of source and destination image areas.
+ //lower-left corners of the images are aligned.
+ int w = RI_INT_MIN(m_width, src.m_width);
+ int h = RI_INT_MIN(m_height, src.m_height);
+ RI_ASSERT(w > 0 && h > 0);
+
+ if(src.m_desc.isLuminance())
+ sourceChannel = VG_RED;
+ else if(src.m_desc.redBits + src.m_desc.greenBits + src.m_desc.blueBits == 0)
+ {
+ RI_ASSERT(src.m_desc.alphaBits);
+ sourceChannel = VG_ALPHA;
+ }
+
+ Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+ Color::InternalFormat lutFormat = getLUTFormat(outputLinear, outputPremultiplied);
+
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ Color s = src.readPixel(i,j); //convert to RGBA [0,1]
+ s.convert(procFormat);
+ int e;
+ switch(sourceChannel)
+ {
+ case VG_RED:
+ e = colorToInt(s.r, 255);
+ break;
+ case VG_GREEN:
+ e = colorToInt(s.g, 255);
+ break;
+ case VG_BLUE:
+ e = colorToInt(s.b, 255);
+ break;
+ default:
+ RI_ASSERT(sourceChannel == VG_ALPHA);
+ e = colorToInt(s.a, 255);
+ break;
+ }
+
+ RIuint32 l = ((const RIuint32*)lookupTable)[e];
+ Color d(0,0,0,0,lutFormat);
+ d.r = intToColor((l>>24), 255);
+ d.g = intToColor((l>>16), 255);
+ d.b = intToColor((l>> 8), 255);
+ d.a = intToColor((l ), 255);
+
+ writeFilteredPixel(i, j, d, channelMask);
+ }
+ }
+}
+
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Surface::Surface(const Color::Descriptor& desc, int width, int height, int numSamples) :
+ m_width(width),
+ m_height(height),
+ m_numSamples(numSamples),
+ m_referenceCount(0),
+ m_image(NULL)
+{
+ RI_ASSERT(width > 0 && height > 0 && numSamples > 0 && numSamples <= 32);
+ m_image = RI_NEW(Image, (desc, width*numSamples, height, 0)); //throws bad_alloc
+ m_image->addReference();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Surface::Surface(Image* image) :
+ m_width(0),
+ m_height(0),
+ m_numSamples(1),
+ m_referenceCount(0),
+ m_image(image)
+{
+ RI_ASSERT(image);
+ m_width = image->getWidth();
+ m_height = image->getHeight();
+ m_image->addReference();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Surface::Surface(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data) :
+ m_width(width),
+ m_height(height),
+ m_numSamples(1),
+ m_referenceCount(0),
+ m_image(NULL)
+{
+ RI_ASSERT(width > 0 && height > 0);
+ m_image = RI_NEW(Image, (desc, width, height, stride, data)); //throws bad_alloc
+ m_image->addReference();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Surface::~Surface()
+{
+ RI_ASSERT(m_referenceCount == 0);
+ if(!m_image->removeReference())
+ RI_DELETE(m_image);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Surface::clear(const Color& clearColor, int x, int y, int w, int h)
+{
+ Rectangle rect;
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = getWidth();
+ rect.height = getHeight();
+ Array<Rectangle> scissors;
+ scissors.push_back(rect);
+ clear(clearColor, x, y, w, h, scissors);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Surface::clear(const Color& clearColor, int x, int y, int w, int h, const Array<Rectangle>& scissors)
+{
+ RI_ASSERT(w > 0 && h > 0);
+
+ //intersect clear region with image bounds
+ Rectangle r(0,0,getWidth(),getHeight());
+ r.intersect(Rectangle(x,y,w,h));
+ if(!r.width || !r.height)
+ return; //intersection is empty or one of the rectangles is invalid
+
+ Array<ScissorEdge> scissorEdges;
+ for(int i=0;i<scissors.size();i++)
+ {
+ if(scissors[i].width > 0 && scissors[i].height > 0)
+ {
+ ScissorEdge e;
+ e.miny = scissors[i].y;
+ e.maxy = RI_INT_ADDSATURATE(scissors[i].y, scissors[i].height);
+
+ e.x = scissors[i].x;
+ e.direction = 1;
+ scissorEdges.push_back(e); //throws bad_alloc
+ e.x = RI_INT_ADDSATURATE(scissors[i].x, scissors[i].width);
+ e.direction = -1;
+ scissorEdges.push_back(e); //throws bad_alloc
+ }
+ }
+ if(!scissorEdges.size())
+ return; //there are no scissor rectangles => nothing is visible
+
+ //sort scissor edges by edge x
+ scissorEdges.sort();
+
+ //clear the image
+ Color col = clearColor;
+ col.clamp();
+ col.convert(m_image->getDescriptor().internalFormat);
+
+ Array<ScissorEdge> scissorAet;
+ for(int j=r.y;j<r.y + r.height;j++)
+ {
+ //gather scissor edges intersecting this scanline
+ scissorAet.clear();
+ for(int e=0;e<scissorEdges.size();e++)
+ {
+ const ScissorEdge& se = scissorEdges[e];
+ if(j >= se.miny && j < se.maxy)
+ scissorAet.push_back(scissorEdges[e]); //throws bad_alloc
+ }
+ if(!scissorAet.size())
+ continue; //scissoring is on, but there are no scissor rectangles on this scanline
+
+ //clear a scanline
+ int scissorWinding = 0;
+ int scissorIndex = 0;
+ for(int i=r.x;i<r.x + r.width;i++)
+ {
+ while(scissorIndex < scissorAet.size() && scissorAet[scissorIndex].x <= i)
+ scissorWinding += scissorAet[scissorIndex++].direction;
+ RI_ASSERT(scissorWinding >= 0);
+
+ if(scissorWinding)
+ {
+ for(int s=0;s<m_numSamples;s++)
+ writeSample(i, j, s, col);
+ }
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Surface::blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h)
+{
+ Rectangle rect;
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = getWidth();
+ rect.height = getHeight();
+ Array<Rectangle> scissors;
+ scissors.push_back(rect);
+ blit(src, sx, sy, dx, dy, w, h, scissors);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note no overlap is possible. Single sample to single or multisample (replicate)
+*//*-------------------------------------------------------------------*/
+
+void Surface::blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h, const Array<Rectangle>& scissors)
+{
+ //img=>fb: vgSetPixels
+ //user=>fb: vgWritePixels
+ computeBlitRegion(sx, sy, dx, dy, w, h, src.getWidth(), src.getHeight(), getWidth(), getHeight());
+ if(w <= 0 || h <= 0)
+ return; //zero area
+
+ Array<ScissorEdge> scissorEdges;
+ for(int i=0;i<scissors.size();i++)
+ {
+ if(scissors[i].width > 0 && scissors[i].height > 0)
+ {
+ ScissorEdge e;
+ e.miny = scissors[i].y;
+ e.maxy = RI_INT_ADDSATURATE(scissors[i].y, scissors[i].height);
+
+ e.x = scissors[i].x;
+ e.direction = 1;
+ scissorEdges.push_back(e); //throws bad_alloc
+ e.x = RI_INT_ADDSATURATE(scissors[i].x, scissors[i].width);
+ e.direction = -1;
+ scissorEdges.push_back(e); //throws bad_alloc
+ }
+ }
+ if(!scissorEdges.size())
+ return; //there are no scissor rectangles => nothing is visible
+
+ //sort scissor edges by edge x
+ scissorEdges.sort();
+
+ Array<ScissorEdge> scissorAet;
+ for(int j=0;j<h;j++)
+ {
+ //gather scissor edges intersecting this scanline
+ scissorAet.clear();
+ for(int e=0;e<scissorEdges.size();e++)
+ {
+ const ScissorEdge& se = scissorEdges[e];
+ if(dy + j >= se.miny && dy + j < se.maxy)
+ scissorAet.push_back(scissorEdges[e]); //throws bad_alloc
+ }
+ if(!scissorAet.size())
+ continue; //scissoring is on, but there are no scissor rectangles on this scanline
+
+ //blit a scanline
+ int scissorWinding = 0;
+ int scissorIndex = 0;
+ for(int i=0;i<w;i++)
+ {
+ while(scissorIndex < scissorAet.size() && scissorAet[scissorIndex].x <= dx + i)
+ scissorWinding += scissorAet[scissorIndex++].direction;
+ RI_ASSERT(scissorWinding >= 0);
+
+ if(scissorWinding)
+ {
+ Color c = src.readPixel(sx + i, sy + j);
+ c.convert(getDescriptor().internalFormat);
+ for(int s=0;s<m_numSamples;s++)
+ writeSample(dx + i, dy + j, s, c);
+ }
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Surface::blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h)
+{
+ Rectangle rect;
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = getWidth();
+ rect.height = getHeight();
+ Array<Rectangle> scissors;
+ scissors.push_back(rect);
+ blit(src, sx, sy, dx, dy, w, h, scissors);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Surface::blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h, const Array<Rectangle>& scissors)
+{
+ RI_ASSERT(m_numSamples == src->m_numSamples);
+
+ //fb=>fb: vgCopyPixels
+ computeBlitRegion(sx, sy, dx, dy, w, h, src->getWidth(), src->getHeight(), getWidth(), getHeight());
+ if(w <= 0 || h <= 0)
+ return; //zero area
+
+ Array<ScissorEdge> scissorEdges;
+ for(int i=0;i<scissors.size();i++)
+ {
+ if(scissors[i].width > 0 && scissors[i].height > 0)
+ {
+ ScissorEdge e;
+ e.miny = scissors[i].y;
+ e.maxy = RI_INT_ADDSATURATE(scissors[i].y, scissors[i].height);
+
+ e.x = scissors[i].x;
+ e.direction = 1;
+ scissorEdges.push_back(e); //throws bad_alloc
+ e.x = RI_INT_ADDSATURATE(scissors[i].x, scissors[i].width);
+ e.direction = -1;
+ scissorEdges.push_back(e); //throws bad_alloc
+ }
+ }
+ if(!scissorEdges.size())
+ return; //there are no scissor rectangles => nothing is visible
+
+ //sort scissor edges by edge x
+ scissorEdges.sort();
+
+ Array<Color> tmp;
+ tmp.resize(w*m_numSamples*h); //throws bad_alloc
+
+ //copy source region to tmp
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ int numSamples = m_numSamples;
+ for(int s=0;s<numSamples;s++)
+ {
+ Color c = src->m_image->readPixel((sx + i)*m_numSamples+s, sy + j);
+ c.convert(m_image->getDescriptor().internalFormat);
+ tmp[(j*w+i)*m_numSamples+s] = c;
+ }
+ }
+ }
+
+ Array<ScissorEdge> scissorAet;
+ for(int j=0;j<h;j++)
+ {
+ //gather scissor edges intersecting this scanline
+ scissorAet.clear();
+ for(int e=0;e<scissorEdges.size();e++)
+ {
+ const ScissorEdge& se = scissorEdges[e];
+ if(dy + j >= se.miny && dy + j < se.maxy)
+ scissorAet.push_back(scissorEdges[e]); //throws bad_alloc
+ }
+ if(!scissorAet.size())
+ continue; //scissoring is on, but there are no scissor rectangles on this scanline
+
+ //blit a scanline
+ int scissorWinding = 0;
+ int scissorIndex = 0;
+ for(int i=0;i<w;i++)
+ {
+ while(scissorIndex < scissorAet.size() && scissorAet[scissorIndex].x <= dx + i)
+ scissorWinding += scissorAet[scissorIndex++].direction;
+ RI_ASSERT(scissorWinding >= 0);
+
+ if(scissorWinding)
+ {
+ int numSamples = m_numSamples;
+ for(int s=0;s<numSamples;s++)
+ {
+ m_image->writePixel((dx + i)*m_numSamples+s, dy + j, tmp[(j*w+i)*m_numSamples+s]);
+ }
+ }
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Surface::mask(const Image* src, VGMaskOperation operation, int x, int y, int w, int h)
+{
+ RI_ASSERT(w > 0 && h > 0);
+
+ if(operation == VG_CLEAR_MASK || operation == VG_FILL_MASK)
+ {
+ //intersect clear region with image bounds
+ Rectangle r(0,0,getWidth(),getHeight());
+ r.intersect(Rectangle(x,y,w,h));
+ if(!r.width || !r.height)
+ return; //intersection is empty or one of the rectangles is invalid
+
+ if(m_numSamples == 1)
+ {
+ RIfloat m = 0.0f;
+ if(operation == VG_FILL_MASK)
+ m = 1.0f;
+ for(int j=r.y;j<r.y + r.height;j++)
+ {
+ for(int i=r.x;i<r.x + r.width;i++)
+ {
+ writeMaskCoverage(i, j, m);
+ }
+ }
+ }
+ else
+ {
+ unsigned int m = 0;
+ if(operation == VG_FILL_MASK)
+ m = (1<<m_numSamples)-1;
+ for(int j=r.y;j<r.y + r.height;j++)
+ {
+ for(int i=r.x;i<r.x + r.width;i++)
+ {
+ writeMaskMSAA(i, j, m);
+ }
+ }
+ }
+ }
+ else
+ {
+ RI_ASSERT(src);
+
+ int sx = 0, sy = 0, dx = x, dy = y;
+ computeBlitRegion(sx, sy, dx, dy, w, h, src->getWidth(), src->getHeight(), getWidth(), getHeight());
+ if(w <= 0 || h <= 0)
+ return; //zero area
+
+ if(m_numSamples == 1)
+ {
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ RIfloat amask = src->readMaskPixel(sx + i, sy + j);
+ if(operation == VG_SET_MASK)
+ writeMaskCoverage(dx + i, dy + j, amask);
+ else
+ {
+ RIfloat aprev = readMaskCoverage(dx + i, dy + j);
+ RIfloat anew = 0.0f;
+ switch(operation)
+ {
+ case VG_UNION_MASK: anew = 1.0f - (1.0f - amask)*(1.0f - aprev); break;
+ case VG_INTERSECT_MASK: anew = amask * aprev; break;
+ default: anew = aprev * (1.0f - amask); RI_ASSERT(operation == VG_SUBTRACT_MASK); break;
+ }
+ writeMaskCoverage(dx + i, dy + j, anew);
+ }
+ }
+ }
+ }
+ else
+ {
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ RIfloat fmask = src->readMaskPixel(sx + i, sy + j);
+ //TODO implement dithering?
+ unsigned int amask = fmask > 0.5f ? (1<<m_numSamples)-1 : 0;
+ if(operation == VG_SET_MASK)
+ writeMaskMSAA(dx + i, dy + j, amask);
+ else
+ {
+ unsigned int aprev = readMaskMSAA(dx + i, dy + j);
+ unsigned int anew = 0;
+ switch(operation)
+ {
+ case VG_UNION_MASK: anew = amask | aprev; break;
+ case VG_INTERSECT_MASK: anew = amask & aprev; break;
+ default: anew = ~amask & aprev; RI_ASSERT(operation == VG_SUBTRACT_MASK); break;
+ }
+ writeMaskMSAA(dx + i, dy + j, anew);
+ }
+ }
+ }
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Surface::mask(const Surface* src, VGMaskOperation operation, int x, int y, int w, int h)
+{
+ RI_ASSERT(w > 0 && h > 0);
+
+ if(operation == VG_CLEAR_MASK || operation == VG_FILL_MASK)
+ {
+ //intersect clear region with image bounds
+ Rectangle r(0,0,getWidth(),getHeight());
+ r.intersect(Rectangle(x,y,w,h));
+ if(!r.width || !r.height)
+ return; //intersection is empty or one of the rectangles is invalid
+
+ if(m_numSamples == 1)
+ {
+ RIfloat m = 0.0f;
+ if(operation == VG_FILL_MASK)
+ m = 1.0f;
+ for(int j=r.y;j<r.y + r.height;j++)
+ {
+ for(int i=r.x;i<r.x + r.width;i++)
+ {
+ writeMaskCoverage(i, j, m);
+ }
+ }
+ }
+ else
+ {
+ unsigned int m = 0;
+ if(operation == VG_FILL_MASK)
+ m = (1<<m_numSamples)-1;
+ for(int j=r.y;j<r.y + r.height;j++)
+ {
+ for(int i=r.x;i<r.x + r.width;i++)
+ {
+ writeMaskMSAA(i, j, m);
+ }
+ }
+ }
+ }
+ else
+ {
+ RI_ASSERT(src);
+ RI_ASSERT(m_numSamples == src->m_numSamples);
+
+ int sx = 0, sy = 0, dx = x, dy = y;
+ computeBlitRegion(sx, sy, dx, dy, w, h, src->getWidth(), src->getHeight(), getWidth(), getHeight());
+ if(w <= 0 || h <= 0)
+ return; //zero area
+
+ if(m_numSamples == 1)
+ {
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ RIfloat amask = src->readMaskCoverage(sx + i, sy + j);
+ if(operation == VG_SET_MASK)
+ writeMaskCoverage(dx + i, dy + j, amask);
+ else
+ {
+ RIfloat aprev = readMaskCoverage(dx + i, dy + j);
+ RIfloat anew = 0.0f;
+ switch(operation)
+ {
+ case VG_UNION_MASK: anew = 1.0f - (1.0f - amask)*(1.0f - aprev); break;
+ case VG_INTERSECT_MASK: anew = amask * aprev; break;
+ default: anew = aprev * (1.0f - amask); RI_ASSERT(operation == VG_SUBTRACT_MASK); break;
+ }
+ writeMaskCoverage(dx + i, dy + j, anew);
+ }
+ }
+ }
+ }
+ else
+ {
+ for(int j=0;j<h;j++)
+ {
+ for(int i=0;i<w;i++)
+ {
+ unsigned int amask = src->readMaskMSAA(sx + i, sy + j);
+ if(operation == VG_SET_MASK)
+ writeMaskMSAA(dx + i, dy + j, amask);
+ else
+ {
+ unsigned int aprev = readMaskMSAA(dx + i, dy + j);
+ unsigned int anew = 0;
+ switch(operation)
+ {
+ case VG_UNION_MASK: anew = amask | aprev; break;
+ case VG_INTERSECT_MASK: anew = amask & aprev; break;
+ default: anew = ~amask & aprev; RI_ASSERT(operation == VG_SUBTRACT_MASK); break;
+ }
+ writeMaskMSAA(dx + i, dy + j, anew);
+ }
+ }
+ }
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+RIfloat Surface::readMaskCoverage(int x, int y) const
+{
+ RI_ASSERT(x >= 0 && x < m_width && y >= 0 && y < m_height);
+ RI_ASSERT(m_numSamples == 1);
+ return m_image->readMaskPixel(x, y);
+}
+
+void Surface::writeMaskCoverage(int x, int y, RIfloat m)
+{
+ RI_ASSERT(x >= 0 && x < m_width && y >= 0 && y < m_height);
+ RI_ASSERT(m_numSamples == 1);
+ m_image->writeMaskPixel(x, y, m); //TODO support other than alpha formats but don't write to color channels?
+}
+
+unsigned int Surface::readMaskMSAA(int x, int y) const
+{
+ RI_ASSERT(x >= 0 && x < m_width && y >= 0 && y < m_height);
+ RI_ASSERT(m_numSamples > 1);
+ unsigned int m = 0;
+ for(int i=0;i<m_numSamples;i++)
+ {
+ if(m_image->readMaskPixel(x*m_numSamples+i, y) > 0.5f) //TODO is this the right formula for converting alpha to bit mask? does it matter?
+ m |= 1<<i;
+ }
+ return m;
+}
+
+void Surface::writeMaskMSAA(int x, int y, unsigned int m)
+{
+ RI_ASSERT(x >= 0 && x < m_width && y >= 0 && y < m_height);
+ RI_ASSERT(m_numSamples > 1);
+ for(int i=0;i<m_numSamples;i++)
+ {
+ RIfloat a = 0.0f;
+ if(m & (1<<i))
+ a = 1.0f;
+ m_image->writeMaskPixel(x*m_numSamples+i, y, a); //TODO support other than alpha formats but don't write to color channels?
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Color Surface::FSAAResolve(int x, int y) const
+{
+ if(m_numSamples == 1)
+ return readSample(x, y, 0);
+
+ Color::InternalFormat aaFormat = getDescriptor().isLuminance() ? Color::lLA_PRE : Color::lRGBA_PRE; //antialias in linear color space
+ Color r(0.0f, 0.0f, 0.0f, 0.0f, aaFormat);
+ for(int i=0;i<m_numSamples;i++)
+ {
+ Color d = readSample(x, y, i);
+ d.convert(aaFormat);
+ r += d;
+ }
+ r *= 1.0f/m_numSamples;
+ return r;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Drawable::Drawable(const Color::Descriptor& desc, int width, int height, int numSamples, int maskBits) :
+ m_referenceCount(0),
+ m_color(NULL),
+ m_mask(NULL)
+{
+ RI_ASSERT(width > 0 && height > 0 && numSamples > 0 && numSamples <= 32);
+ RI_ASSERT(maskBits == 0 || maskBits == 1 || maskBits == 4 || maskBits == 8);
+ m_color = RI_NEW(Surface, (desc, width, height, numSamples)); //throws bad_alloc
+ m_color->addReference();
+ if(maskBits)
+ {
+ VGImageFormat mf = VG_A_1;
+ if(maskBits == 4)
+ mf = VG_A_4;
+ else if(maskBits == 8)
+ mf = VG_A_8;
+ m_mask = RI_NEW(Surface, (Color::formatToDescriptor(mf), width, height, numSamples));
+ m_mask->addReference();
+ m_mask->clear(Color(1,1,1,1,Color::sRGBA), 0, 0, width, height);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Drawable::Drawable(Image* image, int maskBits) :
+ m_referenceCount(0),
+ m_color(NULL),
+ m_mask(NULL)
+{
+ RI_ASSERT(maskBits == 0 || maskBits == 1 || maskBits == 4 || maskBits == 8);
+ RI_ASSERT(image);
+ m_color = RI_NEW(Surface, (image));
+ m_color->addReference();
+ if(maskBits)
+ {
+ VGImageFormat mf = VG_A_1;
+ if(maskBits == 4)
+ mf = VG_A_4;
+ else if(maskBits == 8)
+ mf = VG_A_8;
+ m_mask = RI_NEW(Surface, (Color::formatToDescriptor(mf), image->getWidth(), image->getHeight(), 1));
+ m_mask->addReference();
+ m_mask->clear(Color(1,1,1,1,Color::sRGBA), 0, 0, image->getWidth(), image->getHeight());
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Drawable::Drawable(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data, int maskBits) :
+ m_referenceCount(0),
+ m_color(NULL),
+ m_mask(NULL)
+{
+ RI_ASSERT(width > 0 && height > 0);
+ RI_ASSERT(maskBits == 0 || maskBits == 1 || maskBits == 4 || maskBits == 8);
+ m_color = RI_NEW(Surface, (desc, width, height, stride, data)); //throws bad_alloc
+ m_color->addReference();
+ if(maskBits)
+ {
+ VGImageFormat mf = VG_A_1;
+ if(maskBits == 4)
+ mf = VG_A_4;
+ else if(maskBits == 8)
+ mf = VG_A_8;
+ m_mask = RI_NEW(Surface, (Color::formatToDescriptor(mf), width, height, 1));
+ m_mask->addReference();
+ m_mask->clear(Color(1,1,1,1,Color::sRGBA), 0, 0, width, height);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Drawable::~Drawable()
+{
+ RI_ASSERT(m_referenceCount == 0);
+ if(!m_color->removeReference())
+ RI_DELETE(m_color);
+ if(m_mask)
+ if(!m_mask->removeReference())
+ RI_DELETE(m_mask);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Drawable::resize(int newWidth, int newHeight)
+{
+ Surface* oldcolor = m_color;
+ Surface* oldmask = m_mask;
+ int oldWidth = m_color->getWidth();
+ int oldHeight = m_color->getHeight();
+
+ //TODO check that image is not a proxy
+ m_color = RI_NEW(Surface, (m_color->getDescriptor(), newWidth, newHeight, m_color->getNumSamples()));
+ m_color->addReference();
+ if(m_mask)
+ {
+ m_mask = RI_NEW(Surface, (m_mask->getDescriptor(), newWidth, newHeight, m_mask->getNumSamples()));
+ m_mask->addReference();
+ }
+
+ int wmin = RI_INT_MIN(newWidth,oldWidth);
+ int hmin = RI_INT_MIN(newHeight,oldHeight);
+ m_color->clear(Color(0.0f, 0.0f, 0.0f, 0.0f, getDescriptor().internalFormat), 0, 0, m_color->getWidth(), m_color->getHeight());
+ m_color->blit(oldcolor, 0, 0, 0, 0, wmin, hmin);
+ if(m_mask)
+ {
+ m_mask->clear(Color(1.0f, 1.0f, 1.0f, 1.0f, getDescriptor().internalFormat), 0, 0, m_mask->getWidth(), m_mask->getHeight());
+ m_mask->blit(oldmask, 0, 0, 0, 0, wmin, hmin);
+ }
+
+ if(!oldcolor->removeReference())
+ RI_DELETE(oldcolor);
+ if(oldmask)
+ if(!oldmask->removeReference())
+ RI_DELETE(oldmask);
+}
+
+//==============================================================================================
+
+} //namespace OpenVGRI
+
+//==============================================================================================
diff --git a/src/vg/Image.h b/src/vg/Image.h
new file mode 100644
index 0000000..22af28f
--- /dev/null
+++ b/src/vg/Image.h
@@ -0,0 +1,371 @@
+#ifndef __IMAGE_H
+#define __IMAGE_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Color and Image classes.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "VG/openvg.h"
+#include "Math.h"
+#include "Array.h"
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief A class representing rectangles.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class Rectangle
+{
+public:
+ Rectangle() : x(0), y(0), width(0), height(0) {}
+ Rectangle(int rx, int ry, int rw, int rh) : x(rx), y(ry), width(rw), height(rh) {}
+ void intersect(const Rectangle& r)
+ {
+ if(width >= 0 && r.width >= 0 && height >= 0 && r.height >= 0)
+ {
+ int x1 = RI_INT_MIN(RI_INT_ADDSATURATE(x, width), RI_INT_ADDSATURATE(r.x, r.width));
+ x = RI_INT_MAX(x, r.x);
+ width = RI_INT_MAX(x1 - x, 0);
+
+ int y1 = RI_INT_MIN(RI_INT_ADDSATURATE(y, height), RI_INT_ADDSATURATE(r.y, r.height));
+ y = RI_INT_MAX(y, r.y);
+ height = RI_INT_MAX(y1 - y, 0);
+ }
+ else
+ {
+ x = 0;
+ y = 0;
+ width = 0;
+ height = 0;
+ }
+ }
+
+ int x;
+ int y;
+ int width;
+ int height;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief A class representing color for processing and converting it
+* to and from various surface formats.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class Color
+{
+public:
+ enum InternalFormat
+ {
+ lRGBA = 0,
+ sRGBA = 1,
+ lRGBA_PRE = 2,
+ sRGBA_PRE = 3,
+ lLA = 4,
+ sLA = 5,
+ lLA_PRE = 6,
+ sLA_PRE = 7
+ };
+ enum FormatBits
+ {
+ NONLINEAR = (1<<0),
+ PREMULTIPLIED = (1<<1),
+ LUMINANCE = (1<<2)
+ };
+ class Descriptor
+ {
+ public:
+ bool isNonlinear() const { return (internalFormat & NONLINEAR) ? true : false; }
+ bool isPremultiplied() const { return (internalFormat & PREMULTIPLIED) ? true : false; }
+ bool isLuminance() const { return (internalFormat & LUMINANCE) ? true : false; }
+ bool isAlphaOnly() const { return (alphaBits && (redBits+greenBits+blueBits+luminanceBits) == 0) ? true : false; }
+
+ int redBits;
+ int redShift;
+ int greenBits;
+ int greenShift;
+ int blueBits;
+ int blueShift;
+ int alphaBits;
+ int alphaShift;
+ int luminanceBits;
+ int luminanceShift;
+ VGImageFormat format;
+ InternalFormat internalFormat;
+ int bitsPerPixel;
+ };
+
+ inline Color() : r(0.0f), g(0.0f), b(0.0f), a(0.0f), m_format(lRGBA) {}
+ inline Color(RIfloat cl, RIfloat ca, InternalFormat cs) : r(cl), g(cl), b(cl), a(ca), m_format(cs) { RI_ASSERT(cs == lLA || cs == sLA || cs == lLA_PRE || cs == sLA_PRE); }
+ inline Color(RIfloat cr, RIfloat cg, RIfloat cb, RIfloat ca, InternalFormat cs) : r(cr), g(cg), b(cb), a(ca), m_format(cs) { RI_ASSERT(cs == lRGBA || cs == sRGBA || cs == lRGBA_PRE || cs == sRGBA_PRE || cs == lLA || cs == sLA || cs == lLA_PRE || cs == sLA_PRE); }
+ inline Color(const Color& c) : r(c.r), g(c.g), b(c.b), a(c.a), m_format(c.m_format) {}
+ inline Color& operator=(const Color&c) { r = c.r; g = c.g; b = c.b; a = c.a; m_format = c.m_format; return *this; }
+ inline void operator*=(RIfloat f) { r *= f; g *= f; b *= f; a*= f; }
+ inline void operator+=(const Color& c1) { RI_ASSERT(m_format == c1.getInternalFormat()); r += c1.r; g += c1.g; b += c1.b; a += c1.a; }
+ inline void operator-=(const Color& c1) { RI_ASSERT(m_format == c1.getInternalFormat()); r -= c1.r; g -= c1.g; b -= c1.b; a -= c1.a; }
+
+ void set(RIfloat cl, RIfloat ca, InternalFormat cs) { RI_ASSERT(cs == lLA || cs == sLA || cs == lLA_PRE || cs == sLA_PRE); r = cl; g = cl; b = cl; a = ca; m_format = cs; }
+ void set(RIfloat cr, RIfloat cg, RIfloat cb, RIfloat ca, InternalFormat cs) { RI_ASSERT(cs == lRGBA || cs == sRGBA || cs == lRGBA_PRE || cs == sRGBA_PRE); r = cr; g = cg; b = cb; a = ca; m_format = cs; }
+ void unpack(unsigned int inputData, const Descriptor& inputDesc);
+ unsigned int pack(const Descriptor& outputDesc) const;
+ inline InternalFormat getInternalFormat() const { return m_format; }
+
+ //clamps nonpremultiplied colors and alpha to [0,1] range, and premultiplied alpha to [0,1], colors to [0,a]
+ void clamp() { a = RI_CLAMP(a,0.0f,1.0f); RIfloat u = (m_format & PREMULTIPLIED) ? a : (RIfloat)1.0f; r = RI_CLAMP(r,0.0f,u); g = RI_CLAMP(g,0.0f,u); b = RI_CLAMP(b,0.0f,u); }
+ void convert(InternalFormat outputFormat);
+ void premultiply() { if(!(m_format & PREMULTIPLIED)) { r *= a; g *= a; b *= a; m_format = (InternalFormat)(m_format | PREMULTIPLIED); } }
+ void unpremultiply() { if(m_format & PREMULTIPLIED) { RIfloat ooa = (a != 0.0f) ? 1.0f/a : (RIfloat)0.0f; r *= ooa; g *= ooa; b *= ooa; m_format = (InternalFormat)(m_format & ~PREMULTIPLIED); } }
+ void luminanceToRGB() { if(m_format & LUMINANCE) { RI_ASSERT(r == g && g == b); m_format = (InternalFormat)(m_format & ~LUMINANCE); } }
+
+ bool isNonlinear() const { return (m_format & NONLINEAR) ? true : false; }
+ bool isPremultiplied() const { return (m_format & PREMULTIPLIED) ? true : false; }
+ bool isLuminance() const { return (m_format & LUMINANCE) ? true : false; }
+
+ inline void assertConsistency() const;
+
+ static Descriptor formatToDescriptor(VGImageFormat format);
+ static bool isValidDescriptor(const Descriptor& desc);
+
+ RIfloat r;
+ RIfloat g;
+ RIfloat b;
+ RIfloat a;
+private:
+ InternalFormat m_format;
+};
+
+inline Color operator*(const Color& c, RIfloat f) { return Color(c.r*f, c.g*f, c.b*f, c.a*f, c.getInternalFormat()); }
+inline Color operator*(RIfloat f, const Color& c) { return Color(c.r*f, c.g*f, c.b*f, c.a*f, c.getInternalFormat()); }
+inline Color operator+(const Color& c0, const Color& c1) { RI_ASSERT(c0.getInternalFormat() == c1.getInternalFormat()); return Color(c0.r+c1.r, c0.g+c1.g, c0.b+c1.b, c0.a+c1.a, c0.getInternalFormat()); }
+inline Color operator-(const Color& c0, const Color& c1) { RI_ASSERT(c0.getInternalFormat() == c1.getInternalFormat()); return Color(c0.r-c1.r, c0.g-c1.g, c0.b-c1.b, c0.a-c1.a, c0.getInternalFormat()); }
+inline void Color::assertConsistency() const
+{
+ RI_ASSERT(r >= 0.0f && r <= 1.0f);
+ RI_ASSERT(g >= 0.0f && g <= 1.0f);
+ RI_ASSERT(b >= 0.0f && b <= 1.0f);
+ RI_ASSERT(a >= 0.0f && a <= 1.0f);
+ RI_ASSERT(!isPremultiplied() || (r <= a && g <= a && b <= a)); //premultiplied colors must have color channels less than or equal to alpha
+ RI_ASSERT((isLuminance() && r == g && r == b) || !isLuminance()); //if luminance, r=g=b
+}
+
+//==============================================================================================
+
+/*-------------------------------------------------------------------*//*!
+* \brief Storage and operations for VGImage.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class Surface;
+class Image
+{
+public:
+ Image(const Color::Descriptor& desc, int width, int height, VGbitfield allowedQuality); //throws bad_alloc
+ //use data from a memory buffer. NOTE: data is not copied, so it is user's responsibility to make sure the data remains valid while the Image is in use.
+ Image(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data); //throws bad_alloc
+ //child image constructor
+ Image(Image* parent, int x, int y, int width, int height); //throws bad_alloc
+ ~Image();
+
+ const Color::Descriptor& getDescriptor() const { return m_desc; }
+ int getWidth() const { return m_width; }
+ int getHeight() const { return m_height; }
+ int getStride() const { return m_stride; }
+ Image* getParent() const { return m_parent; }
+ VGbitfield getAllowedQuality() const { return m_allowedQuality; }
+ void addInUse() { m_inUse++; }
+ void removeInUse() { RI_ASSERT(m_inUse > 0); m_inUse--; }
+ int isInUse() const { return m_inUse; }
+ RIuint8* getData() const { return m_data; }
+ void addReference() { m_referenceCount++; }
+ int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+ bool overlaps(const Image* src) const;
+
+ void clear(const Color& clearColor, int x, int y, int w, int h);
+ void blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h, bool dither); //throws bad_alloc
+ void blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h); //throws bad_alloc
+
+ Color readPixel(int x, int y) const;
+ void writePixel(int x, int y, const Color& c);
+ void writeFilteredPixel(int x, int y, const Color& c, VGbitfield channelMask);
+
+ RIfloat readMaskPixel(int x, int y) const; //can read any image format
+ void writeMaskPixel(int x, int y, RIfloat m); //can write only to VG_A_x
+
+ Color resample(RIfloat x, RIfloat y, const Matrix3x3& surfaceToImage, VGImageQuality quality, VGTilingMode tilingMode, const Color& tileFillColor); //throws bad_alloc
+ void makeMipMaps(); //throws bad_alloc
+
+ void colorMatrix(const Image& src, const RIfloat* matrix, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+ void convolve(const Image& src, int kernelWidth, int kernelHeight, int shiftX, int shiftY, const RIint16* kernel, RIfloat scale, RIfloat bias, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+ void separableConvolve(const Image& src, int kernelWidth, int kernelHeight, int shiftX, int shiftY, const RIint16* kernelX, const RIint16* kernelY, RIfloat scale, RIfloat bias, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+ void gaussianBlur(const Image& src, RIfloat stdDeviationX, RIfloat stdDeviationY, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+ void lookup(const Image& src, const RIuint8 * redLUT, const RIuint8 * greenLUT, const RIuint8 * blueLUT, const RIuint8 * alphaLUT, bool outputLinear, bool outputPremultiplied, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+ void lookupSingle(const Image& src, const RIuint32 * lookupTable, VGImageChannel sourceChannel, bool outputLinear, bool outputPremultiplied, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+private:
+ Image(const Image&); //!< Not allowed.
+ void operator=(const Image&); //!< Not allowed.
+
+ Color readTexel(int u, int v, int level, VGTilingMode tilingMode, const Color& tileFillColor) const;
+
+ Color::Descriptor m_desc;
+ int m_width;
+ int m_height;
+ VGbitfield m_allowedQuality;
+ int m_inUse;
+ int m_stride;
+ RIuint8* m_data;
+ int m_referenceCount;
+ bool m_ownsData;
+ Image* m_parent;
+ int m_storageOffsetX;
+ int m_storageOffsetY;
+
+ bool m_mipmapsValid;
+ Array<Image*> m_mipmaps;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief Surface class abstracting multisampled rendering surface.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class Surface
+{
+public:
+ Surface(const Color::Descriptor& desc, int width, int height, int numSamples); //throws bad_alloc
+ Surface(Image* image); //throws bad_alloc
+ Surface(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data); //throws bad_alloc
+ ~Surface();
+
+ inline const Color::Descriptor& getDescriptor() const { return m_image->getDescriptor(); }
+ inline int getWidth() const { return m_width; }
+ inline int getHeight() const { return m_height; }
+ inline int getNumSamples() const { return m_numSamples; }
+ inline void addReference() { m_referenceCount++; }
+ inline int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+ inline int isInUse() const { return m_image->isInUse(); }
+ inline bool isInUse(Image* image) const { return image == m_image ? true : false; }
+
+ void clear(const Color& clearColor, int x, int y, int w, int h);
+ void clear(const Color& clearColor, int x, int y, int w, int h, const Array<Rectangle>& scissors);
+ void blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h); //throws bad_alloc
+ void blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h, const Array<Rectangle>& scissors); //throws bad_alloc
+ void blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h); //throws bad_alloc
+ void blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h, const Array<Rectangle>& scissors); //throws bad_alloc
+ void mask(const Image* src, VGMaskOperation operation, int x, int y, int w, int h);
+ void mask(const Surface* src, VGMaskOperation operation, int x, int y, int w, int h);
+
+ inline Color readSample(int x, int y, int sample) const { return m_image->readPixel(x*m_numSamples+sample, y); }
+ inline void writeSample(int x, int y, int sample, const Color& c) { m_image->writePixel(x*m_numSamples+sample, y, c); }
+
+ RIfloat readMaskCoverage(int x, int y) const;
+ void writeMaskCoverage(int x, int y, RIfloat m);
+ unsigned int readMaskMSAA(int x, int y) const;
+ void writeMaskMSAA(int x, int y, unsigned int m);
+
+ Color FSAAResolve(int x, int y) const; //for fb=>img: vgGetPixels, vgReadPixels
+private:
+ Surface(const Surface&); //!< Not allowed.
+ void operator=(const Surface&); //!< Not allowed.
+
+ struct ScissorEdge
+ {
+ ScissorEdge() : x(0), miny(0), maxy(0), direction(0) {}
+ bool operator<(const ScissorEdge& e) const { return x < e.x; }
+ int x;
+ int miny;
+ int maxy;
+ int direction; //1 start, -1 end
+ };
+
+ int m_width;
+ int m_height;
+ int m_numSamples;
+ int m_referenceCount;
+ Image* m_image;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief Drawable class for encapsulating color and mask buffers.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class Drawable
+{
+public:
+ Drawable(const Color::Descriptor& desc, int width, int height, int numSamples, int maskBits); //throws bad_alloc
+ Drawable(Image* image, int maskBits); //throws bad_alloc
+ Drawable(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data, int maskBits); //throws bad_alloc
+ ~Drawable();
+
+ inline const Color::Descriptor& getDescriptor() const { return m_color->getDescriptor(); }
+ inline int getNumMaskBits() const { if(!m_mask) return 0; return m_mask->getDescriptor().alphaBits; }
+ inline int getWidth() const { return m_color->getWidth(); }
+ inline int getHeight() const { return m_color->getHeight(); }
+ inline int getNumSamples() const { return m_color->getNumSamples(); }
+ inline void addReference() { m_referenceCount++; }
+ inline int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+ inline int isInUse() const { return m_color->isInUse() || (m_mask && m_mask->isInUse()); }
+ inline bool isInUse(Image* image) const { return m_color->isInUse(image) || (m_mask && m_mask->isInUse(image)); }
+ inline Surface* getColorBuffer() const { return m_color; }
+ inline Surface* getMaskBuffer() const { return m_mask; }
+
+ void resize(int newWidth, int newHeight); //throws bad_alloc
+private:
+ Drawable(const Drawable&); //!< Not allowed.
+ void operator=(const Drawable&); //!< Not allowed.
+
+ int m_referenceCount;
+ Surface* m_color;
+ Surface* m_mask;
+};
+
+//==============================================================================================
+
+} //namespace OpenVGRI
+
+//==============================================================================================
+
+#endif /* __IMAGE_H */
diff --git a/src/vg/Math.cpp b/src/vg/Math.cpp
new file mode 100644
index 0000000..1b638ee
--- /dev/null
+++ b/src/vg/Math.cpp
@@ -0,0 +1,75 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Implementation of non-inline matrix functions.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Defs.h"
+#include "Math.h"
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief Inverts a 3x3 matrix. Returns false if the matrix is singular.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool Matrix3x3::invert()
+{
+ bool affine = isAffine();
+ RIfloat det00 = matrix[1][1]*matrix[2][2] - matrix[2][1]*matrix[1][2];
+ RIfloat det01 = matrix[2][0]*matrix[1][2] - matrix[1][0]*matrix[2][2];
+ RIfloat det02 = matrix[1][0]*matrix[2][1] - matrix[2][0]*matrix[1][1];
+
+ RIfloat d = matrix[0][0]*det00 + matrix[0][1]*det01 + matrix[0][2]*det02;
+ if( d == 0.0f ) return false; //singular, leave the matrix unmodified and return false
+ d = 1.0f / d;
+
+ Matrix3x3 t;
+ t[0][0] = d * det00;
+ t[1][0] = d * det01;
+ t[2][0] = d * det02;
+ t[0][1] = d * (matrix[2][1]*matrix[0][2] - matrix[0][1]*matrix[2][2]);
+ t[1][1] = d * (matrix[0][0]*matrix[2][2] - matrix[2][0]*matrix[0][2]);
+ t[2][1] = d * (matrix[2][0]*matrix[0][1] - matrix[0][0]*matrix[2][1]);
+ t[0][2] = d * (matrix[0][1]*matrix[1][2] - matrix[1][1]*matrix[0][2]);
+ t[1][2] = d * (matrix[1][0]*matrix[0][2] - matrix[0][0]*matrix[1][2]);
+ t[2][2] = d * (matrix[0][0]*matrix[1][1] - matrix[1][0]*matrix[0][1]);
+ if(affine)
+ t[2].set(0,0,1); //affine matrix stays affine
+ *this = t;
+ return true;
+}
+
+//==============================================================================================
+
+} //namespace tgOpenVG
diff --git a/src/vg/Math.h b/src/vg/Math.h
new file mode 100644
index 0000000..7cbcdce
--- /dev/null
+++ b/src/vg/Math.h
@@ -0,0 +1,380 @@
+#ifndef __MATH_H
+#define __MATH_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Math functions, Vector and Matrix classes.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Defs.h"
+
+#include <math.h>
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+inline int RI_ISNAN(float a)
+{
+ RIfloatInt p;
+ p.f = a;
+ unsigned int exponent = (p.i>>23) & 0xff;
+ unsigned int mantissa = p.i & 0x7fffff;
+ if(exponent == 255 && mantissa)
+ return 1;
+ return 0;
+}
+
+#if (RI_MANTISSA_BITS > 23)
+#error RI_MANTISSA_BITS is greater than 23
+#elif (RI_EXPONENT_BITS > 8)
+#error RI_EXPONENT_BITS is greater than 8
+#elif (RI_MANTISSA_BITS != 23) || (RI_EXPONENT_BITS != 8)
+
+class RIfloat
+{
+public:
+ RIfloat() : v(0.0f) { removeBits(); }
+ RIfloat(float a) : v(a) { removeBits(); }
+ RIfloat(double a) : v((float)a) { removeBits(); }
+ RIfloat(int a) : v((float)a) { removeBits(); }
+ RIfloat(unsigned int a) : v((float)a) { removeBits(); }
+ RIfloat& operator=(const RIfloat &a) { v = a.v; removeBits(); return *this; }
+ RIfloat& operator+=(const RIfloat &a){ v += a.v; removeBits(); return *this; }
+ RIfloat& operator-=(const RIfloat &a){ v -= a.v; removeBits(); return *this; }
+ RIfloat& operator*=(const RIfloat &a){ v *= a.v; removeBits(); return *this; }
+ RIfloat& operator/=(const RIfloat &a){ v /= a.v; removeBits(); return *this; }
+ RIfloat operator-() const { return -v; }
+ operator float() const { return v; }
+ operator double() const { return (double)v; }
+ operator int() const { return (int)v; }
+
+ friend RIfloat operator+(const RIfloat &a, const RIfloat &b);
+ friend RIfloat operator+(float a, const RIfloat &b);
+ friend RIfloat operator+(const RIfloat &a, float b);
+ friend RIfloat operator-(const RIfloat &a, const RIfloat &b);
+ friend RIfloat operator-(float a, const RIfloat &b);
+ friend RIfloat operator-(const RIfloat &a, float b);
+ friend RIfloat operator*(const RIfloat &a, const RIfloat &b);
+ friend RIfloat operator*(float a, const RIfloat &b);
+ friend RIfloat operator*(const RIfloat &a, float b);
+ friend RIfloat operator/(const RIfloat &a, const RIfloat &b);
+ friend RIfloat operator/(float a, const RIfloat &b);
+ friend RIfloat operator/(const RIfloat &a, float b);
+
+ friend bool operator<(const RIfloat &a, const RIfloat &b);
+ friend bool operator<(float a, const RIfloat &b);
+ friend bool operator<(const RIfloat &a, float b);
+ friend bool operator>(const RIfloat &a, const RIfloat &b);
+ friend bool operator>(float a, const RIfloat &b);
+ friend bool operator>(const RIfloat &a, float b);
+ friend bool operator<=(const RIfloat &a, const RIfloat &b);
+ friend bool operator<=(float a, const RIfloat &b);
+ friend bool operator<=(const RIfloat &a, float b);
+ friend bool operator>=(const RIfloat &a, const RIfloat &b);
+ friend bool operator>=(float a, const RIfloat &b);
+ friend bool operator>=(const RIfloat &a, float b);
+ friend bool operator==(const RIfloat &a, const RIfloat &b);
+ friend bool operator==(float a, const RIfloat &b);
+ friend bool operator==(const RIfloat &a, float b);
+ friend bool operator!=(const RIfloat &a, const RIfloat &b);
+ friend bool operator!=(float a, const RIfloat &b);
+ friend bool operator!=(const RIfloat &a, float b);
+private:
+ void removeBits()
+ {
+ RIfloatInt p;
+ p.f = v;
+ unsigned int exponent = (p.i>>23) & 0xff;
+ if(exponent == 0 || exponent == 255)
+ return; //zero, denormal, infinite, or NaN
+
+ p.i &= ~((1<<(23-RI_MANTISSA_BITS))-1);
+
+#if (RI_EXPONENT_BITS != 8)
+ if (exponent > 127 + (1 << (RI_EXPONENT_BITS-1)))
+ exponent = 127 + (1 << (RI_EXPONENT_BITS-1));
+
+ if (exponent < 127 + 1 - (1 << (RI_EXPONENT_BITS-1)))
+ exponent = 127 + 1 - (1 << (RI_EXPONENT_BITS-1));
+
+ p.i &= ~(0xff<<23);
+ p.i |= exponent<<23;
+#endif
+ v = p.f;
+ }
+
+ float v;
+};
+
+inline RIfloat operator+(const RIfloat &a, const RIfloat &b) { return RIfloat(a.v+b.v); }
+inline RIfloat operator+(float a, const RIfloat &b) { return RIfloat(a+b.v); }
+inline RIfloat operator+(const RIfloat &a, float b) { return RIfloat(a.v+b); }
+inline RIfloat operator-(const RIfloat &a, const RIfloat &b) { return RIfloat(a.v-b.v); }
+inline RIfloat operator-(float a, const RIfloat &b) { return RIfloat(a-b.v); }
+inline RIfloat operator-(const RIfloat &a, float b) { return RIfloat(a.v-b); }
+inline RIfloat operator*(const RIfloat &a, const RIfloat &b) { return RIfloat(a.v*b.v); }
+inline RIfloat operator*(float a, const RIfloat &b) { return RIfloat(a*b.v); }
+inline RIfloat operator*(const RIfloat &a, float b) { return RIfloat(a.v*b); }
+inline RIfloat operator/(const RIfloat &a, const RIfloat &b) { return RIfloat(a.v/b.v); }
+inline RIfloat operator/(float a, const RIfloat &b) { return RIfloat(a/b.v); }
+inline RIfloat operator/(const RIfloat &a, float b) { return RIfloat(a.v/b); }
+
+inline bool operator<(const RIfloat &a, const RIfloat &b) { return a.v < b.v ? true : false; }
+inline bool operator<(float a, const RIfloat &b) { return a < b.v ? true : false; }
+inline bool operator<(const RIfloat &a, float b) { return a.v < b ? true : false; }
+inline bool operator>(const RIfloat &a, const RIfloat &b) { return a.v > b.v ? true : false; }
+inline bool operator>(float a, const RIfloat &b) { return a > b.v ? true : false; }
+inline bool operator>(const RIfloat &a, float b) { return a.v > b ? true : false; }
+inline bool operator<=(const RIfloat &a, const RIfloat &b) { return a.v <= b.v ? true : false; }
+inline bool operator<=(float a, const RIfloat &b) { return a <= b.v ? true : false; }
+inline bool operator<=(const RIfloat &a, float b) { return a.v <= b ? true : false; }
+inline bool operator>=(const RIfloat &a, const RIfloat &b) { return a.v >= b.v ? true : false; }
+inline bool operator>=(float a, const RIfloat &b) { return a >= b.v ? true : false; }
+inline bool operator>=(const RIfloat &a, float b) { return a.v >= b ? true : false; }
+inline bool operator==(const RIfloat &a, const RIfloat &b) { return a.v == b.v ? true : false; }
+inline bool operator==(float a, const RIfloat &b) { return a == b.v ? true : false; }
+inline bool operator==(const RIfloat &a, float b) { return a.v == b ? true : false; }
+inline bool operator!=(const RIfloat &a, const RIfloat &b) { return a.v != b.v ? true : false; }
+inline bool operator!=(float a, const RIfloat &b) { return a != b.v ? true : false; }
+inline bool operator!=(const RIfloat &a, float b) { return a.v != b ? true : false; }
+
+#else
+typedef float RIfloat;
+#endif
+
+#define PI 3.141592654f
+
+inline RIfloat RI_MAX(RIfloat a, RIfloat b) { return (a > b) ? a : b; }
+inline RIfloat RI_MIN(RIfloat a, RIfloat b) { return (a < b) ? a : b; }
+inline RIfloat RI_CLAMP(RIfloat a, RIfloat l, RIfloat h) { if(RI_ISNAN(a)) return l; RI_ASSERT(l <= h); return (a < l) ? l : (a > h) ? h : a; }
+inline void RI_SWAP(RIfloat &a, RIfloat &b) { RIfloat tmp = a; a = b; b = tmp; }
+inline RIfloat RI_ABS(RIfloat a) { return (a < 0.0f) ? -a : a; }
+inline RIfloat RI_SQR(RIfloat a) { return a * a; }
+inline RIfloat RI_DEG_TO_RAD(RIfloat a) { return a * PI / 180.0f; }
+inline RIfloat RI_RAD_TO_DEG(RIfloat a) { return a * 180.0f/ PI; }
+inline RIfloat RI_MOD(RIfloat a, RIfloat b) { if(RI_ISNAN(a) || RI_ISNAN(b)) return 0.0f; RI_ASSERT(b >= 0.0f); if(b == 0.0f) return 0.0f; RIfloat f = (RIfloat)fmod(a, b); if(f < 0.0f) f += b; RI_ASSERT(f >= 0.0f && f <= b); return f; }
+
+inline int RI_INT_MAX(int a, int b) { return (a > b) ? a : b; }
+inline int RI_INT_MIN(int a, int b) { return (a < b) ? a : b; }
+inline void RI_INT_SWAP(int &a, int &b) { int tmp = a; a = b; b = tmp; }
+inline int RI_INT_MOD(int a, int b) { RI_ASSERT(b >= 0); if(!b) return 0; int i = a % b; if(i < 0) i += b; RI_ASSERT(i >= 0 && i < b); return i; }
+inline int RI_INT_ADDSATURATE(int a, int b) { RI_ASSERT(b >= 0); int r = a + b; return (r >= a) ? r : RI_INT32_MAX; }
+
+class Matrix3x3;
+class Vector2;
+class Vector3;
+
+//==============================================================================================
+
+//MatrixRxC, R = number of rows, C = number of columns
+//indexing: matrix[row][column]
+//Matrix3x3 inline functions cannot be inside the class because Vector3 is not defined yet when Matrix3x3 is defined
+
+class Matrix3x3
+{
+public:
+ inline Matrix3x3 (); //initialized to identity
+ inline Matrix3x3 ( const Matrix3x3& m );
+ inline Matrix3x3 ( RIfloat m00, RIfloat m01, RIfloat m02, RIfloat m10, RIfloat m11, RIfloat m12, RIfloat m20, RIfloat m21, RIfloat m22 );
+ inline ~Matrix3x3 ();
+ inline Matrix3x3& operator= ( const Matrix3x3& m );
+ inline Vector3& operator[] ( int i ); //returns a row vector
+ inline const Vector3& operator[] ( int i ) const;
+ inline void set ( RIfloat m00, RIfloat m01, RIfloat m02, RIfloat m10, RIfloat m11, RIfloat m12, RIfloat m20, RIfloat m21, RIfloat m22 );
+ inline const Vector3 getRow ( int i ) const;
+ inline const Vector3 getColumn ( int i ) const;
+ inline void setRow ( int i, const Vector3& v );
+ inline void setColumn ( int i, const Vector3& v );
+ inline void operator*= ( const Matrix3x3& m );
+ inline void operator*= ( RIfloat f );
+ inline void operator+= ( const Matrix3x3& m );
+ inline void operator-= ( const Matrix3x3& m );
+ inline const Matrix3x3 operator- () const;
+ inline void identity ();
+ inline void transpose ();
+ bool invert (); //if the matrix is singular, returns false and leaves it unmodified
+ inline RIfloat det () const;
+ inline bool isAffine () const;
+
+private:
+ RIfloat matrix[3][3];
+};
+
+//==============================================================================================
+
+class Vector2
+{
+public:
+ inline Vector2 () : x(0.0f), y(0.0f) {}
+ inline Vector2 ( const Vector2& v ) : x(v.x), y(v.y) {}
+ inline Vector2 ( RIfloat fx, RIfloat fy ) : x(fx), y(fy) {}
+ inline ~Vector2 () {}
+ inline Vector2& operator= ( const Vector2& v ) { x = v.x; y = v.y; return *this; }
+ inline RIfloat& operator[] ( int i ) { RI_ASSERT(i>=0&&i<2); return (&x)[i]; }
+ inline const RIfloat& operator[] ( int i ) const { RI_ASSERT(i>=0&&i<2); return (&x)[i]; }
+ inline void set ( RIfloat fx, RIfloat fy ) { x = fx; y = fy; }
+ inline void operator*= ( RIfloat f ) { x *= f; y *= f; }
+ inline void operator+= ( const Vector2& v ) { x += v.x; y += v.y; }
+ inline void operator-= ( const Vector2& v ) { x -= v.x; y -= v.y; }
+ inline const Vector2 operator- () const { return Vector2(-x,-y); }
+ //if the vector is zero, returns false and leaves it unmodified
+ inline bool normalize () { double l = (double)x*(double)x+(double)y*(double)y; if( l == 0.0 ) return false; l = 1.0 / sqrt(l); x = (RIfloat)((double)x * l); y = (RIfloat)((double)y * l); return true; }
+ inline RIfloat length () const { return (RIfloat)sqrt((double)x*(double)x+(double)y*(double)y); }
+ inline void scale ( const Vector2& v ) { x *= v.x; y *= v.y; } //component-wise scale
+ inline void negate () { x = -x; y = -y; }
+
+ RIfloat x,y;
+};
+
+//==============================================================================================
+
+class Vector3
+{
+public:
+ inline Vector3 () : x(0.0f), y(0.0f), z(0.0f) {}
+ inline Vector3 ( const Vector3& v ) : x(v.x), y(v.y), z(v.z) {}
+ inline Vector3 ( RIfloat fx, RIfloat fy, RIfloat fz ) : x(fx), y(fy), z(fz) {}
+ inline ~Vector3 () {}
+ inline Vector3& operator= ( const Vector3& v ) { x = v.x; y = v.y; z = v.z; return *this; }
+ inline RIfloat& operator[] ( int i ) { RI_ASSERT(i>=0&&i<3); return (&x)[i]; }
+ inline const RIfloat& operator[] ( int i ) const { RI_ASSERT(i>=0&&i<3); return (&x)[i]; }
+ inline void set ( RIfloat fx, RIfloat fy, RIfloat fz ){ x = fx; y = fy; z = fz; }
+ inline void operator*= ( RIfloat f ) { x *= f; y *= f; z *= f; }
+ inline void operator+= ( const Vector3& v ) { x += v.x; y += v.y; z += v.z; }
+ inline void operator-= ( const Vector3& v ) { x -= v.x; y -= v.y; z -= v.z; }
+ inline const Vector3 operator- () const { return Vector3(-x,-y,-z); }
+ //if the vector is zero, returns false and leaves it unmodified
+ inline bool normalize () { double l = (double)x*(double)x+(double)y*(double)y+(double)z*(double)z; if( l == 0.0 ) return false; l = 1.0 / sqrt(l); x = (RIfloat)((double)x * l); y = (RIfloat)((double)y * l); z = (RIfloat)((double)z * l); return true; }
+ inline RIfloat length () const { return (RIfloat)sqrt((double)x*(double)x+(double)y*(double)y+(double)z*(double)z); }
+ inline void scale ( const Vector3& v ) { x *= v.x; y *= v.y; z *= v.z; } //component-wise scale
+ inline void negate () { x = -x; y = -y; z = -z; }
+
+ RIfloat x,y,z;
+};
+
+//==============================================================================================
+
+//Vector2 global functions
+inline bool operator== ( const Vector2& v1, const Vector2& v2 ) { return (v1.x == v2.x) && (v1.y == v2.y); }
+inline bool operator!= ( const Vector2& v1, const Vector2& v2 ) { return (v1.x != v2.x) || (v1.y != v2.y); }
+inline bool isEqual ( const Vector2& v1, const Vector2& v2, RIfloat epsilon ) { return RI_SQR(v2.x-v1.x) + RI_SQR(v2.y-v1.y) <= epsilon*epsilon; }
+inline bool isZero ( const Vector2& v ) { return (v.x == 0.0f) && (v.y == 0.0f); }
+inline const Vector2 operator* ( RIfloat f, const Vector2& v ) { return Vector2(v.x*f,v.y*f); }
+inline const Vector2 operator* ( const Vector2& v, RIfloat f ) { return Vector2(v.x*f,v.y*f); }
+inline const Vector2 operator+ ( const Vector2& v1, const Vector2& v2 ) { return Vector2(v1.x+v2.x, v1.y+v2.y); }
+inline const Vector2 operator- ( const Vector2& v1, const Vector2& v2 ) { return Vector2(v1.x-v2.x, v1.y-v2.y); }
+inline RIfloat dot ( const Vector2& v1, const Vector2& v2 ) { return v1.x*v2.x+v1.y*v2.y; }
+//if v is a zero vector, returns a zero vector
+inline const Vector2 normalize ( const Vector2& v ) { double l = (double)v.x*(double)v.x+(double)v.y*(double)v.y; if( l != 0.0 ) l = 1.0 / sqrt(l); return Vector2((RIfloat)((double)v.x * l), (RIfloat)((double)v.y * l)); }
+//if onThis is a zero vector, returns a zero vector
+inline const Vector2 project ( const Vector2& v, const Vector2& onThis ) { RIfloat l = dot(onThis,onThis); if( l != 0.0f ) l = dot(v, onThis)/l; return onThis * l; }
+inline const Vector2 lerp ( const Vector2& v1, const Vector2& v2, RIfloat ratio ) { return v1 + ratio * (v2 - v1); }
+inline const Vector2 scale ( const Vector2& v1, const Vector2& v2 ) { return Vector2(v1.x*v2.x, v1.y*v2.y); }
+//matrix * column vector. The input vector2 is implicitly expanded to (x,y,1)
+inline const Vector2 affineTransform( const Matrix3x3& m, const Vector2& v ) { RI_ASSERT(m.isAffine()); return Vector2(v.x * m[0][0] + v.y * m[0][1] + m[0][2], v.x * m[1][0] + v.y * m[1][1] + m[1][2]); }
+//matrix * column vector. The input vector2 is implicitly expanded to (x,y,0)
+inline const Vector2 affineTangentTransform(const Matrix3x3& m, const Vector2& v) { RI_ASSERT(m.isAffine()); return Vector2(v.x * m[0][0] + v.y * m[0][1], v.x * m[1][0] + v.y * m[1][1]); }
+inline const Vector2 perpendicularCW(const Vector2& v) { return Vector2(v.y, -v.x); }
+inline const Vector2 perpendicularCCW(const Vector2& v) { return Vector2(-v.y, v.x); }
+inline const Vector2 perpendicular(const Vector2& v, bool cw) { if(cw) return Vector2(v.y, -v.x); return Vector2(-v.y, v.x); }
+
+//==============================================================================================
+
+//Vector3 global functions
+inline bool operator== ( const Vector3& v1, const Vector3& v2 ) { return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); }
+inline bool operator!= ( const Vector3& v1, const Vector3& v2 ) { return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z); }
+inline bool isEqual ( const Vector3& v1, const Vector3& v2, RIfloat epsilon ) { return RI_SQR(v2.x-v1.x) + RI_SQR(v2.y-v1.y) + RI_SQR(v2.z-v1.z) <= epsilon*epsilon; }
+inline const Vector3 operator* ( RIfloat f, const Vector3& v ) { return Vector3(v.x*f,v.y*f,v.z*f); }
+inline const Vector3 operator* ( const Vector3& v, RIfloat f ) { return Vector3(v.x*f,v.y*f,v.z*f); }
+inline const Vector3 operator+ ( const Vector3& v1, const Vector3& v2 ) { return Vector3(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z); }
+inline const Vector3 operator- ( const Vector3& v1, const Vector3& v2 ) { return Vector3(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z); }
+inline RIfloat dot ( const Vector3& v1, const Vector3& v2 ) { return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z; }
+inline const Vector3 cross ( const Vector3& v1, const Vector3& v2 ) { return Vector3( v1.y*v2.z-v1.z*v2.y, v1.z*v2.x-v1.x*v2.z, v1.x*v2.y-v1.y*v2.x ); }
+//if v is a zero vector, returns a zero vector
+inline const Vector3 normalize ( const Vector3& v ) { double l = (double)v.x*(double)v.x+(double)v.y*(double)v.y+(double)v.z*(double)v.z; if( l != 0.0 ) l = 1.0 / sqrt(l); return Vector3((RIfloat)((double)v.x * l), (RIfloat)((double)v.y * l), (RIfloat)((double)v.z * l)); }
+inline const Vector3 lerp ( const Vector3& v1, const Vector3& v2, RIfloat ratio ) { return v1 + ratio * (v2 - v1); }
+inline const Vector3 scale ( const Vector3& v1, const Vector3& v2 ) { return Vector3(v1.x*v2.x, v1.y*v2.y, v1.z*v2.z); }
+
+//==============================================================================================
+
+//matrix * column vector
+inline const Vector3 operator* ( const Matrix3x3& m, const Vector3& v) { return Vector3( v.x*m[0][0]+v.y*m[0][1]+v.z*m[0][2], v.x*m[1][0]+v.y*m[1][1]+v.z*m[1][2], v.x*m[2][0]+v.y*m[2][1]+v.z*m[2][2] ); }
+
+//==============================================================================================
+
+//Matrix3x3 global functions
+inline bool operator== ( const Matrix3x3& m1, const Matrix3x3& m2 ) { for(int i=0;i<3;i++) for(int j=0;j<3;j++) if( m1[i][j] != m2[i][j] ) return false; return true; }
+inline bool operator!= ( const Matrix3x3& m1, const Matrix3x3& m2 ) { return !(m1 == m2); }
+inline const Matrix3x3 operator* ( const Matrix3x3& m1, const Matrix3x3& m2 ) { Matrix3x3 t; for(int i=0;i<3;i++) for(int j=0;j<3;j++) t[i][j] = m1[i][0] * m2[0][j] + m1[i][1] * m2[1][j] + m1[i][2] * m2[2][j]; return t; }
+inline const Matrix3x3 operator* ( RIfloat f, const Matrix3x3& m ) { Matrix3x3 t(m); t *= f; return t; }
+inline const Matrix3x3 operator* ( const Matrix3x3& m, RIfloat f ) { Matrix3x3 t(m); t *= f; return t; }
+inline const Matrix3x3 operator+ ( const Matrix3x3& m1, const Matrix3x3& m2 ) { Matrix3x3 t(m1); t += m2; return t; }
+inline const Matrix3x3 operator- ( const Matrix3x3& m1, const Matrix3x3& m2 ) { Matrix3x3 t(m1); t -= m2; return t; }
+inline const Matrix3x3 transpose ( const Matrix3x3& m ) { Matrix3x3 t(m); t.transpose(); return t; }
+// if the matrix is singular, returns it unmodified
+inline const Matrix3x3 invert ( const Matrix3x3& m ) { Matrix3x3 t(m); t.invert(); return t; }
+
+//==============================================================================================
+
+//Matrix3x3 inline functions (cannot be inside the class because Vector3 is not defined yet when Matrix3x3 is defined)
+inline Matrix3x3::Matrix3x3 () { identity(); }
+inline Matrix3x3::Matrix3x3 ( const Matrix3x3& m ) { *this = m; }
+inline Matrix3x3::Matrix3x3 ( RIfloat m00, RIfloat m01, RIfloat m02, RIfloat m10, RIfloat m11, RIfloat m12, RIfloat m20, RIfloat m21, RIfloat m22 ) { set(m00,m01,m02,m10,m11,m12,m20,m21,m22); }
+inline Matrix3x3::~Matrix3x3 () {}
+inline Matrix3x3& Matrix3x3::operator= ( const Matrix3x3& m ) { for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] = m.matrix[i][j]; return *this; }
+inline Vector3& Matrix3x3::operator[] ( int i ) { RI_ASSERT(i>=0&&i<3); return (Vector3&)matrix[i][0]; }
+inline const Vector3& Matrix3x3::operator[] ( int i ) const { RI_ASSERT(i>=0&&i<3); return (const Vector3&)matrix[i][0]; }
+inline void Matrix3x3::set ( RIfloat m00, RIfloat m01, RIfloat m02, RIfloat m10, RIfloat m11, RIfloat m12, RIfloat m20, RIfloat m21, RIfloat m22 ) { matrix[0][0] = m00; matrix[0][1] = m01; matrix[0][2] = m02; matrix[1][0] = m10; matrix[1][1] = m11; matrix[1][2] = m12; matrix[2][0] = m20; matrix[2][1] = m21; matrix[2][2] = m22; }
+inline const Vector3 Matrix3x3::getRow ( int i ) const { RI_ASSERT(i>=0&&i<3); return Vector3(matrix[i][0], matrix[i][1], matrix[i][2]); }
+inline const Vector3 Matrix3x3::getColumn ( int i ) const { RI_ASSERT(i>=0&&i<3); return Vector3(matrix[0][i], matrix[1][i], matrix[2][i]); }
+inline void Matrix3x3::setRow ( int i, const Vector3& v ) { RI_ASSERT(i>=0&&i<3); matrix[i][0] = v.x; matrix[i][1] = v.y; matrix[i][2] = v.z; }
+inline void Matrix3x3::setColumn ( int i, const Vector3& v ) { RI_ASSERT(i>=0&&i<3); matrix[0][i] = v.x; matrix[1][i] = v.y; matrix[2][i] = v.z; }
+inline void Matrix3x3::operator*= ( const Matrix3x3& m ) { *this = *this * m; }
+inline void Matrix3x3::operator*= ( RIfloat f ) { for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] *= f; }
+inline void Matrix3x3::operator+= ( const Matrix3x3& m ) { for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] += m.matrix[i][j]; }
+inline void Matrix3x3::operator-= ( const Matrix3x3& m ) { for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] -= m.matrix[i][j]; }
+inline const Matrix3x3 Matrix3x3::operator- () const { return Matrix3x3( -matrix[0][0],-matrix[0][1],-matrix[0][2], -matrix[1][0],-matrix[1][1],-matrix[1][2], -matrix[2][0],-matrix[2][1],-matrix[2][2]); }
+inline void Matrix3x3::identity () { for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] = (i == j) ? 1.0f : 0.0f; }
+inline void Matrix3x3::transpose () { RI_SWAP(matrix[1][0], matrix[0][1]); RI_SWAP(matrix[2][0], matrix[0][2]); RI_SWAP(matrix[2][1], matrix[1][2]); }
+inline RIfloat Matrix3x3::det () const { return matrix[0][0] * (matrix[1][1]*matrix[2][2] - matrix[2][1]*matrix[1][2]) + matrix[0][1] * (matrix[2][0]*matrix[1][2] - matrix[1][0]*matrix[2][2]) + matrix[0][2] * (matrix[1][0]*matrix[2][1] - matrix[2][0]*matrix[1][1]); }
+inline bool Matrix3x3::isAffine () const { if(matrix[2][0] == 0.0f && matrix[2][1] == 0.0f && matrix[2][2] == 1.0f) return true; return false; }
+
+//==============================================================================================
+
+} //namespace tgOpenVG
+
+#endif /* __MATH_H */
diff --git a/src/vg/Path.cpp b/src/vg/Path.cpp
new file mode 100644
index 0000000..71469f5
--- /dev/null
+++ b/src/vg/Path.cpp
@@ -0,0 +1,2579 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Implementation of Path functions.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Path.h"
+
+//==============================================================================================
+
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+RIfloat inputFloat(VGfloat f); //defined in riApi.cpp
+
+/*-------------------------------------------------------------------*//*!
+* \brief Form a reliable normalized average of the two unit input vectors.
+* The average always lies to the given direction from the first
+* vector.
+* \param u0, u1 Unit input vectors.
+* \param cw True if the average should be clockwise from u0, false if
+* counterclockwise.
+* \return Average of the two input vectors.
+* \note
+*//*-------------------------------------------------------------------*/
+
+static const Vector2 unitAverage(const Vector2& u0, const Vector2& u1, bool cw)
+{
+ Vector2 u = 0.5f * (u0 + u1);
+ Vector2 n0 = perpendicularCCW(u0);
+
+ if( dot(u, u) > 0.25f )
+ { //the average is long enough and thus reliable
+ if( dot(n0, u1) < 0.0f )
+ u = -u; //choose the larger angle
+ }
+ else
+ { // the average is too short, use the average of the normals to the vectors instead
+ Vector2 n1 = perpendicularCW(u1);
+ u = 0.5f * (n0 + n1);
+ }
+ if( cw )
+ u = -u;
+
+ return normalize(u);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Form a reliable normalized average of the two unit input vectors.
+* The average lies on the side where the angle between the input
+* vectors is less than 180 degrees.
+* \param u0, u1 Unit input vectors.
+* \return Average of the two input vectors.
+* \note
+*//*-------------------------------------------------------------------*/
+
+static const Vector2 unitAverage(const Vector2& u0, const Vector2& u1)
+{
+ Vector2 u = 0.5f * (u0 + u1);
+
+ if( dot(u, u) < 0.25f )
+ { // the average is unreliable, use the average of the normals to the vectors instead
+ Vector2 n0 = perpendicularCCW(u0);
+ Vector2 n1 = perpendicularCW(u1);
+ u = 0.5f * (n0 + n1);
+ if( dot(n1, u0) < 0.0f )
+ u = -u;
+ }
+
+ return normalize(u);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Interpolate the given unit tangent vectors to the given
+* direction on a unit circle.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static const Vector2 circularLerp(const Vector2& t0, const Vector2& t1, RIfloat ratio, bool cw)
+{
+ Vector2 u0 = t0, u1 = t1;
+ RIfloat l0 = 0.0f, l1 = 1.0f;
+ for(int i=0;i<18;i++)
+ {
+ Vector2 n = unitAverage(u0, u1, cw);
+ RIfloat l = 0.5f * (l0 + l1);
+ if( ratio < l )
+ {
+ u1 = n;
+ l1 = l;
+ }
+ else
+ {
+ u0 = n;
+ l0 = l;
+ }
+ }
+ return u0;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Interpolate the given unit tangent vectors on a unit circle.
+* Smaller angle between the vectors is used.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static const Vector2 circularLerp(const Vector2& t0, const Vector2& t1, RIfloat ratio)
+{
+ Vector2 u0 = t0, u1 = t1;
+ RIfloat l0 = 0.0f, l1 = 1.0f;
+ for(int i=0;i<18;i++)
+ {
+ Vector2 n = unitAverage(u0, u1);
+ RIfloat l = 0.5f * (l0 + l1);
+ if( ratio < l )
+ {
+ u1 = n;
+ l1 = l;
+ }
+ else
+ {
+ u0 = n;
+ l0 = l;
+ }
+ }
+ return u0;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Path constructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Path::Path(VGint format, VGPathDatatype datatype, RIfloat scale, RIfloat bias, int segmentCapacityHint, int coordCapacityHint, VGbitfield caps) :
+ m_format(format),
+ m_datatype(datatype),
+ m_scale(scale),
+ m_bias(bias),
+ m_capabilities(caps),
+ m_referenceCount(0),
+ m_segments(),
+ m_data(),
+ m_vertices(),
+ m_segmentToVertex(),
+ m_userMinx(0.0f),
+ m_userMiny(0.0f),
+ m_userMaxx(0.0f),
+ m_userMaxy(0.0f)
+{
+ RI_ASSERT(format == VG_PATH_FORMAT_STANDARD);
+ RI_ASSERT(datatype >= VG_PATH_DATATYPE_S_8 && datatype <= VG_PATH_DATATYPE_F);
+ if(segmentCapacityHint > 0)
+ m_segments.reserve(RI_INT_MIN(segmentCapacityHint, 65536));
+ if(coordCapacityHint > 0)
+ m_data.reserve(RI_INT_MIN(coordCapacityHint, 65536) * getBytesPerCoordinate(datatype));
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Path destructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Path::~Path()
+{
+ RI_ASSERT(m_referenceCount == 0);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Reads a coordinate and applies scale and bias.
+* \param
+* \return
+*//*-------------------------------------------------------------------*/
+
+RIfloat Path::getCoordinate(int i) const
+{
+ RI_ASSERT(i >= 0 && i < m_data.size() / getBytesPerCoordinate(m_datatype));
+ RI_ASSERT(m_scale != 0.0f);
+
+ const RIuint8* ptr = &m_data[0];
+ switch(m_datatype)
+ {
+ case VG_PATH_DATATYPE_S_8:
+ return (RIfloat)(((const RIint8*)ptr)[i]) * m_scale + m_bias;
+
+ case VG_PATH_DATATYPE_S_16:
+ return (RIfloat)(((const RIint16*)ptr)[i]) * m_scale + m_bias;
+
+ case VG_PATH_DATATYPE_S_32:
+ return (RIfloat)(((const RIint32*)ptr)[i]) * m_scale + m_bias;
+
+ default:
+ RI_ASSERT(m_datatype == VG_PATH_DATATYPE_F);
+ return (RIfloat)(((const RIfloat32*)ptr)[i]) * m_scale + m_bias;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Writes a coordinate, subtracting bias and dividing out scale.
+* \param
+* \return
+* \note If the coordinates do not fit into path datatype range, they
+* will overflow silently.
+*//*-------------------------------------------------------------------*/
+
+void Path::setCoordinate(Array<RIuint8>& data, VGPathDatatype datatype, RIfloat scale, RIfloat bias, int i, RIfloat c)
+{
+ RI_ASSERT(i >= 0 && i < data.size()/getBytesPerCoordinate(datatype));
+ RI_ASSERT(scale != 0.0f);
+
+ c -= bias;
+ c /= scale;
+
+ RIuint8* ptr = &data[0];
+ switch(datatype)
+ {
+ case VG_PATH_DATATYPE_S_8:
+ ((RIint8*)ptr)[i] = (RIint8)floor(c + 0.5f); //add 0.5 for correct rounding
+ break;
+
+ case VG_PATH_DATATYPE_S_16:
+ ((RIint16*)ptr)[i] = (RIint16)floor(c + 0.5f); //add 0.5 for correct rounding
+ break;
+
+ case VG_PATH_DATATYPE_S_32:
+ ((RIint32*)ptr)[i] = (RIint32)floor(c + 0.5f); //add 0.5 for correct rounding
+ break;
+
+ default:
+ RI_ASSERT(datatype == VG_PATH_DATATYPE_F);
+ ((RIfloat32*)ptr)[i] = (RIfloat32)c;
+ break;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Given a datatype, returns the number of bytes per coordinate.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+int Path::getBytesPerCoordinate(VGPathDatatype datatype)
+{
+ if(datatype == VG_PATH_DATATYPE_S_8)
+ return 1;
+ if(datatype == VG_PATH_DATATYPE_S_16)
+ return 2;
+ RI_ASSERT(datatype == VG_PATH_DATATYPE_S_32 || datatype == VG_PATH_DATATYPE_F);
+ return 4;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Given a path segment type, returns the number of coordinates
+* it uses.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+int Path::segmentToNumCoordinates(VGPathSegment segment)
+{
+ RI_ASSERT(((int)segment >> 1) >= 0 && ((int)segment >> 1) <= 12);
+ static const int coords[13] = {0,2,2,1,1,4,6,2,4,5,5,5,5};
+ return coords[(int)segment >> 1];
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Computes the number of coordinates a segment sequence uses.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+int Path::countNumCoordinates(const RIuint8* segments, int numSegments)
+{
+ RI_ASSERT(segments);
+ RI_ASSERT(numSegments >= 0);
+
+ int coordinates = 0;
+ for(int i=0;i<numSegments;i++)
+ coordinates += segmentToNumCoordinates(getPathSegment(segments[i]));
+ return coordinates;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Clears path segments and data, and resets capabilities.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Path::clear(VGbitfield capabilities)
+{
+ m_segments.clear();
+ m_data.clear();
+ m_capabilities = capabilities;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Appends user segments and data.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::appendData(const RIuint8* segments, int numSegments, const RIuint8* data)
+{
+ RI_ASSERT(numSegments > 0);
+ RI_ASSERT(segments && data);
+ RI_ASSERT(m_referenceCount > 0);
+
+ //allocate new arrays
+ int oldSegmentsSize = m_segments.size();
+ int newSegmentsSize = oldSegmentsSize + numSegments;
+ Array<RIuint8> newSegments;
+ newSegments.resize(newSegmentsSize); //throws bad_alloc
+
+ int newCoords = countNumCoordinates(segments, numSegments);
+ int bytesPerCoordinate = getBytesPerCoordinate(m_datatype);
+ int newDataSize = m_data.size() + newCoords * bytesPerCoordinate;
+ Array<RIuint8> newData;
+ newData.resize(newDataSize); //throws bad_alloc
+ //if we get here, the memory allocations have succeeded
+
+ //copy old segments and append new ones
+ if(m_segments.size())
+ memcpy(&newSegments[0], &m_segments[0], m_segments.size());
+ memcpy(&newSegments[0] + m_segments.size(), segments, numSegments);
+
+ //copy old data and append new ones
+ if(newData.size())
+ {
+ if(m_data.size())
+ memcpy(&newData[0], &m_data[0], m_data.size());
+ if(m_datatype == VG_PATH_DATATYPE_F)
+ {
+ RIfloat32* d = (RIfloat32*)(&newData[0] + m_data.size());
+ const RIfloat32* s = (const RIfloat32*)data;
+ for(int i=0;i<newCoords;i++)
+ *d++ = (RIfloat32)inputFloat(*s++);
+ }
+ else
+ {
+ memcpy(&newData[0] + m_data.size(), data, newCoords * bytesPerCoordinate);
+ }
+ }
+
+ RI_ASSERT(newData.size() == countNumCoordinates(&newSegments[0],newSegments.size()) * getBytesPerCoordinate(m_datatype));
+
+ //replace old arrays
+ m_segments.swap(newSegments);
+ m_data.swap(newData);
+
+ int c = 0;
+ for(int i=0;i<m_segments.size();i++)
+ {
+ VGPathSegment segment = getPathSegment(m_segments[i]);
+ int coords = segmentToNumCoordinates(segment);
+ c += coords;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Appends a path.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::append(const Path* srcPath)
+{
+ RI_ASSERT(srcPath);
+ RI_ASSERT(m_referenceCount > 0 && srcPath->m_referenceCount > 0);
+
+ if(srcPath->m_segments.size())
+ {
+ //allocate new arrays
+ int newSegmentsSize = m_segments.size() + srcPath->m_segments.size();
+ Array<RIuint8> newSegments;
+ newSegments.resize(newSegmentsSize); //throws bad_alloc
+
+ int newDataSize = m_data.size() + srcPath->getNumCoordinates() * getBytesPerCoordinate(m_datatype);
+ Array<RIuint8> newData;
+ newData.resize(newDataSize); //throws bad_alloc
+ //if we get here, the memory allocations have succeeded
+
+ //copy old segments and append new ones
+ if(m_segments.size())
+ memcpy(&newSegments[0], &m_segments[0], m_segments.size());
+ if(srcPath->m_segments.size())
+ memcpy(&newSegments[0] + m_segments.size(), &srcPath->m_segments[0], srcPath->m_segments.size());
+
+ //copy old data and append new ones
+ if(m_data.size())
+ memcpy(&newData[0], &m_data[0], m_data.size());
+ for(int i=0;i<srcPath->getNumCoordinates();i++)
+ setCoordinate(newData, m_datatype, m_scale, m_bias, i + getNumCoordinates(), srcPath->getCoordinate(i));
+
+ RI_ASSERT(newData.size() == countNumCoordinates(&newSegments[0],newSegments.size()) * getBytesPerCoordinate(m_datatype));
+
+ //replace old arrays
+ m_segments.swap(newSegments);
+ m_data.swap(newData);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Modifies existing coordinate data.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Path::modifyCoords(int startIndex, int numSegments, const RIuint8* data)
+{
+ RI_ASSERT(numSegments > 0);
+ RI_ASSERT(startIndex >= 0 && startIndex + numSegments <= m_segments.size());
+ RI_ASSERT(data);
+ RI_ASSERT(m_referenceCount > 0);
+
+ int startCoord = countNumCoordinates(&m_segments[0], startIndex);
+ int numCoords = countNumCoordinates(&m_segments[startIndex], numSegments);
+ if(!numCoords)
+ return;
+ int bytesPerCoordinate = getBytesPerCoordinate(m_datatype);
+ RIuint8* dst = &m_data[startCoord * bytesPerCoordinate];
+ if(m_datatype == VG_PATH_DATATYPE_F)
+ {
+ RIfloat32* d = (RIfloat32*)dst;
+ const RIfloat32* s = (const RIfloat32*)data;
+ for(int i=0;i<numCoords;i++)
+ *d++ = (RIfloat32)inputFloat(*s++);
+ }
+ else
+ {
+ memcpy(dst, data, numCoords*bytesPerCoordinate);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Appends a transformed copy of the source path.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::transform(const Path* srcPath, const Matrix3x3& matrix)
+{
+ RI_ASSERT(srcPath);
+ RI_ASSERT(m_referenceCount > 0 && srcPath->m_referenceCount > 0);
+ RI_ASSERT(matrix.isAffine());
+
+ if(!srcPath->m_segments.size())
+ return;
+
+ //count the number of resulting coordinates
+ int numSrcCoords = 0;
+ int numDstCoords = 0;
+ for(int i=0;i<srcPath->m_segments.size();i++)
+ {
+ VGPathSegment segment = getPathSegment(srcPath->m_segments[i]);
+ int coords = segmentToNumCoordinates(segment);
+ numSrcCoords += coords;
+ if(segment == VG_HLINE_TO || segment == VG_VLINE_TO)
+ coords = 2; //convert hline and vline to lines
+ numDstCoords += coords;
+ }
+
+ //allocate new arrays
+ Array<RIuint8> newSegments;
+ newSegments.resize(m_segments.size() + srcPath->m_segments.size()); //throws bad_alloc
+ Array<RIuint8> newData;
+ newData.resize(m_data.size() + numDstCoords * getBytesPerCoordinate(m_datatype)); //throws bad_alloc
+ //if we get here, the memory allocations have succeeded
+
+ //copy old segments
+ if(m_segments.size())
+ memcpy(&newSegments[0], &m_segments[0], m_segments.size());
+
+ //copy old data
+ if(m_data.size())
+ memcpy(&newData[0], &m_data[0], m_data.size());
+
+ int srcCoord = 0;
+ int dstCoord = getNumCoordinates();
+ Vector2 s(0,0); //the beginning of the current subpath
+ Vector2 o(0,0); //the last point of the previous segment
+ for(int i=0;i<srcPath->m_segments.size();i++)
+ {
+ VGPathSegment segment = getPathSegment(srcPath->m_segments[i]);
+ VGPathAbsRel absRel = getPathAbsRel(srcPath->m_segments[i]);
+ int coords = segmentToNumCoordinates(segment);
+
+ switch(segment)
+ {
+ case VG_CLOSE_PATH:
+ {
+ RI_ASSERT(coords == 0);
+ o = s;
+ break;
+ }
+
+ case VG_MOVE_TO:
+ {
+ RI_ASSERT(coords == 2);
+ Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ Vector2 tc;
+
+ if (absRel == VG_ABSOLUTE)
+ tc = affineTransform(matrix, c);
+ else
+ {
+ tc = affineTangentTransform(matrix, c);
+ c += o;
+ }
+
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+ s = c;
+ o = c;
+ break;
+ }
+
+ case VG_LINE_TO:
+ {
+ RI_ASSERT(coords == 2);
+ Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ Vector2 tc;
+
+ if (absRel == VG_ABSOLUTE)
+ tc = affineTransform(matrix, c);
+ else
+ {
+ tc = affineTangentTransform(matrix, c);
+ c += o;
+ }
+
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+ o = c;
+ break;
+ }
+
+ case VG_HLINE_TO:
+ {
+ RI_ASSERT(coords == 1);
+ Vector2 c(srcPath->getCoordinate(srcCoord+0), 0);
+ Vector2 tc;
+
+ if (absRel == VG_ABSOLUTE)
+ {
+ c.y = o.y;
+ tc = affineTransform(matrix, c);
+ }
+ else
+ {
+ tc = affineTangentTransform(matrix, c);
+ c += o;
+ }
+
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+ o = c;
+ segment = VG_LINE_TO;
+ break;
+ }
+
+ case VG_VLINE_TO:
+ {
+ RI_ASSERT(coords == 1);
+ Vector2 c(0, srcPath->getCoordinate(srcCoord+0));
+ Vector2 tc;
+
+ if (absRel == VG_ABSOLUTE)
+ {
+ c.x = o.x;
+ tc = affineTransform(matrix, c);
+ }
+ else
+ {
+ tc = affineTangentTransform(matrix, c);
+ c += o;
+ }
+
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+ o = c;
+ segment = VG_LINE_TO;
+ break;
+ }
+
+ case VG_QUAD_TO:
+ {
+ RI_ASSERT(coords == 4);
+ Vector2 c0(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ Vector2 c1(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+ Vector2 tc0, tc1;
+
+ if (absRel == VG_ABSOLUTE)
+ {
+ tc0 = affineTransform(matrix, c0);
+ tc1 = affineTransform(matrix, c1);
+ }
+ else
+ {
+ tc0 = affineTangentTransform(matrix, c0);
+ tc1 = affineTangentTransform(matrix, c1);
+ c1 += o;
+ }
+
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.y);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y);
+ o = c1;
+ break;
+ }
+
+ case VG_CUBIC_TO:
+ {
+ RI_ASSERT(coords == 6);
+ Vector2 c0(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ Vector2 c1(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+ Vector2 c2(srcPath->getCoordinate(srcCoord+4), srcPath->getCoordinate(srcCoord+5));
+ Vector2 tc0, tc1, tc2;
+
+ if (absRel == VG_ABSOLUTE)
+ {
+ tc0 = affineTransform(matrix, c0);
+ tc1 = affineTransform(matrix, c1);
+ tc2 = affineTransform(matrix, c2);
+ }
+ else
+ {
+ tc0 = affineTangentTransform(matrix, c0);
+ tc1 = affineTangentTransform(matrix, c1);
+ tc2 = affineTangentTransform(matrix, c2);
+ c2 += o;
+ }
+
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.y);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.y);
+ o = c2;
+ break;
+ }
+
+ case VG_SQUAD_TO:
+ {
+ RI_ASSERT(coords == 2);
+ Vector2 c1(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ Vector2 tc1;
+
+ if (absRel == VG_ABSOLUTE)
+ tc1 = affineTransform(matrix, c1);
+ else
+ {
+ tc1 = affineTangentTransform(matrix, c1);
+ c1 += o;
+ }
+
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y);
+ o = c1;
+ break;
+ }
+
+ case VG_SCUBIC_TO:
+ {
+ RI_ASSERT(coords == 4);
+ Vector2 c1(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ Vector2 c2(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+ Vector2 tc1, tc2;
+
+ if (absRel == VG_ABSOLUTE)
+ {
+ tc1 = affineTransform(matrix, c1);
+ tc2 = affineTransform(matrix, c2);
+ }
+ else
+ {
+ tc1 = affineTangentTransform(matrix, c1);
+ tc2 = affineTangentTransform(matrix, c2);
+ c2 += o;
+ }
+
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.y);
+ o = c2;
+ break;
+ }
+
+ default:
+ {
+ RI_ASSERT(segment == VG_SCCWARC_TO || segment == VG_SCWARC_TO ||
+ segment == VG_LCCWARC_TO || segment == VG_LCWARC_TO);
+ RI_ASSERT(coords == 5);
+ RIfloat rh = srcPath->getCoordinate(srcCoord+0);
+ RIfloat rv = srcPath->getCoordinate(srcCoord+1);
+ RIfloat rot = srcPath->getCoordinate(srcCoord+2);
+ Vector2 c(srcPath->getCoordinate(srcCoord+3), srcPath->getCoordinate(srcCoord+4));
+
+ rot = RI_DEG_TO_RAD(rot);
+ Matrix3x3 u((RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv, 0,
+ (RIfloat)sin(rot)*rh, (RIfloat)cos(rot)*rv, 0,
+ 0, 0, 1);
+ u = matrix * u;
+ u[2].set(0,0,1); //force affinity
+ //u maps from the unit circle to transformed ellipse
+
+ //compute new rh, rv and rot
+ Vector2 p(u[0][0], u[1][0]);
+ Vector2 q(u[1][1], -u[0][1]);
+ bool swapped = false;
+ if(dot(p,p) < dot(q,q))
+ {
+ RI_SWAP(p.x,q.x);
+ RI_SWAP(p.y,q.y);
+ swapped = true;
+ }
+ Vector2 h = (p+q) * 0.5f;
+ Vector2 hp = (p-q) * 0.5f;
+ RIfloat hlen = h.length();
+ RIfloat hplen = hp.length();
+ rh = hlen + hplen;
+ rv = hlen - hplen;
+ h = hplen * h + hlen * hp;
+ hlen = dot(h,h);
+ if(hlen == 0.0f)
+ rot = 0.0f;
+ else
+ {
+ h.normalize();
+ rot = (RIfloat)acos(h.x);
+ if(h.y < 0.0f)
+ rot = 2.0f*PI - rot;
+ }
+ if(swapped)
+ rot += PI*0.5f;
+
+ Vector2 tc;
+ if (absRel == VG_ABSOLUTE)
+ tc = affineTransform(matrix, c);
+ else
+ {
+ tc = affineTangentTransform(matrix, c);
+ c += o;
+ }
+
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, rh);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, rv);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, RI_RAD_TO_DEG(rot));
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+ setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+ o = c;
+
+ //flip winding if the determinant is negative
+ if (matrix.det() < 0)
+ {
+ switch (segment)
+ {
+ case VG_SCCWARC_TO: segment = VG_SCWARC_TO; break;
+ case VG_SCWARC_TO: segment = VG_SCCWARC_TO; break;
+ case VG_LCCWARC_TO: segment = VG_LCWARC_TO; break;
+ case VG_LCWARC_TO: segment = VG_LCCWARC_TO; break;
+ default: break;
+ }
+ }
+ break;
+ }
+ }
+
+ newSegments[m_segments.size() + i] = (RIuint8)(segment | absRel);
+ srcCoord += coords;
+ }
+ RI_ASSERT(srcCoord == numSrcCoords);
+ RI_ASSERT(dstCoord == getNumCoordinates() + numDstCoords);
+
+ RI_ASSERT(newData.size() == countNumCoordinates(&newSegments[0],newSegments.size()) * getBytesPerCoordinate(m_datatype));
+
+ //replace old arrays
+ m_segments.swap(newSegments);
+ m_data.swap(newData);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Normalizes a path for interpolation.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Path::normalizeForInterpolation(const Path* srcPath)
+{
+ RI_ASSERT(srcPath);
+ RI_ASSERT(srcPath != this);
+ RI_ASSERT(srcPath->m_referenceCount > 0);
+
+ //count the number of resulting coordinates
+ int numSrcCoords = 0;
+ int numDstCoords = 0;
+ for(int i=0;i<srcPath->m_segments.size();i++)
+ {
+ VGPathSegment segment = getPathSegment(srcPath->m_segments[i]);
+ int coords = segmentToNumCoordinates(segment);
+ numSrcCoords += coords;
+ switch(segment)
+ {
+ case VG_CLOSE_PATH:
+ case VG_MOVE_TO:
+ case VG_LINE_TO:
+ break;
+
+ case VG_HLINE_TO:
+ case VG_VLINE_TO:
+ coords = 2;
+ break;
+
+ case VG_QUAD_TO:
+ case VG_CUBIC_TO:
+ case VG_SQUAD_TO:
+ case VG_SCUBIC_TO:
+ coords = 6;
+ break;
+
+ default:
+ RI_ASSERT(segment == VG_SCCWARC_TO || segment == VG_SCWARC_TO ||
+ segment == VG_LCCWARC_TO || segment == VG_LCWARC_TO);
+ break;
+ }
+ numDstCoords += coords;
+ }
+
+ m_segments.resize(srcPath->m_segments.size()); //throws bad_alloc
+ m_data.resize(numDstCoords * getBytesPerCoordinate(VG_PATH_DATATYPE_F)); //throws bad_alloc
+
+ int srcCoord = 0;
+ int dstCoord = 0;
+ Vector2 s(0,0); //the beginning of the current subpath
+ Vector2 o(0,0); //the last point of the previous segment
+
+ // the last internal control point of the previous segment, if the
+ //segment was a (regular or smooth) quadratic or cubic
+ //Bezier, or else the last point of the previous segment
+ Vector2 p(0,0);
+ for(int i=0;i<srcPath->m_segments.size();i++)
+ {
+ VGPathSegment segment = getPathSegment(srcPath->m_segments[i]);
+ VGPathAbsRel absRel = getPathAbsRel(srcPath->m_segments[i]);
+ int coords = segmentToNumCoordinates(segment);
+
+ switch(segment)
+ {
+ case VG_CLOSE_PATH:
+ {
+ RI_ASSERT(coords == 0);
+ p = s;
+ o = s;
+ break;
+ }
+
+ case VG_MOVE_TO:
+ {
+ RI_ASSERT(coords == 2);
+ Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ if(absRel == VG_RELATIVE)
+ c += o;
+ setCoordinate(dstCoord++, c.x);
+ setCoordinate(dstCoord++, c.y);
+ s = c;
+ p = c;
+ o = c;
+ break;
+ }
+
+ case VG_LINE_TO:
+ {
+ RI_ASSERT(coords == 2);
+ Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ if(absRel == VG_RELATIVE)
+ c += o;
+ setCoordinate(dstCoord++, c.x);
+ setCoordinate(dstCoord++, c.y);
+ p = c;
+ o = c;
+ break;
+ }
+
+ case VG_HLINE_TO:
+ {
+ RI_ASSERT(coords == 1);
+ Vector2 c(srcPath->getCoordinate(srcCoord+0), o.y);
+ if(absRel == VG_RELATIVE)
+ c.x += o.x;
+ setCoordinate(dstCoord++, c.x);
+ setCoordinate(dstCoord++, c.y);
+ p = c;
+ o = c;
+ segment = VG_LINE_TO;
+ break;
+ }
+
+ case VG_VLINE_TO:
+ {
+ RI_ASSERT(coords == 1);
+ Vector2 c(o.x, srcPath->getCoordinate(srcCoord+0));
+ if(absRel == VG_RELATIVE)
+ c.y += o.y;
+ setCoordinate(dstCoord++, c.x);
+ setCoordinate(dstCoord++, c.y);
+ p = c;
+ o = c;
+ segment = VG_LINE_TO;
+ break;
+ }
+
+ case VG_QUAD_TO:
+ {
+ RI_ASSERT(coords == 4);
+ Vector2 c0(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ Vector2 c1(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+ if(absRel == VG_RELATIVE)
+ {
+ c0 += o;
+ c1 += o;
+ }
+ Vector2 d0 = (1.0f/3.0f) * (o + 2.0f * c0);
+ Vector2 d1 = (1.0f/3.0f) * (c1 + 2.0f * c0);
+ setCoordinate(dstCoord++, d0.x);
+ setCoordinate(dstCoord++, d0.y);
+ setCoordinate(dstCoord++, d1.x);
+ setCoordinate(dstCoord++, d1.y);
+ setCoordinate(dstCoord++, c1.x);
+ setCoordinate(dstCoord++, c1.y);
+ p = c0;
+ o = c1;
+ segment = VG_CUBIC_TO;
+ break;
+ }
+
+ case VG_CUBIC_TO:
+ {
+ RI_ASSERT(coords == 6);
+ Vector2 c0(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ Vector2 c1(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+ Vector2 c2(srcPath->getCoordinate(srcCoord+4), srcPath->getCoordinate(srcCoord+5));
+ if(absRel == VG_RELATIVE)
+ {
+ c0 += o;
+ c1 += o;
+ c2 += o;
+ }
+ setCoordinate(dstCoord++, c0.x);
+ setCoordinate(dstCoord++, c0.y);
+ setCoordinate(dstCoord++, c1.x);
+ setCoordinate(dstCoord++, c1.y);
+ setCoordinate(dstCoord++, c2.x);
+ setCoordinate(dstCoord++, c2.y);
+ p = c1;
+ o = c2;
+ break;
+ }
+
+ case VG_SQUAD_TO:
+ {
+ RI_ASSERT(coords == 2);
+ Vector2 c0 = 2.0f * o - p;
+ Vector2 c1(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ if(absRel == VG_RELATIVE)
+ c1 += o;
+ Vector2 d0 = (1.0f/3.0f) * (o + 2.0f * c0);
+ Vector2 d1 = (1.0f/3.0f) * (c1 + 2.0f * c0);
+ setCoordinate(dstCoord++, d0.x);
+ setCoordinate(dstCoord++, d0.y);
+ setCoordinate(dstCoord++, d1.x);
+ setCoordinate(dstCoord++, d1.y);
+ setCoordinate(dstCoord++, c1.x);
+ setCoordinate(dstCoord++, c1.y);
+ p = c0;
+ o = c1;
+ segment = VG_CUBIC_TO;
+ break;
+ }
+
+ case VG_SCUBIC_TO:
+ {
+ RI_ASSERT(coords == 4);
+ Vector2 c0 = 2.0f * o - p;
+ Vector2 c1(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+ Vector2 c2(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+ if(absRel == VG_RELATIVE)
+ {
+ c1 += o;
+ c2 += o;
+ }
+ setCoordinate(dstCoord++, c0.x);
+ setCoordinate(dstCoord++, c0.y);
+ setCoordinate(dstCoord++, c1.x);
+ setCoordinate(dstCoord++, c1.y);
+ setCoordinate(dstCoord++, c2.x);
+ setCoordinate(dstCoord++, c2.y);
+ p = c1;
+ o = c2;
+ segment = VG_CUBIC_TO;
+ break;
+ }
+
+ default:
+ {
+ RI_ASSERT(segment == VG_SCCWARC_TO || segment == VG_SCWARC_TO ||
+ segment == VG_LCCWARC_TO || segment == VG_LCWARC_TO);
+ RI_ASSERT(coords == 5);
+ RIfloat rh = srcPath->getCoordinate(srcCoord+0);
+ RIfloat rv = srcPath->getCoordinate(srcCoord+1);
+ RIfloat rot = srcPath->getCoordinate(srcCoord+2);
+ Vector2 c(srcPath->getCoordinate(srcCoord+3), srcPath->getCoordinate(srcCoord+4));
+ if(absRel == VG_RELATIVE)
+ c += o;
+ setCoordinate(dstCoord++, rh);
+ setCoordinate(dstCoord++, rv);
+ setCoordinate(dstCoord++, rot);
+ setCoordinate(dstCoord++, c.x);
+ setCoordinate(dstCoord++, c.y);
+ p = c;
+ o = c;
+ break;
+ }
+ }
+
+ m_segments[i] = (RIuint8)(segment | VG_ABSOLUTE);
+ srcCoord += coords;
+ }
+ RI_ASSERT(srcCoord == numSrcCoords);
+ RI_ASSERT(dstCoord == numDstCoords);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Appends a linearly interpolated copy of the two source paths.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+bool Path::interpolate(const Path* startPath, const Path* endPath, RIfloat amount)
+{
+ RI_ASSERT(startPath && endPath);
+ RI_ASSERT(m_referenceCount > 0 && startPath->m_referenceCount > 0 && endPath->m_referenceCount > 0);
+
+ if(!startPath->m_segments.size() || startPath->m_segments.size() != endPath->m_segments.size())
+ return false; //start and end paths are incompatible or zero length
+
+ Path start(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, 0);
+ start.normalizeForInterpolation(startPath); //throws bad_alloc
+
+ Path end(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, 0);
+ end.normalizeForInterpolation(endPath); //throws bad_alloc
+
+ //check that start and end paths are compatible
+ if(start.m_data.size() != end.m_data.size() || start.m_segments.size() != end.m_segments.size())
+ return false; //start and end paths are incompatible
+
+ //allocate new arrays
+ Array<RIuint8> newSegments;
+ newSegments.resize(m_segments.size() + start.m_segments.size()); //throws bad_alloc
+ Array<RIuint8> newData;
+ newData.resize(m_data.size() + start.m_data.size() * getBytesPerCoordinate(m_datatype) / getBytesPerCoordinate(start.m_datatype)); //throws bad_alloc
+ //if we get here, the memory allocations have succeeded
+
+ //copy old segments
+ if(m_segments.size())
+ memcpy(&newSegments[0], &m_segments[0], m_segments.size());
+
+ //copy old data
+ if(m_data.size())
+ memcpy(&newData[0], &m_data[0], m_data.size());
+
+ //copy segments
+ for(int i=0;i<start.m_segments.size();i++)
+ {
+ VGPathSegment s = getPathSegment(start.m_segments[i]);
+ VGPathSegment e = getPathSegment(end.m_segments[i]);
+
+ if(s == VG_SCCWARC_TO || s == VG_SCWARC_TO || s == VG_LCCWARC_TO || s == VG_LCWARC_TO)
+ {
+ if(e != VG_SCCWARC_TO && e != VG_SCWARC_TO && e != VG_LCCWARC_TO && e != VG_LCWARC_TO)
+ return false; //start and end paths are incompatible
+ if(amount < 0.5f)
+ newSegments[m_segments.size() + i] = start.m_segments[i];
+ else
+ newSegments[m_segments.size() + i] = end.m_segments[i];
+ }
+ else
+ {
+ if(s != e)
+ return false; //start and end paths are incompatible
+ newSegments[m_segments.size() + i] = start.m_segments[i];
+ }
+ }
+
+ //interpolate data
+ int oldNumCoords = getNumCoordinates();
+ for(int i=0;i<start.getNumCoordinates();i++)
+ setCoordinate(newData, m_datatype, m_scale, m_bias, oldNumCoords + i, start.getCoordinate(i) * (1.0f - amount) + end.getCoordinate(i) * amount);
+
+ RI_ASSERT(newData.size() == countNumCoordinates(&newSegments[0],newSegments.size()) * getBytesPerCoordinate(m_datatype));
+
+ //replace old arrays
+ m_segments.swap(newSegments);
+ m_data.swap(newData);
+
+ return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a path for filling and appends resulting edges
+* to a rasterizer.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::fill(const Matrix3x3& pathToSurface, Rasterizer& rasterizer)
+{
+ RI_ASSERT(m_referenceCount > 0);
+ RI_ASSERT(pathToSurface.isAffine());
+
+ tessellate(pathToSurface, 0.0f); //throws bad_alloc
+
+ try
+ {
+ Vector2 p0(0,0), p1(0,0);
+ for(int i=0;i<m_vertices.size();i++)
+ {
+ p1 = affineTransform(pathToSurface, m_vertices[i].userPosition);
+
+ if(!(m_vertices[i].flags & START_SEGMENT))
+ { //in the middle of a segment
+ rasterizer.addEdge(p0, p1); //throws bad_alloc
+ }
+
+ p0 = p1;
+ }
+ }
+ catch(std::bad_alloc)
+ {
+ rasterizer.clear(); //remove the unfinished path
+ throw;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Smoothly interpolates between two StrokeVertices. Positions
+* are interpolated linearly, while tangents are interpolated
+* on a unit circle. Stroking is implemented so that overlapping
+* geometry doesnt cancel itself when filled with nonzero rule.
+* The resulting polygons are closed.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Path::interpolateStroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v0, const StrokeVertex& v1, RIfloat strokeWidth) const
+{
+ Vector2 pccw = affineTransform(pathToSurface, v0.ccw);
+ Vector2 pcw = affineTransform(pathToSurface, v0.cw);
+ Vector2 p = affineTransform(pathToSurface, v0.p);
+ Vector2 endccw = affineTransform(pathToSurface, v1.ccw);
+ Vector2 endcw = affineTransform(pathToSurface, v1.cw);
+ Vector2 endp = affineTransform(pathToSurface, v1.p);
+
+ const RIfloat tessellationAngle = 5.0f;
+
+ RIfloat angle = RI_RAD_TO_DEG((RIfloat)acos(RI_CLAMP(dot(v0.t, v1.t), -1.0f, 1.0f))) / tessellationAngle;
+ int samples = RI_INT_MAX((int)ceil(angle), 1);
+
+ for(int j=0;j<samples-1;j++)
+ {
+ RIfloat t = (RIfloat)(j+1) / (RIfloat)samples;
+ Vector2 position = v0.p * (1.0f - t) + v1.p * t;
+ Vector2 tangent = circularLerp(v0.t, v1.t, t);
+ Vector2 normal = normalize(perpendicularCCW(tangent)) * strokeWidth * 0.5f;
+
+ Vector2 nccw = affineTransform(pathToSurface, position + normal);
+ Vector2 ncw = affineTransform(pathToSurface, position - normal);
+ Vector2 n = affineTransform(pathToSurface, position);
+
+ rasterizer.clear();
+ rasterizer.addEdge(p, pccw); //throws bad_alloc
+ rasterizer.addEdge(pccw, nccw); //throws bad_alloc
+ rasterizer.addEdge(nccw, n); //throws bad_alloc
+ rasterizer.addEdge(n, ncw); //throws bad_alloc
+ rasterizer.addEdge(ncw, pcw); //throws bad_alloc
+ rasterizer.addEdge(pcw, p); //throws bad_alloc
+ rasterizer.fill();
+
+ pccw = nccw;
+ pcw = ncw;
+ p = n;
+ }
+
+ //connect the last segment to the end coordinates
+ rasterizer.clear();
+ rasterizer.addEdge(p, pccw); //throws bad_alloc
+ rasterizer.addEdge(pccw, endccw); //throws bad_alloc
+ rasterizer.addEdge(endccw, endp); //throws bad_alloc
+ rasterizer.addEdge(endp, endcw); //throws bad_alloc
+ rasterizer.addEdge(endcw, pcw); //throws bad_alloc
+ rasterizer.addEdge(pcw, p); //throws bad_alloc
+ rasterizer.fill();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Generate edges for stroke caps. Resulting polygons are closed.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Path::doCap(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v, RIfloat strokeWidth, VGCapStyle capStyle) const
+{
+ Vector2 ccwt = affineTransform(pathToSurface, v.ccw);
+ Vector2 cwt = affineTransform(pathToSurface, v.cw);
+ Vector2 p = affineTransform(pathToSurface, v.p);
+
+ rasterizer.clear();
+ switch(capStyle)
+ {
+ case VG_CAP_BUTT:
+ break;
+
+ case VG_CAP_ROUND:
+ {
+ const RIfloat tessellationAngle = 5.0f;
+
+ RIfloat angle = 180.0f / tessellationAngle;
+
+ int samples = (int)ceil(angle);
+ RIfloat step = 1.0f / samples;
+ RIfloat t = step;
+ Vector2 u0 = normalize(v.ccw - v.p);
+ Vector2 u1 = normalize(v.cw - v.p);
+ Vector2 prev = ccwt;
+ rasterizer.addEdge(p, ccwt); //throws bad_alloc
+ for(int j=1;j<samples;j++)
+ {
+ Vector2 next = v.p + circularLerp(u0, u1, t, true) * strokeWidth * 0.5f;
+ next = affineTransform(pathToSurface, next);
+
+ rasterizer.addEdge(prev, next); //throws bad_alloc
+ prev = next;
+ t += step;
+ }
+ rasterizer.addEdge(prev, cwt); //throws bad_alloc
+ rasterizer.addEdge(cwt, p); //throws bad_alloc
+ break;
+ }
+
+ default:
+ {
+ RI_ASSERT(capStyle == VG_CAP_SQUARE);
+ Vector2 t = v.t;
+ t.normalize();
+ Vector2 ccws = affineTransform(pathToSurface, v.ccw + t * strokeWidth * 0.5f);
+ Vector2 cws = affineTransform(pathToSurface, v.cw + t * strokeWidth * 0.5f);
+ rasterizer.addEdge(p, ccwt); //throws bad_alloc
+ rasterizer.addEdge(ccwt, ccws); //throws bad_alloc
+ rasterizer.addEdge(ccws, cws); //throws bad_alloc
+ rasterizer.addEdge(cws, cwt); //throws bad_alloc
+ rasterizer.addEdge(cwt, p); //throws bad_alloc
+ break;
+ }
+ }
+ rasterizer.fill();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Generate edges for stroke joins. Resulting polygons are closed.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Path::doJoin(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v0, const StrokeVertex& v1, RIfloat strokeWidth, VGJoinStyle joinStyle, RIfloat miterLimit) const
+{
+ Vector2 ccw0t = affineTransform(pathToSurface, v0.ccw);
+ Vector2 cw0t = affineTransform(pathToSurface, v0.cw);
+ Vector2 m0t = affineTransform(pathToSurface, v0.p);
+ Vector2 ccw1t = affineTransform(pathToSurface, v1.ccw);
+ Vector2 cw1t = affineTransform(pathToSurface, v1.cw);
+ Vector2 m1t = affineTransform(pathToSurface, v1.p);
+
+ Vector2 tccw = v1.ccw - v0.ccw;
+ Vector2 s, e, m, st, et;
+ bool cw;
+
+ rasterizer.clear();
+
+ if( dot(tccw, v0.t) > 0.0f )
+ { //draw ccw miter (draw from point 0 to 1)
+ s = ccw0t;
+ e = ccw1t;
+ st = v0.t;
+ et = v1.t;
+ m = v0.ccw;
+ cw = false;
+ rasterizer.addEdge(m0t, ccw0t); //throws bad_alloc
+ rasterizer.addEdge(ccw1t, m1t); //throws bad_alloc
+ rasterizer.addEdge(m1t, m0t); //throws bad_alloc
+ }
+ else
+ { //draw cw miter (draw from point 1 to 0)
+ s = cw1t;
+ e = cw0t;
+ st = v1.t;
+ et = v0.t;
+ m = v0.cw;
+ cw = true;
+ rasterizer.addEdge(cw0t, m0t); //throws bad_alloc
+ rasterizer.addEdge(m1t, cw1t); //throws bad_alloc
+ rasterizer.addEdge(m0t, m1t); //throws bad_alloc
+ }
+
+ switch(joinStyle)
+ {
+ case VG_JOIN_MITER:
+ {
+ RIfloat theta = (RIfloat)acos(RI_CLAMP(dot(v0.t, -v1.t), -1.0f, 1.0f));
+ RIfloat miterLengthPerStrokeWidth = 1.0f / (RIfloat)sin(theta*0.5f);
+ if( miterLengthPerStrokeWidth < miterLimit )
+ { //miter
+ RIfloat l = (RIfloat)cos(theta*0.5f) * miterLengthPerStrokeWidth * (strokeWidth * 0.5f);
+ l = RI_MIN(l, RI_FLOAT_MAX); //force finite
+ Vector2 c = m + v0.t * l;
+ c = affineTransform(pathToSurface, c);
+ rasterizer.addEdge(s, c); //throws bad_alloc
+ rasterizer.addEdge(c, e); //throws bad_alloc
+ }
+ else
+ { //bevel
+ rasterizer.addEdge(s, e); //throws bad_alloc
+ }
+ break;
+ }
+
+ case VG_JOIN_ROUND:
+ {
+ const RIfloat tessellationAngle = 5.0f;
+
+ Vector2 prev = s;
+ RIfloat angle = RI_RAD_TO_DEG((RIfloat)acos(RI_CLAMP(dot(st, et), -1.0f, 1.0f))) / tessellationAngle;
+ int samples = (int)ceil(angle);
+ if( samples )
+ {
+ RIfloat step = 1.0f / samples;
+ RIfloat t = step;
+ for(int j=1;j<samples;j++)
+ {
+ Vector2 position = v0.p * (1.0f - t) + v1.p * t;
+ Vector2 tangent = circularLerp(st, et, t, true);
+
+ Vector2 next = position + normalize(perpendicular(tangent, cw)) * strokeWidth * 0.5f;
+ next = affineTransform(pathToSurface, next);
+
+ rasterizer.addEdge(prev, next); //throws bad_alloc
+ prev = next;
+ t += step;
+ }
+ }
+ rasterizer.addEdge(prev, e); //throws bad_alloc
+ break;
+ }
+
+ default:
+ RI_ASSERT(joinStyle == VG_JOIN_BEVEL);
+ if(!cw)
+ rasterizer.addEdge(ccw0t, ccw1t); //throws bad_alloc
+ else
+ rasterizer.addEdge(cw1t, cw0t); //throws bad_alloc
+ break;
+ }
+ rasterizer.fill();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellate a path, apply stroking, dashing, caps and joins, and
+* append resulting edges to a rasterizer.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::stroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const Array<RIfloat>& dashPattern, RIfloat dashPhase, bool dashPhaseReset, RIfloat strokeWidth, VGCapStyle capStyle, VGJoinStyle joinStyle, RIfloat miterLimit)
+{
+ RI_ASSERT(pathToSurface.isAffine());
+ RI_ASSERT(m_referenceCount > 0);
+ RI_ASSERT(strokeWidth >= 0.0f);
+ RI_ASSERT(miterLimit >= 1.0f);
+
+ tessellate(pathToSurface, strokeWidth); //throws bad_alloc
+
+ if(!m_vertices.size())
+ return;
+
+ bool dashing = true;
+ int dashPatternSize = dashPattern.size();
+ if( dashPattern.size() & 1 )
+ dashPatternSize--; //odd number of dash pattern entries, discard the last one
+ RIfloat dashPatternLength = 0.0f;
+ for(int i=0;i<dashPatternSize;i++)
+ dashPatternLength += RI_MAX(dashPattern[i], 0.0f);
+ if(!dashPatternSize || dashPatternLength == 0.0f )
+ dashing = false;
+ dashPatternLength = RI_MIN(dashPatternLength, RI_FLOAT_MAX);
+
+ //walk along the path
+ //stop at the next event which is either:
+ //-path vertex
+ //-dash stop
+ //for robustness, decisions based on geometry are done only once.
+ //inDash keeps track whether the last point was in dash or not
+
+ //loop vertex events
+ try
+ {
+ RIfloat nextDash = 0.0f;
+ int d = 0;
+ bool inDash = true;
+ StrokeVertex v0, v1, vs;
+ for(int i=0;i<m_vertices.size();i++)
+ {
+ //read the next vertex
+ Vertex& v = m_vertices[i];
+ v1.p = v.userPosition;
+ v1.t = v.userTangent;
+ RI_ASSERT(!isZero(v1.t)); //don't allow zero tangents
+ v1.ccw = v1.p + normalize(perpendicularCCW(v1.t)) * strokeWidth * 0.5f;
+ v1.cw = v1.p + normalize(perpendicularCW(v1.t)) * strokeWidth * 0.5f;
+ v1.pathLength = v.pathLength;
+ v1.flags = v.flags;
+ v1.inDash = dashing ? inDash : true; //NOTE: for other than START_SEGMENT vertices inDash will be updated after dashing
+
+ //process the vertex event
+ if(v.flags & START_SEGMENT)
+ {
+ if(v.flags & START_SUBPATH)
+ {
+ if( dashing )
+ { //initialize dashing by finding which dash or gap the first point of the path lies in
+ if(dashPhaseReset || i == 0)
+ {
+ d = 0;
+ inDash = true;
+ nextDash = v1.pathLength - RI_MOD(dashPhase, dashPatternLength);
+ for(;;)
+ {
+ RIfloat prevDash = nextDash;
+ nextDash = prevDash + RI_MAX(dashPattern[d], 0.0f);
+ if(nextDash >= v1.pathLength)
+ break;
+
+ if( d & 1 )
+ inDash = true;
+ else
+ inDash = false;
+ d = (d+1) % dashPatternSize;
+ }
+ v1.inDash = inDash;
+ //the first point of the path lies between prevDash and nextDash
+ //d in the index of the next dash stop
+ //inDash is true if the first point is in a dash
+ }
+ }
+ vs = v1; //save the subpath start point
+ }
+ else
+ {
+ if( v.flags & IMPLICIT_CLOSE_SUBPATH )
+ { //do caps for the start and end of the current subpath
+ if( v0.inDash )
+ doCap(pathToSurface, rasterizer, v0, strokeWidth, capStyle); //end cap //throws bad_alloc
+ if( vs.inDash )
+ {
+ StrokeVertex vi = vs;
+ vi.t = -vi.t;
+ RI_SWAP(vi.ccw.x, vi.cw.x);
+ RI_SWAP(vi.ccw.y, vi.cw.y);
+ doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle); //start cap //throws bad_alloc
+ }
+ }
+ else
+ { //join two segments
+ RI_ASSERT(v0.inDash == v1.inDash);
+ if( v0.inDash )
+ doJoin(pathToSurface, rasterizer, v0, v1, strokeWidth, joinStyle, miterLimit); //throws bad_alloc
+ }
+ }
+ }
+ else
+ { //in the middle of a segment
+ if( !(v.flags & IMPLICIT_CLOSE_SUBPATH) )
+ { //normal segment, do stroking
+ if( dashing )
+ {
+ StrokeVertex prevDashVertex = v0; //dashing of the segment starts from the previous vertex
+
+ if(nextDash + 10000.0f * dashPatternLength < v1.pathLength)
+ throw std::bad_alloc(); //too many dashes, throw bad_alloc
+
+ //loop dash events until the next vertex event
+ //zero length dashes are handled as a special case since if they hit the vertex,
+ //we want to include their starting point to this segment already in order to generate a join
+ int numDashStops = 0;
+ while(nextDash < v1.pathLength || (nextDash <= v1.pathLength && dashPattern[(d+1) % dashPatternSize] == 0.0f))
+ {
+ RIfloat edgeLength = v1.pathLength - v0.pathLength;
+ RIfloat ratio = 0.0f;
+ if(edgeLength > 0.0f)
+ ratio = (nextDash - v0.pathLength) / edgeLength;
+ StrokeVertex nextDashVertex;
+ nextDashVertex.p = v0.p * (1.0f - ratio) + v1.p * ratio;
+ nextDashVertex.t = circularLerp(v0.t, v1.t, ratio);
+ nextDashVertex.ccw = nextDashVertex.p + normalize(perpendicularCCW(nextDashVertex.t)) * strokeWidth * 0.5f;
+ nextDashVertex.cw = nextDashVertex.p + normalize(perpendicularCW(nextDashVertex.t)) * strokeWidth * 0.5f;
+
+ if( inDash )
+ { //stroke from prevDashVertex -> nextDashVertex
+ if( numDashStops )
+ { //prevDashVertex is not the start vertex of the segment, cap it (start vertex has already been joined or capped)
+ StrokeVertex vi = prevDashVertex;
+ vi.t = -vi.t;
+ RI_SWAP(vi.ccw.x, vi.cw.x);
+ RI_SWAP(vi.ccw.y, vi.cw.y);
+ doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle); //throws bad_alloc
+ }
+ interpolateStroke(pathToSurface, rasterizer, prevDashVertex, nextDashVertex, strokeWidth); //throws bad_alloc
+ doCap(pathToSurface, rasterizer, nextDashVertex, strokeWidth, capStyle); //end cap //throws bad_alloc
+ }
+ prevDashVertex = nextDashVertex;
+
+ if( d & 1 )
+ { //dash starts
+ RI_ASSERT(!inDash);
+ inDash = true;
+ }
+ else
+ { //dash ends
+ RI_ASSERT(inDash);
+ inDash = false;
+ }
+ d = (d+1) % dashPatternSize;
+ nextDash += RI_MAX(dashPattern[d], 0.0f);
+ numDashStops++;
+ }
+
+ if( inDash )
+ { //stroke prevDashVertex -> v1
+ if( numDashStops )
+ { //prevDashVertex is not the start vertex of the segment, cap it (start vertex has already been joined or capped)
+ StrokeVertex vi = prevDashVertex;
+ vi.t = -vi.t;
+ RI_SWAP(vi.ccw.x, vi.cw.x);
+ RI_SWAP(vi.ccw.y, vi.cw.y);
+ doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle); //throws bad_alloc
+ }
+ interpolateStroke(pathToSurface, rasterizer, prevDashVertex, v1, strokeWidth); //throws bad_alloc
+ //no cap, leave path open
+ }
+
+ v1.inDash = inDash; //update inDash status of the segment end point
+ }
+ else //no dashing, just interpolate segment end points
+ interpolateStroke(pathToSurface, rasterizer, v0, v1, strokeWidth); //throws bad_alloc
+ }
+ }
+
+ if((v.flags & END_SEGMENT) && (v.flags & CLOSE_SUBPATH))
+ { //join start and end of the current subpath
+ if( v1.inDash && vs.inDash )
+ doJoin(pathToSurface, rasterizer, v1, vs, strokeWidth, joinStyle, miterLimit); //throws bad_alloc
+ else
+ { //both start and end are not in dash, cap them
+ if( v1.inDash )
+ doCap(pathToSurface, rasterizer, v1, strokeWidth, capStyle); //end cap //throws bad_alloc
+ if( vs.inDash )
+ {
+ StrokeVertex vi = vs;
+ vi.t = -vi.t;
+ RI_SWAP(vi.ccw.x, vi.cw.x);
+ RI_SWAP(vi.ccw.y, vi.cw.y);
+ doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle); //start cap //throws bad_alloc
+ }
+ }
+ }
+
+ v0 = v1;
+ }
+ }
+ catch(std::bad_alloc)
+ {
+ rasterizer.clear(); //remove the unfinished path
+ throw;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a path, and returns a position and a tangent on the path
+* given a distance along the path.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::getPointAlong(int startIndex, int numSegments, RIfloat distance, Vector2& p, Vector2& t)
+{
+ RI_ASSERT(m_referenceCount > 0);
+ RI_ASSERT(startIndex >= 0 && startIndex + numSegments <= m_segments.size() && numSegments > 0);
+
+ Matrix3x3 identity;
+ identity.identity();
+ tessellate(identity, 0.0f); //throws bad_alloc
+
+ RI_ASSERT(startIndex >= 0 && startIndex < m_segmentToVertex.size());
+ RI_ASSERT(startIndex + numSegments >= 0 && startIndex + numSegments <= m_segmentToVertex.size());
+
+ // ignore move segments at the start of the path
+ while (numSegments && (m_segments[startIndex] & ~VG_RELATIVE) == VG_MOVE_TO)
+ {
+ startIndex++;
+ numSegments--;
+ }
+
+ // ignore move segments at the end of the path
+ while (numSegments && (m_segments[startIndex + numSegments - 1] & ~VG_RELATIVE) == VG_MOVE_TO)
+ numSegments--;
+
+ // empty path?
+ if (!m_vertices.size() || !numSegments)
+ {
+ p.set(0,0);
+ t.set(1,0);
+ return;
+ }
+
+ int startVertex = m_segmentToVertex[startIndex].start;
+ int endVertex = m_segmentToVertex[startIndex + numSegments - 1].end;
+
+ if(startVertex == -1)
+ startVertex = 0;
+
+ // zero length?
+ if (startVertex >= endVertex)
+ {
+ p = m_vertices[startVertex].userPosition;
+ t.set(1,0);
+ return;
+ }
+
+ RI_ASSERT(startVertex >= 0 && startVertex < m_vertices.size());
+ RI_ASSERT(endVertex >= 0 && endVertex < m_vertices.size());
+
+ distance += m_vertices[startVertex].pathLength; //map distance to the range of the whole path
+
+ if(distance <= m_vertices[startVertex].pathLength)
+ { //return the first point of the path
+ p = m_vertices[startVertex].userPosition;
+ t = m_vertices[startVertex].userTangent;
+ return;
+ }
+
+ if(distance >= m_vertices[endVertex].pathLength)
+ { //return the last point of the path
+ p = m_vertices[endVertex].userPosition;
+ t = m_vertices[endVertex].userTangent;
+ return;
+ }
+
+ //search for the segment containing the distance
+ for(int s=startIndex;s<startIndex+numSegments;s++)
+ {
+ int start = m_segmentToVertex[s].start;
+ int end = m_segmentToVertex[s].end;
+ if(start < 0)
+ start = 0;
+ if(end < 0)
+ end = 0;
+ RI_ASSERT(start >= 0 && start < m_vertices.size());
+ RI_ASSERT(end >= 0 && end < m_vertices.size());
+
+ if(distance >= m_vertices[start].pathLength && distance < m_vertices[end].pathLength)
+ { //segment contains the queried distance
+ for(int i=start;i<end;i++)
+ {
+ const Vertex& v0 = m_vertices[i];
+ const Vertex& v1 = m_vertices[i+1];
+ if(distance >= v0.pathLength && distance < v1.pathLength)
+ { //segment found, interpolate linearly between its end points
+ RIfloat edgeLength = v1.pathLength - v0.pathLength;
+ RI_ASSERT(edgeLength > 0.0f);
+ RIfloat r = (distance - v0.pathLength) / edgeLength;
+ p = (1.0f - r) * v0.userPosition + r * v1.userPosition;
+ t = (1.0f - r) * v0.userTangent + r * v1.userTangent;
+ return;
+ }
+ }
+ }
+ }
+
+ RI_ASSERT(0); //point not found (should never get here)
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a path, and computes its length.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+RIfloat Path::getPathLength(int startIndex, int numSegments)
+{
+ RI_ASSERT(m_referenceCount > 0);
+ RI_ASSERT(startIndex >= 0 && startIndex + numSegments <= m_segments.size() && numSegments > 0);
+
+ Matrix3x3 identity;
+ identity.identity();
+ tessellate(identity, 0.0f); //throws bad_alloc
+
+ RI_ASSERT(startIndex >= 0 && startIndex < m_segmentToVertex.size());
+ RI_ASSERT(startIndex + numSegments >= 0 && startIndex + numSegments <= m_segmentToVertex.size());
+
+ int startVertex = m_segmentToVertex[startIndex].start;
+ int endVertex = m_segmentToVertex[startIndex + numSegments - 1].end;
+
+ if(!m_vertices.size())
+ return 0.0f;
+
+ RIfloat startPathLength = 0.0f;
+ if(startVertex >= 0)
+ {
+ RI_ASSERT(startVertex >= 0 && startVertex < m_vertices.size());
+ startPathLength = m_vertices[startVertex].pathLength;
+ }
+ RIfloat endPathLength = 0.0f;
+ if(endVertex >= 0)
+ {
+ RI_ASSERT(endVertex >= 0 && endVertex < m_vertices.size());
+ endPathLength = m_vertices[endVertex].pathLength;
+ }
+
+ return endPathLength - startPathLength;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a path, and computes its bounding box in user space.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::getPathBounds(RIfloat& minx, RIfloat& miny, RIfloat& maxx, RIfloat& maxy)
+{
+ RI_ASSERT(m_referenceCount > 0);
+
+ Matrix3x3 identity;
+ identity.identity();
+ tessellate(identity, 0.0f); //throws bad_alloc
+
+ if(m_vertices.size())
+ {
+ minx = m_userMinx;
+ miny = m_userMiny;
+ maxx = m_userMaxx;
+ maxy = m_userMaxy;
+ }
+ else
+ {
+ minx = miny = 0;
+ maxx = maxy = -1;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a path, and computes its bounding box in surface space.
+* \param
+* \return
+* \note if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::getPathTransformedBounds(const Matrix3x3& pathToSurface, RIfloat& minx, RIfloat& miny, RIfloat& maxx, RIfloat& maxy)
+{
+ RI_ASSERT(m_referenceCount > 0);
+ RI_ASSERT(pathToSurface.isAffine());
+
+ Matrix3x3 identity;
+ identity.identity();
+ tessellate(identity, 0.0f); //throws bad_alloc
+
+ if(m_vertices.size())
+ {
+ Vector3 p0(m_userMinx, m_userMiny, 1.0f);
+ Vector3 p1(m_userMinx, m_userMaxy, 1.0f);
+ Vector3 p2(m_userMaxx, m_userMaxy, 1.0f);
+ Vector3 p3(m_userMaxx, m_userMiny, 1.0f);
+ p0 = pathToSurface * p0;
+ p1 = pathToSurface * p1;
+ p2 = pathToSurface * p2;
+ p3 = pathToSurface * p3;
+
+ minx = RI_MIN(RI_MIN(RI_MIN(p0.x, p1.x), p2.x), p3.x);
+ miny = RI_MIN(RI_MIN(RI_MIN(p0.y, p1.y), p2.y), p3.y);
+ maxx = RI_MAX(RI_MAX(RI_MAX(p0.x, p1.x), p2.x), p3.x);
+ maxy = RI_MAX(RI_MAX(RI_MAX(p0.y, p1.y), p2.y), p3.y);
+ }
+ else
+ {
+ minx = miny = 0;
+ maxx = maxy = -1;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Adds a vertex to a tessellated path.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Path::addVertex(const Vector2& p, const Vector2& t, RIfloat pathLength, unsigned int flags)
+{
+ RI_ASSERT(!isZero(t));
+
+ Vertex v;
+ v.pathLength = pathLength;
+ v.userPosition = p;
+ v.userTangent = t;
+ v.flags = flags;
+ m_vertices.push_back(v); //throws bad_alloc
+ m_numTessVertices++;
+
+ m_userMinx = RI_MIN(m_userMinx, v.userPosition.x);
+ m_userMiny = RI_MIN(m_userMiny, v.userPosition.y);
+ m_userMaxx = RI_MAX(m_userMaxx, v.userPosition.x);
+ m_userMaxy = RI_MAX(m_userMaxy, v.userPosition.y);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Adds an edge to a tessellated path.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Path::addEdge(const Vector2& p0, const Vector2& p1, const Vector2& t0, const Vector2& t1, unsigned int startFlags, unsigned int endFlags)
+{
+ Vertex v;
+ RIfloat pathLength = 0.0f;
+
+ RI_ASSERT(!isZero(t0) && !isZero(t1));
+
+ //segment midpoints are shared between edges
+ if(!m_numTessVertices)
+ {
+ if(m_vertices.size() > 0)
+ pathLength = m_vertices[m_vertices.size()-1].pathLength;
+
+ addVertex(p0, t0, pathLength, startFlags); //throws bad_alloc
+ }
+
+ //other than implicit close paths (caused by a MOVE_TO) add to path length
+ if( !(endFlags & IMPLICIT_CLOSE_SUBPATH) )
+ {
+ //NOTE: with extremely large coordinates the floating point path length is infinite
+ RIfloat l = (p1 - p0).length();
+ pathLength = m_vertices[m_vertices.size()-1].pathLength + l;
+ pathLength = RI_MIN(pathLength, RI_FLOAT_MAX);
+ }
+
+ addVertex(p1, t1, pathLength, endFlags); //throws bad_alloc
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a close-path segment.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Path::addEndPath(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, bool subpathHasGeometry, unsigned int flags)
+{
+ RI_UNREF(pathToSurface);
+ m_numTessVertices = 0;
+ if(!subpathHasGeometry)
+ { //single vertex
+ Vector2 t(1.0f,0.0f);
+ addEdge(p0, p1, t, t, START_SEGMENT | START_SUBPATH, END_SEGMENT | END_SUBPATH); //throws bad_alloc
+ m_numTessVertices = 0;
+ addEdge(p0, p1, -t, -t, IMPLICIT_CLOSE_SUBPATH | START_SEGMENT, IMPLICIT_CLOSE_SUBPATH | END_SEGMENT); //throws bad_alloc
+ return;
+ }
+ //the subpath contains segment commands that have generated geometry
+
+ //add a close path segment to the start point of the subpath
+ RI_ASSERT(m_vertices.size() > 0);
+ m_vertices[m_vertices.size()-1].flags |= END_SUBPATH;
+
+ Vector2 t = normalize(p1 - p0);
+ if(isZero(t))
+ t = m_vertices[m_vertices.size()-1].userTangent; //if the segment is zero-length, use the tangent of the last segment end point so that proper join will be generated
+ RI_ASSERT(!isZero(t));
+
+ addEdge(p0, p1, t, t, flags | START_SEGMENT, flags | END_SEGMENT); //throws bad_alloc
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a line-to segment.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool Path::addLineTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, bool subpathHasGeometry)
+{
+ RI_UNREF(pathToSurface);
+ if(p0 == p1)
+ return false; //discard zero-length segments
+
+ //compute end point tangents
+ Vector2 t = normalize(p1 - p0);
+ RI_ASSERT(!isZero(t));
+
+ m_numTessVertices = 0;
+ unsigned int startFlags = START_SEGMENT;
+ if(!subpathHasGeometry)
+ startFlags |= START_SUBPATH;
+ addEdge(p0, p1, t, t, startFlags, END_SEGMENT); //throws bad_alloc
+ return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a quad-to segment.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool Path::addQuadTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, const Vector2& p2, bool subpathHasGeometry, float strokeWidth)
+{
+ RI_UNREF(pathToSurface);
+ RI_UNREF(strokeWidth);
+ if(p0 == p1 && p0 == p2)
+ {
+ RI_ASSERT(p1 == p2);
+ return false; //discard zero-length segments
+ }
+
+ //compute end point tangents
+
+ Vector2 incomingTangent = normalize(p1 - p0);
+ Vector2 outgoingTangent = normalize(p2 - p1);
+ if(p0 == p1)
+ incomingTangent = normalize(p2 - p0);
+ if(p1 == p2)
+ outgoingTangent = normalize(p2 - p0);
+ RI_ASSERT(!isZero(incomingTangent) && !isZero(outgoingTangent));
+
+ m_numTessVertices = 0;
+ unsigned int startFlags = START_SEGMENT;
+ if(!subpathHasGeometry)
+ startFlags |= START_SUBPATH;
+
+ const int segments = RI_NUM_TESSELLATED_SEGMENTS;
+ Vector2 pp = p0;
+ Vector2 tp = incomingTangent;
+ unsigned int prevFlags = startFlags;
+ for(int i=1;i<segments;i++)
+ {
+ RIfloat t = (RIfloat)i / (RIfloat)segments;
+ RIfloat u = 1.0f-t;
+ Vector2 pn = u*u * p0 + 2.0f*t*u * p1 + t*t * p2;
+ Vector2 tn = (-1.0f+t) * p0 + (1.0f-2.0f*t) * p1 + t * p2;
+ tn = normalize(tn);
+ if(isZero(tn))
+ tn = tp;
+
+ addEdge(pp, pn, tp, tn, prevFlags, 0); //throws bad_alloc
+
+ pp = pn;
+ tp = tn;
+ prevFlags = 0;
+ }
+ addEdge(pp, p2, tp, outgoingTangent, prevFlags, END_SEGMENT); //throws bad_alloc
+ return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a cubic-to segment.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool Path::addCubicTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, const Vector2& p2, const Vector2& p3, bool subpathHasGeometry, float strokeWidth)
+{
+ RI_UNREF(pathToSurface);
+ RI_UNREF(strokeWidth);
+
+ if(p0 == p1 && p0 == p2 && p0 == p3)
+ {
+ RI_ASSERT(p1 == p2 && p1 == p3 && p2 == p3);
+ return false; //discard zero-length segments
+ }
+
+ //compute end point tangents
+ Vector2 incomingTangent = normalize(p1 - p0);
+ Vector2 outgoingTangent = normalize(p3 - p2);
+ if(p0 == p1)
+ {
+ incomingTangent = normalize(p2 - p0);
+ if(p1 == p2)
+ incomingTangent = normalize(p3 - p0);
+ }
+ if(p2 == p3)
+ {
+ outgoingTangent = normalize(p3 - p1);
+ if(p1 == p2)
+ outgoingTangent = normalize(p3 - p0);
+ }
+ RI_ASSERT(!isZero(incomingTangent) && !isZero(outgoingTangent));
+
+ m_numTessVertices = 0;
+ unsigned int startFlags = START_SEGMENT;
+ if(!subpathHasGeometry)
+ startFlags |= START_SUBPATH;
+
+ const int segments = RI_NUM_TESSELLATED_SEGMENTS;
+ Vector2 pp = p0;
+ Vector2 tp = incomingTangent;
+ unsigned int prevFlags = startFlags;
+ for(int i=1;i<segments;i++)
+ {
+ RIfloat t = (RIfloat)i / (RIfloat)segments;
+ Vector2 pn = (1.0f - 3.0f*t + 3.0f*t*t - t*t*t) * p0 + (3.0f*t - 6.0f*t*t + 3.0f*t*t*t) * p1 + (3.0f*t*t - 3.0f*t*t*t) * p2 + t*t*t * p3;
+ Vector2 tn = (-3.0f + 6.0f*t - 3.0f*t*t) * p0 + (3.0f - 12.0f*t + 9.0f*t*t) * p1 + (6.0f*t - 9.0f*t*t) * p2 + 3.0f*t*t * p3;
+
+ tn = normalize(tn);
+ if(isZero(tn))
+ tn = tp;
+
+ addEdge(pp, pn, tp, tn, prevFlags, 0); //throws bad_alloc
+
+ pp = pn;
+ tp = tn;
+ prevFlags = 0;
+ }
+ addEdge(pp, p3, tp, outgoingTangent, prevFlags, END_SEGMENT); //throws bad_alloc
+ return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Finds an ellipse center and transformation from the unit circle to
+* that ellipse.
+* \param rh Length of the horizontal axis
+* rv Length of the vertical axis
+* rot Rotation angle
+* p0,p1 User space end points of the arc
+* c0,c1 (Return value) Unit circle space center points of the two ellipses
+* u0,u1 (Return value) Unit circle space end points of the arc
+* unitCircleToEllipse (Return value) A matrix mapping from unit circle space to user space
+* \return true if ellipse exists, false if doesn't
+* \note
+*//*-------------------------------------------------------------------*/
+
+static bool findEllipses(RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p0, const Vector2& p1, VGPathSegment segment, Vector2& c0, Vector2& c1, Vector2& u0, Vector2& u1, Matrix3x3& unitCircleToEllipse, bool& cw)
+{
+ rh = RI_ABS(rh);
+ rv = RI_ABS(rv);
+ if(rh == 0.0f || rv == 0.0f || p0 == p1)
+ return false; //degenerate ellipse
+
+ rot = RI_DEG_TO_RAD(rot);
+ unitCircleToEllipse.set((RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv, 0,
+ (RIfloat)sin(rot)*rh, (RIfloat)cos(rot)*rv, 0,
+ 0, 0, 1);
+ Matrix3x3 ellipseToUnitCircle = invert(unitCircleToEllipse);
+ //force affinity
+ ellipseToUnitCircle[2][0] = 0.0f;
+ ellipseToUnitCircle[2][1] = 0.0f;
+ ellipseToUnitCircle[2][2] = 1.0f;
+
+ // Transform p0 and p1 into unit space
+ u0 = affineTransform(ellipseToUnitCircle, p0);
+ u1 = affineTransform(ellipseToUnitCircle, p1);
+
+ Vector2 m = 0.5f * (u0 + u1);
+ Vector2 d = u0 - u1;
+
+ RIfloat lsq = (RIfloat)dot(d,d);
+ if(lsq <= 0.0f)
+ return false; //the points are coincident
+
+ RIfloat disc = (1.0f / lsq) - 0.25f;
+ if(disc < 0.0f)
+ { //the points are too far apart for a solution to exist, scale the axes so that there is a solution
+ RIfloat l = (RIfloat)sqrt(lsq);
+ rh *= 0.5f * l;
+ rv *= 0.5f * l;
+
+ //redo the computation with scaled axes
+ unitCircleToEllipse.set((RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv, 0,
+ (RIfloat)sin(rot)*rh, (RIfloat)cos(rot)*rv, 0,
+ 0, 0, 1);
+ ellipseToUnitCircle = invert(unitCircleToEllipse);
+ //force affinity
+ ellipseToUnitCircle[2][0] = 0.0f;
+ ellipseToUnitCircle[2][1] = 0.0f;
+ ellipseToUnitCircle[2][2] = 1.0f;
+
+ // Transform p0 and p1 into unit space
+ u0 = affineTransform(ellipseToUnitCircle, p0);
+ u1 = affineTransform(ellipseToUnitCircle, p1);
+
+ // Solve for intersecting unit circles
+ d = u0 - u1;
+ m = 0.5f * (u0 + u1);
+
+ lsq = dot(d,d);
+ if(lsq <= 0.0f)
+ return false; //the points are coincident
+
+ disc = RI_MAX(0.0f, 1.0f / lsq - 0.25f);
+ }
+
+ if(u0 == u1)
+ return false;
+
+ Vector2 sd = d * (RIfloat)sqrt(disc);
+ Vector2 sp = perpendicularCW(sd);
+ c0 = m + sp;
+ c1 = m - sp;
+
+ //choose the center point and direction
+ Vector2 cp = c0;
+ if(segment == VG_SCWARC_TO || segment == VG_LCCWARC_TO)
+ cp = c1;
+ cw = false;
+ if(segment == VG_SCWARC_TO || segment == VG_LCWARC_TO)
+ cw = true;
+
+ //move the unit circle origin to the chosen center point
+ u0 -= cp;
+ u1 -= cp;
+
+ if(u0 == u1 || isZero(u0) || isZero(u1))
+ return false;
+
+ //transform back to the original coordinate space
+ cp = affineTransform(unitCircleToEllipse, cp);
+ unitCircleToEllipse[0][2] = cp.x;
+ unitCircleToEllipse[1][2] = cp.y;
+ return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates an arc-to segment.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+bool Path::addArcTo(const Matrix3x3& pathToSurface, const Vector2& p0, RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p1, const Vector2& p1r, VGPathSegment segment, bool subpathHasGeometry, float strokeWidth)
+{
+ RI_UNREF(pathToSurface);
+ RI_UNREF(strokeWidth);
+ if(p0 == p1)
+ return false; //discard zero-length segments
+
+ Vector2 c0, c1, u0, u1;
+ Matrix3x3 unitCircleToEllipse;
+ bool cw;
+
+ m_numTessVertices = 0;
+ unsigned int startFlags = START_SEGMENT;
+ if(!subpathHasGeometry)
+ startFlags |= START_SUBPATH;
+
+ if(!findEllipses(rh, rv, rot, Vector2(), p1r, segment, c0, c1, u0, u1, unitCircleToEllipse, cw))
+ { //ellipses don't exist, add line instead
+ Vector2 t = normalize(p1r);
+ RI_ASSERT(!isZero(t));
+ addEdge(p0, p1, t, t, startFlags, END_SEGMENT); //throws bad_alloc
+ return true;
+ }
+
+ //compute end point tangents
+ Vector2 incomingTangent = perpendicular(u0, cw);
+ incomingTangent = affineTangentTransform(unitCircleToEllipse, incomingTangent);
+ incomingTangent = normalize(incomingTangent);
+ Vector2 outgoingTangent = perpendicular(u1, cw);
+ outgoingTangent = affineTangentTransform(unitCircleToEllipse, outgoingTangent);
+ outgoingTangent = normalize(outgoingTangent);
+ RI_ASSERT(!isZero(incomingTangent) && !isZero(outgoingTangent));
+
+ const int segments = RI_NUM_TESSELLATED_SEGMENTS;
+ Vector2 pp = p0;
+ Vector2 tp = incomingTangent;
+ unsigned int prevFlags = startFlags;
+ for(int i=1;i<segments;i++)
+ {
+ RIfloat t = (RIfloat)i / (RIfloat)segments;
+ Vector2 pn = circularLerp(u0, u1, t, cw);
+ Vector2 tn = perpendicular(pn, cw);
+ tn = affineTangentTransform(unitCircleToEllipse, tn);
+ pn = affineTransform(unitCircleToEllipse, pn) + p0;
+ tn = normalize(tn);
+ if(isZero(tn))
+ tn = tp;
+
+ addEdge(pp, pn, tp, tn, prevFlags, 0); //throws bad_alloc
+
+ pp = pn;
+ tp = tn;
+ prevFlags = 0;
+ }
+ addEdge(pp, p1, tp, outgoingTangent, prevFlags, END_SEGMENT); //throws bad_alloc
+ return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Tessellates a path.
+* \param
+* \return
+* \note tessellation output format: A list of vertices describing the
+* path tessellated into line segments and relevant aspects of the
+* input data. Each path segment has a start vertex, a number of
+* internal vertices (possibly zero), and an end vertex. The start
+* and end of segments and subpaths have been flagged, as well as
+* implicit and explicit close subpath segments.
+*//*-------------------------------------------------------------------*/
+
+void Path::tessellate(const Matrix3x3& pathToSurface, float strokeWidth)
+{
+ m_vertices.clear();
+
+ m_userMinx = RI_FLOAT_MAX;
+ m_userMiny = RI_FLOAT_MAX;
+ m_userMaxx = -RI_FLOAT_MAX;
+ m_userMaxy = -RI_FLOAT_MAX;
+
+ try
+ {
+ m_segmentToVertex.resize(m_segments.size());
+
+ int coordIndex = 0;
+ Vector2 s(0,0); //the beginning of the current subpath
+ Vector2 o(0,0); //the last point of the previous segment
+ Vector2 p(0,0); //the last internal control point of the previous segment, if the segment was a (regular or smooth) quadratic or cubic Bezier, or else the last point of the previous segment
+
+ //tessellate the path segments
+ coordIndex = 0;
+ s.set(0,0);
+ o.set(0,0);
+ p.set(0,0);
+ bool subpathHasGeometry = false;
+ VGPathSegment prevSegment = VG_MOVE_TO;
+ for(int i=0;i<m_segments.size();i++)
+ {
+ VGPathSegment segment = getPathSegment(m_segments[i]);
+ VGPathAbsRel absRel = getPathAbsRel(m_segments[i]);
+ int coords = segmentToNumCoordinates(segment);
+ m_segmentToVertex[i].start = m_vertices.size();
+
+ switch(segment)
+ {
+ case VG_CLOSE_PATH:
+ {
+ RI_ASSERT(coords == 0);
+ addEndPath(pathToSurface, o, s, subpathHasGeometry, CLOSE_SUBPATH);
+ p = s;
+ o = s;
+ subpathHasGeometry = false;
+ break;
+ }
+
+ case VG_MOVE_TO:
+ {
+ RI_ASSERT(coords == 2);
+ Vector2 c(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+ if(absRel == VG_RELATIVE)
+ c += o;
+ if(prevSegment != VG_MOVE_TO && prevSegment != VG_CLOSE_PATH)
+ addEndPath(pathToSurface, o, s, subpathHasGeometry, IMPLICIT_CLOSE_SUBPATH);
+ s = c;
+ p = c;
+ o = c;
+ subpathHasGeometry = false;
+ break;
+ }
+
+ case VG_LINE_TO:
+ {
+ RI_ASSERT(coords == 2);
+ Vector2 c(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+ if(absRel == VG_RELATIVE)
+ c += o;
+ if(addLineTo(pathToSurface, o, c, subpathHasGeometry))
+ subpathHasGeometry = true;
+ p = c;
+ o = c;
+ break;
+ }
+
+ case VG_HLINE_TO:
+ {
+ RI_ASSERT(coords == 1);
+ Vector2 c(getCoordinate(coordIndex+0), o.y);
+ if(absRel == VG_RELATIVE)
+ c.x += o.x;
+ if(addLineTo(pathToSurface, o, c, subpathHasGeometry))
+ subpathHasGeometry = true;
+ p = c;
+ o = c;
+ break;
+ }
+
+ case VG_VLINE_TO:
+ {
+ RI_ASSERT(coords == 1);
+ Vector2 c(o.x, getCoordinate(coordIndex+0));
+ if(absRel == VG_RELATIVE)
+ c.y += o.y;
+ if(addLineTo(pathToSurface, o, c, subpathHasGeometry))
+ subpathHasGeometry = true;
+ p = c;
+ o = c;
+ break;
+ }
+
+ case VG_QUAD_TO:
+ {
+ RI_ASSERT(coords == 4);
+ Vector2 c0(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+ Vector2 c1(getCoordinate(coordIndex+2), getCoordinate(coordIndex+3));
+ if(absRel == VG_RELATIVE)
+ {
+ c0 += o;
+ c1 += o;
+ }
+ if(addQuadTo(pathToSurface, o, c0, c1, subpathHasGeometry, strokeWidth))
+ subpathHasGeometry = true;
+ p = c0;
+ o = c1;
+ break;
+ }
+
+ case VG_SQUAD_TO:
+ {
+ RI_ASSERT(coords == 2);
+ Vector2 c0 = 2.0f * o - p;
+ Vector2 c1(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+ if(absRel == VG_RELATIVE)
+ c1 += o;
+ if(addQuadTo(pathToSurface, o, c0, c1, subpathHasGeometry, strokeWidth))
+ subpathHasGeometry = true;
+ p = c0;
+ o = c1;
+ break;
+ }
+
+ case VG_CUBIC_TO:
+ {
+ RI_ASSERT(coords == 6);
+ Vector2 c0(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+ Vector2 c1(getCoordinate(coordIndex+2), getCoordinate(coordIndex+3));
+ Vector2 c2(getCoordinate(coordIndex+4), getCoordinate(coordIndex+5));
+ if(absRel == VG_RELATIVE)
+ {
+ c0 += o;
+ c1 += o;
+ c2 += o;
+ }
+ if(addCubicTo(pathToSurface, o, c0, c1, c2, subpathHasGeometry, strokeWidth))
+ subpathHasGeometry = true;
+ p = c1;
+ o = c2;
+ break;
+ }
+
+ case VG_SCUBIC_TO:
+ {
+ RI_ASSERT(coords == 4);
+ Vector2 c0 = 2.0f * o - p;
+ Vector2 c1(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+ Vector2 c2(getCoordinate(coordIndex+2), getCoordinate(coordIndex+3));
+ if(absRel == VG_RELATIVE)
+ {
+ c1 += o;
+ c2 += o;
+ }
+ if(addCubicTo(pathToSurface, o, c0, c1, c2, subpathHasGeometry, strokeWidth))
+ subpathHasGeometry = true;
+ p = c1;
+ o = c2;
+ break;
+ }
+
+ default:
+ {
+ RI_ASSERT(segment == VG_SCCWARC_TO || segment == VG_SCWARC_TO ||
+ segment == VG_LCCWARC_TO || segment == VG_LCWARC_TO);
+ RI_ASSERT(coords == 5);
+ RIfloat rh = getCoordinate(coordIndex+0);
+ RIfloat rv = getCoordinate(coordIndex+1);
+ RIfloat rot = getCoordinate(coordIndex+2);
+ Vector2 c(getCoordinate(coordIndex+3), getCoordinate(coordIndex+4));
+
+ Vector2 cr = c;
+ if(absRel == VG_ABSOLUTE)
+ cr -= o;
+ else
+ c += o;
+
+ if(addArcTo(pathToSurface, o, rh, rv, rot, c, cr, segment, subpathHasGeometry, strokeWidth))
+ subpathHasGeometry = true;
+ p = c;
+ o = c;
+ break;
+ }
+ }
+
+ if(m_vertices.size() > m_segmentToVertex[i].start)
+ { //segment produced vertices
+ m_segmentToVertex[i].end = m_vertices.size() - 1;
+ }
+ else
+ { //segment didn't produce vertices (zero-length segment). Ignore it.
+ m_segmentToVertex[i].start = m_segmentToVertex[i].end = m_vertices.size()-1;
+ }
+ prevSegment = segment;
+ coordIndex += coords;
+ }
+
+ //add an implicit MOVE_TO to the end to close the last subpath.
+ //if the subpath contained only zero-length segments, this produces the necessary geometry to get it stroked
+ // and included in path bounds. The geometry won't be included in the pointAlongPath query.
+ if(prevSegment != VG_MOVE_TO && prevSegment != VG_CLOSE_PATH)
+ addEndPath(pathToSurface, o, s, subpathHasGeometry, IMPLICIT_CLOSE_SUBPATH);
+
+ //check that the flags are correct
+#ifdef RI_DEBUG
+ int prev = -1;
+ bool subpathStarted = false;
+ bool segmentStarted = false;
+ for(int i=0;i<m_vertices.size();i++)
+ {
+ Vertex& v = m_vertices[i];
+
+ if(v.flags & START_SUBPATH)
+ {
+ RI_ASSERT(!subpathStarted);
+ RI_ASSERT(v.flags & START_SEGMENT);
+ RI_ASSERT(!(v.flags & END_SUBPATH));
+ RI_ASSERT(!(v.flags & END_SEGMENT));
+ RI_ASSERT(!(v.flags & CLOSE_SUBPATH));
+ RI_ASSERT(!(v.flags & IMPLICIT_CLOSE_SUBPATH));
+ subpathStarted = true;
+ }
+
+ if(v.flags & START_SEGMENT)
+ {
+ RI_ASSERT(subpathStarted || (v.flags & CLOSE_SUBPATH) || (v.flags & IMPLICIT_CLOSE_SUBPATH));
+ RI_ASSERT(!segmentStarted);
+ RI_ASSERT(!(v.flags & END_SUBPATH));
+ RI_ASSERT(!(v.flags & END_SEGMENT));
+ segmentStarted = true;
+ }
+
+ if( v.flags & CLOSE_SUBPATH )
+ {
+ RI_ASSERT(segmentStarted);
+ RI_ASSERT(!subpathStarted);
+ RI_ASSERT((v.flags & START_SEGMENT) || (v.flags & END_SEGMENT));
+ RI_ASSERT(!(v.flags & IMPLICIT_CLOSE_SUBPATH));
+ RI_ASSERT(!(v.flags & START_SUBPATH));
+ RI_ASSERT(!(v.flags & END_SUBPATH));
+ }
+ if( v.flags & IMPLICIT_CLOSE_SUBPATH )
+ {
+ RI_ASSERT(segmentStarted);
+ RI_ASSERT(!subpathStarted);
+ RI_ASSERT((v.flags & START_SEGMENT) || (v.flags & END_SEGMENT));
+ RI_ASSERT(!(v.flags & CLOSE_SUBPATH));
+ RI_ASSERT(!(v.flags & START_SUBPATH));
+ RI_ASSERT(!(v.flags & END_SUBPATH));
+ }
+
+ if( prev >= 0 )
+ {
+ RI_ASSERT(segmentStarted);
+ RI_ASSERT(subpathStarted || ((m_vertices[prev].flags & CLOSE_SUBPATH) && (m_vertices[i].flags & CLOSE_SUBPATH)) ||
+ ((m_vertices[prev].flags & IMPLICIT_CLOSE_SUBPATH) && (m_vertices[i].flags & IMPLICIT_CLOSE_SUBPATH)));
+ }
+
+ prev = i;
+ if(v.flags & END_SEGMENT)
+ {
+ RI_ASSERT(subpathStarted || (v.flags & CLOSE_SUBPATH) || (v.flags & IMPLICIT_CLOSE_SUBPATH));
+ RI_ASSERT(segmentStarted);
+ RI_ASSERT(!(v.flags & START_SUBPATH));
+ RI_ASSERT(!(v.flags & START_SEGMENT));
+ segmentStarted = false;
+ prev = -1;
+ }
+
+ if(v.flags & END_SUBPATH)
+ {
+ RI_ASSERT(subpathStarted);
+ RI_ASSERT(v.flags & END_SEGMENT);
+ RI_ASSERT(!(v.flags & START_SUBPATH));
+ RI_ASSERT(!(v.flags & START_SEGMENT));
+ RI_ASSERT(!(v.flags & CLOSE_SUBPATH));
+ RI_ASSERT(!(v.flags & IMPLICIT_CLOSE_SUBPATH));
+ subpathStarted = false;
+ }
+ }
+#endif //RI_DEBUG
+ }
+ catch(std::bad_alloc)
+ {
+ m_vertices.clear();
+ throw;
+ }
+}
+
+//==============================================================================================
+
+} //namespace tgOpenVG
+
+//==============================================================================================
diff --git a/src/vg/Path.h b/src/vg/Path.h
new file mode 100644
index 0000000..d92cb17
--- /dev/null
+++ b/src/vg/Path.h
@@ -0,0 +1,177 @@
+#ifndef __PATH_H
+#define __PATH_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Path class.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "VG/openvg.h"
+#include "Math.h"
+#include "Array.h"
+#include "Rasterizer.h"
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief Storage and operations for VGPath.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class Path
+{
+public:
+ Path(VGint format, VGPathDatatype datatype, RIfloat scale, RIfloat bias, int segmentCapacityHint, int coordCapacityHint, VGbitfield caps); //throws bad_alloc
+ ~Path();
+
+ VGint getFormat() const { return m_format; }
+ VGPathDatatype getDatatype() const { return m_datatype; }
+ RIfloat getScale() const { return m_scale; }
+ RIfloat getBias() const { return m_bias; }
+ VGbitfield getCapabilities() const { return m_capabilities; }
+ void setCapabilities(VGbitfield caps) { m_capabilities = caps; }
+ int getNumSegments() const { return m_segments.size(); }
+ int getNumCoordinates() const { return m_data.size() / getBytesPerCoordinate(m_datatype); }
+ void addReference() { m_referenceCount++; }
+ int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+ void clear(VGbitfield capabilities);
+ void appendData(const RIuint8* segments, int numSegments, const RIuint8* data); //throws bad_alloc
+ void append(const Path* srcPath); //throws bad_alloc
+ void modifyCoords(int startIndex, int numSegments, const RIuint8* data);
+ void transform(const Path* srcPath, const Matrix3x3& matrix); //throws bad_alloc
+ //returns true if interpolation succeeds, false if start and end paths are not compatible
+ bool interpolate(const Path* startPath, const Path* endPath, RIfloat amount); //throws bad_alloc
+ void fill(const Matrix3x3& pathToSurface, Rasterizer& rasterizer); //throws bad_alloc
+ void stroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const Array<RIfloat>& dashPattern, RIfloat dashPhase, bool dashPhaseReset, RIfloat strokeWidth, VGCapStyle capStyle, VGJoinStyle joinStyle, RIfloat miterLimit); //throws bad_alloc
+
+ void getPointAlong(int startIndex, int numSegments, RIfloat distance, Vector2& p, Vector2& t); //throws bad_alloc
+ RIfloat getPathLength(int startIndex, int numSegments); //throws bad_alloc
+ void getPathBounds(RIfloat& minx, RIfloat& miny, RIfloat& maxx, RIfloat& maxy); //throws bad_alloc
+ void getPathTransformedBounds(const Matrix3x3& pathToSurface, RIfloat& minx, RIfloat& miny, RIfloat& maxx, RIfloat& maxy); //throws bad_alloc
+
+private:
+ enum VertexFlags
+ {
+ START_SUBPATH = (1<<0),
+ END_SUBPATH = (1<<1),
+ START_SEGMENT = (1<<2),
+ END_SEGMENT = (1<<3),
+ CLOSE_SUBPATH = (1<<4),
+ IMPLICIT_CLOSE_SUBPATH = (1<<5)
+ };
+ struct Vertex
+ {
+ Vertex() : userPosition(), userTangent(), pathLength(0.0f), flags(0) {}
+ Vector2 userPosition;
+ Vector2 userTangent;
+ RIfloat pathLength;
+ unsigned int flags;
+ };
+ struct StrokeVertex
+ {
+ StrokeVertex() : p(), t(), ccw(), cw(), pathLength(0.0f), flags(0), inDash(false) {}
+ Vector2 p;
+ Vector2 t;
+ Vector2 ccw;
+ Vector2 cw;
+ RIfloat pathLength;
+ unsigned int flags;
+ bool inDash;
+ };
+
+ Path(const Path&); //!< Not allowed.
+ const Path& operator=(const Path&); //!< Not allowed.
+
+ static VGPathSegment getPathSegment(RIuint8 data) { return (VGPathSegment)(data & 0x1e); }
+ static VGPathAbsRel getPathAbsRel(RIuint8 data) { return (VGPathAbsRel)(data & 0x1); }
+ static int segmentToNumCoordinates(VGPathSegment segment);
+ static int countNumCoordinates(const RIuint8* segments, int numSegments);
+ static int getBytesPerCoordinate(VGPathDatatype datatype);
+
+ static void setCoordinate(Array<RIuint8>& data, VGPathDatatype datatype, RIfloat scale, RIfloat bias, int i, RIfloat c);
+
+ RIfloat getCoordinate(int i) const;
+ void setCoordinate(int i, RIfloat c) { setCoordinate(m_data, m_datatype, m_scale, m_bias, i, c); }
+
+ void addVertex(const Vector2& p, const Vector2& t, RIfloat pathLength, unsigned int flags); //throws bad_alloc
+ void addEdge(const Vector2& p0, const Vector2& p1, const Vector2& t0, const Vector2& t1, unsigned int startFlags, unsigned int endFlags); //throws bad_alloc
+
+ void addEndPath(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, bool subpathHasGeometry, unsigned int flags); //throws bad_alloc
+ bool addLineTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, bool subpathHasGeometry); //throws bad_alloc
+ bool addQuadTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, const Vector2& p2, bool subpathHasGeometry, float strokeWidth); //throws bad_alloc
+ bool addCubicTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, const Vector2& p2, const Vector2& p3, bool subpathHasGeometry, float strokeWidth); //throws bad_alloc
+ bool addArcTo(const Matrix3x3& pathToSurface, const Vector2& p0, RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p1, const Vector2& p1r, VGPathSegment segment, bool subpathHasGeometry, float strokeWidth); //throws bad_alloc
+
+ void tessellate(const Matrix3x3& pathToSurface, float strokeWidth); //throws bad_alloc
+
+ void normalizeForInterpolation(const Path* srcPath); //throws bad_alloc
+
+ void interpolateStroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v0, const StrokeVertex& v1, RIfloat strokeWidth) const; //throws bad_alloc
+ void doCap(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v, RIfloat strokeWidth, VGCapStyle capStyle) const; //throws bad_alloc
+ void doJoin(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v0, const StrokeVertex& v1, RIfloat strokeWidth, VGJoinStyle joinStyle, RIfloat miterLimit) const; //throws bad_alloc
+
+ //input data
+ VGint m_format;
+ VGPathDatatype m_datatype;
+ RIfloat m_scale;
+ RIfloat m_bias;
+ VGbitfield m_capabilities;
+ int m_referenceCount;
+ Array<RIuint8> m_segments;
+ Array<RIuint8> m_data;
+
+ //data produced by tessellation
+ struct VertexIndex
+ {
+ int start;
+ int end;
+ };
+ Array<Vertex> m_vertices;
+ int m_numTessVertices;
+ Array<VertexIndex> m_segmentToVertex;
+ RIfloat m_userMinx;
+ RIfloat m_userMiny;
+ RIfloat m_userMaxx;
+ RIfloat m_userMaxy;
+};
+
+//==============================================================================================
+
+} //namespace tgOpenVG
+
+//==============================================================================================
+
+#endif /* __PATH_H */
diff --git a/src/vg/PixelPipe.cpp b/src/vg/PixelPipe.cpp
new file mode 100644
index 0000000..9357ca3
--- /dev/null
+++ b/src/vg/PixelPipe.cpp
@@ -0,0 +1,894 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Implementation of Paint and pixel pipe functionality.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "PixelPipe.h"
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief Paint constructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Paint::Paint() :
+ m_paintType(VG_PAINT_TYPE_COLOR),
+ m_paintColor(0,0,0,1,Color::sRGBA_PRE),
+ m_inputPaintColor(0,0,0,1,Color::sRGBA),
+ m_colorRampSpreadMode(VG_COLOR_RAMP_SPREAD_PAD),
+ m_colorRampStops(),
+ m_inputColorRampStops(),
+ m_colorRampPremultiplied(VG_TRUE),
+ m_inputLinearGradientPoint0(0,0),
+ m_linearGradientPoint0(0,0),
+ m_inputLinearGradientPoint1(1,0),
+ m_linearGradientPoint1(1,0),
+ m_inputRadialGradientCenter(0,0),
+ m_radialGradientCenter(0,0),
+ m_inputRadialGradientFocalPoint(0,0),
+ m_radialGradientFocalPoint(0,0),
+ m_inputRadialGradientRadius(1.0f),
+ m_radialGradientRadius(1.0f),
+ m_patternTilingMode(VG_TILE_FILL),
+ m_pattern(NULL),
+ m_referenceCount(0)
+{
+ Paint::GradientStop gs;
+ gs.offset = 0.0f;
+ gs.color.set(0,0,0,1,Color::sRGBA);
+ m_colorRampStops.push_back(gs); //throws bad_alloc
+ gs.offset = 1.0f;
+ gs.color.set(1,1,1,1,Color::sRGBA);
+ m_colorRampStops.push_back(gs); //throws bad_alloc
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Paint destructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Paint::~Paint()
+{
+ RI_ASSERT(m_referenceCount == 0);
+ if(m_pattern)
+ {
+ m_pattern->removeInUse();
+ if(!m_pattern->removeReference())
+ RI_DELETE(m_pattern);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief PixelPipe constructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+PixelPipe::PixelPipe() :
+ m_drawable(NULL),
+ m_image(NULL),
+ m_paint(NULL),
+ m_defaultPaint(),
+ m_blendMode(VG_BLEND_SRC_OVER),
+ m_imageMode(VG_DRAW_IMAGE_NORMAL),
+ m_imageQuality(VG_IMAGE_QUALITY_FASTER),
+ m_tileFillColor(0,0,0,0,Color::sRGBA),
+ m_colorTransform(false),
+ m_colorTransformValues(),
+ m_surfaceToPaintMatrix(),
+ m_surfaceToImageMatrix()
+{
+ for(int i=0;i<8;i++)
+ m_colorTransformValues[i] = (i < 4) ? 1.0f : 0.0f;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief PixelPipe destructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+PixelPipe::~PixelPipe()
+{
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets the rendering surface.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setDrawable(Drawable* drawable)
+{
+ RI_ASSERT(drawable);
+ m_drawable = drawable;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets the blend mode.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setBlendMode(VGBlendMode blendMode)
+{
+ RI_ASSERT(blendMode >= VG_BLEND_SRC && blendMode <= VG_BLEND_ADDITIVE);
+ m_blendMode = blendMode;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets the mask image. NULL disables masking.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setMask(bool masking)
+{
+ m_masking = masking;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets the image to be drawn. NULL disables image drawing.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setImage(Image* image, VGImageMode imageMode)
+{
+ RI_ASSERT(imageMode == VG_DRAW_IMAGE_NORMAL || imageMode == VG_DRAW_IMAGE_MULTIPLY || imageMode == VG_DRAW_IMAGE_STENCIL);
+ m_image = image;
+ m_imageMode = imageMode;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets the surface-to-paint matrix.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setSurfaceToPaintMatrix(const Matrix3x3& surfaceToPaintMatrix)
+{
+ m_surfaceToPaintMatrix = surfaceToPaintMatrix;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets the surface-to-image matrix.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setSurfaceToImageMatrix(const Matrix3x3& surfaceToImageMatrix)
+{
+ m_surfaceToImageMatrix = surfaceToImageMatrix;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets image quality.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setImageQuality(VGImageQuality imageQuality)
+{
+ RI_ASSERT(imageQuality == VG_IMAGE_QUALITY_NONANTIALIASED || imageQuality == VG_IMAGE_QUALITY_FASTER || imageQuality == VG_IMAGE_QUALITY_BETTER);
+ m_imageQuality = imageQuality;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets fill color for VG_TILE_FILL tiling mode (pattern only).
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setTileFillColor(const Color& c)
+{
+ m_tileFillColor = c;
+ m_tileFillColor.clamp();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets paint.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setPaint(const Paint* paint)
+{
+ m_paint = paint;
+ if(!m_paint)
+ m_paint = &m_defaultPaint;
+ if(m_paint->m_pattern)
+ m_tileFillColor.convert(m_paint->m_pattern->getDescriptor().internalFormat);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Color transform.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setColorTransform(bool enable, RIfloat values[8])
+{
+ m_colorTransform = enable;
+ for(int i=0;i<4;i++)
+ {
+ m_colorTransformValues[i] = RI_CLAMP(values[i], -127.0f, 127.0f);
+ m_colorTransformValues[i+4] = RI_CLAMP(values[i+4], -1.0f, 1.0f);
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Computes the linear gradient function at (x,y).
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::linearGradient(RIfloat& g, RIfloat& rho, RIfloat x, RIfloat y) const
+{
+ RI_ASSERT(m_paint);
+ Vector2 u = m_paint->m_linearGradientPoint1 - m_paint->m_linearGradientPoint0;
+ RIfloat usq = dot(u,u);
+ if( usq <= 0.0f )
+ { //points are equal, gradient is always 1.0f
+ g = 1.0f;
+ rho = 0.0f;
+ return;
+ }
+ RIfloat oou = 1.0f / usq;
+
+ Vector2 p(x, y);
+ p = affineTransform(m_surfaceToPaintMatrix, p);
+ p -= m_paint->m_linearGradientPoint0;
+ RI_ASSERT(usq >= 0.0f);
+ g = dot(p, u) * oou;
+ RIfloat dgdx = oou * u.x * m_surfaceToPaintMatrix[0][0] + oou * u.y * m_surfaceToPaintMatrix[1][0];
+ RIfloat dgdy = oou * u.x * m_surfaceToPaintMatrix[0][1] + oou * u.y * m_surfaceToPaintMatrix[1][1];
+ rho = (RIfloat)sqrt(dgdx*dgdx + dgdy*dgdy);
+ RI_ASSERT(rho >= 0.0f);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Computes the radial gradient function at (x,y).
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::radialGradient(RIfloat &g, RIfloat &rho, RIfloat x, RIfloat y) const
+{
+ RI_ASSERT(m_paint);
+ if( m_paint->m_radialGradientRadius <= 0.0f )
+ {
+ g = 1.0f;
+ rho = 0.0f;
+ return;
+ }
+
+ RIfloat r = m_paint->m_radialGradientRadius;
+ Vector2 c = m_paint->m_radialGradientCenter;
+ Vector2 f = m_paint->m_radialGradientFocalPoint;
+ Vector2 gx(m_surfaceToPaintMatrix[0][0], m_surfaceToPaintMatrix[1][0]);
+ Vector2 gy(m_surfaceToPaintMatrix[0][1], m_surfaceToPaintMatrix[1][1]);
+
+ Vector2 fp = f - c;
+
+ //clamp the focal point inside the gradient circle
+ RIfloat fpLen = fp.length();
+ if( fpLen > 0.999f * r )
+ fp *= 0.999f * r / fpLen;
+
+ RIfloat D = -1.0f / (dot(fp,fp) - r*r);
+ Vector2 p(x, y);
+ p = affineTransform(m_surfaceToPaintMatrix, p) - c;
+ Vector2 d = p - fp;
+ RIfloat s = (RIfloat)sqrt(r*r*dot(d,d) - RI_SQR(p.x*fp.y - p.y*fp.x));
+ g = (dot(fp,d) + s) * D;
+ if(RI_ISNAN(g))
+ g = 0.0f;
+ RIfloat dgdx = D*dot(fp,gx) + (r*r*dot(d,gx) - (gx.x*fp.y - gx.y*fp.x)*(p.x*fp.y - p.y*fp.x)) * (D / s);
+ RIfloat dgdy = D*dot(fp,gy) + (r*r*dot(d,gy) - (gy.x*fp.y - gy.y*fp.x)*(p.x*fp.y - p.y*fp.x)) * (D / s);
+ rho = (RIfloat)sqrt(dgdx*dgdx + dgdy*dgdy);
+ if(RI_ISNAN(rho))
+ rho = 0.0f;
+ RI_ASSERT(rho >= 0.0f);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns the average color within an offset range in the color ramp.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static Color readStopColor(const Array<Paint::GradientStop>& colorRampStops, int i, VGboolean colorRampPremultiplied)
+{
+ RI_ASSERT(i >= 0 && i < colorRampStops.size());
+ Color c = colorRampStops[i].color;
+ RI_ASSERT(c.getInternalFormat() == Color::sRGBA);
+ if(colorRampPremultiplied)
+ c.premultiply();
+ return c;
+}
+
+Color PixelPipe::integrateColorRamp(RIfloat gmin, RIfloat gmax) const
+{
+ RI_ASSERT(gmin <= gmax);
+ RI_ASSERT(gmin >= 0.0f && gmin <= 1.0f);
+ RI_ASSERT(gmax >= 0.0f && gmax <= 1.0f);
+ RI_ASSERT(m_paint->m_colorRampStops.size() >= 2); //there are at least two stops
+
+ Color c(0,0,0,0,m_paint->m_colorRampPremultiplied ? Color::sRGBA_PRE : Color::sRGBA);
+ if(gmin == 1.0f || gmax == 0.0f)
+ return c;
+
+ int i=0;
+ for(;i<m_paint->m_colorRampStops.size()-1;i++)
+ {
+ if(gmin >= m_paint->m_colorRampStops[i].offset && gmin < m_paint->m_colorRampStops[i+1].offset)
+ {
+ RIfloat s = m_paint->m_colorRampStops[i].offset;
+ RIfloat e = m_paint->m_colorRampStops[i+1].offset;
+ RI_ASSERT(s < e);
+ RIfloat g = (gmin - s) / (e - s);
+
+ Color sc = readStopColor(m_paint->m_colorRampStops, i, m_paint->m_colorRampPremultiplied);
+ Color ec = readStopColor(m_paint->m_colorRampStops, i+1, m_paint->m_colorRampPremultiplied);
+ Color rc = (1.0f-g) * sc + g * ec;
+
+ //subtract the average color from the start of the stop to gmin
+ c -= 0.5f*(gmin - s)*(sc + rc);
+ break;
+ }
+ }
+
+ for(;i<m_paint->m_colorRampStops.size()-1;i++)
+ {
+ RIfloat s = m_paint->m_colorRampStops[i].offset;
+ RIfloat e = m_paint->m_colorRampStops[i+1].offset;
+ RI_ASSERT(s <= e);
+
+ Color sc = readStopColor(m_paint->m_colorRampStops, i, m_paint->m_colorRampPremultiplied);
+ Color ec = readStopColor(m_paint->m_colorRampStops, i+1, m_paint->m_colorRampPremultiplied);
+
+ //average of the stop
+ c += 0.5f*(e-s)*(sc + ec);
+
+ if(gmax >= m_paint->m_colorRampStops[i].offset && gmax < m_paint->m_colorRampStops[i+1].offset)
+ {
+ RIfloat g = (gmax - s) / (e - s);
+ Color rc = (1.0f-g) * sc + g * ec;
+
+ //subtract the average color from gmax to the end of the stop
+ c -= 0.5f*(e - gmax)*(rc + ec);
+ break;
+ }
+ }
+ return c;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Maps a gradient function value to a color.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Color PixelPipe::colorRamp(RIfloat gradient, RIfloat rho) const
+{
+ RI_ASSERT(m_paint);
+ RI_ASSERT(rho >= 0.0f);
+
+ Color c(0,0,0,0,m_paint->m_colorRampPremultiplied ? Color::sRGBA_PRE : Color::sRGBA);
+ Color avg;
+
+ if(rho == 0.0f)
+ { //filter size is zero or gradient is degenerate
+ switch(m_paint->m_colorRampSpreadMode)
+ {
+ case VG_COLOR_RAMP_SPREAD_PAD:
+ gradient = RI_CLAMP(gradient, 0.0f, 1.0f);
+ break;
+ case VG_COLOR_RAMP_SPREAD_REFLECT:
+ {
+ RIfloat g = RI_MOD(gradient, 2.0f);
+ gradient = (g < 1.0f) ? g : 2.0f - g;
+ break;
+ }
+ default:
+ RI_ASSERT(m_paint->m_colorRampSpreadMode == VG_COLOR_RAMP_SPREAD_REPEAT);
+ gradient = gradient - (RIfloat)floor(gradient);
+ break;
+ }
+ RI_ASSERT(gradient >= 0.0f && gradient <= 1.0f);
+
+ for(int i=0;i<m_paint->m_colorRampStops.size()-1;i++)
+ {
+ if(gradient >= m_paint->m_colorRampStops[i].offset && gradient < m_paint->m_colorRampStops[i+1].offset)
+ {
+ RIfloat s = m_paint->m_colorRampStops[i].offset;
+ RIfloat e = m_paint->m_colorRampStops[i+1].offset;
+ RI_ASSERT(s < e);
+ RIfloat g = RI_CLAMP((gradient - s) / (e - s), 0.0f, 1.0f); //clamp needed due to numerical inaccuracies
+
+ Color sc = readStopColor(m_paint->m_colorRampStops, i, m_paint->m_colorRampPremultiplied);
+ Color ec = readStopColor(m_paint->m_colorRampStops, i+1, m_paint->m_colorRampPremultiplied);
+ return (1.0f-g) * sc + g * ec; //return interpolated value
+ }
+ }
+ return readStopColor(m_paint->m_colorRampStops, m_paint->m_colorRampStops.size()-1, m_paint->m_colorRampPremultiplied);
+ }
+
+ RIfloat gmin = gradient - rho*0.5f; //filter starting from the gradient point (if starts earlier, radial gradient center will be an average of the first and the last stop, which doesn't look good)
+ RIfloat gmax = gradient + rho*0.5f;
+
+ switch(m_paint->m_colorRampSpreadMode)
+ {
+ case VG_COLOR_RAMP_SPREAD_PAD:
+ {
+ if(gmin < 0.0f)
+ c += (RI_MIN(gmax, 0.0f) - gmin) * readStopColor(m_paint->m_colorRampStops, 0, m_paint->m_colorRampPremultiplied);
+ if(gmax > 1.0f)
+ c += (gmax - RI_MAX(gmin, 1.0f)) * readStopColor(m_paint->m_colorRampStops, m_paint->m_colorRampStops.size()-1, m_paint->m_colorRampPremultiplied);
+ gmin = RI_CLAMP(gmin, 0.0f, 1.0f);
+ gmax = RI_CLAMP(gmax, 0.0f, 1.0f);
+ c += integrateColorRamp(gmin, gmax);
+ c *= 1.0f/rho;
+ c.clamp(); //clamp needed due to numerical inaccuracies
+ return c;
+ }
+
+ case VG_COLOR_RAMP_SPREAD_REFLECT:
+ {
+ avg = integrateColorRamp(0.0f, 1.0f);
+ RIfloat gmini = (RIfloat)floor(gmin);
+ RIfloat gmaxi = (RIfloat)floor(gmax);
+ c = (gmaxi + 1.0f - gmini) * avg; //full ramps
+
+ //subtract beginning
+ if(((int)gmini) & 1)
+ c -= integrateColorRamp(RI_CLAMP(1.0f - (gmin - gmini), 0.0f, 1.0f), 1.0f);
+ else
+ c -= integrateColorRamp(0.0f, RI_CLAMP(gmin - gmini, 0.0f, 1.0f));
+
+ //subtract end
+ if(((int)gmaxi) & 1)
+ c -= integrateColorRamp(0.0f, RI_CLAMP(1.0f - (gmax - gmaxi), 0.0f, 1.0f));
+ else
+ c -= integrateColorRamp(RI_CLAMP(gmax - gmaxi, 0.0f, 1.0f), 1.0f);
+ break;
+ }
+
+ default:
+ {
+ RI_ASSERT(m_paint->m_colorRampSpreadMode == VG_COLOR_RAMP_SPREAD_REPEAT);
+ avg = integrateColorRamp(0.0f, 1.0f);
+ RIfloat gmini = (RIfloat)floor(gmin);
+ RIfloat gmaxi = (RIfloat)floor(gmax);
+ c = (gmaxi + 1.0f - gmini) * avg; //full ramps
+ c -= integrateColorRamp(0.0f, RI_CLAMP(gmin - gmini, 0.0f, 1.0f)); //subtract beginning
+ c -= integrateColorRamp(RI_CLAMP(gmax - gmaxi, 0.0f, 1.0f), 1.0f); //subtract end
+ break;
+ }
+ }
+
+ //divide color by the length of the range
+ c *= 1.0f / rho;
+ c.clamp(); //clamp needed due to numerical inaccuracies
+
+ //hide aliasing by fading to the average color
+ const RIfloat fadeStart = 0.5f;
+ const RIfloat fadeMultiplier = 2.0f; //the larger, the earlier fade to average is done
+
+ if(rho < fadeStart)
+ return c;
+
+ RIfloat ratio = RI_MIN((rho - fadeStart) * fadeMultiplier, 1.0f);
+ return ratio * avg + (1.0f - ratio) * c;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Computes blend.
+* \param
+* \return
+* \note premultiplied blending formulas
+ //src
+ a = asrc
+ r = rsrc
+ //src over
+ a = asrc + adst * (1-asrc)
+ r = rsrc + rdst * (1-asrc)
+ //dst over
+ a = asrc * (1-adst) + adst
+ r = rsrc * (1-adst) + adst
+ //src in
+ a = asrc * adst
+ r = rsrc * adst
+ //dst in
+ a = adst * asrc
+ r = rdst * asrc
+ //multiply
+ a = asrc + adst * (1-asrc)
+ r = rsrc * (1-adst) + rdst * (1-asrc) + rsrc * rdst
+ //screen
+ a = asrc + adst * (1-asrc)
+ r = rsrc + rdst - rsrc * rdst
+ //darken
+ a = asrc + adst * (1-asrc)
+ r = MIN(rsrc + rdst * (1-asrc), rdst + rsrc * (1-adst))
+ //lighten
+ a = asrc + adst * (1-asrc)
+ r = MAX(rsrc + rdst * (1-asrc), rdst + rsrc * (1-adst))
+ //additive
+ a = MIN(asrc+adst,1)
+ r = rsrc + rdst
+*//*-------------------------------------------------------------------*/
+
+Color PixelPipe::blend(const Color& s, RIfloat ar, RIfloat ag, RIfloat ab, const Color& d, VGBlendMode blendMode) const
+{
+ //apply blending in the premultiplied format
+ Color r(0,0,0,0,d.getInternalFormat());
+ RI_ASSERT(s.a >= 0.0f && s.a <= 1.0f);
+ RI_ASSERT(s.r >= 0.0f && s.r <= s.a && s.r <= ar);
+ RI_ASSERT(s.g >= 0.0f && s.g <= s.a && s.g <= ag);
+ RI_ASSERT(s.b >= 0.0f && s.b <= s.a && s.b <= ab);
+ RI_ASSERT(d.a >= 0.0f && d.a <= 1.0f);
+ RI_ASSERT(d.r >= 0.0f && d.r <= d.a);
+ RI_ASSERT(d.g >= 0.0f && d.g <= d.a);
+ RI_ASSERT(d.b >= 0.0f && d.b <= d.a);
+ switch(blendMode)
+ {
+ case VG_BLEND_SRC:
+ r = s;
+ break;
+
+ case VG_BLEND_SRC_OVER:
+ r.r = s.r + d.r * (1.0f - ar);
+ r.g = s.g + d.g * (1.0f - ag);
+ r.b = s.b + d.b * (1.0f - ab);
+ r.a = s.a + d.a * (1.0f - s.a);
+ break;
+
+ case VG_BLEND_DST_OVER:
+ r.r = s.r * (1.0f - d.a) + d.r;
+ r.g = s.g * (1.0f - d.a) + d.g;
+ r.b = s.b * (1.0f - d.a) + d.b;
+ r.a = s.a * (1.0f - d.a) + d.a;
+ break;
+
+ case VG_BLEND_SRC_IN:
+ r.r = s.r * d.a;
+ r.g = s.g * d.a;
+ r.b = s.b * d.a;
+ r.a = s.a * d.a;
+ break;
+
+ case VG_BLEND_DST_IN:
+ r.r = d.r * ar;
+ r.g = d.g * ag;
+ r.b = d.b * ab;
+ r.a = d.a * s.a;
+ break;
+
+ case VG_BLEND_MULTIPLY:
+ r.r = s.r * (1.0f - d.a + d.r) + d.r * (1.0f - ar);
+ r.g = s.g * (1.0f - d.a + d.g) + d.g * (1.0f - ag);
+ r.b = s.b * (1.0f - d.a + d.b) + d.b * (1.0f - ab);
+ r.a = s.a + d.a * (1.0f - s.a);
+ break;
+
+ case VG_BLEND_SCREEN:
+ r.r = s.r + d.r * (1.0f - s.r);
+ r.g = s.g + d.g * (1.0f - s.g);
+ r.b = s.b + d.b * (1.0f - s.b);
+ r.a = s.a + d.a * (1.0f - s.a);
+ break;
+
+ case VG_BLEND_DARKEN:
+ r.r = RI_MIN(s.r + d.r * (1.0f - ar), d.r + s.r * (1.0f - d.a));
+ r.g = RI_MIN(s.g + d.g * (1.0f - ag), d.g + s.g * (1.0f - d.a));
+ r.b = RI_MIN(s.b + d.b * (1.0f - ab), d.b + s.b * (1.0f - d.a));
+ r.a = s.a + d.a * (1.0f - s.a);
+ break;
+
+ case VG_BLEND_LIGHTEN:
+ r.r = RI_MAX(s.r + d.r * (1.0f - ar), d.r + s.r * (1.0f - d.a));
+ r.g = RI_MAX(s.g + d.g * (1.0f - ag), d.g + s.g * (1.0f - d.a));
+ r.b = RI_MAX(s.b + d.b * (1.0f - ab), d.b + s.b * (1.0f - d.a));
+ //although the statement below is equivalent to r.a = s.a + d.a * (1.0f - s.a)
+ //in practice there can be a very slight difference because
+ //of the max operation in the blending formula that may cause color to exceed alpha.
+ //Because of this, we compute the result both ways and return the maximum.
+ r.a = RI_MAX(s.a + d.a * (1.0f - s.a), d.a + s.a * (1.0f - d.a));
+ break;
+
+ default:
+ RI_ASSERT(blendMode == VG_BLEND_ADDITIVE);
+ r.r = RI_MIN(s.r + d.r, 1.0f);
+ r.g = RI_MIN(s.g + d.g, 1.0f);
+ r.b = RI_MIN(s.b + d.b, 1.0f);
+ r.a = RI_MIN(s.a + d.a, 1.0f);
+ break;
+ }
+ return r;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Applies color transform.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::colorTransform(Color& c) const
+{
+ if(m_colorTransform)
+ {
+ c.unpremultiply();
+ c.luminanceToRGB();
+ c.r = c.r * m_colorTransformValues[0] + m_colorTransformValues[4];
+ c.g = c.g * m_colorTransformValues[1] + m_colorTransformValues[5];
+ c.b = c.b * m_colorTransformValues[2] + m_colorTransformValues[6];
+ c.a = c.a * m_colorTransformValues[3] + m_colorTransformValues[7];
+ c.clamp();
+ c.premultiply();
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Applies paint, image drawing, masking and blending at pixel (x,y).
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::pixelPipe(int x, int y, RIfloat coverage, unsigned int sampleMask) const
+{
+ RI_ASSERT(m_drawable);
+ RI_ASSERT(sampleMask);
+ RI_ASSERT(coverage > 0.0f);
+ Color::InternalFormat dstFormat = (Color::InternalFormat)(m_drawable->getDescriptor().internalFormat | Color::PREMULTIPLIED);
+
+ //evaluate paint
+ RI_ASSERT(m_paint);
+ Color s;
+ switch(m_paint->m_paintType)
+ {
+ case VG_PAINT_TYPE_COLOR:
+ s = m_paint->m_paintColor;
+ break;
+
+ case VG_PAINT_TYPE_LINEAR_GRADIENT:
+ {
+ RIfloat g, rho;
+ linearGradient(g, rho, x+0.5f, y+0.5f);
+ s = colorRamp(g, rho);
+ RI_ASSERT((s.getInternalFormat() == Color::sRGBA && !m_paint->m_colorRampPremultiplied) || (s.getInternalFormat() == Color::sRGBA_PRE && m_paint->m_colorRampPremultiplied));
+ s.premultiply();
+ break;
+ }
+
+ case VG_PAINT_TYPE_RADIAL_GRADIENT:
+ {
+ RIfloat g, rho;
+ radialGradient(g, rho, x+0.5f, y+0.5f);
+ s = colorRamp(g, rho);
+ RI_ASSERT((s.getInternalFormat() == Color::sRGBA && !m_paint->m_colorRampPremultiplied) || (s.getInternalFormat() == Color::sRGBA_PRE && m_paint->m_colorRampPremultiplied));
+ s.premultiply();
+ break;
+ }
+
+ default:
+ RI_ASSERT(m_paint->m_paintType == VG_PAINT_TYPE_PATTERN);
+ if(m_paint->m_pattern)
+ s = m_paint->m_pattern->resample(x+0.5f, y+0.5f, m_surfaceToPaintMatrix, m_imageQuality, m_paint->m_patternTilingMode, m_tileFillColor);
+ else
+ s = m_paint->m_paintColor;
+ break;
+ }
+ s.assertConsistency();
+
+ //apply image (vgDrawImage only)
+ //1. paint: convert paint to dst space
+ //2. image: convert image to dst space
+ //3. paint MULTIPLY image: convert paint to image number of channels, multiply with image, and convert to dst
+ //4. paint STENCIL image: convert paint to dst, convert image to dst number of channels, multiply
+
+ //color transform:
+ //paint => transform paint color
+ //image normal => transform image color
+ //image multiply => transform paint*image color
+ //image stencil => transform paint color
+
+ RIfloat ar = 0.0f, ag = 0.0f, ab = 0.0f;
+ if(m_image)
+ {
+ Color im = m_image->resample(x+0.5f, y+0.5f, m_surfaceToImageMatrix, m_imageQuality, VG_TILE_PAD, Color(0,0,0,0,m_image->getDescriptor().internalFormat));
+ im.assertConsistency();
+
+ switch(m_imageMode)
+ {
+ case VG_DRAW_IMAGE_NORMAL:
+ s = im;
+ colorTransform(s);
+ ar = s.a;
+ ag = s.a;
+ ab = s.a;
+ s.convert(dstFormat); //convert image color to destination color space
+ break;
+ case VG_DRAW_IMAGE_MULTIPLY:
+ //the result will be in image color space, except when paint is RGB and image is L the result will be RGB.
+ //paint == RGB && image == RGB: RGB*RGB
+ //paint == RGB && image == L : RGB*LLL
+ //paint == L && image == RGB: LLL*RGB
+ //paint == L && image == L : L*L
+ RI_ASSERT(m_surfaceToPaintMatrix.isAffine());
+ if(!s.isLuminance() && im.isLuminance())
+ im.convert((Color::InternalFormat)(im.getInternalFormat() & ~Color::LUMINANCE));
+ im.r *= s.r;
+ im.g *= s.g;
+ im.b *= s.b;
+ im.a *= s.a;
+ s = im; //use image color space
+ colorTransform(s);
+ ar = s.a;
+ ag = s.a;
+ ab = s.a;
+ s.convert(dstFormat); //convert resulting color to destination color space
+ break;
+ default:
+ //the result will be in paint color space.
+ //dst == RGB && image == RGB: RGB*RGB
+ //dst == RGB && image == L : RGB*LLL
+ //dst == L && image == RGB: L*(0.2126 R + 0.7152 G + 0.0722 B)
+ //dst == L && image == L : L*L
+ RI_ASSERT(m_imageMode == VG_DRAW_IMAGE_STENCIL);
+ if(dstFormat & Color::LUMINANCE && !im.isLuminance())
+ {
+ im.r = im.g = im.b = RI_MIN(0.2126f*im.r + 0.7152f*im.g + 0.0722f*im.b, im.a);
+ }
+ RI_ASSERT(m_surfaceToPaintMatrix.isAffine());
+ //s and im are both in premultiplied format. Each image channel acts as an alpha channel.
+ colorTransform(s);
+ s.convert(dstFormat); //convert paint color to destination space already here, since convert cannot deal with per channel alphas used in this mode.
+ //compute per channel alphas
+ ar = s.a * im.r;
+ ag = s.a * im.g;
+ ab = s.a * im.b;
+ //premultiply each channel by per channel alphas from the image
+ s.r *= im.r;
+ s.g *= im.g;
+ s.b *= im.b;
+ s.a *= im.a;
+ //in nonpremultiplied form the result is
+ // s.rgb = paint.a * paint.rgb * image.a * image.rgb
+ // s.a = paint.a * image.a
+ // argb = paint.a * image.a * image.rgb
+ break;
+ }
+ }
+ else
+ { //paint only
+ colorTransform(s);
+ ar = s.a;
+ ag = s.a;
+ ab = s.a;
+ s.convert(dstFormat); //convert paint color to destination color space
+ }
+ RI_ASSERT(s.getInternalFormat() == Color::lRGBA_PRE || s.getInternalFormat() == Color::sRGBA_PRE || s.getInternalFormat() == Color::lLA_PRE || s.getInternalFormat() == Color::sLA_PRE);
+ s.assertConsistency();
+
+ Surface* colorBuffer = m_drawable->getColorBuffer();
+ Surface* maskBuffer = m_drawable->getMaskBuffer();
+ RI_ASSERT(colorBuffer);
+
+ if(m_drawable->getNumSamples() == 1)
+ { //coverage-based antialiasing
+ RIfloat cov = coverage;
+ if(m_masking && maskBuffer)
+ {
+ cov *= maskBuffer->readMaskCoverage(x, y);
+ if(cov == 0.0f)
+ return;
+ }
+
+ //read destination color
+ Color d = colorBuffer->readSample(x, y, 0);
+ d.premultiply();
+ RI_ASSERT(dstFormat == Color::lRGBA_PRE || dstFormat == Color::sRGBA_PRE || dstFormat == Color::lLA_PRE || dstFormat == Color::sLA_PRE);
+
+ //blend
+ Color r = blend(s, ar, ag, ab, d, m_blendMode);
+
+ //apply antialiasing in linear color space
+ Color::InternalFormat aaFormat = (dstFormat & Color::LUMINANCE) ? Color::lLA_PRE : Color::lRGBA_PRE;
+ r.convert(aaFormat);
+ d.convert(aaFormat);
+ r = r * cov + d * (1.0f - cov);
+
+ //write result to the destination surface
+ r.convert(colorBuffer->getDescriptor().internalFormat);
+ colorBuffer->writeSample(x, y, 0, r);
+ }
+ else
+ { //multisampling FSAA
+ if(m_masking && maskBuffer)
+ {
+ sampleMask &= maskBuffer->readMaskMSAA(x, y);
+ if(!sampleMask)
+ return;
+ }
+
+ {
+ for(int i=0;i<m_drawable->getNumSamples();i++)
+ {
+ if(sampleMask & (1<<i)) //1-bit coverage
+ {
+ //read destination color
+ Color d = colorBuffer->readSample(x, y, i);
+
+ d.premultiply();
+ RI_ASSERT(dstFormat == Color::lRGBA_PRE || dstFormat == Color::sRGBA_PRE || dstFormat == Color::lLA_PRE || dstFormat == Color::sLA_PRE);
+
+ //blend
+ Color r = blend(s, ar, ag, ab, d, m_blendMode);
+
+ //write result to the destination surface
+ r.convert(colorBuffer->getDescriptor().internalFormat);
+ colorBuffer->writeSample(x, y, i, r);
+ }
+ }
+ }
+ }
+}
+
+//=======================================================================
+
+} //namespace tgOpenVG
diff --git a/src/vg/PixelPipe.h b/src/vg/PixelPipe.h
new file mode 100644
index 0000000..2a2278c
--- /dev/null
+++ b/src/vg/PixelPipe.h
@@ -0,0 +1,150 @@
+#ifndef __PIXELPIPE_H
+#define __PIXELPIPE_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Paint and PixelPipe classes.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Math.h"
+#include "Image.h"
+
+//=======================================================================
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief Storage and operations for VGPaint.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class Paint
+{
+public:
+ Paint();
+ ~Paint();
+ void addReference() { m_referenceCount++; }
+ int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+ struct GradientStop
+ {
+ GradientStop() : offset(0.0f), color(0.0f, 0.0f, 0.0f, 0.0f, Color::sRGBA) {}
+ RIfloat offset;
+ Color color;
+ };
+
+ VGPaintType m_paintType;
+ Color m_paintColor;
+ Color m_inputPaintColor;
+ VGColorRampSpreadMode m_colorRampSpreadMode;
+ Array<GradientStop> m_colorRampStops;
+ Array<GradientStop> m_inputColorRampStops;
+ VGboolean m_colorRampPremultiplied;
+ Vector2 m_inputLinearGradientPoint0;
+ Vector2 m_inputLinearGradientPoint1;
+ Vector2 m_inputRadialGradientCenter;
+ Vector2 m_inputRadialGradientFocalPoint;
+ RIfloat m_inputRadialGradientRadius;
+ Vector2 m_linearGradientPoint0;
+ Vector2 m_linearGradientPoint1;
+ Vector2 m_radialGradientCenter;
+ Vector2 m_radialGradientFocalPoint;
+ RIfloat m_radialGradientRadius;
+ VGTilingMode m_patternTilingMode;
+ Image* m_pattern;
+private:
+ Paint(const Paint&); //!< Not allowed.
+ const Paint& operator=(const Paint&); //!< Not allowed.
+
+ int m_referenceCount;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief Encapsulates all information needed for painting a pixel.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class PixelPipe
+{
+public:
+ PixelPipe(); //throws bad_alloc
+ ~PixelPipe();
+
+ void pixelPipe(int x, int y, RIfloat coverage, unsigned int sampleMask) const; //rasterizer calls this function for each pixel
+
+ void setDrawable(Drawable* drawable);
+ void setBlendMode(VGBlendMode blendMode);
+ void setMask(bool masking);
+ void setImage(Image* image, VGImageMode imageMode); //image = NULL disables drawImage functionality
+ void setSurfaceToPaintMatrix(const Matrix3x3& surfaceToPaintMatrix);
+ void setSurfaceToImageMatrix(const Matrix3x3& surfaceToImageMatrix);
+ void setImageQuality(VGImageQuality imageQuality);
+ void setTileFillColor(const Color& c);
+ void setPaint(const Paint* paint);
+ void setColorTransform(bool enable, RIfloat values[8]);
+
+private:
+ void linearGradient(RIfloat& g, RIfloat& rho, RIfloat x, RIfloat y) const;
+ void radialGradient(RIfloat& g, RIfloat& rho, RIfloat x, RIfloat y) const;
+ Color integrateColorRamp(RIfloat gmin, RIfloat gmax) const;
+ Color colorRamp(RIfloat gradient, RIfloat rho) const;
+ Color blend(const Color& s, RIfloat ar, RIfloat ag, RIfloat ab, const Color& d, VGBlendMode blendMode) const;
+ void colorTransform(Color& c) const;
+
+ PixelPipe(const PixelPipe&); //!< Not allowed.
+ const PixelPipe& operator=(const PixelPipe&); //!< Not allowed.
+
+ Drawable* m_drawable;
+ bool m_masking;
+ Image* m_image;
+ const Paint* m_paint;
+ Paint m_defaultPaint;
+ VGBlendMode m_blendMode;
+ VGImageMode m_imageMode;
+ VGImageQuality m_imageQuality;
+ Color m_tileFillColor;
+ bool m_colorTransform;
+ RIfloat m_colorTransformValues[8];
+ Matrix3x3 m_surfaceToPaintMatrix;
+ Matrix3x3 m_surfaceToImageMatrix;
+};
+
+//=======================================================================
+
+} //namespace OpenVGRI
+
+//=======================================================================
+
+#endif /* __PIXELPIPE_H */
diff --git a/src/vg/Rasterizer.cpp b/src/vg/Rasterizer.cpp
new file mode 100644
index 0000000..1c30504
--- /dev/null
+++ b/src/vg/Rasterizer.cpp
@@ -0,0 +1,499 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Implementation of polygon rasterizer.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Rasterizer.h"
+
+//==============================================================================================
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief Rasterizer constructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Rasterizer::Rasterizer() :
+ m_edges(),
+ m_scissorEdges(),
+ m_scissor(false),
+ m_samples(),
+ m_numSamples(0),
+ m_numFSAASamples(0),
+ m_sumWeights(0.0f),
+ m_sampleRadius(0.0f),
+ m_vpx(0),
+ m_vpy(0),
+ m_vpwidth(0),
+ m_vpheight(0),
+ m_fillRule(VG_EVEN_ODD),
+ m_pixelPipe(NULL),
+ m_covBuffer(NULL)
+{}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Rasterizer destructor.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+Rasterizer::~Rasterizer()
+{
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Removes all appended edges.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::clear()
+{
+ m_edges.clear();
+ m_edgeMin.set(RI_FLOAT_MAX, RI_FLOAT_MAX);
+ m_edgeMax.set(-RI_FLOAT_MAX, -RI_FLOAT_MAX);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Appends an edge to the rasterizer.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::addBBox(const Vector2& v)
+{
+ if(v.x < m_edgeMin.x) m_edgeMin.x = v.x;
+ if(v.y < m_edgeMin.y) m_edgeMin.y = v.y;
+ if(v.x > m_edgeMax.x) m_edgeMax.x = v.x;
+ if(v.y > m_edgeMax.y) m_edgeMax.y = v.y;
+}
+
+void Rasterizer::addEdge(const Vector2& v0, const Vector2& v1)
+{
+ if( m_edges.size() >= RI_MAX_EDGES )
+ throw std::bad_alloc(); //throw an out of memory error if there are too many edges
+
+ if(v0.y == v1.y)
+ return; //skip horizontal edges (they don't affect rasterization since we scan horizontally)
+
+ Edge e;
+ if(v0.y < v1.y)
+ { //edge is going upward
+ e.v0 = v0;
+ e.v1 = v1;
+ e.direction = 1;
+ }
+ else
+ { //edge is going downward
+ e.v0 = v1;
+ e.v1 = v0;
+ e.direction = -1;
+ }
+
+ addBBox(v0);
+ addBBox(v1);
+
+ m_edges.push_back(e); //throws bad_alloc
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Set up rasterizer
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::setup(int vpx, int vpy, int vpwidth, int vpheight, VGFillRule fillRule, const PixelPipe* pixelPipe, unsigned int* covBuffer)
+{
+ RI_ASSERT(vpwidth >= 0 && vpheight >= 0);
+ RI_ASSERT(vpx + vpwidth >= vpx && vpy + vpheight >= vpy);
+ RI_ASSERT(fillRule == VG_EVEN_ODD || fillRule == VG_NON_ZERO);
+ RI_ASSERT(pixelPipe || covBuffer);
+ m_vpx = vpx;
+ m_vpy = vpy;
+ m_vpwidth = vpwidth;
+ m_vpheight = vpheight;
+ m_fillRule = fillRule;
+ m_pixelPipe = pixelPipe;
+ m_covBuffer = covBuffer;
+ m_covMinx = vpx+vpwidth;
+ m_covMiny = vpy+vpheight;
+ m_covMaxx = vpx;
+ m_covMaxy = vpy;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Sets scissor rectangles.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::setScissor(const Array<Rectangle>& scissors)
+{
+ m_scissor = true;
+ try
+ {
+ m_scissorEdges.clear();
+ for(int i=0;i<scissors.size();i++)
+ {
+ if(scissors[i].width > 0 && scissors[i].height > 0)
+ {
+ ScissorEdge e;
+ e.miny = scissors[i].y;
+ e.maxy = RI_INT_ADDSATURATE(scissors[i].y, scissors[i].height);
+
+ e.x = scissors[i].x;
+ e.direction = 1;
+ m_scissorEdges.push_back(e); //throws bad_alloc
+ e.x = RI_INT_ADDSATURATE(scissors[i].x, scissors[i].width);
+ e.direction = -1;
+ m_scissorEdges.push_back(e); //throws bad_alloc
+ }
+ }
+ }
+ catch(std::bad_alloc)
+ {
+ m_scissorEdges.clear();
+ throw;
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Returns a radical inverse of a given integer for Hammersley
+* point set.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static double radicalInverseBase2(unsigned int i)
+{
+ if( i == 0 )
+ return 0.0;
+ double p = 0.0;
+ double f = 0.5;
+ double ff = f;
+ for(unsigned int j=0;j<32;j++)
+ {
+ if( i & (1<<j) )
+ p += f;
+ f *= ff;
+ }
+ return p;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Calls PixelPipe::pixelPipe for each pixel with coverage greater
+* than zero.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+int Rasterizer::setupSamplingPattern(VGRenderingQuality renderingQuality, int numFSAASamples)
+{
+ RI_ASSERT(renderingQuality == VG_RENDERING_QUALITY_NONANTIALIASED ||
+ renderingQuality == VG_RENDERING_QUALITY_FASTER ||
+ renderingQuality == VG_RENDERING_QUALITY_BETTER);
+ RI_ASSERT(numFSAASamples > 0 && numFSAASamples <= RI_MAX_SAMPLES);
+
+ //make a sampling pattern
+ m_sumWeights = 0.0f;
+ m_sampleRadius = 0.0f; //max offset of the sampling points from a pixel center
+ m_numFSAASamples = numFSAASamples;
+ if(numFSAASamples == 1)
+ {
+ if(renderingQuality == VG_RENDERING_QUALITY_NONANTIALIASED)
+ {
+ m_numSamples = 1;
+ m_samples[0].x = 0.0f;
+ m_samples[0].y = 0.0f;
+ m_samples[0].weight = 1.0f;
+ m_sampleRadius = 0.0f;
+ m_sumWeights = 1.0f;
+ }
+ else if(renderingQuality == VG_RENDERING_QUALITY_FASTER)
+ { //box filter of diameter 1.0f, 8-queen sampling pattern
+ m_numSamples = 8;
+ m_samples[0].x = 3;
+ m_samples[1].x = 7;
+ m_samples[2].x = 0;
+ m_samples[3].x = 2;
+ m_samples[4].x = 5;
+ m_samples[5].x = 1;
+ m_samples[6].x = 6;
+ m_samples[7].x = 4;
+ for(int i=0;i<m_numSamples;i++)
+ {
+ m_samples[i].x = (m_samples[i].x + 0.5f) / (RScalar)m_numSamples - 0.5f;
+ m_samples[i].y = ((RScalar)i + 0.5f) / (RScalar)m_numSamples - 0.5f;
+ m_samples[i].weight = 1.0f / (RScalar)m_numSamples;
+ m_sumWeights += m_samples[i].weight;
+ }
+ m_sampleRadius = 0.5f;
+ }
+ else
+ {
+ RI_ASSERT(renderingQuality == VG_RENDERING_QUALITY_BETTER);
+ m_numSamples = RI_MAX_SAMPLES;
+ m_sampleRadius = 0.75f;
+ for(int i=0;i<m_numSamples;i++)
+ { //Gaussian filter, implemented using Hammersley point set for sample point locations
+ RScalar x = (RScalar)radicalInverseBase2(i);
+ RScalar y = ((RScalar)i + 0.5f) / (RScalar)m_numSamples;
+ RI_ASSERT(x >= 0.0f && x < 1.0f);
+ RI_ASSERT(y >= 0.0f && y < 1.0f);
+
+ //map unit square to unit circle
+ RScalar r = (RScalar)sqrt(x) * m_sampleRadius;
+ x = r * (RScalar)sin(y*2.0f*PI);
+ y = r * (RScalar)cos(y*2.0f*PI);
+ m_samples[i].weight = (RScalar)exp(-0.5f * RI_SQR(r/m_sampleRadius));
+
+ RI_ASSERT(x >= -1.5f && x <= 1.5f && y >= -1.5f && y <= 1.5f); //the specification restricts the filter radius to be less than or equal to 1.5
+
+ m_samples[i].x = x;
+ m_samples[i].y = y;
+ m_sumWeights += m_samples[i].weight;
+ }
+ }
+ }
+ else
+ { //box filter
+ m_numSamples = numFSAASamples;
+ RI_ASSERT(numFSAASamples >= 1 && numFSAASamples <= 32); //sample mask is a 32-bit uint => can't support more than 32 samples
+ //use Hammersley point set as a sampling pattern
+ for(int i=0;i<m_numSamples;i++)
+ {
+ m_samples[i].x = (RScalar)radicalInverseBase2(i) + 1.0f / (RScalar)(m_numSamples<<1) - 0.5f;
+ m_samples[i].y = ((RScalar)i + 0.5f) / (RScalar)m_numSamples - 0.5f;
+ m_samples[i].weight = 1.0f;
+ RI_ASSERT(m_samples[i].x > -0.5f && m_samples[i].x < 0.5f);
+ RI_ASSERT(m_samples[i].y > -0.5f && m_samples[i].y < 0.5f);
+ }
+ m_sumWeights = (RScalar)m_numSamples;
+ m_sampleRadius = 0.5f;
+ }
+ return m_numSamples;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief Calls PixelPipe::pixelPipe for each pixel with coverage greater
+* than zero.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::fill()
+{
+ if(m_scissor && !m_scissorEdges.size())
+ return; //scissoring is on, but there are no scissor rectangles => nothing is visible
+
+ //proceed scanline by scanline
+ //keep track of edges that can intersect the pixel filters of the current scanline (Active Edge Table)
+ //until all pixels of the scanline have been processed
+ // for all sampling points of the current pixel
+ // determine the winding number using edge functions
+ // add filter weight to coverage
+ // divide coverage by the number of samples
+ // determine a run of pixels with constant coverage
+ // call fill callback for each pixel of the run
+
+ int fillRuleMask = 1;
+ if(m_fillRule == VG_NON_ZERO)
+ fillRuleMask = -1;
+
+ int bbminx = (int)floor(m_edgeMin.x);
+ int bbminy = (int)floor(m_edgeMin.y);
+ int bbmaxx = (int)floor(m_edgeMax.x)+1;
+ int bbmaxy = (int)floor(m_edgeMax.y)+1;
+ int sx = RI_INT_MAX(m_vpx, bbminx);
+ int ex = RI_INT_MIN(m_vpx+m_vpwidth, bbmaxx);
+ int sy = RI_INT_MAX(m_vpy, bbminy);
+ int ey = RI_INT_MIN(m_vpy+m_vpheight, bbmaxy);
+ if(sx < m_covMinx) m_covMinx = sx;
+ if(sy < m_covMiny) m_covMiny = sy;
+ if(ex > m_covMaxx) m_covMaxx = ex;
+ if(ey > m_covMaxy) m_covMaxy = ey;
+
+ //fill the screen
+ Array<ActiveEdge> aet;
+ Array<ScissorEdge> scissorAet;
+ for(int j=sy;j<ey;j++)
+ {
+ //gather scissor edges intersecting this scanline
+ scissorAet.clear();
+ if( m_scissor )
+ {
+ for(int e=0;e<m_scissorEdges.size();e++)
+ {
+ const ScissorEdge& se = m_scissorEdges[e];
+ if(j >= se.miny && j < se.maxy)
+ scissorAet.push_back(m_scissorEdges[e]); //throws bad_alloc
+ }
+ if(!scissorAet.size())
+ continue; //scissoring is on, but there are no scissor rectangles on this scanline
+ }
+
+ //simple AET: scan through all the edges and pick the ones intersecting this scanline
+ aet.clear();
+ for(int e=0;e<m_edges.size();e++)
+ {
+ RScalar cminy = (RScalar)j - m_sampleRadius + 0.5f;
+ RScalar cmaxy = (RScalar)j + m_sampleRadius + 0.5f;
+ const Edge& ed = m_edges[e];
+ RI_ASSERT(ed.v0.y <= ed.v1.y); //horizontal edges should have been dropped already
+
+ ActiveEdge ae;
+ ae.v0 = ed.v0;
+ ae.v1 = ed.v1;
+ ae.direction = ed.direction;
+
+ if(cmaxy >= ae.v0.y && cminy < ae.v1.y)
+ {
+ ae.n.set(ae.v0.y - ae.v1.y, ae.v1.x - ae.v0.x); //edge normal
+ ae.cnst = ae.v0.x * ae.n.x + ae.v0.y * ae.n.y; //distance of v0 from the origin along the edge normal
+
+ //compute edge min and max x-coordinates for this scanline
+ Vector2 vd(ae.v1.x - ae.v0.x, ae.v1.y - ae.v0.y);
+ RScalar wl = 1.0f / vd.y;
+ RScalar sx = ae.v0.x + vd.x * (cminy - ae.v0.y) * wl;
+ RScalar ex = ae.v0.x + vd.x * (cmaxy - ae.v0.y) * wl;
+ RScalar bminx = RI_MIN(ae.v0.x, ae.v1.x);
+ RScalar bmaxx = RI_MAX(ae.v0.x, ae.v1.x);
+ sx = RI_CLAMP(sx, bminx, bmaxx);
+ ex = RI_CLAMP(ex, bminx, bmaxx);
+ ae.minx = RI_MIN(sx,ex);
+ ae.maxx = RI_MAX(sx,ex);
+ aet.push_back(ae); //throws bad_alloc
+ }
+ }
+ if(!aet.size())
+ continue; //no edges on the whole scanline, skip it
+
+ //sort AET by edge minx
+ aet.sort();
+
+ //sort scissor AET by edge x
+ scissorAet.sort();
+
+ //fill the scanline
+ int scissorWinding = m_scissor ? 0 : 1; //if scissoring is off, winding is always 1
+ int scissorIndex = 0;
+ int aes = 0;
+ int aen = 0;
+ for(int i=sx;i<ex;)
+ {
+ Vector2 pc(i + 0.5f, j + 0.5f); //pixel center
+
+ //find edges that intersect or are to the left of the pixel antialiasing filter
+ while(aes < aet.size() && pc.x + m_sampleRadius >= aet[aes].minx)
+ aes++;
+ //edges [0,aes[ may have an effect on winding, and need to be evaluated while sampling
+
+ //compute coverage
+ RScalar coverage = 0.0f;
+ unsigned int sampleMask = 0;
+ for(int s=0;s<m_numSamples;s++)
+ {
+ Vector2 sp = pc; //sampling point
+ sp.x += m_samples[s].x;
+ sp.y += m_samples[s].y;
+
+ //compute winding number by evaluating the edge functions of edges to the left of the sampling point
+ int winding = 0;
+ for(int e=0;e<aes;e++)
+ {
+ if(sp.y >= aet[e].v0.y && sp.y < aet[e].v1.y)
+ { //evaluate edge function to determine on which side of the edge the sampling point lies
+ RScalar side = sp.x * aet[e].n.x + sp.y * aet[e].n.y - aet[e].cnst;
+ if(side <= 0.0f) //implicit tie breaking: a sampling point on an opening edge is in, on a closing edge it's out
+ {
+ winding += aet[e].direction;
+ }
+ }
+ }
+ if(winding & fillRuleMask)
+ {
+ coverage += m_samples[s].weight;
+ sampleMask |= (unsigned int)(1<<s);
+ }
+ }
+
+ //constant coverage optimization:
+ //scan AET from left to right and skip all the edges that are completely to the left of the pixel filter.
+ //since AET is sorted by minx, the edge we stop at is the leftmost of the edges we haven't passed yet.
+ //if that edge is to the right of this pixel, coverage is constant between this pixel and the start of the edge.
+ while(aen < aet.size() && aet[aen].maxx < pc.x - m_sampleRadius - 0.01f) //0.01 is a safety region to prevent too aggressive optimization due to numerical inaccuracy
+ aen++;
+
+ int endSpan = m_vpx + m_vpwidth; //endSpan is the first pixel NOT part of the span
+ if(aen < aet.size())
+ endSpan = RI_INT_MAX(i+1, RI_INT_MIN(endSpan, (int)ceil(aet[aen].minx - m_sampleRadius - 0.5f)));
+
+ coverage /= m_sumWeights;
+ RI_ASSERT(coverage >= 0.0f && coverage <= 1.0f);
+
+ //fill a run of pixels with constant coverage
+ if(sampleMask)
+ {
+ for(;i<endSpan;i++)
+ {
+ //update scissor winding number
+ while(scissorIndex < scissorAet.size() && scissorAet[scissorIndex].x <= i)
+ scissorWinding += scissorAet[scissorIndex++].direction;
+ RI_ASSERT(scissorWinding >= 0);
+
+ if(scissorWinding)
+ {
+ if(m_covBuffer)
+ m_covBuffer[j*m_vpwidth+i] |= (RIuint32)sampleMask;
+ else
+ m_pixelPipe->pixelPipe(i, j, coverage, sampleMask);
+ }
+ }
+ }
+ i = endSpan;
+ }
+ }
+}
+
+//=======================================================================
+
+} //namespace tgOpenVG
diff --git a/src/vg/Rasterizer.h b/src/vg/Rasterizer.h
new file mode 100644
index 0000000..f1539a7
--- /dev/null
+++ b/src/vg/Rasterizer.h
@@ -0,0 +1,165 @@
+#ifndef __RASTERIZER_H
+#define __RASTERIZER_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Rasterizer class.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include "Math.h"
+#include "Array.h"
+#include "PixelPipe.h"
+
+//=======================================================================
+
+namespace tgOpenVG
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief Scalar and vector data types used by the rasterizer.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+typedef RIfloat RScalar; //change this if you want to have different precision for rasterizer scalars and RIfloat
+
+struct RVector2
+{
+ inline RVector2() { }
+ inline RVector2(const Vector2& v) { x = v.x; y = v.y; }
+ inline RVector2(RIfloat vx, RIfloat vy) { x = vx; y = vy; }
+ inline void set(RIfloat vx, RIfloat vy) { x = vx; y = vy; }
+ RScalar x;
+ RScalar y;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief Converts a set of edges to coverage values for each pixel and
+* calls PixelPipe::pixelPipe for painting a pixel.
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+class Rasterizer
+{
+public:
+ Rasterizer(); //throws bad_alloc
+ ~Rasterizer();
+
+ void setup(int vpx, int vpy, int vpwidth, int vpheight, VGFillRule fillRule, const PixelPipe* pixelPipe, RIuint32* covBuffer);
+ void setScissor(const Array<Rectangle>& scissors); //throws bad_alloc
+
+ void clear();
+ void addEdge(const Vector2& v0, const Vector2& v1); //throws bad_alloc
+
+ int setupSamplingPattern(VGRenderingQuality renderingQuality, int numFSAASamples);
+ void fill(); //throws bad_alloc
+
+ void getBBox(int& sx, int& sy, int& ex, int& ey) const { sx = m_covMinx; sy = m_covMiny; ex = m_covMaxx; ey = m_covMaxy; }
+private:
+ Rasterizer(const Rasterizer&); //!< Not allowed.
+ const Rasterizer& operator=(const Rasterizer&); //!< Not allowed.
+
+ struct ScissorEdge
+ {
+ ScissorEdge() : x(0), miny(0), maxy(0), direction(0) {}
+ bool operator<(const ScissorEdge& e) const { return x < e.x; }
+ int x;
+ int miny;
+ int maxy;
+ int direction; //1 start, -1 end
+ };
+
+ struct Edge
+ {
+ Edge() : v0(), v1(), direction(1) {}
+ bool operator<(const Edge& e) const { return v0.y < e.v0.y; }
+ RVector2 v0;
+ RVector2 v1;
+ int direction;
+ };
+
+ struct ActiveEdge
+ {
+ ActiveEdge() : v0(), v1(), direction(0), minx(0.0f), maxx(0.0f), n(), cnst(0.0f) {}
+ bool operator<(const ActiveEdge& e) const { return minx < e.minx; }
+ RVector2 v0;
+ RVector2 v1;
+ int direction; //-1 down, 1 up
+ RScalar minx; //for the current scanline
+ RScalar maxx; //for the current scanline
+ RVector2 n;
+ RScalar cnst;
+ };
+
+ struct Sample
+ {
+ Sample() : x(0.0f), y(0.0f), weight(0.0f) {}
+ RScalar x;
+ RScalar y;
+ RScalar weight;
+ };
+
+ void addBBox(const Vector2& v);
+
+ Array<Edge> m_edges;
+ Array<ScissorEdge> m_scissorEdges;
+ bool m_scissor;
+
+ Sample m_samples[RI_MAX_SAMPLES];
+ int m_numSamples;
+ int m_numFSAASamples;
+ RScalar m_sumWeights;
+ RScalar m_sampleRadius;
+
+ Vector2 m_edgeMin;
+ Vector2 m_edgeMax;
+ int m_covMinx;
+ int m_covMiny;
+ int m_covMaxx;
+ int m_covMaxy;
+ int m_vpx;
+ int m_vpy;
+ int m_vpwidth;
+ int m_vpheight;
+ VGFillRule m_fillRule;
+ const PixelPipe* m_pixelPipe;
+ RIuint32* m_covBuffer;
+};
+
+//=======================================================================
+
+} //namespace tgOpenVG
+
+//=======================================================================
+
+#endif /* __RASTERIZER_H */
diff --git a/src/vgu/VGU.cpp b/src/vgu/VGU.cpp
new file mode 100644
index 0000000..8e19ce4
--- /dev/null
+++ b/src/vgu/VGU.cpp
@@ -0,0 +1,469 @@
+/*------------------------------------------------------------------------
+ *
+ * VGU library for OpenVG 1.1 Reference Implementation
+ * ---------------------------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Implementation of the VGU utility library for OpenVG
+ *//*-------------------------------------------------------------------*/
+
+#include "VG/vgu.h"
+#include "VG/openvg.h"
+#include "../vg/Math.h"
+
+using namespace tgOpenVG;
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+static void append(VGPath path, int numSegments, const VGubyte* segments, int numCoordinates, const VGfloat* coordinates)
+{
+ RI_ASSERT(numCoordinates <= 26);
+
+ VGPathDatatype datatype = (VGPathDatatype)vgGetParameteri(path, VG_PATH_DATATYPE);
+ VGfloat scale = vgGetParameterf(path, VG_PATH_SCALE);
+ VGfloat bias = vgGetParameterf(path, VG_PATH_BIAS);
+
+ switch(datatype)
+ {
+ case VG_PATH_DATATYPE_S_8:
+ {
+ RIint8 data[26];
+ for(int i=0;i<numCoordinates;i++)
+ data[i] = (RIint8)floor((coordinates[i] - bias) / scale + 0.5f); //add 0.5 for correct rounding
+ vgAppendPathData(path, numSegments, segments, data);
+ break;
+ }
+
+ case VG_PATH_DATATYPE_S_16:
+ {
+ RIint16 data[26];
+ for(int i=0;i<numCoordinates;i++)
+ data[i] = (RIint16)floor((coordinates[i] - bias) / scale + 0.5f); //add 0.5 for correct rounding
+ vgAppendPathData(path, numSegments, segments, data);
+ break;
+ }
+
+ case VG_PATH_DATATYPE_S_32:
+ {
+ RIint32 data[26];
+ for(int i=0;i<numCoordinates;i++)
+ data[i] = (RIint32)floor((coordinates[i] - bias) / scale + 0.5f); //add 0.5 for correct rounding
+ vgAppendPathData(path, numSegments, segments, data);
+ break;
+ }
+
+ default:
+ {
+ RI_ASSERT(datatype == VG_PATH_DATATYPE_F);
+ RIfloat32 data[26];
+ for(int i=0;i<numCoordinates;i++)
+ data[i] = (RIfloat32)((coordinates[i] - bias) / scale);
+ vgAppendPathData(path, numSegments, segments, data);
+ break;
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGUErrorCode RI_APIENTRY vguLine(VGPath path, VGfloat x0, VGfloat y0, VGfloat x1, VGfloat y1)
+{
+ VGErrorCode error = vgGetError(); //clear the error state
+ static const VGubyte segments[2] = {VG_MOVE_TO | VG_ABSOLUTE, VG_LINE_TO | VG_ABSOLUTE};
+ const VGfloat data[4] = {x0, y0, x1, y1};
+ append(path, 2, segments, 4, data);
+
+ error = vgGetError();
+ if(error == VG_BAD_HANDLE_ERROR)
+ return VGU_BAD_HANDLE_ERROR;
+ else if(error == VG_PATH_CAPABILITY_ERROR)
+ return VGU_PATH_CAPABILITY_ERROR;
+ return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGUErrorCode RI_APIENTRY vguPolygon(VGPath path, const VGfloat * points, VGint count, VGboolean closed)
+{
+ VGErrorCode error = vgGetError(); //clear the error state
+ if(!points || (((RIuintptr)points) & 3) || count <= 0)
+ return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+ VGubyte segments[1] = {VG_MOVE_TO | VG_ABSOLUTE};
+ VGfloat data[2];
+ for(int i=0;i<count;i++)
+ {
+ data[0] = points[i*2+0];
+ data[1] = points[i*2+1];
+ append(path, 1, segments, 2, data);
+ segments[0] = VG_LINE_TO | VG_ABSOLUTE;
+ }
+ if(closed)
+ {
+ segments[0] = VG_CLOSE_PATH;
+ append(path, 1, segments, 0, data);
+ }
+
+ error = vgGetError();
+ if(error == VG_BAD_HANDLE_ERROR)
+ return VGU_BAD_HANDLE_ERROR;
+ else if(error == VG_PATH_CAPABILITY_ERROR)
+ return VGU_PATH_CAPABILITY_ERROR;
+ return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGUErrorCode RI_APIENTRY vguRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height)
+{
+ VGErrorCode error = vgGetError(); //clear the error state
+ if(width <= 0 || height <= 0)
+ return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+ static const VGubyte segments[5] = {VG_MOVE_TO | VG_ABSOLUTE,
+ VG_HLINE_TO | VG_ABSOLUTE,
+ VG_VLINE_TO | VG_ABSOLUTE,
+ VG_HLINE_TO | VG_ABSOLUTE,
+ VG_CLOSE_PATH};
+ const VGfloat data[5] = {x, y, x + width, y + height, x};
+ append(path, 5, segments, 5, data);
+
+ error = vgGetError();
+ if(error == VG_BAD_HANDLE_ERROR)
+ return VGU_BAD_HANDLE_ERROR;
+ else if(error == VG_PATH_CAPABILITY_ERROR)
+ return VGU_PATH_CAPABILITY_ERROR;
+ return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGUErrorCode RI_APIENTRY vguRoundRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat arcWidth, VGfloat arcHeight)
+{
+ VGErrorCode error = vgGetError(); //clear the error state
+ if(width <= 0 || height <= 0)
+ return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+ arcWidth = RI_CLAMP(arcWidth, 0.0f, width);
+ arcHeight = RI_CLAMP(arcHeight, 0.0f, height);
+
+ static const VGubyte segments[10] = {VG_MOVE_TO | VG_ABSOLUTE,
+ VG_HLINE_TO | VG_ABSOLUTE,
+ VG_SCCWARC_TO | VG_ABSOLUTE,
+ VG_VLINE_TO | VG_ABSOLUTE,
+ VG_SCCWARC_TO | VG_ABSOLUTE,
+ VG_HLINE_TO | VG_ABSOLUTE,
+ VG_SCCWARC_TO | VG_ABSOLUTE,
+ VG_VLINE_TO | VG_ABSOLUTE,
+ VG_SCCWARC_TO | VG_ABSOLUTE,
+ VG_CLOSE_PATH};
+ const VGfloat data[26] = {x + arcWidth/2, y,
+ x + width - arcWidth/2,
+ arcWidth/2, arcHeight/2, 0, x + width, y + arcHeight/2,
+ y + height - arcHeight/2,
+ arcWidth/2, arcHeight/2, 0, x + width - arcWidth/2, y + height,
+ x + arcWidth/2,
+ arcWidth/2, arcHeight/2, 0, x, y + height - arcHeight/2,
+ y + arcHeight/2,
+ arcWidth/2, arcHeight/2, 0, x + arcWidth/2, y};
+ append(path, 10, segments, 26, data);
+
+ error = vgGetError();
+ if(error == VG_BAD_HANDLE_ERROR)
+ return VGU_BAD_HANDLE_ERROR;
+ else if(error == VG_PATH_CAPABILITY_ERROR)
+ return VGU_PATH_CAPABILITY_ERROR;
+ return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGUErrorCode RI_APIENTRY vguEllipse(VGPath path, VGfloat cx, VGfloat cy, VGfloat width, VGfloat height)
+{
+ VGErrorCode error = vgGetError(); //clear the error state
+ if(width <= 0 || height <= 0)
+ return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+ static const VGubyte segments[4] = {VG_MOVE_TO | VG_ABSOLUTE,
+ VG_SCCWARC_TO | VG_ABSOLUTE,
+ VG_SCCWARC_TO | VG_ABSOLUTE,
+ VG_CLOSE_PATH};
+ const VGfloat data[12] = {cx + width/2, cy,
+ width/2, height/2, 0, cx - width/2, cy,
+ width/2, height/2, 0, cx + width/2, cy};
+ append(path, 4, segments, 12, data);
+
+ error = vgGetError();
+ if(error == VG_BAD_HANDLE_ERROR)
+ return VGU_BAD_HANDLE_ERROR;
+ else if(error == VG_PATH_CAPABILITY_ERROR)
+ return VGU_PATH_CAPABILITY_ERROR;
+ return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGUErrorCode RI_APIENTRY vguArc(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat startAngle, VGfloat angleExtent, VGUArcType arcType)
+{
+ VGErrorCode error = vgGetError(); //clear the error state
+ if((arcType != VGU_ARC_OPEN && arcType != VGU_ARC_CHORD && arcType != VGU_ARC_PIE) || width <= 0.0f || height <= 0.0f)
+ return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+ startAngle = RI_DEG_TO_RAD(startAngle);
+ angleExtent = RI_DEG_TO_RAD(angleExtent);
+
+ VGfloat w = width/2.0f;
+ VGfloat h = height/2.0f;
+
+ VGubyte segments[1];
+ VGfloat data[5];
+
+ segments[0] = VG_MOVE_TO | VG_ABSOLUTE;
+ data[0] = x + w * (VGfloat)cos(startAngle);
+ data[1] = y + h * (VGfloat)sin(startAngle);
+ append(path, 1, segments, 2, data);
+
+ data[0] = w;
+ data[1] = h;
+ data[2] = 0.0f;
+ VGfloat endAngle = startAngle + angleExtent;
+ if(angleExtent >= 0.0f)
+ {
+ segments[0] = VG_SCCWARC_TO | VG_ABSOLUTE;
+ for(VGfloat a = startAngle + PI;a < endAngle; a += PI)
+ {
+ data[3] = x + w * (VGfloat)cos(a);
+ data[4] = y + h * (VGfloat)sin(a);
+ append(path, 1, segments, 5, data);
+ }
+ }
+ else
+ {
+ segments[0] = VG_SCWARC_TO | VG_ABSOLUTE;
+ for(VGfloat a = startAngle - PI;a > endAngle; a -= PI)
+ {
+ data[3] = x + w * (VGfloat)cos(a);
+ data[4] = y + h * (VGfloat)sin(a);
+ append(path, 1, segments, 5, data);
+ }
+ }
+ data[3] = x + w * (VGfloat)cos(endAngle);
+ data[4] = y + h * (VGfloat)sin(endAngle);
+ append(path, 1, segments, 5, data);
+
+ if(arcType == VGU_ARC_CHORD)
+ {
+ segments[0] = VG_CLOSE_PATH;
+ append(path, 1, segments, 0, data);
+ }
+ else if(arcType == VGU_ARC_PIE)
+ {
+ segments[0] = VG_LINE_TO | VG_ABSOLUTE;
+ data[0] = x;
+ data[1] = y;
+ append(path, 1, segments, 2, data);
+ segments[0] = VG_CLOSE_PATH;
+ append(path, 1, segments, 0, data);
+ }
+
+ error = vgGetError();
+ if(error == VG_BAD_HANDLE_ERROR)
+ return VGU_BAD_HANDLE_ERROR;
+ else if(error == VG_PATH_CAPABILITY_ERROR)
+ return VGU_PATH_CAPABILITY_ERROR;
+ return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGUErrorCode RI_APIENTRY vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix)
+{
+ if(!matrix || ((RIuintptr)matrix) & 3)
+ return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+ VGfloat mat[9];
+ VGUErrorCode ret = vguComputeWarpSquareToQuad(sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, mat);
+ if(ret == VGU_BAD_WARP_ERROR)
+ return VGU_BAD_WARP_ERROR;
+ Matrix3x3 m(mat[0], mat[3], mat[6],
+ mat[1], mat[4], mat[7],
+ mat[2], mat[5], mat[8]);
+ bool nonsingular = m.invert();
+ if(!nonsingular)
+ return VGU_BAD_WARP_ERROR;
+ matrix[0] = m[0][0];
+ matrix[1] = m[1][0];
+ matrix[2] = m[2][0];
+ matrix[3] = m[0][1];
+ matrix[4] = m[1][1];
+ matrix[5] = m[2][1];
+ matrix[6] = m[0][2];
+ matrix[7] = m[1][2];
+ matrix[8] = m[2][2];
+ return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGUErrorCode RI_APIENTRY vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat * matrix)
+{
+ if(!matrix || ((RIuintptr)matrix) & 3)
+ return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+ //from Heckbert:Fundamentals of Texture Mapping and Image Warping
+ //Note that his mapping of vertices is different from OpenVG's
+ //(0,0) => (dx0,dy0)
+ //(1,0) => (dx1,dy1)
+ //(0,1) => (dx2,dy2)
+ //(1,1) => (dx3,dy3)
+
+ VGfloat diffx1 = dx1 - dx3;
+ VGfloat diffy1 = dy1 - dy3;
+ VGfloat diffx2 = dx2 - dx3;
+ VGfloat diffy2 = dy2 - dy3;
+
+ VGfloat det = diffx1*diffy2 - diffx2*diffy1;
+ if(det == 0.0f)
+ return VGU_BAD_WARP_ERROR;
+
+ VGfloat sumx = dx0 - dx1 + dx3 - dx2;
+ VGfloat sumy = dy0 - dy1 + dy3 - dy2;
+
+ if(sumx == 0.0f && sumy == 0.0f)
+ { //affine mapping
+ matrix[0] = dx1 - dx0;
+ matrix[1] = dy1 - dy0;
+ matrix[2] = 0.0f;
+ matrix[3] = dx3 - dx1;
+ matrix[4] = dy3 - dy1;
+ matrix[5] = 0.0f;
+ matrix[6] = dx0;
+ matrix[7] = dy0;
+ matrix[8] = 1.0f;
+ return VGU_NO_ERROR;
+ }
+
+ VGfloat oodet = 1.0f / det;
+ VGfloat g = (sumx*diffy2 - diffx2*sumy) * oodet;
+ VGfloat h = (diffx1*sumy - sumx*diffy1) * oodet;
+
+ matrix[0] = dx1-dx0+g*dx1;
+ matrix[1] = dy1-dy0+g*dy1;
+ matrix[2] = g;
+ matrix[3] = dx2-dx0+h*dx2;
+ matrix[4] = dy2-dy0+h*dy2;
+ matrix[5] = h;
+ matrix[6] = dx0;
+ matrix[7] = dy0;
+ matrix[8] = 1.0f;
+ return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief
+* \param
+* \return
+* \note
+*//*-------------------------------------------------------------------*/
+
+VGUErrorCode RI_APIENTRY vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix)
+{
+ if(!matrix || ((RIuintptr)matrix) & 3)
+ return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+ VGfloat qtos[9];
+ VGUErrorCode ret1 = vguComputeWarpQuadToSquare(sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, qtos);
+ if(ret1 == VGU_BAD_WARP_ERROR)
+ return VGU_BAD_WARP_ERROR;
+
+ VGfloat stoq[9];
+ VGUErrorCode ret2 = vguComputeWarpSquareToQuad(dx0, dy0, dx1, dy1, dx2, dy2, dx3, dy3, stoq);
+ if(ret2 == VGU_BAD_WARP_ERROR)
+ return VGU_BAD_WARP_ERROR;
+
+ Matrix3x3 m1(qtos[0], qtos[3], qtos[6],
+ qtos[1], qtos[4], qtos[7],
+ qtos[2], qtos[5], qtos[8]);
+ Matrix3x3 m2(stoq[0], stoq[3], stoq[6],
+ stoq[1], stoq[4], stoq[7],
+ stoq[2], stoq[5], stoq[8]);
+ Matrix3x3 r = m2 * m1;
+
+ matrix[0] = r[0][0];
+ matrix[1] = r[1][0];
+ matrix[2] = r[2][0];
+ matrix[3] = r[0][1];
+ matrix[4] = r[1][1];
+ matrix[5] = r[2][1];
+ matrix[6] = r[0][2];
+ matrix[7] = r[1][2];
+ matrix[8] = r[2][2];
+ return VGU_NO_ERROR;
+}
diff --git a/tests/Simple_Texture2D/CMakeLists.txt b/tests/Simple_Texture2D/CMakeLists.txt
new file mode 100644
index 0000000..c8b7468
--- /dev/null
+++ b/tests/Simple_Texture2D/CMakeLists.txt
@@ -0,0 +1,39 @@
+cmake_minimum_required(VERSION 2.8)
+
+project (SimpleTexture)
+
+set(EXECUTABLE_NAME ${PROJECT_NAME})
+
+# Linux on ARM
+#if(MALI_BUILD)
+#set(DUMMY_MALI_LIBRARIES MiniEGL EGL GLESv2 X11 pthread m gles2-bc OpenVG OpenVGU )
+#set(DUMMY_MALI_LIBRARIES GLESv2 MiniEGL gles2-bc EGL mali OpenVG OpenVGU X11 pthread m )
+#else()
+# set(DUMMY_MALI_LIBRARIES MiniEGL OpenVG OpenVGU)
+#endif()
+#set(DUMMY_MALI_LIBRARIES EGL )
+set(DEFAULT_LIB_PATH "/usr/local/lib")
+#set(MALI_LIB_PATH "/opt/mali_r4p0_02rel0/fbdev/")
+#set(MALI_LIB_PATH "/usr/lib/mali")
+
+
+set(DUMMY_MALI_LIBRARIES EGL GLESv2 X11 pthread m OpenVG )
+
+INCLUDE_DIRECTORIES("/usr/local/include")
+INCLUDE_DIRECTORIES("../../include")
+
+set(CMAKE_C_FLAGS "-g -mcpu=cortex-a15 -mfpu=neon-vfpv4 -ftree-vectorize -funsafe-math-optimizations" CACHE STRING "" FORCE)
+
+#add_subdirectory(arm)
+LINK_DIRECTORIES(${DEFAULT_LIB_PATH})
+LINK_DIRECTORIES(${MALI_LIB_PATH})
+
+set(ALL_LIBRARIES ${DUMMY_MALI_LIBRARIES})
+
+
+set(SimpleTexture_TESTS_SOURCE
+ main.c
+ )
+
+add_executable(${EXECUTABLE_NAME} ${SimpleTexture_TESTS_SOURCE})
+target_link_libraries(${EXECUTABLE_NAME} ${ALL_LIBRARIES})
diff --git a/tests/Simple_Texture2D/main.c b/tests/Simple_Texture2D/main.c
new file mode 100644
index 0000000..498bb9e
--- /dev/null
+++ b/tests/Simple_Texture2D/main.c
@@ -0,0 +1,216 @@
+//
+// Book: OpenGL(R) ES 2.0 Programming Guide
+// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
+// ISBN-10: 0321502795
+// ISBN-13: 9780321502797
+// Publisher: Addison-Wesley Professional
+// URLs: http://safari.informit.com/9780321563835
+// http://www.opengles-book.com
+//
+
+// Simple_Texture2D.c
+//
+// This is a simple example that draws a quad with a 2D
+// texture image. The purpose of this example is to demonstrate
+// the basics of 2D texturing
+//
+#include <stdlib.h>
+#include "esUtil.h"
+
+GLubyte blue=0;
+
+typedef struct
+{
+ // Handle to a program object
+ GLuint programObject;
+
+ // Attribute locations
+ GLint positionLoc;
+ GLint texCoordLoc;
+
+ // Sampler location
+ GLint samplerLoc;
+
+ // Texture handle
+ GLuint textureId;
+
+ float time;
+} UserData;
+
+///
+// Create a simple 2x2 texture image with four different colors
+//
+GLuint CreateSimpleTexture2D( )
+{
+ // Texture object handle
+ GLuint textureId;
+
+ // 2x2 Image, 3 bytes per pixel (R, G, B)
+ GLubyte pixels[4 * 3] =
+ {
+ 255, 0, 0, // Red
+ 0, 255, 0, // Green
+ 0, 0, 255, // Blue
+ 255, 255, 0 // Yellow
+ };
+
+ pixels[2] = blue;
+ if (blue == 255)
+ blue =0;
+ blue++;
+
+ // Use tightly packed data
+ glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
+
+ // Generate a texture object
+ glGenTextures ( 1, &textureId );
+
+ // Bind the texture object
+ glBindTexture ( GL_TEXTURE_2D, textureId );
+
+ // Load the texture
+ glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
+
+ // Set the filtering mode
+ glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+
+ return textureId;
+
+}
+
+
+///
+// Initialize the shader and program object
+//
+int Init ( ESContext *esContext )
+{
+ esContext->userData = malloc(sizeof(UserData));
+ UserData *userData = esContext->userData;
+ GLbyte vShaderStr[] =
+ "attribute vec4 a_position; \n"
+ "attribute vec2 a_texCoord; \n"
+ "varying vec2 v_texCoord; \n"
+ "void main() \n"
+ "{ \n"
+ " gl_Position = a_position; \n"
+ " v_texCoord = a_texCoord; \n"
+ "} \n";
+
+ GLbyte fShaderStr[] =
+ "precision mediump float; \n"
+ "varying vec2 v_texCoord; \n"
+ "uniform sampler2D s_texture; \n"
+ "void main() \n"
+ "{ \n"
+ " gl_FragColor = texture2D( s_texture, v_texCoord );\n"
+ "} \n";
+
+ // Load the shaders and get a linked program object
+ userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
+
+ // Get the attribute locations
+ userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
+ userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" );
+
+ // Get the sampler location
+ userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" );
+
+ // Load the texture
+ userData->textureId = CreateSimpleTexture2D ();
+ userData->time = 1.0f;
+
+ glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
+ return GL_TRUE;
+}
+
+void Update(ESContext *esContext, float deltaTime) {
+ UserData *userData = esContext ->userData;
+
+ glDeleteTextures ( 1, &userData->textureId );
+ userData->textureId = CreateSimpleTexture2D ();
+}
+
+///
+// Draw a triangle using the shader pair created in Init()
+//
+void Draw ( ESContext *esContext )
+{
+ UserData *userData = esContext->userData;
+ GLfloat vVertices[] = { -0.5f, 0.5f, 0.0f, // Position 0
+ 0.0f, 0.0f, // TexCoord 0
+ -0.5f, -0.5f, 0.0f, // Position 1
+ 0.0f, 1.0f, // TexCoord 1
+ 0.5f, -0.5f, 0.0f, // Position 2
+ 1.0f, 1.0f, // TexCoord 2
+ 0.5f, 0.5f, 0.0f, // Position 3
+ 1.0f, 0.0f // TexCoord 3
+ };
+ GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
+
+ // Set the viewport
+ glViewport ( 0, 0, esContext->width, esContext->height );
+
+ // Clear the color buffer
+ glClear ( GL_COLOR_BUFFER_BIT );
+
+ // Use the program object
+ glUseProgram ( userData->programObject );
+
+ // Load the vertex position
+ glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT,
+ GL_FALSE, 5 * sizeof(GLfloat), vVertices );
+ // Load the texture coordinate
+ glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT,
+ GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3] );
+
+ glEnableVertexAttribArray ( userData->positionLoc );
+ glEnableVertexAttribArray ( userData->texCoordLoc );
+
+ // Bind the texture
+ glActiveTexture ( GL_TEXTURE0 );
+ glBindTexture ( GL_TEXTURE_2D, userData->textureId );
+
+ // Set the sampler texture unit to 0
+ glUniform1i ( userData->samplerLoc, 0 );
+
+ glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
+
+}
+
+///
+// Cleanup
+//
+void ShutDown ( ESContext *esContext )
+{
+ UserData *userData = esContext->userData;
+
+ // Delete texture object
+ glDeleteTextures ( 1, &userData->textureId );
+
+ // Delete program object
+ glDeleteProgram ( userData->programObject );
+
+ free(esContext->userData);
+}
+
+int main ( int argc, char *argv[] )
+{
+ ESContext esContext;
+ UserData userData;
+
+ esInitContext ( &esContext );
+ esContext.userData = &userData;
+
+ esCreateWindow ( &esContext, "Simple Texture 2D", 320, 240, ES_WINDOW_RGB );
+
+ if ( !Init ( &esContext ) )
+ return 0;
+
+ esRegisterDrawFunc ( &esContext, Draw );
+ esRegisterUpdateFunc ( &esContext, Update);
+
+ esMainLoop ( &esContext );
+
+ ShutDown ( &esContext );
+}
diff --git a/tests/font/CMakeLists.txt b/tests/font/CMakeLists.txt
new file mode 100644
index 0000000..b2e055e
--- /dev/null
+++ b/tests/font/CMakeLists.txt
@@ -0,0 +1,39 @@
+cmake_minimum_required(VERSION 2.8)
+
+project (font)
+
+set(EXECUTABLE_NAME ${PROJECT_NAME})
+
+set(CMAKE_VERBOSE_MAKEFILE ON)
+# Linux on ARM
+if(MALI_BUILD)
+ set(DUMMY_MALI_LIBRARIES GLESv1_CM GLESv2 EGL mali OpenVG OpenVGU pthread)
+else()
+ set(DUMMY_MALI_LIBRARIES EGL GLESv2 OpenVG OpenVGU)
+endif()
+set(DEFAULT_LIB_PATH "/usr/local/lib")
+#set(MALI_LIB_PATH "/opt/mali_r4p0_02rel0/fbdev/")
+set(MALI_LIB_PATH "/usr/lib/mali")
+
+INCLUDE_DIRECTORIES("/usr/local/include")
+INCLUDE_DIRECTORIES("../../include")
+
+#add_subdirectory(arm)
+LINK_DIRECTORIES(${DEFAULT_LIB_PATH})
+LINK_DIRECTORIES(${MALI_LIB_PATH})
+
+set(ALL_LIBRARIES ${DUMMY_MALI_LIBRARIES})
+
+set(CMAKE_CXX_FLAGS " -mcpu=cortex-a15 -mfpu=neon-vfpv4 -ftree-vectorize -funsafe-math-optimizations" CACHE STRING "" FORCE)
+set(CMAKE_C_FLAGS " -mcpu=cortex-a15 -mfpu=neon-vfpv4 -ftree-vectorize -funsafe-math-optimizations" CACHE STRING "" FORCE)
+
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
+
+set(FONT_TESTS_SOURCE
+ main.c
+ )
+
+add_executable(${EXECUTABLE_NAME} ${FONT_TESTS_SOURCE})
+target_link_libraries(${EXECUTABLE_NAME} ${ALL_LIBRARIES})
diff --git a/tests/font/Default-568h@2x.png b/tests/font/Default-568h@2x.png
new file mode 100644
index 0000000..0891b7a
--- /dev/null
+++ b/tests/font/Default-568h@2x.png
Binary files differ
diff --git a/tests/font/DejaVuSans.inc b/tests/font/DejaVuSans.inc
new file mode 100644
index 0000000..79ee55c
--- /dev/null
+++ b/tests/font/DejaVuSans.inc
@@ -0,0 +1,937 @@
+/* Generated by font2openvg. See http://developer.hybrid.fi for more information. */
+
+/* converted from font file /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf */
+/* font family name: DejaVu Sans */
+/* font style name: Book */
+
+static const unsigned char DejaVuSans_glyphInstructions[4753] = {
+ 2,4,4,4,4,0,2,4,4,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,4,4,10,10,4,10,10,4,10,10,10,10,4,4,4,10,10,
+ 4,10,10,4,10,10,10,10,4,0,2,4,10,10,10,10,0,2,4,10,
+ 10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,
+ 10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,
+ 2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,4,0,2,
+ 4,10,10,4,10,10,4,4,4,10,10,10,10,10,10,10,10,10,10,10,
+ 10,4,10,10,10,10,10,10,0,2,4,4,4,4,0,2,10,10,10,10,
+ 4,10,10,10,10,4,0,2,4,10,10,10,10,4,10,10,10,10,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,10,10,10,
+ 10,10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,
+ 10,10,4,10,10,10,10,10,10,4,4,4,10,10,10,10,10,10,4,10,
+ 10,10,10,10,10,0,2,4,4,4,0,2,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,10,10,10,10,10,10,10,10,4,10,10,
+ 10,10,10,10,10,10,4,0,2,10,10,10,10,10,10,10,10,0,2,4,
+ 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,2,4,4,
+ 4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,
+ 10,10,10,0,2,4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
+ 10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,0,2,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,10,10,
+ 4,10,10,10,10,10,10,4,10,10,10,10,10,10,4,10,10,10,10,4,
+ 0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,
+ 4,4,4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,4,
+ 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,4,0,2,4,
+ 4,4,0,2,4,4,4,4,4,4,4,4,0,2,4,4,10,10,10,10,
+ 4,0,2,4,4,10,10,10,10,4,0,2,4,10,10,10,10,10,10,10,
+ 10,4,4,0,2,4,10,10,10,10,10,10,10,10,4,10,10,10,10,10,
+ 10,10,10,0,2,4,4,10,10,10,10,4,0,2,4,10,10,10,10,4,
+ 4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,4,10,10,10,10,10,10,
+ 10,10,4,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,10,10,4,4,4,
+ 10,10,4,0,2,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,
+ 4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,0,
+ 2,4,4,4,4,4,4,4,4,4,4,0,2,10,10,10,10,10,10,10,
+ 10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,10,10,10,10,4,
+ 0,2,4,10,10,10,10,4,4,4,4,0,2,10,10,10,10,10,10,10,
+ 10,0,2,4,4,4,10,10,10,10,10,10,10,10,10,10,0,2,10,10,
+ 4,4,4,10,10,4,4,4,4,4,10,10,10,10,0,2,4,4,10,10,
+ 10,10,4,0,2,4,10,10,10,10,10,10,4,10,10,10,10,10,10,4,
+ 10,10,10,10,10,10,4,10,10,10,10,10,10,0,2,4,4,4,4,4,
+ 4,4,4,0,2,4,4,10,10,10,10,4,4,4,10,10,10,10,4,0,
+ 2,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,
+ 4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,
+ 0,2,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,10,10,10,10,10,10,4,4,0,2,4,
+ 4,4,10,10,10,10,10,10,4,4,10,10,10,10,4,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,4,
+ 4,4,4,4,0,2,4,10,10,10,10,10,10,10,10,4,10,10,10,10,
+ 10,10,10,10,0,2,4,4,4,4,4,10,10,10,10,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,0,2,4,4,10,10,10,10,4,10,10,
+ 10,10,10,10,10,10,0,2,10,10,10,10,4,0,2,4,4,10,10,4,
+ 4,4,4,4,4,4,4,4,4,4,10,10,4,0,2,10,10,10,10,10,
+ 10,10,10,0,2,10,10,10,10,4,10,10,10,10,4,10,10,10,10,10,
+ 10,10,10,4,4,4,0,2,4,4,4,10,10,10,10,4,4,4,4,4,
+ 10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 10,10,4,4,4,10,10,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,10,10,10,10,4,
+ 4,4,10,10,10,10,4,4,4,10,10,10,10,4,4,4,4,4,10,10,
+ 10,10,0,2,4,4,4,10,10,10,10,4,4,4,4,4,10,10,10,10,
+ 0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,
+ 0,2,4,4,4,4,4,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,4,4,4,4,4,0,2,10,10,10,10,4,4,4,4,
+ 4,10,10,10,10,4,0,2,4,10,10,10,10,10,10,4,10,10,10,10,
+ 10,10,4,10,10,10,10,10,10,4,10,10,10,10,10,10,0,2,4,4,
+ 4,4,4,10,10,4,4,4,10,10,4,4,4,4,4,4,0,2,4,4,
+ 4,10,10,10,10,4,4,4,4,4,10,10,10,10,0,2,4,0,2,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,10,10,4,
+ 4,4,10,10,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,10,10,4,10,10,4,4,4,10,10,4,10,10,
+ 4,4,4,10,10,4,10,10,10,10,4,10,10,4,0,2,4,4,4,4,
+ 0,2,4,10,10,4,10,10,10,10,4,10,10,4,4,4,10,10,4,10,
+ 10,4,4,4,10,10,4,10,10,4,4,0,2,4,10,10,10,10,10,10,
+ 10,10,4,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,
+ 4,0,2,4,10,10,10,10,0,2,4,10,10,4,10,10,4,10,10,4,
+ 4,4,10,10,10,10,4,4,4,10,10,0,2,4,10,10,10,10,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,10,10,10,10,0,2,4,
+ 4,4,10,10,10,10,4,4,4,10,10,10,10,4,4,4,10,10,10,10,
+ 4,4,4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,10,10,
+ 10,10,10,10,10,10,0,2,4,10,10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,4,10,10,10,10,10,4,10,10,10,10,10,10,10,10,
+ 10,10,0,2,4,4,4,4,0,2,4,4,4,4,0,2,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,0,2,4,10,10,10,10,10,10,10,
+ 10,4,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,4,
+ 4,10,10,10,10,10,10,4,4,10,10,10,10,4,10,10,10,10,0,2,
+ 10,10,10,10,10,10,4,4,0,2,4,4,4,4,4,4,4,0,2,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,4,4,0,2,4,4,4,4,
+ 0,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,2,
+ 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,2,4,4,
+ 4,10,10,10,10,0,2,10,10,10,10,10,10,4,4,4,10,10,4,4,
+ 4,4,4,0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,10,10,10,
+ 10,10,10,4,10,10,10,10,10,10,0,2,10,10,10,10,10,10,4,10,
+ 10,10,10,10,10,4,4,4,10,10,10,10,10,10,4,10,10,10,10,10,
+ 10,0,2,4,4,4,4,0,2,4,4,4,10,10,10,10,4,4,4,10,
+ 10,10,10,4,10,10,10,10,10,10,10,10,4,4,0,2,4,4,4,4,
+ 4,4,4,4,10,10,10,10,0,2,4,4,4,4,0,2,10,10,10,10,
+ 10,10,4,10,10,10,10,10,10,4,0,2,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,0,2,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,
+ 0,2,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,0,2,4,
+ 4,4,4,10,10,10,10,10,10,4,10,10,10,10,10,10,0,2,4,4,
+ 4,4,0,2,10,10,10,10,10,10,4,10,10,10,10,10,10,4,4,4,
+ 10,10,10,10,10,10,4,10,10,10,10,10,10,0,2,4,4,4,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,10,10,4,10,10,10,10,10,10,4,10,10,10,10,10,10,4,10,10,
+ 10,10,4,0,2,4,4,4,4,0,2,4,4,4,0,2,4,4,4,4,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,0,2,4,4,4,
+ 4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,0,2,4,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,
+ 0,2,4,4,4,4,4,4,4,4,0,2,4,10,10,10,10,4,4,10,
+ 10,10,10,4,10,10,10,10,4,4,10,10,10,10,0,2,4,4,4,0,
+ 2,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,0,2,10,10,
+ 10,10,10,10,10,10,4,4,4,4,4,4,4,0,2,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 10,10,10,10,10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,10,
+ 10,10,10,10,10,4,10,10,10,10,10,10,4,0,2,4,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,0,2,4,4,
+ 4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,10,10,10,10,4,4,4,4,4,4,0,2,4,4,4,4,4,4,
+ 10,10,10,10,4,0,2,4,4,4,4,4,4,4,4,4,4,0,2,4,
+ 10,10,10,10,4,4,10,10,10,10,4,10,10,10,10,4,4,10,10,10,
+ 10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,
+ 10,0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,
+ 10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,10,10,10,10,10,
+ 10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,
+ 4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,
+ 10,10,0,2,4,10,10,10,10,4,4,10,10,10,10,4,10,10,10,10,
+ 4,4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,
+ 10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,10,10,10,10,10,
+ 10,0,2,10,10,10,10,10,10,4,0,2,10,10,10,10,10,10,4,4,
+ 4,10,10,10,10,10,10,4,4,4,0,2,4,4,10,10,10,10,4,4,
+ 4,10,10,10,10,4,0,2,4,4,4,4,0,2,4,4,10,10,10,10,
+ 4,4,4,10,10,10,10,4,0,2,4,4,4,4,0,2,4,4,10,10,
+ 10,10,4,4,4,10,10,10,10,4,0,2,4,4,4,4,4,4,4,0,
+ 2,4,4,10,10,10,10,4,4,4,10,10,10,10,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,10,10,10,10,4,4,4,4,0,2,4,
+ 4,10,10,10,10,4,0,2,10,10,10,10,10,10,10,10,4,10,10,10,
+ 10,10,10,4,10,10,10,10,10,10,4,10,10,10,10,10,10,10,10,4,
+ 4,4,0,2,10,10,10,10,10,10,4,4,0,2,4,4,4,10,10,10,
+ 10,10,10,4,4,10,10,10,10,4,10,10,10,10,0,2,4,4,4,4,
+ 0,2,10,10,10,10,10,10,4,4,0,2,4,4,4,10,10,10,10,10,
+ 10,4,4,10,10,10,10,4,10,10,10,10,0,2,4,4,4,4,0,2,
+ 10,10,10,10,10,10,4,4,0,2,4,4,4,10,10,10,10,10,10,4,
+ 4,10,10,10,10,4,10,10,10,10,0,2,4,4,4,4,4,4,4,0,
+ 2,10,10,10,10,10,10,4,4,0,2,4,4,4,10,10,10,10,10,10,
+ 4,4,10,10,10,10,4,10,10,10,10,0,2,4,10,10,10,10,4,10,
+ 10,10,10,4,10,10,10,10,4,10,10,10,10,0,2,10,10,10,10,10,
+ 10,4,4,0,2,4,4,4,10,10,10,10,10,10,4,4,10,10,10,10,
+ 4,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,4,0,2,10,
+ 10,10,10,10,10,4,4,0,2,4,4,4,10,10,10,10,10,10,4,4,
+ 10,10,10,10,4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,4,0,2,10,10,
+ 10,10,4,4,10,10,10,10,4,10,10,10,10,10,10,10,10,10,10,4,
+ 4,10,10,10,10,4,10,10,10,10,0,2,10,10,10,10,10,10,4,4,
+ 0,2,4,10,10,10,10,10,10,10,10,4,10,10,10,10,10,10,10,10,
+ 0,2,10,10,10,10,10,10,4,10,10,10,10,10,10,4,0,2,4,4,
+ 10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,4,
+ 0,2,4,4,4,4,0,2,4,4,10,10,10,10,4,10,10,10,10,10,
+ 10,10,10,0,2,10,10,10,10,4,0,2,4,4,4,4,0,2,4,4,
+ 10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,4,
+ 0,2,4,4,4,4,4,4,4,0,2,4,4,10,10,10,10,4,10,10,
+ 10,10,10,10,10,10,0,2,10,10,10,10,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,0,2,4,4,4,
+ 4,0,2,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,10,10,10,10,
+ 10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,10,10,4,4,
+ 4,4,4,4,4,4,4,4,4,0,2,4,4,4,10,10,10,10,4,4,
+ 4,4,4,10,10,10,10,0,2,4,10,10,10,10,4,10,10,10,10,4,
+ 10,10,10,10,4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,
+ 4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,
+ 10,0,2,4,4,4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,
+ 0,2,10,10,10,10,10,10,10,10,0,2,4,10,10,10,10,4,10,10,
+ 10,10,4,10,10,10,10,4,10,10,10,10,0,2,10,10,10,10,10,10,
+ 10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,10,10,10,10,10,10,0,2,10,10,10,10,10,10,4,
+ 0,2,10,10,10,10,10,10,4,4,4,10,10,10,10,10,10,4,4,4,
+ 0,2,4,4,4,10,10,10,10,4,4,4,4,4,10,10,10,10,0,2,
+ 4,0,2,4,4,4,4,0,2,4,4,4,10,10,10,10,4,4,4,4,
+ 4,10,10,10,10,0,2,4,0,2,4,4,4,4,0,2,4,4,4,10,
+ 10,10,10,4,4,4,4,4,10,10,10,10,0,2,4,0,2,4,4,4,
+ 4,4,4,4,0,2,4,4,4,10,10,10,10,4,4,4,4,4,10,10,
+ 10,10,0,2,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,10,
+ 10,4,4,4,10,10,4,4,4,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,
+ 10,10,10,10,0,2,10,10,4,4,4,10,10,4,4,4,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0 };
+static const int DejaVuSans_glyphInstructionIndices[224] = {
+ 0,0,14,26,62,104,150,189,195,207,219,239,253,261,267,273,279,299,312,335,
+ 366,384,408,437,446,484,513,525,539,548,560,569,601,658,673,704,724,742,756,768,
+ 792,806,812,824,837,845,860,872,892,912,937,964,994,1004,1020,1029,1044,1058,1069,1081,
+ 1091,1097,1107,1116,1122,1128,1160,1185,1205,1230,1254,1274,1307,1325,1337,1355,1368,1374,1403,1421,
+ 1441,1466,1491,1507,1537,1557,1578,1587,1602,1616,1632,1644,1675,1681,1712,1732,1744,1756,1768,1780,
+ 1792,1804,1816,1828,1840,1852,1864,1876,1888,1900,1912,1924,1936,1948,1960,1972,1984,1996,2008,2020,
+ 2032,2044,2056,2068,2080,2092,2104,2116,2128,2128,2142,2172,2198,2238,2265,2277,2323,2335,2391,2429,
+ 2447,2455,2461,2524,2530,2552,2572,2591,2622,2628,2655,2669,2675,2691,2704,2730,2748,2785,2823,2878,
+ 2910,2931,2952,2976,3015,3042,3074,3098,3134,3154,3174,3197,3223,3235,3247,3262,3280,3306,3342,3368,
+ 3394,3423,3467,3499,3513,3551,3573,3595,3620,3648,3665,3687,3723,3761,3799,3840,3894,3938,3990,4041,
+ 4077,4107,4137,4170,4206,4221,4236,4254,4275,4310,4350,4376,4402,4431,4473,4505,4523,4561,4588,4615,
+ 4645,4678,4700,4725 };
+static const int DejaVuSans_glyphInstructionCounts[224] = {
+ 0,14,12,36,42,46,39,6,12,12,20,14,8,6,6,6,20,13,23,31,
+ 18,24,29,9,38,29,12,14,9,12,9,32,57,15,31,20,18,14,12,24,
+ 14,6,12,13,8,15,12,20,20,25,27,30,10,16,9,15,14,11,12,10,
+ 6,10,9,6,6,32,25,20,25,24,20,33,18,12,18,13,6,29,18,20,
+ 25,25,16,30,20,21,9,15,14,16,12,31,6,31,20,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,0,14,30,26,40,27,12,46,12,56,38,18,
+ 8,6,63,6,22,20,19,31,6,27,14,6,16,13,26,18,37,38,55,32,
+ 21,21,24,39,27,32,24,36,20,20,23,26,12,12,15,18,26,36,26,26,
+ 29,44,32,14,38,22,22,25,28,17,22,36,38,38,41,54,44,52,51,36,
+ 30,30,33,36,15,15,18,21,35,40,26,26,29,42,32,18,38,27,27,30,
+ 33,22,25,28 };
+
+static const int DejaVuSans_glyphPointIndices[224] = {
+ 0,0,12,22,56,119,192,257,262,281,300,319,332,339,344,349,354,388,400,438,
+ 492,508,547,598,606,673,724,734,746,754,764,772,820,923,936,980,1015,1039,1052,1063,
+ 1102,1115,1120,1135,1147,1154,1168,1179,1213,1239,1280,1317,1370,1379,1402,1410,1424,1437,1447,1458,
+ 1467,1472,1481,1489,1494,1499,1549,1588,1623,1662,1700,1723,1778,1803,1813,1833,1845,1850,1894,1919,
+ 1953,1992,2031,2054,2107,2130,2157,2165,2179,2192,2211,2222,2268,2273,2319,2354,2364,2374,2384,2394,
+ 2404,2414,2424,2434,2444,2454,2464,2474,2484,2494,2504,2514,2524,2534,2544,2554,2564,2574,2584,2594,
+ 2604,2614,2624,2634,2644,2654,2664,2674,2684,2684,2696,2740,2773,2835,2861,2871,2954,2964,3065,3120,
+ 3136,3143,3148,3251,3256,3294,3312,3342,3396,3401,3443,3460,3465,3492,3504,3543,3559,3592,3639,3714,
+ 3762,3780,3798,3819,3871,3894,3939,3961,4023,4041,4059,4080,4103,4113,4123,4136,4151,4183,4233,4272,
+ 4311,4353,4426,4470,4483,4542,4570,4598,4629,4662,4677,4705,4768,4823,4878,4936,5023,5083,5167,5251,
+ 5313,5356,5399,5445,5493,5505,5517,5532,5549,5602,5664,5703,5742,5784,5855,5899,5914,5973,6005,6037,
+ 6072,6109,6133,6172 };
+static const int DejaVuSans_glyphPoints[6201*2] = {
+ 13136,10800,21760,10800,21760,0,13136,0,13136,10800,13136,63456,21760,63456,21760,35616,20912,20448,14032,20448,
+ 13136,35616,13136,63456,15600,63456,15600,39872,8368,39872,8368,63456,15600,63456,31664,63456,31664,39872,24432,39872,
+ 24432,63456,31664,63456,44496,38288,32128,38288,28560,24096,41008,24096,44496,38288,38128,62480,33696,44832,46112,44832,
+ 50576,62480,57376,62480,52992,44832,66256,44832,66256,38288,51344,38288,47856,24096,61376,24096,61376,17600,46192,17600,
+ 41776,0,34976,0,39360,17600,26896,17600,22528,0,15680,0,20096,17600,6720,17600,6720,24096,21680,24096,
+ 25248,38288,11568,38288,11568,44832,26896,44832,31232,62480,38128,62480,29408,-12800,25168,-12800,25120,0,20656,80,
+ 16192,1040,11728,2000,7232,3904,7232,11568,11568,8848,16008,7464,20448,6080,25168,6032,25168,25408,15760,26944,
+ 11496,30600,7232,34256,7232,40624,7232,47552,11864,51552,16496,55552,25168,56144,25168,66128,29408,66128,29408,56272,
+ 33360,56096,37056,55440,40752,54784,44288,53632,44288,46192,40752,47984,37040,48960,33328,49936,29408,50112,29408,31968,
+ 39056,30480,43608,26648,48160,22816,48160,16192,48160,9008,43336,4864,38512,720,29408,80,29408,-12800,25168,32720,
+ 25168,50144,20224,49600,17632,47344,15040,45088,15040,41360,15040,37696,17440,35656,19840,33616,25168,32720,29408,24560,
+ 29408,6160,34800,6880,37544,9224,40288,11568,40288,15392,40288,19120,37672,21336,35056,23552,29408,24560,63280,27920,
+ 59584,27920,57480,24776,55376,21632,55376,16016,55376,10496,57480,7328,59584,4160,63280,4160,66896,4160,69000,7328,
+ 71104,10496,71104,16016,71104,21584,69000,24752,66896,27920,63280,27920,63280,33328,70000,33328,73952,28648,77904,23968,
+ 77904,16016,77904,8080,73928,3424,69952,-1232,63280,-1232,56480,-1232,52528,3424,48576,8080,48576,16016,48576,24016,
+ 52552,28672,56528,33328,63280,33328,19424,59200,15760,59200,13664,56032,11568,52864,11568,47344,11568,41728,13648,38584,
+ 15728,35440,19424,35440,23120,35440,25224,38584,27328,41728,27328,47344,27328,52832,25200,56016,23072,59200,19424,59200,
+ 57808,64608,64608,64608,24912,-1232,18112,-1232,57808,64608,19424,64608,26144,64608,30136,59952,34128,55296,34128,47344,
+ 34128,39312,30152,34680,26176,30048,19424,30048,12672,30048,8736,34704,4800,39360,4800,47344,4800,55248,8752,59928,
+ 12704,64608,19424,64608,21168,34128,17296,30688,15488,27264,13680,23840,13680,20096,13680,13904,18184,9776,22688,5648,
+ 29488,5648,33536,5648,37064,6992,40592,8336,43696,11056,21168,34128,27152,38880,48752,16784,51248,20576,52656,24888,
+ 54064,29200,54320,34048,62224,34048,61712,28432,59504,22952,57296,17472,53344,12112,65200,0,54480,0,48400,6240,
+ 43984,2464,39144,616,34304,-1232,28736,-1232,18480,-1232,11984,4608,5488,10448,5488,19600,5488,25040,8336,29816,
+ 11184,34592,16880,38800,14832,41488,13768,44144,12704,46800,12704,49344,12704,56224,17424,60416,22144,64608,29968,64608,
+ 33488,64608,36992,63840,40496,63072,44112,61536,44112,53808,40416,55808,37056,56848,33696,57888,30816,57888,26352,57888,
+ 23568,55528,20784,53168,20784,49424,20784,47264,22040,45072,23296,42880,27152,38880,15600,63456,15600,39872,8368,39872,
+ 8368,63456,15600,63456,26992,66048,21296,56272,18528,46712,15760,37152,15760,27328,15760,17504,18544,7880,21328,-1744,
+ 26992,-11472,20192,-11472,13808,-1488,10648,8160,7488,17808,7488,27328,7488,36800,10632,46408,13776,56016,20192,66048,
+ 26992,66048,6976,66048,13776,66048,20144,56016,23312,46408,26480,36800,26480,27328,26480,17808,23312,8160,20144,-1488,
+ 13776,-11472,6976,-11472,12624,-1744,15408,7880,18192,17504,18192,27328,18192,37152,15408,46712,12624,56272,6976,66048,
+ 40928,52992,25664,44752,40928,36464,38464,32304,24176,40928,24176,24912,19344,24912,19344,40928,5056,32304,2592,36464,
+ 17856,44752,2592,52992,5056,57200,19344,48576,19344,64608,24176,64608,24176,48576,38464,57200,40928,52992,40032,54576,
+ 40032,30896,63712,30896,63712,23680,40032,23680,40032,0,32896,0,32896,23680,9216,23680,9216,30896,32896,30896,
+ 32896,54576,40032,54576,10208,10800,19168,10800,19168,3488,12192,-10112,6720,-10112,10208,3488,10208,10800,4256,27328,
+ 27152,27328,27152,20352,4256,20352,4256,27328,9312,10800,18272,10800,18272,0,9312,0,9312,10800,22096,63456,
+ 29328,63456,7232,-8080,0,-8080,22096,63456,27664,57808,21040,57808,17704,51280,14368,44752,14368,31664,14368,18608,
+ 17704,12088,21040,5568,27664,5568,34336,5568,37672,12088,41008,18608,41008,31664,41008,44752,37672,51280,34336,57808,
+ 27664,57808,27664,64608,38336,64608,43968,56168,49600,47728,49600,31664,49600,15648,43968,7208,38336,-1232,27664,-1232,
+ 17008,-1232,11376,7208,5744,15648,5744,31664,5744,47728,11376,56168,17008,64608,27664,64608,10800,7232,24816,7232,
+ 24816,55632,9568,52576,9568,60400,24736,63456,33328,63456,33328,7232,47344,7232,47344,0,10800,0,10800,7232,
+ 16704,7232,46672,7232,46672,0,6368,0,6368,7232,11264,12288,19696,20808,28128,29328,30304,31792,34432,36416,
+ 36064,39632,37696,42848,37696,45936,37696,51008,34152,54192,30608,57376,24912,57376,20864,57376,16384,55976,11904,54576,
+ 6800,51728,6800,60400,11984,62480,16488,63544,20992,64608,24736,64608,34592,64608,40456,59672,46320,54736,46320,46496,
+ 46320,42592,44856,39080,43392,35568,39520,30816,38464,29584,32768,23696,27072,17808,16704,7232,35312,34208,41488,32896,
+ 44944,28728,48400,24560,48400,18448,48400,9056,41944,3912,35488,-1232,23584,-1232,19600,-1232,15368,-448,11136,336,
+ 6624,1920,6624,10208,10208,8112,14456,7056,18704,6000,23328,6000,31408,6000,35640,9184,39872,12368,39872,18448,
+ 39872,24048,35936,27216,32000,30384,24992,30384,17600,30384,17600,37440,25328,37440,31664,37440,35024,39968,38384,42496,
+ 38384,47264,38384,52144,34920,54760,31456,57376,24992,57376,21456,57376,17424,56608,13392,55840,8544,54224,8544,61888,
+ 13424,63248,17696,63928,21968,64608,25760,64608,35536,64608,41232,60160,46928,55712,46928,48160,46928,42880,43904,39248,
+ 40880,35616,35312,34208,32896,55968,11216,22096,32896,22096,32896,55968,30640,63456,41440,63456,41440,22096,50496,22096,
+ 50496,14960,41440,14960,41440,0,32896,0,32896,14960,4256,14960,4256,23248,30640,63456,9392,63456,43088,63456,
+ 43088,56224,17248,56224,17248,40672,19120,41312,20992,41632,22864,41952,24736,41952,35360,41952,41568,36128,47776,30304,
+ 47776,20352,47776,10112,41400,4440,35024,-1232,23424,-1232,19424,-1232,15280,-552,11136,128,6720,1488,6720,10112,
+ 10544,8032,14624,7016,18704,6000,23248,6000,30608,6000,34896,9864,39184,13728,39184,20352,39184,26992,34896,30856,
+ 30608,34720,23248,34720,19808,34720,16384,33960,12960,33200,9392,31584,9392,63456,28736,35152,22944,35152,19568,31200,
+ 16192,27248,16192,20352,16192,13520,19568,9544,22944,5568,28736,5568,34512,5568,37888,9544,41264,13520,41264,20352,
+ 41264,27248,37888,31200,34512,35152,28736,35152,45776,62048,45776,54224,42544,55760,39248,56568,35952,57376,32720,57376,
+ 24224,57376,19744,51640,15264,45904,14624,34304,17120,38000,20904,39976,24688,41952,29248,41952,38800,41952,44344,36152,
+ 49888,30352,49888,20352,49888,10576,44112,4672,38336,-1232,28736,-1232,17728,-1232,11904,7208,6080,15648,6080,31664,
+ 6080,46704,13216,55656,20352,64608,32384,64608,35616,64608,38912,63968,42208,63328,45776,62048,7136,63456,47936,63456,
+ 47936,59792,24912,0,15936,0,37616,56224,7136,56224,7136,63456,27664,30128,21552,30128,18040,26856,14528,23584,
+ 14528,17856,14528,12112,18040,8840,21552,5568,27664,5568,33792,5568,37320,8864,40848,12160,40848,17856,40848,23584,
+ 37336,26856,33824,30128,27664,30128,19088,33792,13552,35152,10472,38936,7392,42720,7392,48160,7392,55760,12816,60184,
+ 18240,64608,27664,64608,37152,64608,42544,60184,47936,55760,47936,48160,47936,42720,44856,38936,41776,35152,36288,33792,
+ 42496,32336,45960,28128,49424,23920,49424,17856,49424,8624,43792,3696,38160,-1232,27664,-1232,17168,-1232,11536,3696,
+ 5904,8624,5904,17856,5904,23920,9392,28128,12880,32336,19088,33792,15936,47344,15936,42416,19016,39656,22096,36896,
+ 27664,36896,33200,36896,36320,39656,39440,42416,39440,47344,39440,52272,36320,55040,33200,57808,27664,57808,22096,57808,
+ 19016,55040,15936,52272,15936,47344,9568,1312,9568,9136,12800,7600,16112,6800,19424,6000,22608,6000,31104,6000,
+ 35592,11712,40080,17424,40720,29072,38256,25408,34472,23456,30688,21504,26096,21504,16576,21504,11032,27264,5488,33024,
+ 5488,43008,5488,52784,11264,58696,17040,64608,26640,64608,37648,64608,43456,56168,49264,47728,49264,31664,49264,16656,
+ 42144,7712,35024,-1232,22992,-1232,19760,-1232,16448,-592,13136,48,9568,1312,26640,28224,32432,28224,35808,32176,
+ 39184,36128,39184,43008,39184,49856,35808,53832,32432,57808,26640,57808,20864,57808,17488,53832,14112,49856,14112,43008,
+ 14112,36128,17488,32176,20864,28224,26640,28224,10208,10800,19168,10800,19168,0,10208,0,10208,10800,10208,45008,
+ 19168,45008,19168,34208,10208,34208,10208,45008,10208,45008,19168,45008,19168,34208,10208,34208,10208,45008,10208,10800,
+ 19168,10800,19168,3488,12192,-10112,6720,-10112,10208,3488,10208,10800,63712,42848,19840,27248,63712,11728,63712,4000,
+ 9216,23760,9216,30816,63712,50576,63712,42848,9216,39520,63712,39520,63712,32384,9216,32384,9216,39520,9216,22192,
+ 63712,22192,63712,14960,9216,14960,9216,22192,9216,42848,9216,50576,63712,30816,63712,23760,9216,4000,9216,11728,
+ 52992,27248,9216,42848,16624,10800,25248,10800,25248,0,16624,0,16624,10800,24992,17040,16880,17040,16880,23584,
+ 16880,27888,18064,30648,19248,33408,23072,37056,26896,40848,29328,43088,30408,45088,31488,47088,31488,49168,31488,52960,
+ 28704,55296,25920,57632,21328,57632,17984,57632,14176,56144,10368,54656,6240,51808,6240,59792,10240,62224,14344,63416,
+ 18448,64608,22816,64608,30640,64608,35384,60480,40128,56352,40128,49600,40128,46368,38592,43456,37056,40544,33232,36896,
+ 29488,33232,27504,31232,26672,30112,25840,28992,25504,27920,25248,27024,25120,25752,24992,24480,24992,22272,24992,17040,
+ 32384,22816,32384,16752,35400,13288,38416,9824,43696,9824,48912,9824,51912,13304,54912,16784,54912,22816,54912,28768,
+ 51848,32280,48784,35792,43600,35792,38464,35792,35424,32304,32384,28816,32384,22816,55552,10112,52992,6848,49704,5296,
+ 46416,3744,42032,3744,34720,3744,30152,9032,25584,14320,25584,22816,25584,31328,30176,36640,34768,41952,42032,41952,
+ 46416,41952,49728,40360,53040,38768,55552,35536,55552,41104,61632,41104,61632,9824,67824,10752,71336,15488,74848,20224,
+ 74848,27760,74848,32304,73504,36296,72160,40288,69440,43696,65024,49264,58672,52216,52320,55168,44832,55168,39616,55168,
+ 34808,53784,30000,52400,25920,49680,19248,45344,15488,38312,11728,31280,11728,23072,11728,16320,14176,10416,16624,4512,
+ 21248,0,25712,-4416,31576,-6736,37440,-9056,44112,-9056,49600,-9056,54888,-7208,60176,-5360,64608,-1920,68432,-6624,
+ 63120,-10752,56848,-12944,50576,-15136,44112,-15136,36256,-15136,29288,-12352,22320,-9568,16880,-4256,11440,1056,8592,8048,
+ 5744,15040,5744,23072,5744,30816,8632,37824,11520,44832,16880,50144,22352,55552,29536,58416,36720,61280,44752,61280,
+ 53760,61280,61472,57584,69184,53888,74416,47088,77600,42928,79280,38040,80960,33152,80960,27920,80960,16752,74200,10288,
+ 67440,3824,55552,3568,55552,10112,29744,54992,18112,23424,41440,23424,29744,54992,24912,63456,34640,63456,58816,0,
+ 49888,0,44112,16272,15520,16272,9728,0,688,0,24912,63456,17120,30304,17120,7056,30896,7056,37824,7056,
+ 41160,9928,44496,12800,44496,18704,44496,24656,41160,27480,37824,30304,30896,30304,17120,30304,17120,56400,17120,37280,
+ 29840,37280,36128,37280,39208,39632,42288,41984,42288,46832,42288,51632,39208,54016,36128,56400,29840,56400,17120,56400,
+ 8544,63456,30480,63456,40288,63456,45600,59376,50912,55296,50912,47776,50912,41952,48192,38504,45472,35056,40208,34208,
+ 46544,32848,50048,28536,53552,24224,53552,17760,53552,9264,47768,4632,41984,0,31328,0,8544,0,8544,63456,
+ 56064,58560,56064,49520,51728,53552,46816,55552,41904,57552,36384,57552,25504,57552,19720,50896,13936,44240,13936,31664,
+ 13936,19120,19720,12472,25504,5824,36384,5824,41904,5824,46816,7824,51728,9824,56064,13856,56064,4880,51552,1824,
+ 46520,296,41488,-1232,35872,-1232,21456,-1232,13168,7584,4880,16400,4880,31664,4880,46960,13168,55784,21456,64608,
+ 35872,64608,41568,64608,46600,63096,51632,61584,56064,58560,17120,56400,17120,7056,27504,7056,40624,7056,46728,13008,
+ 52832,18960,52832,31792,52832,44544,46728,50472,40624,56400,27504,56400,17120,56400,8544,63456,26176,63456,44624,63456,
+ 53256,55784,61888,48112,61888,31792,61888,15392,53216,7696,44544,0,26176,0,8544,0,8544,63456,8544,63456,
+ 48656,63456,48656,56224,17120,56224,17120,37440,47344,37440,47344,30224,17120,30224,17120,7232,49424,7232,49424,0,
+ 8544,0,8544,63456,8544,63456,45008,63456,45008,56224,17120,56224,17120,37520,42288,37520,42288,30304,17120,30304,
+ 17120,0,8544,0,8544,63456,51808,9056,51808,26096,37776,26096,37776,33152,60304,33152,60304,5904,55328,2384,
+ 49336,576,43344,-1232,36544,-1232,21680,-1232,13280,7456,4880,16144,4880,31664,4880,47216,13280,55912,21680,64608,
+ 36544,64608,42752,64608,48344,63072,53936,61536,58656,58560,58656,49424,53888,53472,48536,55512,43184,57552,37280,57552,
+ 25632,57552,19784,51048,13936,44544,13936,31664,13936,18832,19784,12328,25632,5824,37280,5824,41824,5824,45392,6608,
+ 48960,7392,51808,9056,8544,63456,17120,63456,17120,37440,48320,37440,48320,63456,56912,63456,56912,0,48320,0,
+ 48320,30224,17120,30224,17120,0,8544,0,8544,63456,8544,63456,17120,63456,17120,0,8544,0,8544,63456,
+ 8544,63456,17120,63456,17120,4416,17120,-7056,12768,-12240,8416,-17424,-1232,-17424,-4512,-17424,-4512,-10208,-1824,-10208,
+ 3872,-10208,6208,-7016,8544,-3824,8544,4416,8544,63456,8544,63456,17120,63456,17120,36640,45600,63456,56656,63456,
+ 25168,33872,58912,0,47600,0,17120,30560,17120,0,8544,0,8544,63456,8544,63456,17120,63456,17120,7232,
+ 48032,7232,48032,0,8544,0,8544,63456,8544,63456,21328,63456,37520,20272,53808,63456,66592,63456,66592,0,
+ 58224,0,58224,55712,41856,12192,33232,12192,16880,55712,16880,0,8544,0,8544,63456,8544,63456,20096,63456,
+ 48240,10368,48240,63456,56560,63456,56560,0,45008,0,16880,53088,16880,0,8544,0,8544,63456,34304,57632,
+ 24944,57632,19440,50664,13936,43696,13936,31664,13936,19680,19440,12712,24944,5744,34304,5744,43648,5744,49112,12712,
+ 54576,19680,54576,31664,54576,43696,49112,50664,43648,57632,34304,57632,34304,64608,47648,64608,55632,55656,63616,46704,
+ 63616,31664,63616,16656,55632,7712,47648,-1232,34304,-1232,20912,-1232,12896,7696,4880,16624,4880,31664,4880,46704,
+ 12896,55656,20912,64608,34304,64608,17120,56400,17120,32560,27920,32560,33920,32560,37192,35664,40464,38768,40464,44496,
+ 40464,50192,37192,53296,33920,56400,27920,56400,17120,56400,8544,63456,27920,63456,38592,63456,44056,58632,49520,53808,
+ 49520,44496,49520,35104,44056,30304,38592,25504,27920,25504,17120,25504,17120,0,8544,0,8544,63456,34304,57632,
+ 24944,57632,19440,50664,13936,43696,13936,31664,13936,19680,19440,12712,24944,5744,34304,5744,43648,5744,49112,12712,
+ 54576,19680,54576,31664,54576,43696,49112,50664,43648,57632,34304,57632,46320,1152,57632,-11216,47264,-11216,37872,-1056,
+ 36464,-1152,35720,-1192,34976,-1232,34304,-1232,20912,-1232,12896,7712,4880,16656,4880,31664,4880,46704,12896,55656,
+ 20912,64608,34304,64608,47648,64608,55632,55656,63616,46704,63616,31664,63616,20608,59176,12744,54736,4880,46320,1152,
+ 38640,29744,41392,28816,44008,25752,46624,22688,49264,17344,57968,0,48752,0,40624,16272,37488,22656,34536,24736,
+ 31584,26816,26480,26816,17120,26816,17120,0,8544,0,8544,63456,27920,63456,38800,63456,44160,58904,49520,54352,
+ 49520,45184,49520,39184,46736,35232,43952,31280,38640,29744,17120,56400,17120,33872,27920,33872,34128,33872,37296,36744,
+ 40464,39616,40464,45184,40464,50752,37296,53576,34128,56400,27920,56400,17120,56400,46576,61376,46576,52992,41696,55328,
+ 37360,56480,33024,57632,28992,57632,21968,57632,18168,54912,14368,52192,14368,47168,14368,42960,16896,40816,19424,38672,
+ 26480,37360,31664,36288,41264,34464,45832,29856,50400,25248,50400,17504,50400,8288,44216,3528,38032,-1232,26096,-1232,
+ 21584,-1232,16512,-216,11440,800,6000,2800,6000,11648,11216,8720,16232,7232,21248,5744,26096,5744,33440,5744,
+ 37440,8632,41440,11520,41440,16880,41440,21552,38568,24184,35696,26816,29152,28128,23920,29152,14320,31072,10032,35152,
+ 5744,39232,5744,46496,5744,54912,11672,59760,17600,64608,28000,64608,32464,64608,37096,63800,41728,62992,46576,61376,
+ -256,63456,53424,63456,53424,56224,30896,56224,30896,0,22272,0,22272,56224,-256,56224,-256,63456,7568,63456,
+ 16192,63456,16192,24912,16192,14704,19888,10224,23584,5744,31872,5744,40128,5744,43824,10224,47520,14704,47520,24912,
+ 47520,63456,56144,63456,56144,23840,56144,11440,50000,5104,43856,-1232,31872,-1232,19840,-1232,13704,5104,7568,11440,
+ 7568,23840,7568,63456,24912,0,688,63456,9648,63456,29744,10032,49888,63456,58816,63456,34640,0,24912,0,
+ 2896,63456,11568,63456,24912,9824,38208,63456,47856,63456,61200,9824,74496,63456,83216,63456,67280,0,56480,0,
+ 43088,55088,29584,0,18784,0,2896,63456,5488,63456,14704,63456,30480,39872,46320,63456,55552,63456,35152,32976,
+ 56912,0,47680,0,29840,26992,11856,0,2592,0,25248,33872,5488,63456,-176,63456,9056,63456,26640,37360,
+ 44112,63456,53344,63456,30896,30224,30896,0,22272,0,22272,30224,-176,63456,4880,63456,54736,63456,54736,56912,
+ 14624,7232,55712,7232,55712,0,3904,0,3904,6544,44032,56224,4880,56224,4880,63456,7488,66128,25504,66128,
+ 25504,60048,15296,60048,15296,-5392,25504,-5392,25504,-11472,7488,-11472,7488,66128,7232,63456,29328,-8080,22096,-8080,
+ 0,63456,7232,63456,26480,66128,26480,-11472,8464,-11472,8464,-5392,18608,-5392,18608,60048,8464,60048,8464,66128,
+ 26480,66128,40624,63456,63712,39776,55168,39776,36464,56560,17760,39776,9216,39776,32304,63456,40624,63456,44368,-14448,
+ 44368,-20528,-848,-20528,-848,-14448,44368,-14448,15600,69616,27584,53728,21088,53728,7232,69616,15600,69616,29840,23920,
+ 20352,23920,16696,21760,13040,19600,13040,14368,13040,10208,15784,7760,18528,5312,23248,5312,29744,5312,33680,9920,
+ 37616,14528,37616,22192,37616,23920,29840,23920,45440,27152,45440,0,37616,0,37616,7232,34928,2896,30936,832,
+ 26944,-1232,21168,-1232,13856,-1232,9544,2872,5232,6976,5232,13856,5232,21888,10608,25968,15984,30048,26640,30048,
+ 37616,30048,37616,30816,37616,36208,34064,39160,30512,42112,24096,42112,20016,42112,16152,41136,12288,40160,8720,38208,
+ 8720,45440,13008,47088,17048,47920,21088,48752,24912,48752,35232,48752,40336,43392,45440,38032,45440,27152,42368,23760,
+ 42368,32384,38824,37296,35280,42208,29072,42208,22864,42208,19312,37296,15760,32384,15760,23760,15760,15136,19312,10224,
+ 22864,5312,29072,5312,35280,5312,38824,10224,42368,15136,42368,23760,15760,40368,18240,44624,22000,46688,25760,48752,
+ 30976,48752,39648,48752,45072,41864,50496,34976,50496,23760,50496,12544,45072,5656,39648,-1232,30976,-1232,25760,-1232,
+ 22000,832,18240,2896,15760,7136,15760,0,7904,0,7904,66128,15760,66128,15760,40368,42464,45776,42464,38464,
+ 39136,40288,35800,41200,32464,42112,29072,42112,21456,42112,17248,37288,13040,32464,13040,23760,13040,15040,17248,10216,
+ 21456,5392,29072,5392,32464,5392,35800,6312,39136,7232,42464,9056,42464,1824,39184,304,35680,-464,32176,-1232,
+ 28224,-1232,17472,-1232,11136,5528,4800,12288,4800,23760,4800,35408,11200,42080,17600,48752,28736,48752,32336,48752,
+ 35784,48008,39232,47264,42464,45776,39520,40368,39520,66128,47344,66128,47344,0,39520,0,39520,7136,37056,2896,
+ 33296,832,29536,-1232,24272,-1232,15648,-1232,10224,5656,4800,12544,4800,23760,4800,34976,10224,41864,15648,48752,
+ 24272,48752,29536,48752,33296,46688,37056,44624,39520,40368,12880,23760,12880,15136,16424,10224,19968,5312,26176,5312,
+ 32384,5312,35952,10224,39520,15136,39520,23760,39520,32384,35952,37296,32384,42208,26176,42208,19968,42208,16424,37296,
+ 12880,32384,12880,23760,48912,25760,48912,21936,12960,21936,13472,13856,17832,9624,22192,5392,29968,5392,34464,5392,
+ 38696,6496,42928,7600,47088,9824,47088,2416,42880,640,38464,-296,34048,-1232,29488,-1232,18112,-1232,11456,5400,
+ 4800,12032,4800,23328,4800,35024,11112,41888,17424,48752,28128,48752,37744,48752,43328,42568,48912,36384,48912,25760,
+ 41104,28048,41008,34464,37504,38288,34000,42112,28224,42112,21680,42112,17744,38416,13808,34720,13216,28000,41104,28048,
+ 32304,66128,32304,59632,24816,59632,20608,59632,18976,57928,17344,56224,17344,51808,17344,47600,30224,47600,30224,41520,
+ 17344,41520,17344,0,9472,0,9472,41520,2000,41520,2000,47600,9472,47600,9472,50912,9472,58864,13176,62496,
+ 16880,66128,24912,66128,32304,66128,39520,24352,39520,32848,36016,37528,32512,42208,26176,42208,19888,42208,16384,37528,
+ 12880,32848,12880,24352,12880,15888,16384,11216,19888,6544,26176,6544,32512,6544,36016,11216,39520,15888,39520,24352,
+ 47344,5904,47344,-6240,41944,-12176,36544,-18112,25408,-18112,21296,-18112,17640,-17496,13984,-16880,10544,-15600,10544,-7984,
+ 13984,-9856,17344,-10752,20704,-11648,24176,-11648,31872,-11648,35696,-7632,39520,-3616,39520,4512,39520,8368,37104,4160,
+ 33320,2080,29536,0,24272,0,15520,0,10160,6672,4800,13344,4800,24352,4800,35408,10160,42080,15520,48752,
+ 24272,48752,29536,48752,33320,46664,37104,44576,39520,40368,39520,47600,47344,47600,47344,5904,47776,28736,47776,0,
+ 39952,0,39952,28480,39952,35232,37320,38592,34688,41952,29408,41952,23072,41952,19416,37912,15760,33872,15760,26896,
+ 15760,0,7904,0,7904,66128,15760,66128,15760,40208,18576,44496,22376,46624,26176,48752,31152,48752,39360,48752,
+ 43568,43672,47776,38592,47776,28736,8208,47600,16016,47600,16016,0,8208,0,8208,47600,8208,66128,16016,66128,
+ 16016,56224,8208,56224,8208,66128,8208,47600,16016,47600,16016,-848,16016,-9952,12552,-14032,9088,-18112,1408,-18112,
+ -1568,-18112,-1568,-11472,512,-11472,4976,-11472,6592,-9416,8208,-7360,8208,-848,8208,47600,8208,66128,16016,66128,
+ 16016,56224,8208,56224,8208,66128,7904,66128,15760,66128,15760,27072,39104,47600,49088,47600,23840,25328,50144,0,
+ 39952,0,15760,23248,15760,0,7904,0,7904,66128,8208,66128,16016,66128,16016,0,8208,0,8208,66128,
+ 45264,38464,48192,43728,52272,46240,56352,48752,61888,48752,69312,48752,73352,43544,77392,38336,77392,28736,77392,0,
+ 69536,0,69536,28480,69536,35312,67112,38632,64688,41952,59712,41952,53632,41952,50104,37912,46576,33872,46576,26896,
+ 46576,0,38720,0,38720,28480,38720,35360,36296,38656,33872,41952,28816,41952,22816,41952,19288,37888,15760,33824,
+ 15760,26896,15760,0,7904,0,7904,47600,15760,47600,15760,40208,18448,44576,22184,46664,25920,48752,31072,48752,
+ 36256,48752,39888,46112,43520,43472,45264,38464,47776,28736,47776,0,39952,0,39952,28480,39952,35232,37320,38592,
+ 34688,41952,29408,41952,23072,41952,19416,37912,15760,33872,15760,26896,15760,0,7904,0,7904,47600,15760,47600,
+ 15760,40208,18576,44496,22376,46624,26176,48752,31152,48752,39360,48752,43568,43672,47776,38592,47776,28736,26640,42112,
+ 20352,42112,16696,37208,13040,32304,13040,23760,13040,15216,16680,10304,20320,5392,26640,5392,32896,5392,36552,10328,
+ 40208,15264,40208,23760,40208,32208,36552,37160,32896,42112,26640,42112,26640,48752,36848,48752,42672,42120,48496,35488,
+ 48496,23760,48496,12064,42672,5416,36848,-1232,26640,-1232,16400,-1232,10600,5416,4800,12064,4800,23760,4800,35488,
+ 10600,42120,16400,48752,26640,48752,15760,7136,15760,-18112,7904,-18112,7904,47600,15760,47600,15760,40368,18240,44624,
+ 22000,46688,25760,48752,30976,48752,39648,48752,45072,41864,50496,34976,50496,23760,50496,12544,45072,5656,39648,-1232,
+ 30976,-1232,25760,-1232,22000,832,18240,2896,15760,7136,42368,23760,42368,32384,38824,37296,35280,42208,29072,42208,
+ 22864,42208,19312,37296,15760,32384,15760,23760,15760,15136,19312,10224,22864,5312,29072,5312,35280,5312,38824,10224,
+ 42368,15136,42368,23760,12880,23760,12880,15136,16424,10224,19968,5312,26176,5312,32384,5312,35952,10224,39520,15136,
+ 39520,23760,39520,32384,35952,37296,32384,42208,26176,42208,19968,42208,16424,37296,12880,32384,12880,23760,39520,7136,
+ 37056,2896,33296,832,29536,-1232,24272,-1232,15648,-1232,10224,5656,4800,12544,4800,23760,4800,34976,10224,41864,
+ 15648,48752,24272,48752,29536,48752,33296,46688,37056,44624,39520,40368,39520,47600,47344,47600,47344,-18112,39520,-18112,
+ 39520,7136,35792,40288,34464,41056,32912,41416,31360,41776,29488,41776,22864,41776,19312,37464,15760,33152,15760,25072,
+ 15760,0,7904,0,7904,47600,15760,47600,15760,40208,18240,44544,22192,46648,26144,48752,31792,48752,32592,48752,
+ 33576,48640,34560,48528,35744,48320,35792,40288,38544,46192,38544,38800,35232,40496,31664,41352,28096,42208,24272,42208,
+ 18448,42208,15536,40424,12624,38640,12624,35056,12624,32336,14704,30792,16784,29248,23072,27840,25760,27248,34080,25456,
+ 37592,22208,41104,18960,41104,13136,41104,6496,35856,2632,30608,-1232,21424,-1232,17600,-1232,13456,-488,9312,256,
+ 4720,1744,4720,9824,9056,7568,13264,6440,17472,5312,21584,5312,27120,5312,30096,7200,33072,9088,33072,12544,
+ 33072,15728,30920,17424,28768,19120,21504,20704,18784,21328,11520,22864,8288,26032,5056,29200,5056,34720,5056,41440,
+ 9816,45096,14576,48752,23328,48752,27664,48752,31488,48112,35312,47472,38544,46192,15936,61120,15936,47600,32048,47600,
+ 32048,41520,15936,41520,15936,15680,15936,9856,17528,8200,19120,6544,24016,6544,32048,6544,32048,0,24016,0,
+ 14960,0,11520,3376,8080,6752,8080,15680,8080,41520,2336,41520,2336,47600,8080,47600,8080,61120,15936,61120,
+ 7392,18784,7392,47600,15216,47600,15216,19088,15216,12320,17848,8944,20480,5568,25760,5568,32080,5568,35760,9608,
+ 39440,13648,39440,20608,39440,47600,47264,47600,47264,0,39440,0,39440,7312,36592,2976,32832,872,29072,-1232,
+ 24096,-1232,15888,-1232,11640,3864,7392,8960,7392,18784,27072,48752,27072,48752,2592,47600,10880,47600,25760,7648,
+ 40624,47600,48912,47600,31072,0,20448,0,2592,47600,3648,47600,11472,47600,21248,10448,30976,47600,40208,47600,
+ 49984,10448,59712,47600,67536,47600,55088,0,45856,0,35616,39008,25328,0,16112,0,3648,47600,47776,47600,
+ 30560,24432,48656,0,39440,0,25584,18704,11728,0,2512,0,20992,24912,4080,47600,13296,47600,25920,30640,
+ 38544,47600,47776,47600,28000,-4416,24688,-12928,21544,-15520,18400,-18112,13136,-18112,6880,-18112,6880,-11568,11472,-11568,
+ 14704,-11568,16488,-10032,18272,-8496,20448,-2800,21840,768,2592,47600,10880,47600,25760,10368,40624,47600,48912,47600,
+ 28000,-4416,4800,47600,41952,47600,41952,40464,12544,6240,41952,6240,41952,0,3744,0,3744,7136,33152,41360,
+ 4800,41360,4800,47600,44496,-8080,44496,-14192,41856,-14192,31280,-14192,27688,-11048,24096,-7904,24096,1488,24096,11648,
+ 24096,18064,21800,20528,19504,22992,13472,22992,10880,22992,10880,29072,13472,29072,19552,29072,21824,31512,24096,33952,
+ 24096,40288,24096,50496,24096,59888,27688,63008,31280,66128,41856,66128,44496,66128,44496,60048,41600,60048,35616,60048,
+ 33792,58184,31968,56320,31968,50320,31968,39776,31968,33104,30032,30088,28096,27072,23424,26016,28128,24864,30048,21848,
+ 31968,18832,31968,12192,31968,1664,31968,-4336,33792,-6208,35616,-8080,41600,-8080,44496,-8080,18272,66512,18272,-20528,
+ 11056,-20528,11056,66512,18272,66512,10880,-8080,13856,-8080,19808,-8080,21616,-6248,23424,-4416,23424,1664,23424,12192,
+ 23424,18832,25336,21848,27248,24864,31968,26016,27248,27072,25336,30088,23424,33104,23424,39776,23424,50320,23424,56352,
+ 21616,58200,19808,60048,13856,60048,10880,60048,10880,66128,13552,66128,24144,66128,27688,63008,31232,59888,31232,50496,
+ 31232,40288,31232,33952,33528,31512,35824,29072,41856,29072,44496,29072,44496,22992,41856,22992,35824,22992,33528,20528,
+ 31232,18064,31232,11648,31232,1488,31232,-7904,27688,-11048,24144,-14192,13552,-14192,10880,-14192,10880,-8080,63712,34720,
+ 63712,27152,59248,23808,55440,22360,51632,20912,47520,20912,42848,20912,36640,23424,36160,23584,35952,23680,35664,23808,
+ 35024,24016,28432,26640,24432,26640,20704,26640,17048,25008,13392,23376,9216,19840,9216,27408,13680,30768,17488,32232,
+ 21296,33696,25408,33696,30096,33696,36336,31152,36768,30976,36976,30896,37312,30768,37904,30560,44496,27920,48496,27920,
+ 52144,27920,55736,29536,59328,31152,63712,34720,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,
+ 43008,-10544,43008,56480,9216,56480,9216,-10544,21760,52656,13136,52656,13136,63456,21760,63456,21760,52656,21760,0,
+ 13136,0,13136,27840,14032,43008,20912,43008,21760,27840,21760,0,28816,5568,28816,41952,22560,41184,19080,36384,
+ 15600,31584,15600,23760,15600,15888,19080,11088,22560,6288,28816,5568,45008,45776,45008,38464,41856,40208,38968,41096,
+ 36080,41984,33200,42112,33152,5392,36128,5616,39040,6504,41952,7392,45008,9056,45008,1824,42240,560,39328,-184,
+ 36416,-928,33152,-1232,33152,-13296,28816,-13296,28816,-1056,18576,-208,12944,6312,7312,12832,7312,23760,7312,34720,
+ 12944,41224,18576,47728,28816,48656,28816,60864,33152,60864,33200,48656,36288,48496,39200,47792,42112,47088,45008,45776,
+ 46832,62048,46832,54320,43600,56064,40712,56936,37824,57808,35232,57808,28944,57808,26480,54512,24016,51216,24016,42208,
+ 24016,33072,40624,33072,40624,26992,24016,26992,24016,7232,47680,7232,47680,0,5488,0,5488,7232,15520,7232,
+ 15520,26992,7056,26992,7056,33072,15520,33072,15520,43184,15520,54272,20064,59440,24608,64608,34464,64608,37056,64608,
+ 40264,63944,43472,63280,46832,62048,37872,42208,46672,51088,51504,46192,42752,37440,44320,34928,45088,32400,45856,29872,
+ 45856,27248,45856,24560,45048,22120,44240,19680,42544,17248,51424,8464,46576,3648,37776,12448,35280,10752,32816,9944,
+ 30352,9136,27760,9136,25280,9136,22736,9920,20192,10704,17600,12288,8800,3488,4000,8368,12800,17120,11216,19760,
+ 10432,22272,9648,24784,9648,27248,9648,29968,10456,32432,11264,34896,12880,37280,4080,46032,8960,50912,17760,42112,
+ 20096,43776,22568,44560,25040,45344,27760,45344,30304,45344,32792,44584,35280,43824,37872,42208,39184,27328,39184,32080,
+ 35888,35360,32592,38640,27760,38640,22992,38640,19632,35360,16272,32080,16272,27328,16272,22480,19608,19168,22944,15856,
+ 27760,15856,32560,15856,35872,19192,39184,22528,39184,27328,49520,19344,31968,19344,31968,0,23424,0,23424,19344,
+ 5744,19344,5744,24560,23424,24560,23424,26736,19840,33328,5744,33328,5744,38544,16960,38544,3488,63456,11568,63456,
+ 27664,33696,43696,63456,51808,63456,38288,38544,49520,38544,49520,33328,35440,33328,31872,26736,31872,24560,49520,24560,
+ 49520,19344,18272,17344,18272,-14880,11056,-14880,11056,17344,18272,17344,18272,60864,18272,28640,11056,28640,11056,60864,
+ 18272,60864,16112,39776,13424,37824,12112,35912,10800,34000,10800,32048,10800,28816,13752,25992,16704,23168,27328,17424,
+ 30000,19344,31320,21272,32640,23200,32640,25168,32640,28352,29600,31240,26560,34128,16112,39776,35232,62128,35232,55168,
+ 31712,56816,28672,57648,25632,58480,23248,58480,19120,58480,16824,56784,14528,55088,14528,52064,14528,48240,23296,43344,
+ 24400,42720,24992,42368,33952,37312,36736,34040,39520,30768,39520,26480,39520,22656,37568,19680,35616,16704,31664,14448,
+ 34304,12240,35512,9920,36720,7600,36720,4880,36720,-1152,32384,-4720,28048,-8288,20704,-8288,17600,-8288,14328,-7672,
+ 11056,-7056,7312,-5824,7312,1152,11008,-512,14152,-1336,17296,-2160,19760,-2160,24096,-2160,26496,-376,28896,1408,
+ 28896,4640,28896,8960,19504,14192,18448,14784,9344,19888,6624,23144,3904,26400,3904,30720,3904,34592,5880,37632,
+ 7856,40672,11728,42752,9216,44624,7968,47008,6720,49392,6720,52320,6720,57840,10968,61224,15216,64608,22272,64608,
+ 25376,64608,28624,63984,31872,63360,35232,62128,25760,65968,34384,65968,34384,57376,25760,57376,25760,65968,9136,65968,
+ 17760,65968,17760,57376,9136,57376,9136,65968,43520,63120,49984,63120,55568,60776,61152,58432,65792,53808,70416,49168,
+ 72712,43600,75008,38032,75008,31488,75008,25040,72712,19488,70416,13936,65792,9312,61152,4672,55568,2336,49984,0,
+ 43520,0,37056,0,31472,2336,25888,4672,21248,9312,16624,13936,14328,19488,12032,25040,12032,31488,12032,38032,
+ 14328,43600,16624,49168,21248,53808,25888,58432,31472,60776,37056,63120,43520,63120,43520,58736,37952,58736,33152,56736,
+ 28352,54736,24352,50752,20352,46752,18312,41888,16272,37024,16272,31488,16272,26016,18312,21192,20352,16368,24352,12368,
+ 28352,8368,33152,6352,37952,4336,43520,4336,49136,4336,53960,6352,58784,8368,62768,12368,66720,16320,68696,21120,
+ 70672,25920,70672,31488,70672,37152,68680,41976,66688,46800,62768,50752,58784,54736,53960,56736,49136,58736,43520,58736,
+ 56224,48320,56224,42848,53424,44240,50664,44920,47904,45600,45088,45600,38768,45600,35216,41880,31664,38160,31664,31488,
+ 31664,24736,35296,21040,38928,17344,45520,17344,48240,17344,50832,18000,53424,18656,56224,20096,56224,14704,53376,13472,
+ 50464,12880,47552,12288,44576,12288,35408,12288,30072,17472,24736,22656,24736,31488,24736,40368,30072,45512,35408,50656,
+ 44576,50656,47680,50656,50576,50064,53472,49472,56224,48320,5904,25168,35152,25168,35152,19936,5904,19936,5904,25168,
+ 35056,49520,35056,30480,28736,30480,28736,35232,26864,32560,23800,31112,20736,29664,16784,29664,11344,29664,8112,32536,
+ 4880,35408,4880,40208,4880,45936,8944,48872,13008,51808,20992,51808,28736,51808,28736,51984,28736,55840,26248,57776,
+ 23760,59712,18784,59712,16144,59712,13256,58992,10368,58272,7488,56816,7488,62224,10576,63408,13664,64008,16752,64608,
+ 19680,64608,27456,64608,31256,60864,35056,57120,35056,49520,23328,46928,16496,46928,13816,45504,11136,44080,11136,40720,
+ 11136,38000,13216,36360,15296,34720,18784,34720,23200,34720,25968,37784,28736,40848,28736,45680,28736,46928,23328,46928,
+ 45088,45008,45088,36896,32304,25504,45088,14112,45088,6000,25168,23760,25168,27248,45088,45008,26640,45008,26640,36896,
+ 13856,25504,26640,14112,26640,6000,6720,23760,6720,27248,26640,45008,9216,36640,63712,36640,63712,12192,56560,12192,
+ 56560,29408,9216,29408,9216,36640,4256,27328,27152,27328,27152,20352,4256,20352,4256,27328,43520,58736,37952,58736,
+ 33152,56736,28352,54736,24352,50752,20352,46752,18312,41888,16272,37024,16272,31488,16272,26016,18312,21192,20352,16368,
+ 24352,12368,28352,8368,33152,6352,37952,4336,43520,4336,49136,4336,53960,6352,58784,8368,62768,12368,66720,16320,
+ 68696,21120,70672,25920,70672,31488,70672,37152,68680,41976,66688,46800,62768,50752,58784,54736,53960,56736,49136,58736,
+ 43520,58736,43520,63120,49984,63120,55568,60776,61152,58432,65792,53808,70416,49168,72712,43600,75008,38032,75008,31488,
+ 75008,25040,72712,19488,70416,13936,65792,9312,61152,4672,55568,2336,49984,0,43520,0,37056,0,31472,2336,
+ 25888,4672,21248,9312,16624,13936,14328,19488,12032,25040,12032,31488,12032,38032,14328,43600,16624,49168,21248,53808,
+ 25888,58432,31472,60776,37056,63120,43520,63120,42368,45520,37152,45520,37152,33792,42368,33792,47040,33792,48896,35104,
+ 50752,36416,50752,39616,50752,42848,48880,44184,47008,45520,42368,45520,42672,49888,50144,49888,53848,47360,57552,44832,
+ 57552,39696,57552,36048,55320,33664,53088,31280,49008,30560,50016,30224,51440,28584,52864,26944,54832,23840,60640,14368,
+ 53344,14368,47856,23248,45344,27328,43792,28408,42240,29488,39952,29488,37152,29488,37152,14368,30560,14368,30560,49888,
+ 42672,49888,9056,64848,34464,64848,34464,58560,9056,58560,9056,64848,21760,59120,18368,59120,16024,56760,13680,54400,
+ 13680,51008,13680,47648,16024,45328,18368,43008,21760,43008,25168,43008,27504,45328,29840,47648,29840,51008,29840,54352,
+ 27480,56736,25120,59120,21760,59120,21760,64608,24480,64608,26984,63560,29488,62512,31328,60560,33280,58656,34256,56232,
+ 35232,53808,35232,51008,35232,45392,31304,41504,27376,37616,21680,37616,15936,37616,12112,41440,8288,45264,8288,51008,
+ 8288,56688,12200,60648,16112,64608,21760,64608,40032,54576,40032,38128,63712,38128,63712,30896,40032,30896,40032,14448,
+ 32896,14448,32896,30896,9216,30896,9216,38128,32896,38128,32896,54576,40032,54576,9216,7232,63712,7232,63712,0,
+ 9216,0,9216,7232,11392,33232,29408,33232,29408,28384,4000,28384,4000,33072,5440,34384,8112,36768,22736,49728,
+ 22736,53728,22736,56528,20528,58248,18320,59968,14704,59968,12496,59968,9904,59224,7312,58480,4256,56992,4256,62224,
+ 7520,63408,10344,64008,13168,64608,15600,64608,21760,64608,25456,61800,29152,58992,29152,54400,29152,48496,15088,36416,
+ 12704,34384,11392,33232,22272,47600,26176,46832,28328,44520,30480,42208,30480,38720,30480,33440,26440,30600,22400,27760,
+ 14880,27760,12448,27760,9792,28200,7136,28640,4160,29488,4160,34640,6368,33488,8904,32936,11440,32384,14288,32384,
+ 18912,32384,21464,34064,24016,35744,24016,38720,24016,41856,21656,43472,19296,45088,14704,45088,11056,45088,11056,49680,
+ 15040,49680,19040,49680,21104,51024,23168,52368,23168,54912,23168,57376,21040,58672,18912,59968,14880,59968,13168,59968,
+ 11008,59584,8848,59200,5392,58224,5392,63120,8496,63840,11216,64224,13936,64608,16272,64608,22400,64608,25992,62096,
+ 29584,59584,29584,55376,29584,52448,27672,50408,25760,48368,22272,47600,27664,69616,36128,69616,22272,53632,15760,53632,
+ 27664,69616,7392,-18112,7392,47600,15216,47600,15216,18016,15216,11856,18152,8712,21088,5568,26816,5568,33104,5568,
+ 36272,9136,39440,12704,39440,19840,39440,47600,47264,47600,47264,10960,47264,8416,48008,7208,48752,6000,50320,6000,
+ 50704,6000,51384,6232,52064,6464,53248,6976,53248,688,51504,-304,49952,-768,48400,-1232,46928,-1232,43984,-1232,
+ 42240,424,40496,2080,39872,5488,37744,2128,34664,448,31584,-1232,27408,-1232,23072,-1232,20040,424,17008,2080,
+ 15216,5392,15216,-18112,7392,-18112,26896,63456,45936,63456,45936,-8368,39952,-8368,39952,58224,31872,58224,31872,-8368,
+ 25840,-8368,25840,27584,16704,28304,11712,33000,6720,37696,6720,45520,6720,53600,12240,58528,17760,63456,26896,63456,
+ 9312,35616,18272,35616,18272,24816,9312,24816,9312,35616,25328,0,27664,-2640,28816,-4872,29968,-7104,29968,-9136,
+ 29968,-12928,27416,-14856,24864,-16784,19840,-16784,17888,-16784,16040,-16528,14192,-16272,12368,-15760,12368,-10208,13808,-10928,
+ 15384,-11248,16960,-11568,18960,-11568,21456,-11568,22736,-10544,24016,-9520,24016,-7568,24016,-6288,23104,-4440,22192,-2592,
+ 20272,0,25328,0,6624,33072,15296,33072,15296,59040,5824,57296,5824,62224,15600,63872,21424,63872,21424,33072,
+ 30128,33072,30128,28384,6624,28384,6624,33072,5904,25168,35152,25168,35152,19936,5904,19936,5904,25168,20528,64608,
+ 28128,64608,32512,59904,36896,55200,36896,47088,36896,38976,32512,34320,28128,29664,20528,29664,12928,29664,8504,34336,
+ 4080,39008,4080,47088,4080,55200,8504,59904,12928,64608,20528,64608,20528,59712,16064,59712,13384,56288,10704,52864,
+ 10704,47088,10704,41440,13408,38040,16112,34640,20528,34640,24992,34640,27648,38040,30304,41440,30304,47088,30304,52912,
+ 27672,56312,25040,59712,20528,59712,8208,45008,28128,27248,28128,23760,8208,6000,8208,14112,20992,25504,8208,36896,
+ 8208,45008,26640,45008,46576,27248,46576,23760,26640,6000,26640,14112,39440,25504,26640,36896,26640,45008,6624,33072,
+ 15296,33072,15296,59040,5824,57296,5824,62224,15600,63872,21424,63872,21424,33072,30128,33072,30128,28384,6624,28384,
+ 6624,33072,69424,30064,56288,12256,69424,12256,69424,30064,68496,35200,75552,35200,75552,12256,81280,12256,81280,7616,
+ 75552,7616,75552,-288,69424,-288,69424,7616,51824,7616,51824,12768,68496,35200,58496,64608,65296,64608,25680,-1232,
+ 18880,-1232,58496,64608,6624,33072,15296,33072,15296,59040,5824,57296,5824,62224,15600,63872,21424,63872,21424,33072,
+ 30128,33072,30128,28384,6624,28384,6624,33072,60544,4560,78560,4560,78560,-288,53152,-288,53152,4400,54592,5712,
+ 57264,8096,71888,21056,71888,25056,71888,27856,69680,29576,67472,31296,63856,31296,61648,31296,59056,30552,56464,29808,
+ 53408,28320,53408,33552,56672,34736,59496,35336,62320,35936,64752,35936,70912,35936,74608,33128,78304,30320,78304,25728,
+ 78304,19824,64240,7744,61856,5712,60544,4560,58496,64608,65296,64608,25680,-1232,18880,-1232,58496,64608,22272,47600,
+ 26176,46832,28328,44520,30480,42208,30480,38720,30480,33440,26440,30600,22400,27760,14880,27760,12448,27760,9792,28200,
+ 7136,28640,4160,29488,4160,34640,6368,33488,8904,32936,11440,32384,14288,32384,18912,32384,21464,34064,24016,35744,
+ 24016,38720,24016,41856,21656,43472,19296,45088,14704,45088,11056,45088,11056,49680,15040,49680,19040,49680,21104,51024,
+ 23168,52368,23168,54912,23168,57376,21040,58672,18912,59968,14880,59968,13168,59968,11008,59584,8848,59200,5392,58224,
+ 5392,63120,8496,63840,11216,64224,13936,64608,16272,64608,22400,64608,25992,62096,29584,59584,29584,55376,29584,52448,
+ 27672,50408,25760,48368,22272,47600,69424,30064,56288,12256,69424,12256,69424,30064,68496,35200,75552,35200,75552,12256,
+ 81280,12256,81280,7616,75552,7616,75552,-288,69424,-288,69424,7616,51824,7616,51824,12768,68496,35200,58496,64608,
+ 65296,64608,25680,-1232,18880,-1232,58496,64608,21248,46416,29328,46416,29328,39776,29328,35488,28160,32728,26992,29968,
+ 23168,26272,19344,22528,16880,20272,15792,18272,14704,16272,14704,14192,14704,10416,17488,8080,20272,5744,24912,5744,
+ 28224,5744,32048,7232,35872,8720,39952,11568,39952,3568,35952,1152,31872,-40,27792,-1232,23424,-1232,15600,-1232,
+ 10840,2888,6080,7008,6080,13776,6080,17008,7632,19912,9184,22816,12960,26480,16704,30128,18736,32128,19544,33256,
+ 20352,34384,20704,35440,20992,36336,21120,37608,21248,38880,21248,41184,21248,46416,29584,52656,20992,52656,20992,63456,
+ 29584,63456,29584,52656,29744,54992,18112,23424,41440,23424,29744,54992,24912,63456,34640,63456,58816,0,49888,0,
+ 44112,16272,15520,16272,9728,0,688,0,24912,63456,27024,80208,35344,68992,28848,68992,19072,80208,27024,80208,
+ 29744,54992,18112,23424,41440,23424,29744,54992,24912,63456,34640,63456,58816,0,49888,0,44112,16272,15520,16272,
+ 9728,0,688,0,24912,63456,31776,80208,39632,80208,29952,68992,23440,68992,31776,80208,29744,54992,18112,23424,
+ 41440,23424,29744,54992,24912,63456,34640,63456,58816,0,49888,0,44112,16272,15520,16272,9728,0,688,0,
+ 24912,63456,25440,80304,33440,80304,42400,68992,36496,68992,29440,76560,22384,68992,16480,68992,25440,80304,29744,54992,
+ 18112,23424,41440,23424,29744,54992,24912,63456,34640,63456,58816,0,49888,0,44112,16272,15520,16272,9728,0,
+ 688,0,24912,63456,29264,72176,26848,73584,25792,74176,25128,74408,24464,74640,23952,74640,22432,74640,21576,73584,
+ 20720,72528,20720,70608,20720,70352,15408,70352,15408,74640,17600,77152,19792,79664,23440,79664,24976,79664,26272,79320,
+ 27568,78976,29616,77840,32032,76560,33008,76000,33728,75752,34448,75504,35088,75504,36448,75504,37304,76584,38160,77664,
+ 38160,79408,38160,79664,43472,79664,43376,75408,41192,72880,39008,70352,35440,70352,33984,70352,32728,70696,31472,71040,
+ 29264,72176,29744,54992,18112,23424,41440,23424,29744,54992,24912,63456,34640,63456,58816,0,49888,0,44112,16272,
+ 15520,16272,9728,0,688,0,24912,63456,33440,78976,42064,78976,42064,70352,33440,70352,33440,78976,16816,78976,
+ 25440,78976,25440,70352,16816,70352,16816,78976,36208,69104,36208,71776,34320,73672,32432,75568,29744,75568,27024,75568,
+ 25176,73720,23328,71872,23328,69104,23328,66432,25200,64560,27072,62688,29744,62688,32432,62688,34320,64560,36208,66432,
+ 36208,69104,29744,54992,18192,23424,41360,23424,29744,54992,23328,59376,20736,61120,19424,63560,18112,66000,18112,69104,
+ 18112,74000,21488,77400,24864,80800,29744,80800,34592,80800,38016,77376,41440,73952,41440,69104,41440,66128,40104,63624,
+ 38768,61120,36208,59376,58816,0,49888,0,44112,16272,15520,16272,9728,0,688,0,23328,59376,78416,63456,
+ 78416,56224,46928,56224,46928,37440,77136,37440,77136,30224,46928,30224,46928,7232,79216,7232,79216,0,38288,0,
+ 38288,16272,15856,16272,9056,0,336,0,26896,63456,78416,63456,32816,56736,18784,23424,38288,23424,38288,56736,
+ 32816,56736,56064,58560,56064,49520,51728,53552,46816,55552,41904,57552,36384,57552,25504,57552,19720,50896,13936,44240,
+ 13936,31664,13936,19120,19720,12472,25504,5824,36384,5824,41904,5824,46816,7824,51728,9824,56064,13856,56064,4880,
+ 51552,1824,46520,296,41488,-1232,35872,-1232,21456,-1232,13168,7584,4880,16400,4880,31664,4880,46960,13168,55784,
+ 21456,64608,35872,64608,41568,64608,46600,63096,51632,61584,56064,58560,38640,0,40976,-2640,42128,-4872,43280,-7104,
+ 43280,-9136,43280,-12928,40728,-14856,38176,-16784,33152,-16784,31200,-16784,29352,-16528,27504,-16272,25680,-15760,25680,-10208,
+ 27120,-10928,28696,-11248,30272,-11568,32272,-11568,34768,-11568,36048,-10544,37328,-9520,37328,-7568,37328,-6288,36416,-4440,
+ 35504,-2592,33584,0,38640,0,8544,63456,48656,63456,48656,56224,17120,56224,17120,37440,47344,37440,47344,30224,
+ 17120,30224,17120,7232,49424,7232,49424,0,8544,0,8544,63456,26000,80208,34320,68992,27824,68992,18048,80208,
+ 26000,80208,8544,63456,48656,63456,48656,56224,17120,56224,17120,37440,47344,37440,47344,30224,17120,30224,17120,7232,
+ 49424,7232,49424,0,8544,0,8544,63456,30752,80208,38608,80208,28928,68992,22416,68992,30752,80208,8544,63456,
+ 48656,63456,48656,56224,17120,56224,17120,37440,47344,37440,47344,30224,17120,30224,17120,7232,49424,7232,49424,0,
+ 8544,0,8544,63456,24416,80304,32416,80304,41376,68992,35472,68992,28416,76560,21360,68992,15456,68992,24416,80304,
+ 8544,63456,48656,63456,48656,56224,17120,56224,17120,37440,47344,37440,47344,30224,17120,30224,17120,7232,49424,7232,
+ 49424,0,8544,0,8544,63456,32416,78976,41040,78976,41040,70352,32416,70352,32416,78976,15792,78976,24416,78976,
+ 24416,70352,15792,70352,15792,78976,8544,63456,17120,63456,17120,0,8544,0,8544,63456,10640,80208,18960,68992,
+ 12464,68992,2688,80208,10640,80208,8544,63456,17120,63456,17120,0,8544,0,8544,63456,15392,80208,23248,80208,
+ 13568,68992,7056,68992,15392,80208,8544,63456,17120,63456,17120,0,8544,0,8544,63456,9056,80304,17056,80304,
+ 26016,68992,20112,68992,13056,76560,6000,68992,96,68992,9056,80304,8544,63456,17120,63456,17120,0,8544,0,
+ 8544,63456,17056,78976,25680,78976,25680,70352,17056,70352,17056,78976,432,78976,9056,78976,9056,70352,432,70352,
+ 432,78976,8960,63456,26640,63456,45056,63456,53680,55784,62304,48112,62304,31792,62304,15392,53656,7696,45008,0,
+ 26640,0,8960,0,8960,29744,432,29744,432,35872,8960,35872,8960,63456,17600,56400,17600,35872,31872,35872,
+ 31872,29744,17600,29744,17600,7056,27920,7056,41056,7056,47152,13008,53248,18960,53248,31792,53248,44544,47152,50472,
+ 41056,56400,27920,56400,17600,56400,8544,63456,20096,63456,48240,10368,48240,63456,56560,63456,56560,0,45008,0,
+ 16880,53088,16880,0,8544,0,8544,63456,32336,72176,29920,73584,28864,74176,28200,74408,27536,74640,27024,74640,
+ 25504,74640,24648,73584,23792,72528,23792,70608,23792,70352,18480,70352,18480,74640,20672,77152,22864,79664,26512,79664,
+ 28048,79664,29344,79320,30640,78976,32688,77840,35104,76560,36080,76000,36800,75752,37520,75504,38160,75504,39520,75504,
+ 40376,76584,41232,77664,41232,79408,41232,79664,46544,79664,46448,75408,44264,72880,42080,70352,38512,70352,37056,70352,
+ 35800,70696,34544,71040,32336,72176,34304,57632,24944,57632,19440,50664,13936,43696,13936,31664,13936,19680,19440,12712,
+ 24944,5744,34304,5744,43648,5744,49112,12712,54576,19680,54576,31664,54576,43696,49112,50664,43648,57632,34304,57632,
+ 34304,64608,47648,64608,55632,55656,63616,46704,63616,31664,63616,16656,55632,7712,47648,-1232,34304,-1232,20912,-1232,
+ 12896,7696,4880,16624,4880,31664,4880,46704,12896,55656,20912,64608,34304,64608,32144,80208,40464,68992,33968,68992,
+ 24192,80208,32144,80208,34304,57632,24944,57632,19440,50664,13936,43696,13936,31664,13936,19680,19440,12712,24944,5744,
+ 34304,5744,43648,5744,49112,12712,54576,19680,54576,31664,54576,43696,49112,50664,43648,57632,34304,57632,34304,64608,
+ 47648,64608,55632,55656,63616,46704,63616,31664,63616,16656,55632,7712,47648,-1232,34304,-1232,20912,-1232,12896,7696,
+ 4880,16624,4880,31664,4880,46704,12896,55656,20912,64608,34304,64608,36896,80208,44752,80208,35072,68992,28560,68992,
+ 36896,80208,34304,57632,24944,57632,19440,50664,13936,43696,13936,31664,13936,19680,19440,12712,24944,5744,34304,5744,
+ 43648,5744,49112,12712,54576,19680,54576,31664,54576,43696,49112,50664,43648,57632,34304,57632,34304,64608,47648,64608,
+ 55632,55656,63616,46704,63616,31664,63616,16656,55632,7712,47648,-1232,34304,-1232,20912,-1232,12896,7696,4880,16624,
+ 4880,31664,4880,46704,12896,55656,20912,64608,34304,64608,30560,80304,38560,80304,47520,68992,41616,68992,34560,76560,
+ 27504,68992,21600,68992,30560,80304,34304,57632,24944,57632,19440,50664,13936,43696,13936,31664,13936,19680,19440,12712,
+ 24944,5744,34304,5744,43648,5744,49112,12712,54576,19680,54576,31664,54576,43696,49112,50664,43648,57632,34304,57632,
+ 34304,64608,47648,64608,55632,55656,63616,46704,63616,31664,63616,16656,55632,7712,47648,-1232,34304,-1232,20912,-1232,
+ 12896,7696,4880,16624,4880,31664,4880,46704,12896,55656,20912,64608,34304,64608,34384,72176,31968,73584,30912,74176,
+ 30248,74408,29584,74640,29072,74640,27552,74640,26696,73584,25840,72528,25840,70608,25840,70352,20528,70352,20528,74640,
+ 22720,77152,24912,79664,28560,79664,30096,79664,31392,79320,32688,78976,34736,77840,37152,76560,38128,76000,38848,75752,
+ 39568,75504,40208,75504,41568,75504,42424,76584,43280,77664,43280,79408,43280,79664,48592,79664,48496,75408,46312,72880,
+ 44128,70352,40560,70352,39104,70352,37848,70696,36592,71040,34384,72176,34304,57632,24944,57632,19440,50664,13936,43696,
+ 13936,31664,13936,19680,19440,12712,24944,5744,34304,5744,43648,5744,49112,12712,54576,19680,54576,31664,54576,43696,
+ 49112,50664,43648,57632,34304,57632,34304,64608,47648,64608,55632,55656,63616,46704,63616,31664,63616,16656,55632,7712,
+ 47648,-1232,34304,-1232,20912,-1232,12896,7696,4880,16624,4880,31664,4880,46704,12896,55656,20912,64608,34304,64608,
+ 38560,78976,47184,78976,47184,70352,38560,70352,38560,78976,21936,78976,30560,78976,30560,70352,21936,70352,21936,78976,
+ 61024,46752,41600,27248,61024,7824,55968,2672,36464,22192,16960,2672,11936,7824,31328,27248,11936,46752,16960,51888,
+ 36464,32384,55968,51888,61024,46752,51248,47264,20784,11312,23424,8592,26840,7168,30256,5744,34304,5744,43648,5744,
+ 49112,12712,54576,19680,54576,31664,54576,36416,53744,40328,52912,44240,51248,47264,47776,52064,45184,54784,41760,56208,
+ 38336,57632,34304,57632,24944,57632,19440,50664,13936,43696,13936,31664,13936,26896,14768,22904,15600,18912,17248,16016,
+ 47776,52064,11568,9312,8240,13648,6560,19256,4880,24864,4880,31664,4880,46704,12896,55656,20912,64608,34304,64608,
+ 39824,64608,44520,62968,49216,61328,52912,58144,59792,66256,64128,62480,56912,54064,60224,49680,61920,44032,63616,38384,
+ 63616,31664,63616,16656,55632,7712,47648,-1232,34304,-1232,28864,-1232,24168,360,19472,1952,15600,5136,8720,-2976,
+ 4336,768,11568,9312,7568,63456,16192,63456,16192,24912,16192,14704,19888,10224,23584,5744,31872,5744,40128,5744,
+ 43824,10224,47520,14704,47520,24912,47520,63456,56144,63456,56144,23840,56144,11440,50000,5104,43856,-1232,31872,-1232,
+ 19840,-1232,13704,5104,7568,11440,7568,23840,7568,63456,29072,80208,37392,68992,30896,68992,21120,80208,29072,80208,
+ 7568,63456,16192,63456,16192,24912,16192,14704,19888,10224,23584,5744,31872,5744,40128,5744,43824,10224,47520,14704,
+ 47520,24912,47520,63456,56144,63456,56144,23840,56144,11440,50000,5104,43856,-1232,31872,-1232,19840,-1232,13704,5104,
+ 7568,11440,7568,23840,7568,63456,33824,80208,41680,80208,32000,68992,25488,68992,33824,80208,7568,63456,16192,63456,
+ 16192,24912,16192,14704,19888,10224,23584,5744,31872,5744,40128,5744,43824,10224,47520,14704,47520,24912,47520,63456,
+ 56144,63456,56144,23840,56144,11440,50000,5104,43856,-1232,31872,-1232,19840,-1232,13704,5104,7568,11440,7568,23840,
+ 7568,63456,27488,80304,35488,80304,44448,68992,38544,68992,31488,76560,24432,68992,18528,68992,27488,80304,7568,63456,
+ 16192,63456,16192,24912,16192,14704,19888,10224,23584,5744,31872,5744,40128,5744,43824,10224,47520,14704,47520,24912,
+ 47520,63456,56144,63456,56144,23840,56144,11440,50000,5104,43856,-1232,31872,-1232,19840,-1232,13704,5104,7568,11440,
+ 7568,23840,7568,63456,35488,78976,44112,78976,44112,70352,35488,70352,35488,78976,18864,78976,27488,78976,27488,70352,
+ 18864,70352,18864,78976,-176,63456,9056,63456,26640,37360,44112,63456,53344,63456,30896,30224,30896,0,22272,0,
+ 22272,30224,-176,63456,28704,80208,36560,80208,26880,68992,20368,68992,28704,80208,8544,63456,17120,63456,17120,52240,
+ 27920,52240,38592,52240,44056,47456,49520,42672,49520,33328,49520,23968,44056,19168,38592,14368,27920,14368,17120,14368,
+ 17120,0,8544,0,8544,63456,17120,45184,17120,21424,27920,21424,33920,21424,37192,24528,40464,27632,40464,33328,
+ 40464,39008,37208,42096,33952,45184,27920,45184,17120,45184,7904,48320,7904,56816,12984,61472,18064,66128,27328,66128,
+ 36160,66128,40816,61200,45472,56272,45600,46752,39184,46416,35616,43968,32048,41520,32048,37440,32048,35440,33280,33720,
+ 34512,32000,37280,30224,39696,28640,46752,24144,48792,21128,50832,18112,50832,13856,50832,6544,46048,2656,41264,-1232,
+ 32304,-1232,29584,-1232,26696,-704,23808,-176,20704,848,20704,7824,24096,6544,27072,5928,30048,5312,32816,5312,
+ 37744,5312,40296,7328,42848,9344,42848,13216,42848,15888,41592,17680,40336,19472,36048,22096,32128,24432,28048,26944,
+ 26200,29816,24352,32688,24352,36544,24352,41952,27904,45608,31456,49264,37872,50496,37520,54864,34744,57248,31968,59632,
+ 27152,59632,21632,59632,18744,56680,15856,53728,15856,48160,15856,0,7904,0,7904,48320,29840,23920,20352,23920,
+ 16696,21760,13040,19600,13040,14368,13040,10208,15784,7760,18528,5312,23248,5312,29744,5312,33680,9920,37616,14528,
+ 37616,22192,37616,23920,29840,23920,45440,27152,45440,0,37616,0,37616,7232,34928,2896,30936,832,26944,-1232,
+ 21168,-1232,13856,-1232,9544,2872,5232,6976,5232,13856,5232,21888,10608,25968,15984,30048,26640,30048,37616,30048,
+ 37616,30816,37616,36208,34064,39160,30512,42112,24096,42112,20016,42112,16152,41136,12288,40160,8720,38208,8720,45440,
+ 13008,47088,17048,47920,21088,48752,24912,48752,35232,48752,40336,43392,45440,38032,45440,27152,18672,69616,30656,53728,
+ 24160,53728,10304,69616,18672,69616,29840,23920,20352,23920,16696,21760,13040,19600,13040,14368,13040,10208,15784,7760,
+ 18528,5312,23248,5312,29744,5312,33680,9920,37616,14528,37616,22192,37616,23920,29840,23920,45440,27152,45440,0,
+ 37616,0,37616,7232,34928,2896,30936,832,26944,-1232,21168,-1232,13856,-1232,9544,2872,5232,6976,5232,13856,
+ 5232,21888,10608,25968,15984,30048,26640,30048,37616,30048,37616,30816,37616,36208,34064,39160,30512,42112,24096,42112,
+ 20016,42112,16152,41136,12288,40160,8720,38208,8720,45440,13008,47088,17048,47920,21088,48752,24912,48752,35232,48752,
+ 40336,43392,45440,38032,45440,27152,30736,69616,39200,69616,25344,53632,18832,53632,30736,69616,29840,23920,20352,23920,
+ 16696,21760,13040,19600,13040,14368,13040,10208,15784,7760,18528,5312,23248,5312,29744,5312,33680,9920,37616,14528,
+ 37616,22192,37616,23920,29840,23920,45440,27152,45440,0,37616,0,37616,7232,34928,2896,30936,832,26944,-1232,
+ 21168,-1232,13856,-1232,9544,2872,5232,6976,5232,13856,5232,21888,10608,25968,15984,30048,26640,30048,37616,30048,
+ 37616,30816,37616,36208,34064,39160,30512,42112,24096,42112,20016,42112,16152,41136,12288,40160,8720,38208,8720,45440,
+ 13008,47088,17048,47920,21088,48752,24912,48752,35232,48752,40336,43392,45440,38032,45440,27152,21680,69616,27984,69616,
+ 38384,53632,32480,53632,24832,64048,17184,53632,11280,53632,21680,69616,29840,23920,20352,23920,16696,21760,13040,19600,
+ 13040,14368,13040,10208,15784,7760,18528,5312,23248,5312,29744,5312,33680,9920,37616,14528,37616,22192,37616,23920,
+ 29840,23920,45440,27152,45440,0,37616,0,37616,7232,34928,2896,30936,832,26944,-1232,21168,-1232,13856,-1232,
+ 9544,2872,5232,6976,5232,13856,5232,21888,10608,25968,15984,30048,26640,30048,37616,30048,37616,30816,37616,36208,
+ 34064,39160,30512,42112,24096,42112,20016,42112,16152,41136,12288,40160,8720,38208,8720,45440,13008,47088,17048,47920,
+ 21088,48752,24912,48752,35232,48752,40336,43392,45440,38032,45440,27152,24656,58224,22240,60560,21312,61408,20608,61816,
+ 19904,62224,19344,62224,17728,62224,16968,60672,16208,59120,16112,55632,10800,55632,10896,61376,13064,64496,15232,67616,
+ 19088,67616,20704,67616,22064,67024,23424,66432,25008,65024,27424,62688,28352,61840,29056,61432,29760,61024,30320,61024,
+ 31936,61024,32696,62576,33456,64128,33552,67616,38864,67616,38768,61888,36600,58760,34432,55632,30576,55632,28960,55632,
+ 27600,56224,26240,56816,24656,58224,29840,23920,20352,23920,16696,21760,13040,19600,13040,14368,13040,10208,15784,7760,
+ 18528,5312,23248,5312,29744,5312,33680,9920,37616,14528,37616,22192,37616,23920,29840,23920,45440,27152,45440,0,
+ 37616,0,37616,7232,34928,2896,30936,832,26944,-1232,21168,-1232,13856,-1232,9544,2872,5232,6976,5232,13856,
+ 5232,21888,10608,25968,15984,30048,26640,30048,37616,30048,37616,30816,37616,36208,34064,39160,30512,42112,24096,42112,
+ 20016,42112,16152,41136,12288,40160,8720,38208,8720,45440,13008,47088,17048,47920,21088,48752,24912,48752,35232,48752,
+ 40336,43392,45440,38032,45440,27152,28832,65968,37456,65968,37456,57376,28832,57376,28832,65968,12208,65968,20832,65968,
+ 20832,57376,12208,57376,12208,65968,29840,23920,20352,23920,16696,21760,13040,19600,13040,14368,13040,10208,15784,7760,
+ 18528,5312,23248,5312,29744,5312,33680,9920,37616,14528,37616,22192,37616,23920,29840,23920,45440,27152,45440,0,
+ 37616,0,37616,7232,34928,2896,30936,832,26944,-1232,21168,-1232,13856,-1232,9544,2872,5232,6976,5232,13856,
+ 5232,21888,10608,25968,15984,30048,26640,30048,37616,30048,37616,30816,37616,36208,34064,39160,30512,42112,24096,42112,
+ 20016,42112,16152,41136,12288,40160,8720,38208,8720,45440,13008,47088,17048,47920,21088,48752,24912,48752,35232,48752,
+ 40336,43392,45440,38032,45440,27152,31296,64768,31296,67440,29424,69312,27552,71184,24832,71184,22064,71184,20216,69336,
+ 18368,67488,18368,64768,18368,62000,20216,60152,22064,58304,24832,58304,27552,58304,29424,60176,31296,62048,31296,64768,
+ 36480,64768,36480,59888,33096,56488,29712,53088,24832,53088,19952,53088,16568,56488,13184,59888,13184,64768,13184,69664,
+ 16568,73040,19952,76416,24832,76416,29712,76416,33096,73040,36480,69664,36480,64768,73008,28048,72976,34464,69472,38288,
+ 65968,42112,60144,42112,53632,42112,49704,38416,45776,34720,45184,28000,73008,28048,42288,40928,45440,44752,49944,46752,
+ 54448,48752,60048,48752,69664,48752,75272,42568,80880,36384,80880,25760,80880,21936,44928,21936,45440,13808,49768,9560,
+ 54096,5312,61888,5312,66304,5312,70552,6440,74800,7568,79056,9824,79056,2416,74800,640,70384,-296,65968,-1232,
+ 61456,-1232,54352,-1232,49088,1336,43824,3904,40544,8960,37440,3872,32848,1320,28256,-1232,22192,-1232,14160,-1232,
+ 9696,2744,5232,6720,5232,13856,5232,21888,10608,25968,15984,30048,26640,30048,37616,30048,37616,30816,37616,36208,
+ 34064,39160,30512,42112,24096,42112,20016,42112,16152,41136,12288,40160,8720,38208,8720,45440,13008,47088,17048,47920,
+ 21088,48752,24912,48752,30944,48752,35472,46712,40000,44672,42288,40928,29840,23920,20352,23920,16696,21760,13040,19600,
+ 13040,14368,13040,10208,15784,7760,18528,5312,23248,5312,29744,5312,33680,9920,37616,14528,37616,22192,37616,23920,
+ 29840,23920,42464,45776,42464,38464,39136,40288,35800,41200,32464,42112,29072,42112,21456,42112,17248,37288,13040,32464,
+ 13040,23760,13040,15040,17248,10216,21456,5392,29072,5392,32464,5392,35800,6312,39136,7232,42464,9056,42464,1824,
+ 39184,304,35680,-464,32176,-1232,28224,-1232,17472,-1232,11136,5528,4800,12288,4800,23760,4800,35408,11200,42080,
+ 17600,48752,28736,48752,32336,48752,35784,48008,39232,47264,42464,45776,31472,0,33808,-2640,34960,-4872,36112,-7104,
+ 36112,-9136,36112,-12928,33560,-14856,31008,-16784,25984,-16784,24032,-16784,22184,-16528,20336,-16272,18512,-15760,18512,-10208,
+ 19952,-10928,21528,-11248,23104,-11568,25104,-11568,27600,-11568,28880,-10544,30160,-9520,30160,-7568,30160,-6288,29248,-4440,
+ 28336,-2592,26416,0,31472,0,48912,25760,48912,21936,12960,21936,13472,13856,17832,9624,22192,5392,29968,5392,
+ 34464,5392,38696,6496,42928,7600,47088,9824,47088,2416,42880,640,38464,-296,34048,-1232,29488,-1232,18112,-1232,
+ 11456,5400,4800,12032,4800,23328,4800,35024,11112,41888,17424,48752,28128,48752,37744,48752,43328,42568,48912,36384,
+ 48912,25760,41104,28048,41008,34464,37504,38288,34000,42112,28224,42112,21680,42112,17744,38416,13808,34720,13216,28000,
+ 41104,28048,21744,69616,33728,53728,27232,53728,13376,69616,21744,69616,48912,25760,48912,21936,12960,21936,13472,13856,
+ 17832,9624,22192,5392,29968,5392,34464,5392,38696,6496,42928,7600,47088,9824,47088,2416,42880,640,38464,-296,
+ 34048,-1232,29488,-1232,18112,-1232,11456,5400,4800,12032,4800,23328,4800,35024,11112,41888,17424,48752,28128,48752,
+ 37744,48752,43328,42568,48912,36384,48912,25760,41104,28048,41008,34464,37504,38288,34000,42112,28224,42112,21680,42112,
+ 17744,38416,13808,34720,13216,28000,41104,28048,33808,69616,42272,69616,28416,53632,21904,53632,33808,69616,48912,25760,
+ 48912,21936,12960,21936,13472,13856,17832,9624,22192,5392,29968,5392,34464,5392,38696,6496,42928,7600,47088,9824,
+ 47088,2416,42880,640,38464,-296,34048,-1232,29488,-1232,18112,-1232,11456,5400,4800,12032,4800,23328,4800,35024,
+ 11112,41888,17424,48752,28128,48752,37744,48752,43328,42568,48912,36384,48912,25760,41104,28048,41008,34464,37504,38288,
+ 34000,42112,28224,42112,21680,42112,17744,38416,13808,34720,13216,28000,41104,28048,24752,69616,31056,69616,41456,53632,
+ 35552,53632,27904,64048,20256,53632,14352,53632,24752,69616,48912,25760,48912,21936,12960,21936,13472,13856,17832,9624,
+ 22192,5392,29968,5392,34464,5392,38696,6496,42928,7600,47088,9824,47088,2416,42880,640,38464,-296,34048,-1232,
+ 29488,-1232,18112,-1232,11456,5400,4800,12032,4800,23328,4800,35024,11112,41888,17424,48752,28128,48752,37744,48752,
+ 43328,42568,48912,36384,48912,25760,41104,28048,41008,34464,37504,38288,34000,42112,28224,42112,21680,42112,17744,38416,
+ 13808,34720,13216,28000,41104,28048,31904,65968,40528,65968,40528,57376,31904,57376,31904,65968,15280,65968,23904,65968,
+ 23904,57376,15280,57376,15280,65968,6384,69616,18368,53728,11872,53728,-1984,69616,6384,69616,8208,47600,16016,47600,
+ 16016,0,8208,0,8208,47600,12112,48752,12112,48752,18448,69616,26912,69616,13056,53632,6544,53632,18448,69616,
+ 8208,47600,16016,47600,16016,0,8208,0,8208,47600,12112,48752,12112,48752,8208,47600,16016,47600,16016,0,
+ 8208,0,8208,47600,12112,48752,12112,48752,9392,69616,15696,69616,26096,53632,20192,53632,12544,64048,4896,53632,
+ -1008,53632,9392,69616,8208,47600,16016,47600,16016,0,8208,0,8208,47600,12112,48752,12112,48752,16544,65968,
+ 25168,65968,25168,57376,16544,57376,16544,65968,-80,65968,8544,65968,8544,57376,-80,57376,-80,65968,35616,38880,
+ 33488,39616,31616,39952,29744,40288,28000,40288,20912,40288,16976,35696,13040,31104,13040,22816,13040,14832,16744,10112,
+ 20448,5392,26640,5392,32816,5392,36512,10112,40208,14832,40208,22816,40208,28000,39056,32000,37904,36000,35616,38880,
+ 38288,48496,43648,42416,46072,36296,48496,30176,48496,22816,48496,11984,42456,5376,36416,-1232,26640,-1232,16832,-1232,
+ 10816,5376,4800,11984,4800,22816,4800,33440,10664,40056,16528,46672,25920,46672,26688,46672,27792,46560,28896,46448,
+ 30688,46240,23920,53888,10368,49344,8960,53552,20912,57456,13216,66128,22912,66128,28304,59968,42464,64688,43856,60560,
+ 31328,56400,38288,48496,47776,28736,47776,0,39952,0,39952,28480,39952,35232,37320,38592,34688,41952,29408,41952,
+ 23072,41952,19416,37912,15760,33872,15760,26896,15760,0,7904,0,7904,47600,15760,47600,15760,40208,18576,44496,
+ 22376,46624,26176,48752,31152,48752,39360,48752,43568,43672,47776,38592,47776,28736,27728,58224,25312,60560,24384,61408,
+ 23680,61816,22976,62224,22416,62224,20800,62224,20040,60672,19280,59120,19184,55632,13872,55632,13968,61376,16136,64496,
+ 18304,67616,22160,67616,23776,67616,25136,67024,26496,66432,28080,65024,30496,62688,31424,61840,32128,61432,32832,61024,
+ 33392,61024,35008,61024,35768,62576,36528,64128,36624,67616,41936,67616,41840,61888,39672,58760,37504,55632,33648,55632,
+ 32032,55632,30672,56224,29312,56816,27728,58224,26640,42112,20352,42112,16696,37208,13040,32304,13040,23760,13040,15216,
+ 16680,10304,20320,5392,26640,5392,32896,5392,36552,10328,40208,15264,40208,23760,40208,32208,36552,37160,32896,42112,
+ 26640,42112,26640,48752,36848,48752,42672,42120,48496,35488,48496,23760,48496,12064,42672,5416,36848,-1232,26640,-1232,
+ 16400,-1232,10600,5416,4800,12064,4800,23760,4800,35488,10600,42120,16400,48752,26640,48752,20720,69616,32704,53728,
+ 26208,53728,12352,69616,20720,69616,26640,42112,20352,42112,16696,37208,13040,32304,13040,23760,13040,15216,16680,10304,
+ 20320,5392,26640,5392,32896,5392,36552,10328,40208,15264,40208,23760,40208,32208,36552,37160,32896,42112,26640,42112,
+ 26640,48752,36848,48752,42672,42120,48496,35488,48496,23760,48496,12064,42672,5416,36848,-1232,26640,-1232,16400,-1232,
+ 10600,5416,4800,12064,4800,23760,4800,35488,10600,42120,16400,48752,26640,48752,32784,69616,41248,69616,27392,53632,
+ 20880,53632,32784,69616,26640,42112,20352,42112,16696,37208,13040,32304,13040,23760,13040,15216,16680,10304,20320,5392,
+ 26640,5392,32896,5392,36552,10328,40208,15264,40208,23760,40208,32208,36552,37160,32896,42112,26640,42112,26640,48752,
+ 36848,48752,42672,42120,48496,35488,48496,23760,48496,12064,42672,5416,36848,-1232,26640,-1232,16400,-1232,10600,5416,
+ 4800,12064,4800,23760,4800,35488,10600,42120,16400,48752,26640,48752,23728,69616,30032,69616,40432,53632,34528,53632,
+ 26880,64048,19232,53632,13328,53632,23728,69616,26640,42112,20352,42112,16696,37208,13040,32304,13040,23760,13040,15216,
+ 16680,10304,20320,5392,26640,5392,32896,5392,36552,10328,40208,15264,40208,23760,40208,32208,36552,37160,32896,42112,
+ 26640,42112,26640,48752,36848,48752,42672,42120,48496,35488,48496,23760,48496,12064,42672,5416,36848,-1232,26640,-1232,
+ 16400,-1232,10600,5416,4800,12064,4800,23760,4800,35488,10600,42120,16400,48752,26640,48752,26704,58224,24288,60560,
+ 23360,61408,22656,61816,21952,62224,21392,62224,19776,62224,19016,60672,18256,59120,18160,55632,12848,55632,12944,61376,
+ 15112,64496,17280,67616,21136,67616,22752,67616,24112,67024,25472,66432,27056,65024,29472,62688,30400,61840,31104,61432,
+ 31808,61024,32368,61024,33984,61024,34744,62576,35504,64128,35600,67616,40912,67616,40816,61888,38648,58760,36480,55632,
+ 32624,55632,31008,55632,29648,56224,28288,56816,26704,58224,26640,42112,20352,42112,16696,37208,13040,32304,13040,23760,
+ 13040,15216,16680,10304,20320,5392,26640,5392,32896,5392,36552,10328,40208,15264,40208,23760,40208,32208,36552,37160,
+ 32896,42112,26640,42112,26640,48752,36848,48752,42672,42120,48496,35488,48496,23760,48496,12064,42672,5416,36848,-1232,
+ 26640,-1232,16400,-1232,10600,5416,4800,12064,4800,23760,4800,35488,10600,42120,16400,48752,26640,48752,30880,65968,
+ 39504,65968,39504,57376,30880,57376,30880,65968,14256,65968,22880,65968,22880,57376,14256,57376,14256,65968,31232,48240,
+ 41696,48240,41696,37776,31232,37776,31232,48240,31232,16784,41696,16784,41696,6368,31232,6368,31232,16784,9216,30896,
+ 63712,30896,63712,23680,9216,23680,9216,30896,38464,34048,17760,8880,19504,7104,21696,6248,23888,5392,26640,5392,
+ 32896,5392,36552,10328,40208,15264,40208,23760,40208,27120,39784,29600,39360,32080,38464,34048,35440,38640,33664,40368,
+ 31472,41240,29280,42112,26640,42112,20224,42112,16632,37120,13040,32128,13040,23168,13040,20096,13448,17760,13856,15424,
+ 14704,13472,35440,38640,9392,7056,7104,10320,5952,14512,4800,18704,4800,23760,4800,35488,10600,42120,16400,48752,
+ 26640,48752,30608,48752,33984,47664,37360,46576,40208,44368,46112,51504,50144,48160,43952,40544,46192,37280,47344,33072,
+ 48496,28864,48496,23760,48496,12064,42672,5416,36848,-1232,26640,-1232,22560,-1232,19144,-128,15728,976,13040,3152,
+ 7136,-4000,3056,-688,9392,7056,7392,18784,7392,47600,15216,47600,15216,19088,15216,12320,17848,8944,20480,5568,
+ 25760,5568,32080,5568,35760,9608,39440,13648,39440,20608,39440,47600,47264,47600,47264,0,39440,0,39440,7312,
+ 36592,2976,32832,872,29072,-1232,24096,-1232,15888,-1232,11640,3864,7392,8960,7392,18784,27072,48752,27072,48752,
+ 20720,69616,32704,53728,26208,53728,12352,69616,20720,69616,7392,18784,7392,47600,15216,47600,15216,19088,15216,12320,
+ 17848,8944,20480,5568,25760,5568,32080,5568,35760,9608,39440,13648,39440,20608,39440,47600,47264,47600,47264,0,
+ 39440,0,39440,7312,36592,2976,32832,872,29072,-1232,24096,-1232,15888,-1232,11640,3864,7392,8960,7392,18784,
+ 27072,48752,27072,48752,32784,69616,41248,69616,27392,53632,20880,53632,32784,69616,7392,18784,7392,47600,15216,47600,
+ 15216,19088,15216,12320,17848,8944,20480,5568,25760,5568,32080,5568,35760,9608,39440,13648,39440,20608,39440,47600,
+ 47264,47600,47264,0,39440,0,39440,7312,36592,2976,32832,872,29072,-1232,24096,-1232,15888,-1232,11640,3864,
+ 7392,8960,7392,18784,27072,48752,27072,48752,23728,69616,30032,69616,40432,53632,34528,53632,26880,64048,19232,53632,
+ 13328,53632,23728,69616,7392,18784,7392,47600,15216,47600,15216,19088,15216,12320,17848,8944,20480,5568,25760,5568,
+ 32080,5568,35760,9608,39440,13648,39440,20608,39440,47600,47264,47600,47264,0,39440,0,39440,7312,36592,2976,
+ 32832,872,29072,-1232,24096,-1232,15888,-1232,11640,3864,7392,8960,7392,18784,27072,48752,27072,48752,30880,65968,
+ 39504,65968,39504,57376,30880,57376,30880,65968,14256,65968,22880,65968,22880,57376,14256,57376,14256,65968,28000,-4416,
+ 24688,-12928,21544,-15520,18400,-18112,13136,-18112,6880,-18112,6880,-11568,11472,-11568,14704,-11568,16488,-10032,18272,-8496,
+ 20448,-2800,21840,768,2592,47600,10880,47600,25760,10368,40624,47600,48912,47600,28000,-4416,31760,69616,40224,69616,
+ 26368,53632,19856,53632,31760,69616,15760,7136,15760,-18112,7904,-18112,7904,66128,15760,66128,15760,40368,18240,44624,
+ 22000,46688,25760,48752,30976,48752,39648,48752,45072,41864,50496,34976,50496,23760,50496,12544,45072,5656,39648,-1232,
+ 30976,-1232,25760,-1232,22000,832,18240,2896,15760,7136,42368,23760,42368,32384,38824,37296,35280,42208,29072,42208,
+ 22864,42208,19312,37296,15760,32384,15760,23760,15760,15136,19312,10224,22864,5312,29072,5312,35280,5312,38824,10224,
+ 42368,15136,42368,23760,28000,-4416,24688,-12928,21544,-15520,18400,-18112,13136,-18112,6880,-18112,6880,-11568,11472,-11568,
+ 14704,-11568,16488,-10032,18272,-8496,20448,-2800,21840,768,2592,47600,10880,47600,25760,10368,40624,47600,48912,47600,
+ 28000,-4416,29856,65968,38480,65968,38480,57376,29856,57376,29856,65968,13232,65968,21856,65968,21856,57376,13232,57376,
+ 13232,65968 };
+static const int DejaVuSans_glyphAdvances[224] = {
+ 27664,34896,40032,72928,55376,82704,67872,23920,33952,33952,43520,72928,27664,31408,27664,29328,55376,55376,55376,55376,
+ 55376,55376,55376,55376,55376,55376,29328,29328,72928,72928,72928,46192,87040,59536,59712,60768,67024,54992,50064,67440,
+ 65456,25664,25664,57072,48496,75104,65104,68512,52480,68512,60480,55248,53168,63712,59536,86064,59632,53168,59632,33952,
+ 29328,33952,72928,43520,43520,53344,55248,47856,55248,53552,30640,55248,55168,24176,24176,50400,24176,84784,55168,53248,
+ 55248,55248,35792,45344,34128,55168,51504,71184,51504,51504,45680,55376,29328,55376,72928,52240,52240,52240,52240,52240,
+ 52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,
+ 52240,52240,52240,52240,52240,52240,52240,52240,27664,34896,55376,55376,55376,55376,29328,43520,43520,87040,41008,53248,
+ 72928,31408,87040,43520,43520,72928,34896,34896,43520,55376,55376,27664,43520,34896,41008,53248,84368,84368,84368,46192,
+ 59536,59536,59536,59536,59536,59536,84784,60768,54992,54992,54992,54992,25664,25664,25664,25664,67440,65104,68512,68512,
+ 68512,68512,68512,72928,68512,63712,63712,63712,63712,53168,52656,54832,53344,53344,53344,53344,53344,53344,85472,47856,
+ 53552,53552,53552,53552,24176,24176,24176,24176,53248,55168,53248,53248,53248,53248,53248,72928,53248,55168,55168,55168,
+ 55168,51504,55248,51504 };
+
+static const int DejaVuSans_glyphCount = 224;
+static const short DejaVuSans_characterMap[256] = {
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
+ 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,
+ 68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,
+ 88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,
+ 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
+ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,
+ 148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,
+ 168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,
+ 188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
+ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223 };
+
diff --git a/tests/font/DejaVuSansMono.inc b/tests/font/DejaVuSansMono.inc
new file mode 100644
index 0000000..5017dc7
--- /dev/null
+++ b/tests/font/DejaVuSansMono.inc
@@ -0,0 +1,965 @@
+/* Generated by font2openvg. See http://developer.hybrid.fi for more information. */
+
+/* converted from font file /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf */
+/* font family name: DejaVu Sans Mono */
+/* font style name: Book */
+
+static const unsigned char DejaVuSansMono_glyphInstructions[4892] = {
+ 2,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,10,10,10,10,0,2,4,10,10,10,10,0,2,4,4,10,
+ 10,4,10,10,4,10,10,10,10,4,4,4,10,10,4,10,10,4,10,10,
+ 10,10,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,
+ 10,10,10,10,10,0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,
+ 10,0,2,10,10,10,10,10,10,10,10,10,10,0,2,4,10,10,10,4,
+ 4,4,10,10,4,4,4,10,10,10,10,10,10,10,10,10,10,10,10,4,
+ 10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,4,0,2,4,
+ 4,4,4,0,2,10,10,10,10,4,10,10,10,10,4,0,2,4,10,10,
+ 10,10,4,10,10,10,10,0,2,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,
+ 10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,
+ 4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,10,10,10,10,
+ 10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,
+ 10,4,10,10,10,10,10,10,4,4,4,10,10,10,10,10,10,4,10,10,
+ 10,10,10,10,0,2,4,4,4,0,2,4,4,4,4,4,4,4,4,4,
+ 4,4,0,2,4,4,4,4,10,10,10,10,10,10,10,10,4,10,10,10,
+ 10,10,10,10,10,4,0,2,4,10,10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,
+ 4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,
+ 10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,4,4,4,0,2,4,4,10,10,4,10,10,10,10,10,10,
+ 4,10,10,10,10,10,10,4,10,10,4,4,0,2,4,4,4,4,0,2,
+ 10,10,10,10,10,10,10,10,0,2,4,4,10,10,10,10,10,10,10,10,
+ 4,10,10,10,10,10,10,10,10,4,10,10,10,10,10,10,10,10,4,0,
+ 2,4,4,4,0,2,4,4,4,4,4,4,4,4,0,2,4,4,10,10,
+ 10,10,4,0,2,4,4,10,10,10,10,4,0,2,4,10,10,10,10,10,
+ 10,10,10,4,4,0,2,10,10,10,10,10,10,10,10,4,10,10,10,10,
+ 10,10,10,10,4,0,2,10,10,10,10,4,4,4,0,2,10,10,10,10,
+ 4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,
+ 4,4,4,4,4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,4,
+ 10,10,10,10,10,10,10,10,4,4,4,4,4,0,2,4,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,4,10,10,10,10,4,4,4,4,4,10,10,10,10,0,2,4,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,0,
+ 2,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,
+ 4,4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,
+ 10,10,10,10,10,10,0,2,4,4,10,10,10,10,4,0,2,4,10,10,
+ 10,10,4,4,4,4,0,2,10,10,10,10,10,10,10,10,10,10,4,4,
+ 4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,4,4,4,10,10,
+ 4,4,4,4,4,10,10,10,10,0,2,4,4,10,10,10,10,4,0,2,
+ 4,10,10,10,10,10,10,4,10,10,10,10,10,10,4,10,10,10,10,10,
+ 10,4,10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,4,0,2,
+ 4,4,4,10,10,10,10,10,10,10,10,4,4,4,10,10,10,10,10,10,
+ 10,10,0,2,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,
+ 0,2,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,10,10,10,10,10,10,4,
+ 4,0,2,4,4,4,10,10,10,10,10,10,4,4,10,10,10,10,4,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,
+ 4,10,10,10,10,10,10,10,10,4,0,2,4,4,4,4,4,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,
+ 10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,4,
+ 0,2,4,4,10,10,4,4,4,4,4,4,4,4,4,4,4,10,10,4,
+ 0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,4,10,10,10,
+ 10,4,4,10,10,10,10,10,10,10,10,4,4,4,0,2,4,4,4,10,
+ 10,10,10,4,4,4,4,4,10,10,10,10,0,2,4,4,4,4,4,4,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,10,10,4,
+ 4,4,10,10,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,
+ 4,4,4,4,0,2,10,10,4,4,4,10,10,4,4,4,4,4,0,2,
+ 10,10,10,10,4,4,4,10,10,10,10,4,4,4,10,10,10,10,4,4,
+ 4,4,4,10,10,10,10,0,2,4,4,4,10,10,10,10,4,4,4,4,
+ 4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,4,4,4,4,4,10,10,10,10,10,10,10,10,
+ 0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,
+ 0,2,10,10,10,10,10,10,10,10,4,4,4,4,4,0,2,10,10,10,
+ 10,4,4,4,4,4,10,10,10,10,4,0,2,4,10,10,10,10,10,10,
+ 4,10,10,10,10,10,10,4,10,10,10,10,10,4,4,10,10,10,10,10,
+ 10,0,2,4,4,4,4,4,10,10,4,4,4,10,10,4,4,4,4,4,
+ 4,0,2,4,4,4,10,10,10,10,4,4,4,4,4,10,10,10,10,0,
+ 2,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,10,
+ 10,10,10,4,4,4,10,10,4,4,4,4,4,4,0,2,4,4,4,4,
+ 4,4,4,4,4,4,0,2,4,4,10,10,4,10,10,4,4,4,10,10,
+ 4,10,10,4,4,4,10,10,4,10,10,10,10,4,10,10,4,0,2,4,
+ 4,4,4,0,2,4,10,10,4,10,10,10,10,4,10,10,4,4,4,10,
+ 10,4,10,10,4,4,4,10,10,4,10,10,4,4,0,2,4,10,10,10,
+ 10,10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,4,4,0,2,4,10,10,4,10,10,4,10,10,4,4,4,10,10,
+ 10,10,4,4,4,10,10,0,2,4,10,10,10,10,0,2,4,10,10,10,
+ 10,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,10,10,10,10,
+ 0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,10,10,10,10,4,
+ 4,4,10,10,10,10,4,4,4,10,10,10,10,4,4,4,10,10,10,10,
+ 0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,4,10,
+ 10,10,10,10,4,10,10,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 10,10,10,10,10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,10,
+ 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,
+ 10,4,4,0,2,4,4,4,10,10,10,10,10,10,4,4,10,10,10,10,
+ 4,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 0,2,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,0,2,4,
+ 4,4,4,0,2,10,10,10,10,10,10,4,4,4,10,10,4,4,4,4,
+ 4,0,2,4,4,4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,0,2,4,4,4,4,0,2,10,10,10,10,10,10,
+ 10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,
+ 0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,
+ 4,10,10,10,10,10,10,4,10,10,10,10,10,10,4,0,2,10,10,10,
+ 10,10,10,4,10,10,10,10,10,10,4,4,4,10,10,10,10,10,10,4,
+ 10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,10,10,10,
+ 10,4,4,4,10,10,10,10,4,10,10,10,10,10,10,10,10,4,4,0,
+ 2,4,4,4,4,4,4,4,4,10,10,10,10,0,2,4,4,4,4,0,
+ 2,10,10,10,10,10,10,4,10,10,10,10,10,10,4,0,2,4,4,4,
+ 4,4,4,4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,
+ 10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,
+ 4,4,4,4,4,0,2,4,4,4,0,2,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,
+ 4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,10,10,10,10,10,
+ 10,4,10,10,10,10,10,10,4,0,2,4,4,4,4,4,4,4,4,4,
+ 4,4,0,2,4,4,4,0,2,10,10,10,10,10,10,4,10,10,10,10,
+ 10,10,4,4,4,10,10,10,10,10,10,4,10,10,10,10,10,10,0,2,
+ 4,4,4,4,0,2,4,4,10,10,4,10,10,10,10,10,10,4,10,10,
+ 10,10,10,10,4,10,10,10,10,4,0,2,4,4,4,4,0,2,4,4,
+ 4,0,2,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,0,2,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,0,2,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,
+ 4,4,0,2,4,4,4,0,2,4,4,4,4,4,4,4,4,0,2,4,
+ 10,10,10,10,4,4,10,10,10,10,4,10,10,10,10,4,4,10,10,10,
+ 10,0,2,4,4,4,0,2,4,4,4,4,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,
+ 4,4,4,0,2,10,10,10,10,10,10,10,10,4,4,4,4,4,4,4,
+ 0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,
+ 4,4,4,4,0,2,10,10,10,10,10,10,4,10,10,10,10,10,10,4,
+ 0,2,10,10,10,10,10,10,10,10,4,10,10,10,10,10,10,10,10,4,
+ 0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 10,10,10,10,4,4,4,4,4,4,4,0,2,10,10,10,10,4,4,4,
+ 4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,0,2,4,10,
+ 10,10,10,4,4,10,10,10,10,4,10,10,10,10,4,4,10,10,10,10,
+ 0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,
+ 0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,
+ 10,10,10,10,10,10,0,2,4,4,4,4,0,2,10,10,10,10,10,10,
+ 10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,4,
+ 4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,
+ 10,0,2,4,10,10,10,10,4,4,10,10,10,10,4,10,10,10,10,4,
+ 4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,10,10,10,10,10,10,4,
+ 0,2,4,10,10,10,10,10,10,0,2,10,10,10,10,10,10,4,4,4,
+ 10,10,10,10,10,10,4,4,4,0,2,4,4,4,10,10,10,10,10,10,
+ 10,10,4,4,4,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,
+ 2,4,4,4,10,10,10,10,10,10,10,10,4,4,4,10,10,10,10,10,
+ 10,10,10,0,2,4,4,4,4,0,2,4,4,4,10,10,10,10,10,10,
+ 10,10,4,4,4,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,
+ 4,4,0,2,4,4,4,10,10,10,10,10,10,10,10,4,4,4,10,10,
+ 10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,10,
+ 10,10,10,4,0,2,4,4,4,10,10,10,10,4,4,4,4,0,2,10,
+ 10,10,10,10,10,10,10,4,10,10,10,10,10,10,4,10,10,10,10,10,
+ 10,4,10,10,10,10,10,10,10,10,4,4,4,0,2,4,10,10,10,10,
+ 10,10,4,4,0,2,4,4,4,10,10,10,10,10,10,4,4,10,10,10,
+ 10,4,10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,10,10,10,
+ 10,10,10,4,4,0,2,4,4,4,10,10,10,10,10,10,4,4,10,10,
+ 10,10,4,10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,10,10,
+ 10,10,10,10,4,4,0,2,4,4,4,10,10,10,10,10,10,4,4,10,
+ 10,10,10,4,10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,0,
+ 2,4,10,10,10,10,10,10,4,4,0,2,4,4,4,10,10,10,10,10,
+ 10,4,4,10,10,10,10,4,10,10,10,10,10,10,0,2,4,10,10,10,
+ 10,4,10,10,10,10,4,10,10,10,10,4,10,10,10,10,0,2,4,10,
+ 10,10,10,10,10,4,4,0,2,4,4,4,10,10,10,10,10,10,4,4,
+ 10,10,10,10,4,10,10,10,10,10,10,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,10,10,10,10,10,10,4,4,0,2,4,4,4,10,
+ 10,10,10,10,10,4,4,10,10,10,10,4,10,10,10,10,10,10,0,2,
+ 10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,
+ 4,4,10,10,10,10,10,10,0,2,4,10,10,10,10,4,4,0,2,4,
+ 10,10,10,10,10,10,4,10,10,10,10,10,10,10,10,10,10,4,4,10,
+ 10,10,10,4,10,10,10,10,10,10,10,10,4,0,2,10,10,10,10,10,
+ 10,4,10,10,10,10,10,10,4,0,2,10,10,10,10,10,10,10,10,4,
+ 10,10,10,10,10,10,10,10,4,0,2,4,4,4,10,10,10,10,4,10,
+ 10,10,10,10,10,10,10,0,2,10,10,10,10,4,0,2,4,4,4,4,
+ 0,2,4,4,4,10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,
+ 10,10,10,10,4,0,2,4,4,4,4,0,2,4,4,4,10,10,10,10,
+ 4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,4,0,2,4,4,
+ 4,4,4,4,4,0,2,4,4,4,10,10,10,10,4,10,10,10,10,10,
+ 10,10,10,0,2,10,10,10,10,4,0,2,4,4,4,4,0,2,4,4,
+ 4,4,0,2,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,0,
+ 2,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,10,10,10,10,10,10,10,10,10,10,10,10,4,4,4,
+ 4,4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,10,10,0,2,
+ 4,4,4,10,10,10,10,4,4,4,4,4,10,10,10,10,0,2,4,10,
+ 10,10,10,4,10,10,10,10,4,10,10,10,10,4,10,10,10,10,0,2,
+ 10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,
+ 4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,
+ 10,10,10,10,0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,10,
+ 0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,0,
+ 2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,
+ 2,4,10,10,10,10,4,10,10,10,10,4,10,10,10,10,4,10,10,10,
+ 10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,
+ 10,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,10,10,10,10,10,10,
+ 0,2,10,10,10,10,10,10,4,0,2,10,10,10,10,10,10,4,4,4,
+ 10,10,10,10,10,10,4,4,4,0,2,4,4,4,10,10,10,10,4,4,
+ 4,4,4,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,10,10,
+ 10,10,4,4,4,4,4,10,10,10,10,0,2,4,4,4,4,0,2,4,
+ 4,4,10,10,10,10,4,4,4,4,4,10,10,10,10,0,2,4,4,4,
+ 4,4,4,4,0,2,4,4,4,10,10,10,10,4,4,4,4,4,10,10,
+ 10,10,0,2,4,4,4,4,0,2,4,4,4,4,0,2,10,10,10,10,
+ 4,4,4,10,10,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,
+ 10,10,0,2,10,10,10,10,4,4,4,10,10,4,4,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0 };
+static const int DejaVuSansMono_glyphInstructionIndices[224] = {
+ 0,0,14,26,62,104,154,198,204,216,228,248,262,270,276,282,288,318,331,354,
+ 385,403,427,456,465,503,532,544,558,567,579,588,619,660,675,706,726,744,758,770,
+ 794,808,822,838,852,860,875,887,907,927,952,979,1009,1019,1043,1052,1067,1081,1092,1104,
+ 1114,1120,1130,1139,1145,1151,1186,1211,1231,1256,1281,1301,1335,1353,1371,1391,1405,1419,1448,1466,
+ 1486,1511,1536,1552,1582,1602,1620,1629,1644,1658,1675,1687,1718,1724,1755,1775,1787,1799,1811,1823,
+ 1835,1847,1859,1871,1883,1895,1907,1919,1931,1943,1955,1967,1979,1991,2003,2015,2027,2039,2051,2063,
+ 2075,2087,2099,2111,2123,2135,2147,2159,2171,2171,2185,2215,2241,2281,2308,2320,2366,2378,2434,2472,
+ 2490,2498,2504,2567,2573,2595,2615,2636,2667,2673,2700,2714,2720,2736,2749,2775,2793,2830,2870,2925,
+ 2957,2978,2999,3023,3062,3089,3121,3145,3181,3201,3221,3244,3270,3290,3310,3333,3359,3385,3421,3447,
+ 3473,3502,3546,3578,3592,3630,3660,3690,3723,3759,3776,3798,3834,3875,3916,3960,4017,4064,4119,4174,
+ 4210,4241,4272,4306,4343,4361,4379,4400,4424,4459,4499,4525,4551,4580,4622,4654,4672,4710,4734,4758,
+ 4785,4815,4838,4863 };
+static const int DejaVuSansMono_glyphInstructionCounts[224] = {
+ 0,14,12,36,42,50,44,6,12,12,20,14,8,6,6,6,30,13,23,31,
+ 18,24,29,9,38,29,12,14,9,12,9,31,41,15,31,20,18,14,12,24,
+ 14,14,16,14,8,15,12,20,20,25,27,30,10,24,9,15,14,11,12,10,
+ 6,10,9,6,6,35,25,20,25,25,20,34,18,18,20,14,14,29,18,20,
+ 25,25,16,30,20,18,9,15,14,17,12,31,6,31,20,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,0,14,30,26,40,27,12,46,12,56,38,18,
+ 8,6,63,6,22,20,21,31,6,27,14,6,16,13,26,18,37,40,55,32,
+ 21,21,24,39,27,32,24,36,20,20,23,26,20,20,23,26,26,36,26,26,
+ 29,44,32,14,38,30,30,33,36,17,22,36,41,41,44,57,47,55,55,36,
+ 31,31,34,37,18,18,21,24,35,40,26,26,29,42,32,18,38,24,24,27,
+ 30,23,25,29 };
+
+static const int DejaVuSansMono_glyphPointIndices[224] = {
+ 0,0,12,22,56,119,200,273,278,297,316,335,348,355,360,365,370,421,433,471,
+ 525,541,580,631,639,706,757,767,779,787,797,805,850,921,934,978,1013,1037,1050,1061,
+ 1100,1113,1126,1149,1162,1169,1183,1194,1228,1254,1295,1332,1385,1394,1433,1441,1455,1468,1478,1489,
+ 1498,1503,1512,1520,1525,1530,1585,1624,1659,1698,1737,1760,1816,1841,1857,1879,1892,1909,1953,1978,
+ 2012,2051,2090,2113,2165,2188,2213,2221,2235,2248,2270,2281,2327,2332,2378,2413,2423,2433,2443,2453,
+ 2463,2473,2483,2493,2503,2513,2523,2533,2543,2553,2563,2573,2583,2593,2603,2613,2623,2633,2643,2653,
+ 2663,2673,2683,2693,2703,2713,2723,2733,2743,2743,2755,2799,2832,2894,2920,2930,3013,3023,3124,3179,
+ 3195,3202,3207,3310,3315,3353,3371,3403,3457,3462,3504,3521,3526,3553,3565,3604,3620,3653,3702,3777,
+ 3825,3843,3861,3882,3934,3957,4002,4024,4086,4104,4122,4143,4166,4184,4202,4223,4246,4278,4328,4367,
+ 4406,4448,4521,4565,4578,4637,4681,4725,4772,4821,4836,4864,4927,4987,5047,5110,5202,5267,5356,5446,
+ 5508,5552,5596,5643,5692,5708,5724,5743,5764,5819,5881,5920,5959,6001,6072,6116,6131,6190,6220,6250,
+ 6283,6318,6345,6384 };
+static const int DejaVuSansMono_glyphPoints[6416*2] = {
+ 21936,63456,30560,63456,30560,35616,29664,20448,22816,20448,21936,35616,21936,63456,21936,10800,30560,10800,30560,0,
+ 21936,0,21936,10800,38032,63456,38032,39872,30640,39872,30640,63456,38032,63456,21760,63456,21760,39872,14368,39872,
+ 14368,63456,21760,63456,29072,62480,24656,44832,35056,44832,39520,62480,46320,62480,41856,44832,52240,44832,52240,38288,
+ 40288,38288,36720,24096,47344,24096,47344,17600,35056,17600,30640,0,23840,0,28304,17600,17856,17600,13392,0,
+ 6624,0,11056,17600,80,17600,80,24096,12704,24096,16272,38288,4976,38288,4976,44832,17856,44832,22272,62480,
+ 29072,62480,33488,38288,23072,38288,19504,24096,29968,24096,33488,38288,29408,24656,29408,6208,34080,6336,36720,8800,
+ 39360,11264,39360,15520,39360,19472,36976,21656,34592,23840,29408,24656,25168,32720,25168,50272,20736,50112,18248,47728,
+ 15760,45344,15760,41360,15760,37696,18080,35568,20400,33440,25168,32720,29408,-12800,25168,-12800,25120,0,20784,208,
+ 16512,1184,12240,2160,8080,3904,8080,11568,12320,8928,16640,7528,20960,6128,25168,6032,25168,25504,16656,26816,
+ 12368,30688,8080,34560,8080,40928,8080,47600,12560,51576,17040,55552,25168,56144,25168,66128,29408,66128,29456,56144,
+ 32816,55936,36256,55296,39696,54656,43264,53552,43264,46192,39648,48032,36232,49024,32816,50016,29408,50192,29408,31872,
+ 38160,30560,42752,26440,47344,22320,47344,15760,47344,9216,42392,4840,37440,464,29456,80,29408,-12800,29584,13552,
+ 29584,10240,31816,7992,34048,5744,37360,5744,40624,5744,42904,8016,45184,10288,45184,13552,45184,16832,42888,19128,
+ 40592,21424,37360,21424,34048,21424,31816,19168,29584,16912,29584,13552,23840,13552,23840,19296,27752,23224,31664,27152,
+ 37360,27152,40080,27152,42520,26136,44960,25120,46928,23168,48880,21168,49944,18704,51008,16240,51008,13552,51008,7904,
+ 47048,3952,43088,0,37360,0,31584,0,27712,3888,23840,7776,23840,13552,5136,19760,3648,23840,47936,41600,
+ 49680,37520,5136,19760,7136,47264,7136,43904,9368,41672,11600,39440,14960,39440,18240,39440,20528,41712,22816,43984,
+ 22816,47264,22816,50528,20528,52808,18240,55088,14960,55088,11680,55088,9408,52832,7136,50576,7136,47264,1408,47264,
+ 1408,52992,5312,56928,9216,60864,14960,60864,17680,60864,20168,59840,22656,58816,24560,56912,26480,54992,27520,52504,
+ 28560,50016,28560,47264,28560,41568,24608,37632,20656,33696,14960,33696,9216,33696,5312,37608,1408,41520,1408,47264,
+ 23248,38544,40928,14784,42592,16880,43400,20064,44208,23248,44208,27664,44208,29024,44080,32000,44032,32304,51008,32304,
+ 51008,30640,51008,23808,49432,18640,47856,13472,44672,9728,51888,0,42848,0,39520,4640,36000,1664,32048,216,
+ 28096,-1232,23584,-1232,14400,-1232,8408,4488,2416,10208,2416,18864,2416,24688,5352,29664,8288,34640,14192,38880,
+ 12064,41952,11048,44880,10032,47808,10032,50832,10032,57200,14256,60904,18480,64608,25840,64608,28608,64608,31392,64096,
+ 34176,63584,37152,62608,37152,54832,34640,56480,31984,57264,29328,58048,26400,58048,22272,58048,19888,56120,17504,54192,
+ 17504,50912,17504,48400,18736,45664,19968,42928,23248,38544,17680,34128,13776,31024,11840,27560,9904,24096,9904,20192,
+ 9904,13776,14152,9544,18400,5312,24992,5312,26768,5312,28728,5824,30688,6336,32560,7312,33696,7952,34440,8440,
+ 35184,8928,35872,9472,17680,34128,29840,63456,29840,39872,22448,39872,22448,63456,29840,63456,37616,66048,31968,56352,
+ 29184,46728,26400,37104,26400,27328,26400,17600,29184,7952,31968,-1696,37616,-11472,30816,-11472,24400,-1360,21256,8224,
+ 18112,17808,18112,27328,18112,36800,21256,46408,24400,56016,30816,66048,37616,66048,14784,66048,21584,66048,28000,56016,
+ 31152,46408,34304,36800,34304,27328,34304,17760,31152,8160,28000,-1440,21584,-11472,14784,-11472,20448,-1616,23232,8032,
+ 26016,17680,26016,27328,26016,37024,23232,46672,20448,56320,14784,66048,45344,52992,30128,44752,45344,36464,42928,32304,
+ 28640,40928,28640,24912,23760,24912,23760,40928,9472,32304,7056,36464,22272,44752,7056,52992,9472,57200,23760,48576,
+ 23760,64608,28640,64608,28640,48576,42928,57200,45344,52992,29744,49760,29744,30896,48656,30896,48656,23680,29744,23680,
+ 29744,4800,22608,4800,22608,23680,3744,23680,3744,30896,22608,30896,22608,49760,29744,49760,21328,12880,32048,12880,
+ 32048,4080,23680,-12192,17120,-12192,21328,4080,21328,12880,15136,27328,37280,27328,37280,20352,15136,20352,15136,27328,
+ 20784,12960,31488,12960,31488,0,20784,0,20784,12960,37776,63456,45856,63456,12448,-8080,4336,-8080,37776,63456,
+ 20528,31872,20528,34208,22168,35912,23808,37616,26096,37616,28480,37616,30176,35912,31872,34208,31872,31872,31872,29488,
+ 30192,27832,28512,26176,26096,26176,23712,26176,22120,27792,20528,29408,20528,31872,26176,57808,20192,57808,17240,51344,
+ 14288,44880,14288,31664,14288,18480,17240,12024,20192,5568,26176,5568,32208,5568,35168,12024,38128,18480,38128,31664,
+ 38128,44880,35168,51344,32208,57808,26176,57808,26176,64608,36336,64608,41544,56272,46752,47936,46752,31664,46752,15424,
+ 41544,7096,36336,-1232,26176,-1232,16016,-1232,10832,7096,5648,15424,5648,31664,5648,47936,10832,56272,16016,64608,
+ 26176,64608,11472,7232,24816,7232,24816,55712,10448,52480,10448,60304,24736,63456,33328,63456,33328,7232,46496,7232,
+ 46496,0,11472,0,11472,7232,15856,7232,45008,7232,45008,0,6464,0,6464,7232,14400,15600,20352,22016,
+ 26304,28432,28560,31072,32816,36256,34304,39464,35792,42672,35792,46032,35792,51344,32664,54360,29536,57376,24096,57376,
+ 20224,57376,15976,55976,11728,54576,6976,51728,6976,60400,11344,62480,15576,63544,19808,64608,23920,64608,33232,64608,
+ 38904,59656,44576,54704,44576,46672,44576,42592,42688,38512,40800,34432,36544,29488,34176,26736,29648,21848,25120,16960,
+ 15856,7232,32976,33952,39232,32304,42544,28072,45856,23840,45856,17504,45856,8752,39968,3760,34080,-1232,23680,-1232,
+ 19296,-1232,14752,-424,10208,384,5824,1920,5824,10448,10160,8208,14368,7104,18576,6000,22736,6000,29792,6000,
+ 33576,9184,37360,12368,37360,18368,37360,23888,33576,27136,29792,30384,23328,30384,16784,30384,16784,37440,23328,37440,
+ 29248,37440,32560,40032,35872,42624,35872,47264,35872,52144,32792,54760,29712,57376,24016,57376,20224,57376,16192,56528,
+ 12160,55680,7728,53968,7728,61888,12880,63248,16896,63928,20912,64608,24016,64608,33280,64608,38824,59952,44368,55296,
+ 44368,47600,44368,42368,41456,38888,38544,35408,32976,33952,31232,55632,11216,22096,31232,22096,31232,55632,29840,63456,
+ 39776,63456,39776,22096,48240,22096,48240,15136,39776,15136,39776,0,31232,0,31232,15136,4336,15136,4336,23248,
+ 29840,63456,8800,63456,40928,63456,40928,56224,16624,56224,16624,40624,18448,41312,20296,41632,22144,41952,24016,41952,
+ 33872,41952,39656,36128,45440,30304,45440,20352,45440,10320,39384,4544,33328,-1232,22816,-1232,17760,-1232,13576,-552,
+ 9392,128,6080,1488,6080,10208,9984,8080,13936,7040,17888,6000,22016,6000,29120,6000,32960,9736,36800,13472,
+ 36800,20352,36800,27152,32832,30936,28864,34720,21760,34720,18320,34720,15048,33936,11776,33152,8800,31584,8800,63456,
+ 42112,62048,42112,54144,39440,55712,36424,56544,33408,57376,30128,57376,21968,57376,17760,51232,13552,45088,13552,33152,
+ 15600,37408,19208,39680,22816,41952,27504,41952,36672,41952,41712,36320,46752,30688,46752,20352,46752,10080,41568,4424,
+ 36384,-1232,26992,-1232,15936,-1232,10792,6696,5648,14624,5648,31664,5648,47728,11832,56168,18016,64608,29744,64608,
+ 32896,64608,36040,63944,39184,63280,42112,62048,26816,35232,21328,35232,18184,31280,15040,27328,15040,20352,15040,13392,
+ 18184,9440,21328,5488,26816,5488,32512,5488,35400,9248,38288,13008,38288,20352,38288,27760,35400,31496,32512,35232,
+ 26816,35232,5904,63456,45856,63456,45856,59792,23168,0,14192,0,36288,56224,5904,56224,5904,63456,26176,30128,
+ 20448,30128,17320,26920,14192,23712,14192,17856,14192,11984,17360,8736,20528,5488,26176,5488,31968,5488,35088,8696,
+ 38208,11904,38208,17856,38208,23680,35040,26904,31872,30128,26176,30128,18704,33696,13216,35104,10136,38928,7056,42752,
+ 7056,48160,7056,55712,12200,60160,17344,64608,26176,64608,35056,64608,40200,60160,45344,55712,45344,48160,45344,42752,
+ 42264,38928,39184,35104,33696,33696,40080,32304,43456,28056,46832,23808,46832,17040,46832,8464,41352,3616,35872,-1232,
+ 26176,-1232,16496,-1232,11032,3592,5568,8416,5568,16960,5568,23760,8944,28032,12320,32304,18704,33696,15600,47344,
+ 15600,42240,18320,39568,21040,36896,26176,36896,31360,36896,34080,39568,36800,42240,36800,47344,36800,52528,34104,55248,
+ 31408,57968,26176,57968,21040,57968,18320,55224,15600,52480,15600,47344,25328,28128,30816,28128,33936,32088,37056,36048,
+ 37056,43008,37056,49984,33936,53936,30816,57888,25328,57888,19632,57888,16744,54128,13856,50368,13856,43008,13856,35616,
+ 16728,31872,19600,28128,25328,28128,10032,1312,10032,9216,12704,7648,15720,6824,18736,6000,22016,6000,30176,6000,
+ 34360,12136,38544,18272,38544,30224,36544,25968,32936,23696,29328,21424,24656,21424,15472,21424,10432,27072,5392,32720,
+ 5392,43088,5392,53344,10560,58976,15728,64608,25168,64608,36208,64608,41352,56656,46496,48704,46496,31664,46496,15648,
+ 40312,7208,34128,-1232,22352,-1232,19248,-1232,16104,-576,12960,80,10032,1312,20784,45184,31488,45184,31488,32304,
+ 20784,32304,20784,45184,20784,12960,31488,12960,31488,0,20784,0,20784,12960,21328,12880,32048,12880,32048,4080,
+ 23680,-12192,17120,-12192,21328,4080,21328,12880,20784,45184,31488,45184,31488,32304,20784,32304,20784,45184,48656,40848,
+ 12544,27248,48656,13776,48656,6000,3744,23760,3744,30816,48656,48576,48656,40848,3744,22272,48656,22272,48656,14960,
+ 3744,14960,3744,22272,3744,39520,48656,39520,48656,32304,3744,32304,3744,39520,3744,40848,3744,48576,48656,30816,
+ 48656,23760,3744,6000,3744,13776,39872,27248,3744,40848,29072,17040,20992,17040,20992,23584,20992,27760,22288,30664,
+ 23584,33568,27152,37056,30976,40848,33616,43344,34616,45216,35616,47088,35616,49168,35616,52960,32832,55296,30048,57632,
+ 25408,57632,22096,57632,18312,56168,14528,54704,10368,51808,10368,59792,14368,62224,18424,63416,22480,64608,26896,64608,
+ 34800,64608,39504,60528,44208,56448,44208,49600,44208,46368,42784,43584,41360,40800,37360,36896,33616,33232,30688,30432,
+ 29880,28648,29072,26864,29072,24272,29072,22272,29072,17040,20704,10800,29328,10800,29328,0,20704,0,20704,10800,
+ 44112,23168,44112,28640,41392,31936,38672,35232,34128,35232,29584,35232,26840,31936,24096,28640,24096,23168,24096,17632,
+ 26840,14344,29584,11056,34128,11056,38672,11056,41392,14344,44112,17632,44112,23168,50064,5744,43952,5744,43952,10448,
+ 42368,7776,39584,6328,36800,4880,33328,4880,26480,4880,21992,10024,17504,15168,17504,23168,17504,31152,21992,36296,
+ 26480,41440,33328,41440,36720,41440,39568,39952,42416,38464,43952,35872,43952,38544,43952,45184,40208,49216,36464,53248,
+ 30304,53248,19840,53248,13664,45112,7488,36976,7488,23072,7488,9088,14496,800,21504,-7488,33152,-7488,35440,-7488,
+ 37736,-7056,40032,-6624,42464,-5744,44496,-11472,41824,-12544,39208,-13048,36592,-13552,34128,-13552,18960,-13552,10056,-3656,
+ 1152,6240,1152,23072,1152,39648,9136,49464,17120,59280,30560,59280,39440,59280,44752,53632,50064,47984,50064,38464,
+ 50064,5744,26176,55888,17120,23424,35232,23424,26176,55888,20992,63456,31408,63456,50832,0,41952,0,37280,16528,
+ 15040,16528,10448,0,1568,0,20992,63456,15680,30304,15680,7056,25840,7056,33328,7056,36512,9672,39696,12288,
+ 39696,18272,39696,24480,36336,27392,32976,30304,25840,30304,15680,30304,15680,56400,15680,37280,25664,37280,31872,37280,
+ 34656,39656,37440,42032,37440,47344,37440,52144,34704,54272,31968,56400,25664,56400,15680,56400,7056,63456,25840,63456,
+ 35568,63456,40840,59248,46112,55040,46112,47344,46112,41520,43328,38160,40544,34800,34976,33952,41232,33024,44776,28624,
+ 48320,24224,48320,17424,48320,8800,42672,4400,37024,0,25840,0,7056,0,7056,63456,45600,2256,42336,512,
+ 38888,-360,35440,-1232,31584,-1232,19376,-1232,12640,7392,5904,16016,5904,31664,5904,47216,12688,55912,19472,64608,
+ 31584,64608,35440,64608,38888,63736,42336,62864,45600,61120,45600,52320,42464,54912,38848,56272,35232,57632,31584,57632,
+ 23200,57632,19040,51168,14880,44704,14880,31664,14880,18656,19040,12200,23200,5744,31584,5744,35312,5744,38904,7104,
+ 42496,8464,45600,11056,45600,2256,18528,7056,29360,7056,33656,12392,37952,17728,37952,31664,37952,45728,33680,51064,
+ 29408,56400,18528,56400,14448,56400,14448,7056,18528,7056,18704,63456,33232,63456,40120,55720,47008,47984,47008,31664,
+ 47008,15424,40120,7712,33232,0,18704,0,5824,0,5824,63456,18704,63456,8368,63456,46032,63456,46032,56224,
+ 16960,56224,16960,37440,44752,37440,44752,30224,16960,30224,16960,7232,46832,7232,46832,0,8368,0,8368,63456,
+ 9904,63456,47264,63456,47264,56224,18528,56224,18528,37520,44576,37520,44576,30304,18528,30304,18528,0,9904,0,
+ 9904,63456,46928,5232,43472,2048,39160,408,34848,-1232,29840,-1232,17760,-1232,11048,7416,4336,16064,4336,31664,
+ 4336,47216,11136,55912,17936,64608,30048,64608,34048,64608,37704,63480,41360,62352,44752,60048,44752,51248,41312,54528,
+ 37696,56080,34080,57632,30048,57632,21680,57632,17488,51152,13296,44672,13296,31664,13296,18448,17360,12096,21424,5744,
+ 29840,5744,32688,5744,34832,6400,36976,7056,38720,8464,38720,25504,29488,25504,29488,32560,46928,32560,46928,5232,
+ 5824,63456,14448,63456,14448,37440,37952,37440,37952,63456,46576,63456,46576,0,37952,0,37952,30224,14448,30224,
+ 14448,0,5824,0,5824,63456,8544,63456,43776,63456,43776,56224,30480,56224,30480,7232,43776,7232,43776,0,
+ 8544,0,8544,7232,21840,7232,21840,56224,8544,56224,8544,63456,4640,2592,4640,12624,8496,9184,12624,7464,
+ 16752,5744,21168,5744,27248,5744,29648,8904,32048,12064,32048,20704,32048,56224,15856,56224,15856,63456,40624,63456,
+ 40624,20704,40624,8720,36144,3744,31664,-1232,21168,-1232,17088,-1232,13048,-296,9008,640,4640,2592,5824,63456,
+ 14448,63456,14448,35232,41264,63456,51344,63456,26640,37520,52064,0,41696,0,20992,31792,14448,24816,14448,0,
+ 5824,0,5824,63456,9136,63456,17760,63456,17760,7232,48400,7232,48400,0,9136,0,9136,63456,3648,63456,
+ 15136,63456,26096,31152,37152,63456,48656,63456,48656,0,40720,0,40720,56064,29408,22608,22912,22608,11568,56064,
+ 11568,0,3648,0,3648,63456,5904,63456,16784,63456,38208,11216,38208,63456,46496,63456,46496,0,35616,0,
+ 14192,52240,14192,0,5904,0,5904,63456,38464,31664,38464,45648,35592,51640,32720,57632,26176,57632,19680,57632,
+ 16808,51640,13936,45648,13936,31664,13936,17728,16808,11736,19680,5744,26176,5744,32720,5744,35592,11712,38464,17680,
+ 38464,31664,47424,31664,47424,15088,42176,6928,36928,-1232,26176,-1232,15424,-1232,10200,6888,4976,15008,4976,31664,
+ 4976,48288,10224,56448,15472,64608,26176,64608,36928,64608,42176,56448,47424,48288,47424,31664,16960,56400,16960,32560,
+ 26896,32560,32848,32560,36184,35704,39520,38848,39520,44496,39520,50144,36208,53272,32896,56400,26896,56400,16960,56400,
+ 8368,63456,26896,63456,37520,63456,43008,58632,48496,53808,48496,44496,48496,35104,43032,30304,37568,25504,26896,25504,
+ 16960,25504,16960,0,8368,0,8368,63456,27840,-1152,27536,-1152,26984,-1192,26432,-1232,26096,-1232,15472,-1232,
+ 10224,6928,4976,15088,4976,31664,4976,48288,10224,56448,15472,64608,26176,64608,36928,64608,42176,56448,47424,48288,
+ 47424,31664,47424,19168,44512,11536,41600,3904,35696,848,44208,-7232,37776,-11472,27840,-1152,38464,31664,38464,45648,
+ 35592,51640,32720,57632,26176,57632,19680,57632,16808,51640,13936,45648,13936,31664,13936,17728,16808,11736,19680,5744,
+ 26176,5744,32720,5744,35592,11712,38464,17680,38464,31664,32304,29968,35616,29120,37952,26760,40288,24400,43776,17344,
+ 52400,0,43184,0,35616,16016,32336,22864,29728,24840,27120,26816,22912,26816,14704,26816,14704,0,6080,0,
+ 6080,63456,23760,63456,34208,63456,39776,58736,45344,54016,45344,45088,45344,38800,41928,34824,38512,30848,32304,29968,
+ 14704,56400,14704,33872,24096,33872,30256,33872,33272,36632,36288,39392,36288,45088,36288,50576,33080,53488,29872,56400,
+ 23760,56400,14704,56400,43008,61280,43008,52576,39104,55088,35168,56360,31232,57632,27248,57632,21168,57632,17640,54808,
+ 14112,51984,14112,47168,14112,42960,16424,40752,18736,38544,25072,37056,29584,36048,38512,33952,42592,29496,46672,25040,
+ 46672,17344,46672,8288,41056,3528,35440,-1232,24736,-1232,20272,-1232,15768,-272,11264,688,6720,2592,6720,11728,
+ 11600,8624,15960,7184,20320,5744,24736,5744,31232,5744,34848,8656,38464,11568,38464,16784,38464,21552,35976,24056,
+ 33488,26560,27328,27920,22736,28992,13904,30976,9904,35016,5904,39056,5904,45856,5904,54352,11624,59480,17344,64608,
+ 26816,64608,30480,64608,34512,63776,38544,62944,43008,61280,2000,63456,50400,63456,50400,56224,30560,56224,30560,0,
+ 21936,0,21936,56224,2000,56224,2000,63456,6240,24352,6240,63456,14880,63456,14880,20448,14880,15808,15136,13832,
+ 15392,11856,16016,10800,17376,8288,19952,7016,22528,5744,26176,5744,29872,5744,32424,7016,34976,8288,36384,10800,
+ 37024,11856,37272,13808,37520,15760,37520,20352,37520,63456,46112,63456,46112,24352,46112,14624,44904,10520,43696,6416,
+ 40720,3744,37904,1232,34296,0,30688,-1232,26176,-1232,21712,-1232,18104,0,14496,1232,11648,3744,8720,6368,
+ 7480,10560,6240,14752,6240,24352,26176,7232,41104,63456,49984,63456,31408,0,20992,0,2416,63456,11312,63456,
+ 26176,7232,0,63456,8368,63456,14448,11936,21680,46032,30640,46032,37952,11856,44032,63456,52400,63456,42928,0,
+ 34800,0,26176,37696,17600,0,9472,0,0,63456,3648,63456,12880,63456,26816,39520,41008,63456,50240,63456,
+ 31232,33616,51600,0,42368,0,26816,27328,10032,0,768,0,22016,33616,3648,63456,1568,63456,10704,63456,
+ 26176,35440,41600,63456,50832,63456,30480,28480,30480,0,21840,0,21840,28480,1568,63456,7568,63456,48752,63456,
+ 48752,56912,15600,7232,49680,7232,49680,0,6624,0,6624,6544,38880,56224,7568,56224,7568,63456,19680,66128,
+ 37696,66128,37696,60048,27504,60048,27504,-5392,37696,-5392,37696,-11472,19680,-11472,19680,66128,12448,63456,45856,-8080,
+ 37776,-8080,4336,63456,12448,63456,32720,66128,32720,-11472,14704,-11472,14704,-5392,24912,-5392,24912,60048,14704,60048,
+ 14704,66128,32720,66128,29968,63456,49344,39776,41776,39776,26176,56560,10624,39776,3056,39776,22448,63456,29968,63456,
+ 52400,-17120,52400,-20528,0,-20528,0,-17120,52400,-17120,20272,69616,32208,53632,25664,53632,11856,69616,20272,69616,
+ 29840,23920,27248,23920,20400,23920,16936,21520,13472,19120,13472,14368,13472,10080,16064,7696,18656,5312,23248,5312,
+ 29712,5312,33408,9800,37104,14288,37152,22192,37152,23920,29840,23920,45008,27152,45008,0,37152,0,37152,7056,
+ 34640,2800,30832,784,27024,-1232,21584,-1232,14320,-1232,9984,2872,5648,6976,5648,13856,5648,21808,10984,25928,
+ 16320,30048,26640,30048,37152,30048,37152,31280,37104,36976,34256,39544,31408,42112,25168,42112,21168,42112,17088,40968,
+ 13008,39824,9136,37616,9136,45440,13472,47088,17448,47920,21424,48752,25168,48752,31072,48752,35256,47008,39440,45264,
+ 42032,41776,43648,39648,44328,36528,45008,33408,45008,27152,39008,23760,39008,32848,36120,37480,33232,42112,27584,42112,
+ 21888,42112,18952,37464,16016,32816,16016,23760,16016,14752,18952,10072,21888,5392,27584,5392,33232,5392,36120,10024,
+ 39008,14656,39008,23760,16016,41520,17888,45008,21184,46880,24480,48752,28816,48752,37408,48752,42336,42144,47264,35536,
+ 47264,23920,47264,12160,42312,5464,37360,-1232,28736,-1232,24480,-1232,21232,616,17984,2464,16016,6000,16016,0,
+ 8208,0,8208,66128,16016,66128,16016,41520,45088,2416,41952,592,38616,-320,35280,-1232,31792,-1232,20736,-1232,
+ 14512,5400,8288,12032,8288,23760,8288,35488,14512,42120,20736,48752,31792,48752,35232,48752,38504,47856,41776,46960,
+ 45088,45088,45088,36896,41984,39648,38864,40880,35744,42112,31792,42112,24432,42112,20480,37352,16528,32592,16528,23760,
+ 16528,14960,20504,10176,24480,5392,31792,5392,35872,5392,39104,6648,42336,7904,45088,10544,45088,2416,36464,41520,
+ 36464,66128,44288,66128,44288,0,36464,0,36464,6000,34512,2464,31256,616,28000,-1232,23760,-1232,15136,-1232,
+ 10184,5464,5232,12160,5232,23920,5232,35536,10200,42144,15168,48752,23760,48752,28048,48752,31320,46904,34592,45056,
+ 36464,41520,13472,23760,13472,14656,16360,10024,19248,5392,24912,5392,30560,5392,33512,10072,36464,14752,36464,23760,
+ 36464,32816,33512,37464,30560,42112,24912,42112,19248,42112,16360,37480,13472,32848,13472,23760,47264,25760,47264,21936,
+ 13392,21936,13392,21680,13392,13904,17448,9648,21504,5392,28896,5392,32640,5392,36720,6584,40800,7776,45440,10208,
+ 45440,2416,40976,592,36832,-320,32688,-1232,28816,-1232,17728,-1232,11480,5416,5232,12064,5232,23760,5232,35152,
+ 11352,41952,17472,48752,27664,48752,36768,48752,42016,42584,47264,36416,47264,25760,39440,28048,39264,34928,36184,38520,
+ 33104,42112,27328,42112,21680,42112,18024,38376,14368,34640,13680,28000,39440,28048,45184,66128,45184,59632,36288,59632,
+ 32080,59632,30448,57912,28816,56192,28816,51808,28816,47600,45184,47600,45184,41520,28816,41520,28816,0,20992,0,
+ 20992,41520,8288,41520,8288,47600,20992,47600,20992,50912,20992,58736,24584,62432,28176,66128,35792,66128,45184,66128,
+ 36464,24176,36464,32976,33592,37544,30720,42112,25248,42112,19504,42112,16488,37544,13472,32976,13472,24176,13472,15392,
+ 16512,10776,19552,6160,25328,6160,30720,6160,33592,10792,36464,15424,36464,24176,44288,3056,44288,-7648,39232,-13176,
+ 34176,-18704,24352,-18704,21120,-18704,17592,-18104,14064,-17504,10544,-16368,10544,-8624,14704,-10576,18104,-11512,21504,-12448,
+ 24352,-12448,30688,-12448,33576,-9008,36464,-5568,36464,1920,36464,2256,36464,7568,34592,3568,31360,1616,28128,-336,
+ 23504,-336,15168,-336,10200,6336,5232,13008,5232,24176,5232,35408,10200,42080,15168,48752,23504,48752,28096,48752,
+ 31280,46920,34464,45088,36464,41264,36464,47424,44288,47424,44288,3056,44672,29488,44672,0,36800,0,36800,29488,
+ 36800,35920,34552,38936,32304,41952,27504,41952,22016,41952,19064,38064,16112,34176,16112,26896,16112,0,8288,0,
+ 8288,66128,16112,66128,16112,40464,18192,44544,21760,46648,25328,48752,30224,48752,37488,48752,41080,43968,44672,39184,
+ 44672,29488,10880,47600,30896,47600,30896,6080,46416,6080,46416,0,7568,0,7568,6080,23072,6080,23072,41520,
+ 10880,41520,10880,47600,23072,66128,30896,66128,30896,56224,23072,56224,23072,66128,25504,-848,25504,41520,12032,41520,
+ 12032,47600,33328,47600,33328,-848,33328,-9136,29520,-13624,25712,-18112,18704,-18112,7904,-18112,7904,-11472,17856,-11472,
+ 21680,-11472,23592,-8816,25504,-6160,25504,-848,25504,66128,33328,66128,33328,56224,25504,56224,25504,66128,10032,66128,
+ 18112,66128,18112,27840,38640,47600,48160,47600,29408,29664,51088,0,41520,0,23920,24560,18112,19088,18112,0,
+ 10032,0,10032,66128,27152,17248,27152,11984,29088,9304,31024,6624,34800,6624,43952,6624,43952,0,34048,0,
+ 27024,0,23184,4504,19344,9008,19344,17248,19344,60480,6800,60480,6800,66592,27152,66592,27152,17248,28736,42752,
+ 30176,45808,32408,47280,34640,48752,37776,48752,43520,48752,45880,44312,48240,39872,48240,27584,48240,0,41104,0,
+ 41104,27248,41104,37312,39976,39760,38848,42208,35872,42208,32464,42208,31216,39592,29968,36976,29968,27248,29968,0,
+ 22816,0,22816,27248,22816,37440,21608,39824,20400,42208,17248,42208,14160,42208,12944,39592,11728,36976,11728,27248,
+ 11728,0,4640,0,4640,47600,11728,47600,11728,43520,13136,46064,15240,47408,17344,48752,20016,48752,23248,48752,
+ 25392,47264,27536,45776,28736,42752,44672,29488,44672,0,36800,0,36800,29488,36800,35920,34552,38936,32304,41952,
+ 27504,41952,22016,41952,19064,38064,16112,34176,16112,26896,16112,0,8288,0,8288,47600,16112,47600,16112,40464,
+ 18192,44544,21760,46648,25328,48752,30224,48752,37488,48752,41080,43968,44672,39184,44672,29488,26176,42112,20224,42112,
+ 17168,37480,14112,32848,14112,23760,14112,14704,17168,10048,20224,5392,26176,5392,32176,5392,35232,10048,38288,14704,
+ 38288,23760,38288,32848,35232,37480,32176,42112,26176,42112,26176,48752,36080,48752,41328,42336,46576,35920,46576,23760,
+ 46576,11568,41352,5168,36128,-1232,26176,-1232,16272,-1232,11048,5168,5824,11568,5824,23760,5824,35920,11048,42336,
+ 16272,48752,26176,48752,15936,6000,15936,-18112,8080,-18112,8080,47600,15936,47600,15936,41520,17888,45056,21144,46904,
+ 24400,48752,28640,48752,37280,48752,42184,42080,47088,35408,47088,23584,47088,11984,42160,5376,37232,-1232,28640,-1232,
+ 24304,-1232,21056,616,17808,2464,15936,6000,38880,23760,38880,32848,36016,37480,33152,42112,27504,42112,21808,42112,
+ 18872,37464,15936,32816,15936,23760,15936,14752,18872,10072,21808,5392,27504,5392,33152,5392,36016,10024,38880,14656,
+ 38880,23760,14112,23584,14112,14496,16976,9864,19840,5232,25504,5232,31152,5232,34064,9880,36976,14528,36976,23584,
+ 36976,32640,34064,37296,31152,41952,25504,41952,19840,41952,16976,37320,14112,32688,14112,23584,36976,5904,35056,2384,
+ 31808,488,28560,-1408,24272,-1408,15728,-1408,10776,5200,5824,11808,5824,23424,5824,35232,10752,41904,15680,48576,
+ 24272,48576,28512,48576,31768,46728,35024,44880,36976,41360,36976,47424,44832,47424,44832,-18272,36976,-18272,36976,5904,
+ 49088,37776,46576,39744,43984,40632,41392,41520,38288,41520,30976,41520,27112,36928,23248,32336,23248,23680,23248,0,
+ 15392,0,15392,47600,23248,47600,23248,38288,25200,43344,29264,46048,33328,48752,38880,48752,41776,48752,44288,48024,
+ 46800,47296,49088,45776,49088,37776,41360,45936,41360,38288,38000,40240,34600,41224,31200,42208,27664,42208,22352,42208,
+ 19736,40488,17120,38768,17120,35232,17120,32048,19080,30472,21040,28896,28816,27408,31968,26816,37776,25712,40776,22400,
+ 43776,19088,43776,13776,43776,6720,38760,2744,33744,-1232,24816,-1232,21296,-1232,17424,-488,13552,256,9056,1744,
+ 9056,9824,13424,7568,17424,6440,21424,5312,24992,5312,30176,5312,33024,7416,35872,9520,35872,13296,35872,18736,
+ 25456,20832,25120,20912,22192,21504,15424,22816,12320,25944,9216,29072,9216,34464,9216,41312,13848,45032,18480,48752,
+ 27072,48752,30896,48752,34424,48048,37952,47344,41360,45936,26096,61120,26096,47600,43856,47600,43856,41520,26096,41520,
+ 26096,15680,26096,10416,28096,8328,30096,6240,35056,6240,43856,6240,43856,0,34304,0,25504,0,21888,3528,
+ 18272,7056,18272,15680,18272,41520,5568,41520,5568,47600,18272,47600,18272,61120,26096,61120,8288,18016,8288,47520,
+ 16112,47520,16112,18016,16112,11600,18384,8584,20656,5568,25408,5568,30944,5568,33872,9456,36800,13344,36800,20608,
+ 36800,47520,44672,47520,44672,0,36800,0,36800,7136,34720,3024,31128,896,27536,-1232,22736,-1232,15424,-1232,
+ 11856,3552,8288,8336,8288,18016,4256,47600,12368,47600,26176,7648,40032,47600,48160,47600,31232,0,21168,0,
+ 4256,47600,0,47600,7728,47600,16016,9136,22816,33696,29488,33696,36384,9136,44672,47600,52400,47600,41264,0,
+ 33792,0,26176,26096,18608,0,11136,0,0,47600,47520,47600,30480,24816,49168,0,40128,0,26176,19088,
+ 12288,0,3232,0,21936,24816,4880,47600,13552,47600,26176,30384,38720,47600,47520,47600,36464,15296,34512,10320,
+ 31488,2208,27280,-9008,25840,-11472,23888,-14784,20952,-16448,18016,-18112,14112,-18112,7824,-18112,7824,-11568,12448,-11568,
+ 15888,-11568,17848,-9568,19808,-7568,22816,768,4416,47600,12704,47600,26816,10368,40720,47600,49008,47600,36464,15296,
+ 9648,47680,44208,47680,44208,40544,16880,6368,44208,6368,44208,0,8624,0,8624,7232,35952,41440,9648,41440,
+ 9648,47680,43008,-8080,43008,-14192,40288,-14192,29712,-14192,26120,-11048,22528,-7904,22528,1488,22528,11648,22528,18064,
+ 20256,20528,17984,22992,12032,22992,9392,22992,9392,29072,12032,29072,18016,29072,20272,31496,22528,33920,22528,40288,
+ 22528,50496,22528,59888,26120,63008,29712,66128,40288,66128,43008,66128,43008,60048,40032,60048,34080,60048,32280,58200,
+ 30480,56352,30480,50320,30480,39776,30480,33104,28544,30088,26608,27072,21936,26016,26640,24864,28560,21848,30480,18832,
+ 30480,12192,30480,1664,30480,-4416,32280,-6248,34080,-8080,40032,-8080,43008,-8080,29840,66512,29840,-20528,22528,-20528,
+ 22528,66512,29840,66512,9392,-8080,12288,-8080,18272,-8080,20104,-6208,21936,-4336,21936,1664,21936,12192,21936,18832,
+ 23848,21848,25760,24864,30480,26016,25792,27072,23864,30088,21936,33104,21936,39776,21936,50320,21936,56320,20104,58184,
+ 18272,60048,12288,60048,9392,60048,9392,66128,12032,66128,22608,66128,26176,63008,29744,59888,29744,50496,29744,40288,
+ 29744,33920,32024,31496,34304,29072,40288,29072,43008,29072,43008,22992,40288,22992,34304,22992,32024,20528,29744,18064,
+ 29744,11648,29744,1488,29744,-7904,26176,-11048,22608,-14192,12032,-14192,9392,-14192,9392,-8080,48656,33152,48656,25760,
+ 45472,23248,42432,22080,39392,20912,36048,20912,32208,20912,27408,23072,26480,23504,26016,23680,22736,25072,20552,25584,
+ 18368,26096,16192,26096,12832,26096,9840,24840,6848,23584,3744,20912,3744,28304,7056,30848,10160,32000,13264,33152,
+ 16784,33152,19040,33152,21168,32680,23296,32208,26432,30896,26944,30688,27840,30256,32768,27920,36720,27920,39696,27920,
+ 42608,29216,45520,30512,48656,33152,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,4416,-15392,4416,61376,47936,61376,47936,-15392,4416,-15392,9312,-10544,43088,-10544,
+ 43088,56480,9312,56480,9312,-10544,21936,52656,21936,63456,30560,63456,30560,52656,21936,52656,21936,0,21936,27840,
+ 22816,43008,29664,43008,30560,27840,30560,0,21936,0,45088,45776,45088,38464,42240,40160,39480,41096,36720,42032,
+ 34048,42208,34048,5232,36720,5440,39504,6400,42288,7360,45088,9056,45088,1744,41984,432,39224,-296,36464,-1024,
+ 34048,-1152,34048,-13296,29664,-13296,29664,-1152,20096,-208,14576,6440,9056,13088,9056,23760,9056,34384,14640,41120,
+ 20224,47856,29664,48656,29664,60864,34048,60864,34048,48656,36464,48528,39224,47808,41984,47088,45088,45776,29664,5392,
+ 29664,42112,24048,41600,20648,36592,17248,31584,17248,23760,17248,15936,20648,10944,24048,5952,29664,5392,46416,62128,
+ 46416,54320,43776,56192,41080,57120,38384,58048,35536,58048,29840,58048,27136,54248,24432,50448,24432,42288,24432,33072,
+ 40208,33072,40208,26992,24432,26992,24432,7232,47264,7232,47264,0,5904,0,5904,7232,15936,7232,15936,26992,
+ 7488,26992,7488,33072,15936,33072,15936,43184,15936,53968,20592,59288,25248,64608,34720,64608,37488,64608,40400,63984,
+ 43312,63360,46416,62128,36896,27328,36896,31152,34256,33768,31616,36384,27760,36384,23920,36384,21264,33768,18608,31152,
+ 18608,27328,18608,23424,21264,20768,23920,18112,27760,18112,31616,18112,34256,20784,36896,23456,36896,27328,35872,39264,
+ 42928,46320,46752,42368,39696,35312,40976,33232,41592,31256,42208,29280,42208,27248,42208,25120,41568,23184,40928,21248,
+ 39616,19344,46752,12288,42752,8288,35696,15392,33744,14064,31808,13432,29872,12800,27760,12800,25712,12800,23672,13416,
+ 21632,14032,19600,15216,12624,8288,8720,12112,15760,19168,14448,21328,13832,23304,13216,25280,13216,27248,13216,29360,
+ 13872,31344,14528,33328,15856,35232,8720,42288,12704,46320,19760,39184,21712,40496,23648,41136,25584,41776,27760,41776,
+ 29712,41776,31704,41160,33696,40544,35872,39264,1568,63456,10704,63456,26176,35440,41600,63456,50832,63456,36800,39616,
+ 47520,39616,47520,34896,34128,34896,30480,28480,30480,26992,47520,26992,47520,22272,30480,22272,30480,0,21840,0,
+ 21840,22272,4880,22272,4880,26992,21840,26992,21840,28480,18016,34896,4880,34896,4880,39616,15216,39616,1568,63456,
+ 29840,60864,29840,28640,22528,28640,22528,60864,29840,60864,29840,17344,29840,-14880,22528,-14880,22528,17344,29840,17344,
+ 39776,62128,39776,55168,36256,56816,33216,57648,30176,58480,27760,58480,23632,58480,21360,56784,19088,55088,19088,52064,
+ 19088,48240,27792,43344,28896,42720,29488,42368,38512,37312,41272,34040,44032,30768,44032,26480,44032,22656,42096,19680,
+ 40160,16704,36208,14448,38800,12240,40032,9920,41264,7600,41264,4880,41264,-1152,36928,-4720,32592,-8288,25248,-8288,
+ 22144,-8288,18848,-7672,15552,-7056,11856,-5824,11856,1152,15552,-512,18696,-1336,21840,-2160,24272,-2160,28608,-2160,
+ 31008,-376,33408,1408,33408,4640,33408,8960,24016,14192,22992,14784,13904,19888,11184,23144,8464,26400,8464,30720,
+ 8464,34592,10440,37632,12416,40672,16272,42752,13728,44624,12472,47008,11216,49392,11216,52320,11216,57840,15472,61224,
+ 19728,64608,26816,64608,29872,64608,33128,63984,36384,63360,39776,62128,20608,39776,17984,37872,16688,35960,15392,34048,
+ 15392,32048,15392,28816,18384,25944,21376,23072,31872,17424,34512,19344,35784,21256,37056,23168,37056,25168,37056,28384,
+ 34016,31280,30976,34176,20608,39776,13552,65968,22192,65968,22192,57376,13552,57376,13552,65968,30224,65968,38800,65968,
+ 38800,57376,30224,57376,30224,65968,36720,45520,36720,40928,34256,42112,31896,42688,29536,43264,27072,43264,22096,43264,
+ 19232,40096,16368,36928,16368,31488,16368,25888,19344,22864,22320,19840,27840,19840,30224,19840,32408,20376,34592,20912,
+ 36720,22016,36720,17600,34512,16624,32088,16152,29664,15680,27072,15680,19424,15680,15024,19928,10624,24176,10624,31488,
+ 10624,38848,15048,43136,19472,47424,27072,47424,29664,47424,32088,46960,34512,46496,36720,45520,26176,53344,21680,53344,
+ 17832,51768,13984,50192,10800,47008,7600,43824,5968,39912,4336,36000,4336,31488,4336,27072,5968,23184,7600,19296,
+ 10800,16112,14032,12880,17872,11264,21712,9648,26176,9648,30688,9648,34536,11264,38384,12880,41600,16112,44832,19344,
+ 46432,23184,48032,27024,48032,31488,48032,36000,46416,39912,44800,43824,41600,47008,38416,50192,34568,51768,30720,53344,
+ 26176,53344,26176,57712,31584,57712,36216,55800,40848,53888,44672,50064,48496,46192,50448,41520,52400,36848,52400,31488,
+ 52400,26176,50464,21544,48528,16912,44672,13040,40800,9184,36168,7248,31536,5312,26176,5312,20864,5312,16232,7248,
+ 11600,9184,7728,13040,3872,16912,1936,21544,0,26176,0,31488,0,36848,1952,41520,3904,46192,7728,50064,
+ 11568,53888,16200,55800,20832,57712,26176,57712,29072,46928,22944,46928,20312,45480,17680,44032,17680,40720,17680,38000,
+ 19528,36360,21376,34720,24432,34720,28896,34720,31680,37760,34464,40800,34464,45680,34464,46928,29072,46928,40544,49520,
+ 40544,30480,34464,30480,34464,35232,32384,32464,29600,31064,26816,29664,23328,29664,17856,29664,14664,32552,11472,35440,
+ 11472,40368,11472,45856,15448,48832,19424,51808,26736,51808,34464,51808,34464,51984,34464,55808,31936,57760,29408,59712,
+ 24432,59712,22272,59712,19616,58968,16960,58224,14112,56816,14112,62224,17008,63408,19872,64008,22736,64608,25408,64608,
+ 33232,64608,36888,60952,40544,57296,40544,49520,12448,25168,40848,25168,40848,19936,12448,19936,12448,25168,24992,45008,
+ 24992,36896,12192,25504,24992,14112,24992,6000,5056,23760,5056,27248,24992,45008,44288,45008,44288,36896,31488,25504,
+ 44288,14112,44288,6000,24352,23760,24352,27248,44288,45008,3744,36640,48656,36640,48656,15760,41520,15760,41520,29328,
+ 3744,29328,3744,36640,15136,27328,37280,27328,37280,20352,15136,20352,15136,27328,25504,46752,31744,46752,34808,44672,
+ 37872,42592,37872,38288,37872,35280,36000,33304,34128,31328,30720,30720,31536,30512,32768,29088,34000,27664,35616,25168,
+ 40464,17248,34384,17248,29840,24656,27760,28048,26464,28944,25168,29840,23248,29840,20912,29840,20912,17248,15392,17248,
+ 15392,46752,25504,46752,25248,43184,20912,43184,20912,33328,25248,33328,29072,33328,30640,34472,32208,35616,32208,38288,
+ 32208,40928,30640,42056,29072,43184,25248,43184,26176,57712,31584,57712,36216,55800,40848,53888,44672,50064,48496,46192,
+ 50448,41520,52400,36848,52400,31488,52400,26176,50464,21544,48528,16912,44672,13040,40800,9184,36168,7248,31536,5312,
+ 26176,5312,20864,5312,16232,7248,11600,9184,7728,13040,3872,16912,1936,21544,0,26176,0,31488,0,36848,
+ 1952,41520,3904,46192,7728,50064,11568,53888,16200,55800,20832,57712,26176,57712,26176,53344,21680,53344,17832,51768,
+ 13984,50192,10800,47008,7600,43824,5968,39912,4336,36000,4336,31488,4336,27072,5968,23184,7600,19296,10800,16112,
+ 14032,12880,17872,11264,21712,9648,26176,9648,30688,9648,34536,11264,38384,12880,41600,16112,44832,19344,46432,23184,
+ 48032,27024,48032,31488,48032,36000,46416,39912,44800,43824,41600,47008,38416,50192,34568,51768,30720,53344,26176,53344,
+ 13472,64848,38880,64848,38880,58560,13472,58560,13472,64848,26176,64608,28944,64608,31432,63560,33920,62512,35792,60560,
+ 37696,58656,38696,56232,39696,53808,39696,51008,39696,45392,35744,41504,31792,37616,26096,37616,20352,37616,16528,41440,
+ 12704,45264,12704,51008,12704,56688,16616,60648,20528,64608,26176,64608,26176,59120,22816,59120,20464,56760,18112,54400,
+ 18112,51008,18112,47600,20424,45304,22736,43008,26096,43008,29488,43008,31896,45344,34304,47680,34304,51008,34304,54352,
+ 31920,56736,29536,59120,26176,59120,3744,7232,48656,7232,48656,0,3744,0,3744,7232,29744,49760,29744,35792,
+ 48656,35792,48656,28560,29744,28560,29744,14448,22608,14448,22608,28560,3744,28560,3744,35792,22608,35792,22608,49760,
+ 29744,49760,20528,33232,37952,33232,37952,28384,13680,28384,13680,33072,23504,42672,27792,46800,29512,49392,31232,51984,
+ 31232,54144,31232,56736,29112,58352,26992,59968,23504,59968,21424,59968,19024,59200,16624,58432,13936,56912,13936,62224,
+ 16704,63408,19272,64008,21840,64608,24352,64608,30384,64608,34040,61776,37696,58944,37696,54400,37696,51984,36128,49456,
+ 34560,46928,29488,41952,20528,33232,31072,47600,35056,46704,37160,44408,39264,42112,39264,38720,39264,33440,35232,30600,
+ 31200,27760,23680,27760,21200,27760,18784,28200,16368,28640,13856,29488,13856,34640,16784,33488,19184,32936,21584,32384,
+ 23504,32384,27792,32384,30304,34104,32816,35824,32816,38720,32816,41856,30472,43472,28128,45088,23504,45088,20704,45088,
+ 20704,49680,23840,49680,27792,49680,29880,51024,31968,52368,31968,54912,31968,57296,29928,58632,27888,59968,24176,59968,
+ 22320,59968,19936,59456,17552,58944,15040,57968,15040,63120,17984,63840,20464,64224,22944,64608,25072,64608,31232,64608,
+ 34808,62096,38384,59584,38384,55376,38384,52368,36512,50384,34640,48400,31072,47600,32128,69616,40544,69616,26736,53632,
+ 20192,53632,32128,69616,8288,-18192,8288,47600,16112,47600,16112,18016,16112,11984,18656,8776,21200,5568,25920,5568,
+ 31328,5568,34064,9184,36800,12800,36800,19840,36800,47600,44672,47600,44672,10880,44672,8368,45352,7184,46032,6000,
+ 47424,6000,47808,6000,48424,6208,49040,6416,50240,6976,50240,688,48624,-304,47176,-768,45728,-1232,44288,-1232,
+ 41648,-1232,40056,448,38464,2128,37952,5488,36000,2080,33176,424,30352,-1232,26560,-1232,22656,-1232,19952,384,
+ 17248,2000,15392,5392,15392,-18192,8288,-18192,24736,63456,43776,63456,43776,-8368,37776,-8368,37776,58224,29664,58224,
+ 29664,-8368,23680,-8368,23680,27584,14528,28304,9520,33000,4512,37696,4512,45520,4512,53600,10056,58528,15600,63456,
+ 24736,63456,20784,36720,31488,36720,31488,23760,20784,23760,20784,36720,29744,0,32128,-2640,33256,-4872,34384,-7104,
+ 34384,-9136,34384,-12928,31832,-14856,29280,-16784,24272,-16784,22352,-16784,20504,-16528,18656,-16272,16784,-15760,16784,-10208,
+ 18240,-10928,19832,-11248,21424,-11568,23424,-11568,25888,-11568,27184,-10544,28480,-9520,28480,-7568,28480,-6288,27544,-4440,
+ 26608,-2592,24736,0,29744,0,15392,33072,24096,33072,24096,59040,14624,57296,14624,62224,24352,63872,30224,63872,
+ 30224,33072,38880,33072,38880,28384,15392,28384,15392,33072,26176,59632,21840,59632,19400,56312,16960,52992,16960,47088,
+ 16960,41184,19400,37912,21840,34640,26176,34640,30480,34640,32960,37976,35440,41312,35440,47088,35440,52992,33000,56312,
+ 30560,59632,26176,59632,26176,64608,33408,64608,37720,59848,42032,55088,42032,47088,42032,39136,37736,34400,33440,29664,
+ 26176,29664,18960,29664,14664,34400,10368,39136,10368,47088,10368,55088,14680,59848,18992,64608,26176,64608,11728,25168,
+ 40464,25168,40464,19936,11728,19936,11728,25168,27504,45008,47424,27248,47424,23760,27504,6000,27504,14112,40288,25504,
+ 27504,36896,27504,45008,8208,45008,28128,27248,28128,23760,8208,6000,8208,14112,20992,25504,8208,36896,8208,45008,
+ 35008,23936,41888,23936,41888,1072,46832,1072,46832,-3648,41888,-3648,41888,-11552,36032,-11552,36032,-3648,19584,-3648,
+ 19584,1504,35008,23936,36032,18624,24384,1072,36032,1072,36032,18624,4128,39216,12832,39216,12832,65184,3360,63440,
+ 3360,68368,13088,70016,18960,70016,18960,39216,27616,39216,27616,34528,4128,34528,4128,39216,2160,21424,1152,26016,
+ 46192,37152,47344,32560,2160,21424,4128,39216,12832,39216,12832,65184,3360,63440,3360,68368,13088,70016,18960,70016,
+ 18960,39216,27616,39216,27616,34528,4128,34528,4128,39216,2160,21424,1152,26016,46192,37152,47344,32560,2160,21424,
+ 28720,-6704,46144,-6704,46144,-11552,21872,-11552,21872,-6864,31696,2736,35984,6864,37704,9456,39424,12048,39424,14208,
+ 39424,16800,37304,18416,35184,20032,31696,20032,29616,20032,27216,19264,24816,18496,22128,16976,22128,22288,24896,23472,
+ 27464,24072,30032,24672,32544,24672,38576,24672,42232,21840,45888,19008,45888,14464,45888,12048,44320,9520,42752,6992,
+ 37680,2016,28720,-6704,35008,23936,41888,23936,41888,1072,46832,1072,46832,-3648,41888,-3648,41888,-11552,36032,-11552,
+ 36032,-3648,19584,-3648,19584,1504,35008,23936,36032,18624,24384,1072,36032,1072,36032,18624,21856,53744,25840,52848,
+ 27944,50552,30048,48256,30048,44864,30048,39584,26016,36744,21984,33904,14464,33904,11984,33904,9568,34344,7152,34784,
+ 4640,35632,4640,40784,7568,39632,9968,39080,12368,38528,14288,38528,18576,38528,21088,40248,23600,41968,23600,44864,
+ 23600,48000,21256,49616,18912,51232,14288,51232,11488,51232,11488,55824,14624,55824,18576,55824,20664,57168,22752,58512,
+ 22752,61056,22752,63440,20712,64776,18672,66112,14960,66112,13104,66112,10720,65600,8336,65088,5824,64112,5824,69264,
+ 8768,69984,11248,70368,13728,70752,15856,70752,22016,70752,25592,68240,29168,65728,29168,61520,29168,58512,27296,56528,
+ 25424,54544,21856,53744,2160,21424,1152,26016,46192,37152,47344,32560,2160,21424,23328,46416,31408,46416,31408,39872,
+ 31408,35696,30112,32784,28816,29872,25248,26400,21424,22608,18784,20096,17784,18232,16784,16368,16784,14288,16784,10496,
+ 19568,8160,22352,5824,26992,5824,30304,5824,34088,7288,37872,8752,42032,11648,42032,3648,38032,1232,33976,40,
+ 29920,-1152,25504,-1152,17600,-1152,12904,2928,8208,7008,8208,13856,8208,17088,9632,19872,11056,22656,15040,26560,
+ 18784,30224,21632,32944,22440,34728,23248,36512,23248,39184,23248,39232,23248,39392,23328,40368,23328,41184,23328,46416,
+ 31664,52656,23072,52656,23072,63456,31664,63456,31664,52656,26176,55888,17120,23424,35232,23424,26176,55888,20992,63456,
+ 31408,63456,50832,0,41952,0,37280,16528,15040,16528,10448,0,1568,0,20992,63456,23840,80208,32208,68992,
+ 25664,68992,16016,80208,23840,80208,26176,55888,17120,23424,35232,23424,26176,55888,20992,63456,31408,63456,50832,0,
+ 41952,0,37280,16528,15040,16528,10448,0,1568,0,20992,63456,28560,80208,36464,80208,26736,68992,20192,68992,
+ 28560,80208,26176,55888,17120,23424,35232,23424,26176,55888,20992,63456,31408,63456,50832,0,41952,0,37280,16528,
+ 15040,16528,10448,0,1568,0,20992,63456,22192,80304,30224,80304,39184,68992,33232,68992,26176,76560,19168,68992,
+ 13216,68992,22192,80304,26176,55888,17120,23424,35232,23424,26176,55888,20992,63456,31408,63456,50832,0,41952,0,
+ 37280,16528,15040,16528,10448,0,1568,0,20992,63456,26016,72176,23584,73584,22528,74176,21864,74408,21200,74640,
+ 20704,74640,19216,74640,18360,73584,17504,72528,17504,70608,17504,70352,12192,70352,12192,74640,14384,77152,16576,79664,
+ 20192,79664,21712,79664,23008,79320,24304,78976,26400,77840,28816,76560,29744,76000,30488,75752,31232,75504,31872,75504,
+ 33200,75504,34048,76584,34896,77664,34896,79408,34896,79664,40208,79664,40128,75408,37960,72880,35792,70352,32208,70352,
+ 30768,70352,29496,70696,28224,71040,26016,72176,26176,55888,17120,23424,35232,23424,26176,55888,20992,63456,31408,63456,
+ 50832,0,41952,0,37280,16528,15040,16528,10448,0,1568,0,20992,63456,13552,78976,22192,78976,22192,70352,
+ 13552,70352,13552,78976,30224,78976,38800,78976,38800,70352,30224,70352,30224,78976,32640,69104,32640,71776,30752,73672,
+ 28864,75568,26176,75568,23456,75568,21608,73720,19760,71872,19760,69104,19760,66432,21632,64560,23504,62688,26176,62688,
+ 28864,62688,30752,64560,32640,66432,32640,69104,26176,55712,17120,23424,35232,23424,26176,55712,19760,59456,17296,60864,
+ 15912,63432,14528,66000,14528,69104,14528,73952,17928,77376,21328,80800,26176,80800,31024,80800,34448,77376,37872,73952,
+ 37872,69104,37872,66000,36512,63496,35152,60992,32640,59456,50832,0,41952,0,37280,16528,15040,16528,10448,0,
+ 1568,0,19760,59456,49344,63456,49344,56224,34976,56224,34976,37440,48032,37440,48032,30224,34976,30224,34976,7232,
+ 50144,7232,50144,0,27072,0,27072,16272,12112,16272,7824,0,0,0,17424,63456,49344,63456,22528,56224,
+ 13936,23424,27072,23424,27072,56224,22528,56224,33840,0,36224,-2640,37352,-4872,38480,-7104,38480,-9136,38480,-12928,
+ 35928,-14856,33376,-16784,28368,-16784,26448,-16784,24600,-16528,22752,-16272,20880,-15760,20880,-10208,22336,-10928,23928,-11248,
+ 25520,-11568,27520,-11568,29984,-11568,31280,-10544,32576,-9520,32576,-7568,32576,-6288,31640,-4440,30704,-2592,28832,0,
+ 33840,0,45600,2256,42336,512,38888,-360,35440,-1232,31584,-1232,19376,-1232,12640,7392,5904,16016,5904,31664,
+ 5904,47216,12688,55912,19472,64608,31584,64608,35440,64608,38888,63736,42336,62864,45600,61120,45600,52320,42464,54912,
+ 38848,56272,35232,57632,31584,57632,23200,57632,19040,51168,14880,44704,14880,31664,14880,18656,19040,12200,23200,5744,
+ 31584,5744,35312,5744,38904,7104,42496,8464,45600,11056,45600,2256,8368,63456,46032,63456,46032,56224,16960,56224,
+ 16960,37440,44752,37440,44752,30224,16960,30224,16960,7232,46832,7232,46832,0,8368,0,8368,63456,24864,80208,
+ 33232,68992,26688,68992,17040,80208,24864,80208,8368,63456,46032,63456,46032,56224,16960,56224,16960,37440,44752,37440,
+ 44752,30224,16960,30224,16960,7232,46832,7232,46832,0,8368,0,8368,63456,29584,80208,37488,80208,27760,68992,
+ 21216,68992,29584,80208,8368,63456,46032,63456,46032,56224,16960,56224,16960,37440,44752,37440,44752,30224,16960,30224,
+ 16960,7232,46832,7232,46832,0,8368,0,8368,63456,23216,80304,31248,80304,40208,68992,34256,68992,27200,76560,
+ 20192,68992,14240,68992,23216,80304,8368,63456,46032,63456,46032,56224,16960,56224,16960,37440,44752,37440,44752,30224,
+ 16960,30224,16960,7232,46832,7232,46832,0,8368,0,8368,63456,14576,78976,23216,78976,23216,70352,14576,70352,
+ 14576,78976,31248,78976,39824,78976,39824,70352,31248,70352,31248,78976,8544,63456,43776,63456,43776,56224,30480,56224,
+ 30480,7232,43776,7232,43776,0,8544,0,8544,7232,21840,7232,21840,56224,8544,56224,8544,63456,23840,80208,
+ 32208,68992,25664,68992,16016,80208,23840,80208,8544,63456,43776,63456,43776,56224,30480,56224,30480,7232,43776,7232,
+ 43776,0,8544,0,8544,7232,21840,7232,21840,56224,8544,56224,8544,63456,28560,80208,36464,80208,26736,68992,
+ 20192,68992,28560,80208,8544,63456,43776,63456,43776,56224,30480,56224,30480,7232,43776,7232,43776,0,8544,0,
+ 8544,7232,21840,7232,21840,56224,8544,56224,8544,63456,22192,80304,30224,80304,39184,68992,33232,68992,26176,76560,
+ 19168,68992,13216,68992,22192,80304,8544,63456,43776,63456,43776,56224,30480,56224,30480,7232,43776,7232,43776,0,
+ 8544,0,8544,7232,21840,7232,21840,56224,8544,56224,8544,63456,13552,78976,22192,78976,22192,70352,13552,70352,
+ 13552,78976,30224,78976,38800,78976,38800,70352,30224,70352,30224,78976,18528,63456,33072,63456,39952,55720,46832,47984,
+ 46832,31664,46832,15424,39928,7712,33024,0,18528,0,5648,0,5648,30128,336,30128,336,36464,5648,36464,
+ 5648,63456,18528,63456,18528,7056,29360,7056,33656,12392,37952,17728,37952,31664,37952,45728,33680,51064,29408,56400,
+ 18528,56400,14448,56400,14448,36464,25664,36464,25664,30128,14448,30128,14448,7056,18528,7056,5904,63456,16784,63456,
+ 38208,11216,38208,63456,46496,63456,46496,0,35616,0,14192,52240,14192,0,5904,0,5904,63456,26016,73200,
+ 23584,74608,22528,75200,21864,75432,21200,75664,20704,75664,19216,75664,18360,74608,17504,73552,17504,71632,17504,71376,
+ 12192,71376,12192,75664,14384,78176,16576,80688,20192,80688,21712,80688,23008,80344,24304,80000,26400,78864,28816,77584,
+ 29744,77024,30488,76776,31232,76528,31872,76528,33200,76528,34048,77608,34896,78688,34896,80432,34896,80688,40208,80688,
+ 40128,76432,37960,73904,35792,71376,32208,71376,30768,71376,29496,71720,28224,72064,26016,73200,38464,31664,38464,45648,
+ 35592,51640,32720,57632,26176,57632,19680,57632,16808,51640,13936,45648,13936,31664,13936,17728,16808,11736,19680,5744,
+ 26176,5744,32720,5744,35592,11712,38464,17680,38464,31664,47424,31664,47424,15088,42176,6928,36928,-1232,26176,-1232,
+ 15424,-1232,10200,6888,4976,15008,4976,31664,4976,48288,10224,56448,15472,64608,26176,64608,36928,64608,42176,56448,
+ 47424,48288,47424,31664,23840,80208,32208,68992,25664,68992,16016,80208,23840,80208,38464,31664,38464,45648,35592,51640,
+ 32720,57632,26176,57632,19680,57632,16808,51640,13936,45648,13936,31664,13936,17728,16808,11736,19680,5744,26176,5744,
+ 32720,5744,35592,11712,38464,17680,38464,31664,47424,31664,47424,15088,42176,6928,36928,-1232,26176,-1232,15424,-1232,
+ 10200,6888,4976,15008,4976,31664,4976,48288,10224,56448,15472,64608,26176,64608,36928,64608,42176,56448,47424,48288,
+ 47424,31664,28560,80208,36464,80208,26736,68992,20192,68992,28560,80208,38464,31664,38464,45648,35592,51640,32720,57632,
+ 26176,57632,19680,57632,16808,51640,13936,45648,13936,31664,13936,17728,16808,11736,19680,5744,26176,5744,32720,5744,
+ 35592,11712,38464,17680,38464,31664,47424,31664,47424,15088,42176,6928,36928,-1232,26176,-1232,15424,-1232,10200,6888,
+ 4976,15008,4976,31664,4976,48288,10224,56448,15472,64608,26176,64608,36928,64608,42176,56448,47424,48288,47424,31664,
+ 22192,80304,30224,80304,39184,68992,33232,68992,26176,76560,19168,68992,13216,68992,22192,80304,38464,31664,38464,45648,
+ 35592,51640,32720,57632,26176,57632,19680,57632,16808,51640,13936,45648,13936,31664,13936,17728,16808,11736,19680,5744,
+ 26176,5744,32720,5744,35592,11712,38464,17680,38464,31664,47424,31664,47424,15088,42176,6928,36928,-1232,26176,-1232,
+ 15424,-1232,10200,6888,4976,15008,4976,31664,4976,48288,10224,56448,15472,64608,26176,64608,36928,64608,42176,56448,
+ 47424,48288,47424,31664,26016,72176,23584,73584,22528,74176,21864,74408,21200,74640,20704,74640,19216,74640,18360,73584,
+ 17504,72528,17504,70608,17504,70352,12192,70352,12192,74640,14384,77152,16576,79664,20192,79664,21712,79664,23008,79320,
+ 24304,78976,26400,77840,28816,76560,29744,76000,30488,75752,31232,75504,31872,75504,33200,75504,34048,76584,34896,77664,
+ 34896,79408,34896,79664,40208,79664,40128,75408,37960,72880,35792,70352,32208,70352,30768,70352,29496,70696,28224,71040,
+ 26016,72176,38464,31664,38464,45648,35592,51640,32720,57632,26176,57632,19680,57632,16808,51640,13936,45648,13936,31664,
+ 13936,17728,16808,11736,19680,5744,26176,5744,32720,5744,35592,11712,38464,17680,38464,31664,47424,31664,47424,15088,
+ 42176,6928,36928,-1232,26176,-1232,15424,-1232,10200,6888,4976,15008,4976,31664,4976,48288,10224,56448,15472,64608,
+ 26176,64608,36928,64608,42176,56448,47424,48288,47424,31664,13552,78976,22192,78976,22192,70352,13552,70352,13552,78976,
+ 30224,78976,38800,78976,38800,70352,30224,70352,30224,78976,6368,12448,21248,27248,6368,42112,11312,47088,26176,32208,
+ 41104,47088,46032,42112,31152,27248,45936,12448,41008,7392,26176,22272,11392,7392,6368,12448,15760,12880,17040,9568,
+ 19824,7656,22608,5744,26176,5744,32720,5744,35592,11712,38464,17680,38464,31664,38464,36336,38248,39224,38032,42112,
+ 37616,44032,15760,12880,14368,20016,35792,50576,34720,54016,32280,55824,29840,57632,26176,57632,19504,57632,16720,51424,
+ 13936,45216,13936,29152,13936,25760,14048,23608,14160,21456,14368,20016,43856,52992,45600,49552,46512,44072,47424,38592,
+ 47424,31664,47424,15088,42176,6928,36928,-1232,26176,-1232,21040,-1232,17216,488,13392,2208,10800,5648,4720,-2976,
+ 336,0,7904,10704,6544,13808,5760,19376,4976,24944,4976,31664,4976,48288,10224,56448,15472,64608,26176,64608,
+ 31072,64608,34744,62864,38416,61120,40848,57712,46752,66256,51008,63120,43856,52992,6240,24352,6240,63456,14880,63456,
+ 14880,20448,14880,15808,15136,13832,15392,11856,16016,10800,17376,8288,19952,7016,22528,5744,26176,5744,29872,5744,
+ 32424,7016,34976,8288,36384,10800,37024,11856,37272,13808,37520,15760,37520,20352,37520,63456,46112,63456,46112,24352,
+ 46112,14624,44904,10520,43696,6416,40720,3744,37904,1232,34296,0,30688,-1232,26176,-1232,21712,-1232,18104,0,
+ 14496,1232,11648,3744,8720,6368,7480,10560,6240,14752,6240,24352,23840,80208,32208,68992,25664,68992,16016,80208,
+ 23840,80208,6240,24352,6240,63456,14880,63456,14880,20448,14880,15808,15136,13832,15392,11856,16016,10800,17376,8288,
+ 19952,7016,22528,5744,26176,5744,29872,5744,32424,7016,34976,8288,36384,10800,37024,11856,37272,13808,37520,15760,
+ 37520,20352,37520,63456,46112,63456,46112,24352,46112,14624,44904,10520,43696,6416,40720,3744,37904,1232,34296,0,
+ 30688,-1232,26176,-1232,21712,-1232,18104,0,14496,1232,11648,3744,8720,6368,7480,10560,6240,14752,6240,24352,
+ 28560,80208,36464,80208,26736,68992,20192,68992,28560,80208,6240,24352,6240,63456,14880,63456,14880,20448,14880,15808,
+ 15136,13832,15392,11856,16016,10800,17376,8288,19952,7016,22528,5744,26176,5744,29872,5744,32424,7016,34976,8288,
+ 36384,10800,37024,11856,37272,13808,37520,15760,37520,20352,37520,63456,46112,63456,46112,24352,46112,14624,44904,10520,
+ 43696,6416,40720,3744,37904,1232,34296,0,30688,-1232,26176,-1232,21712,-1232,18104,0,14496,1232,11648,3744,
+ 8720,6368,7480,10560,6240,14752,6240,24352,22192,80304,30224,80304,39184,68992,33232,68992,26176,76560,19168,68992,
+ 13216,68992,22192,80304,6240,24352,6240,63456,14880,63456,14880,20448,14880,15808,15136,13832,15392,11856,16016,10800,
+ 17376,8288,19952,7016,22528,5744,26176,5744,29872,5744,32424,7016,34976,8288,36384,10800,37024,11856,37272,13808,
+ 37520,15760,37520,20352,37520,63456,46112,63456,46112,24352,46112,14624,44904,10520,43696,6416,40720,3744,37904,1232,
+ 34296,0,30688,-1232,26176,-1232,21712,-1232,18104,0,14496,1232,11648,3744,8720,6368,7480,10560,6240,14752,
+ 6240,24352,13552,78976,22192,78976,22192,70352,13552,70352,13552,78976,30224,78976,38800,78976,38800,70352,30224,70352,
+ 30224,78976,1568,63456,10704,63456,26176,35440,41600,63456,50832,63456,30480,28480,30480,0,21840,0,21840,28480,
+ 1568,63456,28560,80208,36464,80208,26736,68992,20192,68992,28560,80208,17120,44928,17120,22608,27072,22608,33792,22608,
+ 37128,25416,40464,28224,40464,33792,40464,39360,37128,42144,33792,44928,27072,44928,17120,44928,8544,63456,17120,63456,
+ 17120,51984,27920,51984,38976,51984,44248,47520,49520,43056,49520,33792,49520,24480,44248,20040,38976,15600,27920,15600,
+ 17120,15600,17120,0,8544,0,8544,63456,7984,48320,7984,57376,12448,61752,16912,66128,26096,66128,34768,66128,
+ 39232,61432,43696,56736,43776,47552,37184,46960,33616,44328,30048,41696,30048,37440,30048,35360,31216,33720,32384,32080,
+ 35232,30304,37696,28736,44112,24784,46472,21296,48832,17808,48832,12880,48832,6336,44072,2552,39312,-1232,30976,-1232,
+ 28048,-1232,25184,-704,22320,-176,19504,848,19504,7824,22736,6496,25560,5864,28384,5232,30896,5232,35488,5232,
+ 38208,7288,40928,9344,40928,12800,40928,15808,39544,17824,38160,19840,33072,22992,30224,24656,26304,27024,24376,29856,
+ 22448,32688,22448,36048,22448,41488,25888,45120,29328,48752,35952,50240,35872,54784,33296,57208,30720,59632,25920,59632,
+ 20784,59632,18360,56848,15936,54064,15936,48160,15936,0,7984,0,7984,48320,29840,23920,27248,23920,20400,23920,
+ 16936,21520,13472,19120,13472,14368,13472,10080,16064,7696,18656,5312,23248,5312,29712,5312,33408,9800,37104,14288,
+ 37152,22192,37152,23920,29840,23920,45008,27152,45008,0,37152,0,37152,7056,34640,2800,30832,784,27024,-1232,
+ 21584,-1232,14320,-1232,9984,2872,5648,6976,5648,13856,5648,21808,10984,25928,16320,30048,26640,30048,37152,30048,
+ 37152,31280,37104,36976,34256,39544,31408,42112,25168,42112,21168,42112,17088,40968,13008,39824,9136,37616,9136,45440,
+ 13472,47088,17448,47920,21424,48752,25168,48752,31072,48752,35256,47008,39440,45264,42032,41776,43648,39648,44328,36528,
+ 45008,33408,45008,27152,20272,69616,32208,53632,25664,53632,11856,69616,20272,69616,29840,23920,27248,23920,20400,23920,
+ 16936,21520,13472,19120,13472,14368,13472,10080,16064,7696,18656,5312,23248,5312,29712,5312,33408,9800,37104,14288,
+ 37152,22192,37152,23920,29840,23920,45008,27152,45008,0,37152,0,37152,7056,34640,2800,30832,784,27024,-1232,
+ 21584,-1232,14320,-1232,9984,2872,5648,6976,5648,13856,5648,21808,10984,25928,16320,30048,26640,30048,37152,30048,
+ 37152,31280,37104,36976,34256,39544,31408,42112,25168,42112,21168,42112,17088,40968,13008,39824,9136,37616,9136,45440,
+ 13472,47088,17448,47920,21424,48752,25168,48752,31072,48752,35256,47008,39440,45264,42032,41776,43648,39648,44328,36528,
+ 45008,33408,45008,27152,32128,69616,40544,69616,26736,53632,20192,53632,32128,69616,29840,23920,27248,23920,20400,23920,
+ 16936,21520,13472,19120,13472,14368,13472,10080,16064,7696,18656,5312,23248,5312,29712,5312,33408,9800,37104,14288,
+ 37152,22192,37152,23920,29840,23920,45008,27152,45008,0,37152,0,37152,7056,34640,2800,30832,784,27024,-1232,
+ 21584,-1232,14320,-1232,9984,2872,5648,6976,5648,13856,5648,21808,10984,25928,16320,30048,26640,30048,37152,30048,
+ 37152,31280,37104,36976,34256,39544,31408,42112,25168,42112,21168,42112,17088,40968,13008,39824,9136,37616,9136,45440,
+ 13472,47088,17448,47920,21424,48752,25168,48752,31072,48752,35256,47008,39440,45264,42032,41776,43648,39648,44328,36528,
+ 45008,33408,45008,27152,23072,69616,29328,69616,39776,53632,33872,53632,26176,64048,18528,53632,12624,53632,23072,69616,
+ 29840,23920,27248,23920,20400,23920,16936,21520,13472,19120,13472,14368,13472,10080,16064,7696,18656,5312,23248,5312,
+ 29712,5312,33408,9800,37104,14288,37152,22192,37152,23920,29840,23920,45008,27152,45008,0,37152,0,37152,7056,
+ 34640,2800,30832,784,27024,-1232,21584,-1232,14320,-1232,9984,2872,5648,6976,5648,13856,5648,21808,10984,25928,
+ 16320,30048,26640,30048,37152,30048,37152,31280,37104,36976,34256,39544,31408,42112,25168,42112,21168,42112,17088,40968,
+ 13008,39824,9136,37616,9136,45440,13472,47088,17448,47920,21424,48752,25168,48752,31072,48752,35256,47008,39440,45264,
+ 42032,41776,43648,39648,44328,36528,45008,33408,45008,27152,26016,58224,23584,60560,22688,61408,21992,61816,21296,62224,
+ 20704,62224,19088,62224,18320,60648,17552,59072,17472,55632,12192,55632,12240,61328,14408,64472,16576,67616,20448,67616,
+ 22096,67616,23456,67024,24816,66432,26400,65024,28816,62688,29712,61840,30408,61432,31104,61024,31664,61024,33328,61024,
+ 34088,62600,34848,64176,34896,67616,40208,67616,40160,61920,37992,58776,35824,55632,31968,55632,30304,55632,28944,56224,
+ 27584,56816,26016,58224,29840,23920,27248,23920,20400,23920,16936,21520,13472,19120,13472,14368,13472,10080,16064,7696,
+ 18656,5312,23248,5312,29712,5312,33408,9800,37104,14288,37152,22192,37152,23920,29840,23920,45008,27152,45008,0,
+ 37152,0,37152,7056,34640,2800,30832,784,27024,-1232,21584,-1232,14320,-1232,9984,2872,5648,6976,5648,13856,
+ 5648,21808,10984,25928,16320,30048,26640,30048,37152,30048,37152,31280,37104,36976,34256,39544,31408,42112,25168,42112,
+ 21168,42112,17088,40968,13008,39824,9136,37616,9136,45440,13472,47088,17448,47920,21424,48752,25168,48752,31072,48752,
+ 35256,47008,39440,45264,42032,41776,43648,39648,44328,36528,45008,33408,45008,27152,13552,65968,22192,65968,22192,57376,
+ 13552,57376,13552,65968,30224,65968,38800,65968,38800,57376,30224,57376,30224,65968,29840,23920,27248,23920,20400,23920,
+ 16936,21520,13472,19120,13472,14368,13472,10080,16064,7696,18656,5312,23248,5312,29712,5312,33408,9800,37104,14288,
+ 37152,22192,37152,23920,29840,23920,45008,27152,45008,0,37152,0,37152,7056,34640,2800,30832,784,27024,-1232,
+ 21584,-1232,14320,-1232,9984,2872,5648,6976,5648,13856,5648,21808,10984,25928,16320,30048,26640,30048,37152,30048,
+ 37152,31280,37104,36976,34256,39544,31408,42112,25168,42112,21168,42112,17088,40968,13008,39824,9136,37616,9136,45440,
+ 13472,47088,17448,47920,21424,48752,25168,48752,31072,48752,35256,47008,39440,45264,42032,41776,43648,39648,44328,36528,
+ 45008,33408,45008,27152,37872,64768,37872,59888,34488,56488,31104,53088,26176,53088,21296,53088,17912,56488,14528,59888,
+ 14528,64768,14528,69664,17912,73040,21296,76416,26176,76416,31104,76416,34488,73040,37872,69664,37872,64768,32640,64768,
+ 32640,67440,30768,69312,28896,71184,26176,71184,23456,71184,21608,69336,19760,67488,19760,64768,19760,62000,21608,60152,
+ 23456,58304,26176,58304,28896,58304,30768,60176,32640,62048,32640,64768,23072,18784,23072,21840,20992,21840,13808,21840,
+ 11264,19928,8720,18016,8720,13216,8720,9440,10608,7376,12496,5312,16016,5312,19936,5312,21504,8136,23072,10960,
+ 23072,18784,44032,27920,44032,30128,44032,36544,42392,39376,40752,42208,37056,42208,33360,42208,31744,39312,30128,36416,
+ 30128,29744,30128,27920,44032,27920,51008,21840,30128,21840,30096,21200,30072,20464,30048,19728,30048,18272,30048,11440,
+ 32192,8376,34336,5312,39104,5312,42464,5312,45200,6400,47936,7488,50064,9648,50064,2336,47728,592,44920,-320,
+ 42112,-1232,39104,-1232,34432,-1232,31264,512,28096,2256,26736,5568,25072,2160,22248,464,19424,-1232,15296,-1232,
+ 8672,-1232,5208,2424,1744,6080,1744,13040,1744,20320,5992,24120,10240,27920,18368,27920,23328,27920,23328,31664,
+ 23328,36768,21224,39488,19120,42208,15136,42208,12752,42208,9944,41288,7136,40368,4512,38720,4512,45856,7776,47344,
+ 10584,48048,13392,48752,15936,48752,19808,48752,22440,47408,25072,46064,26640,43344,28048,45936,30856,47344,33664,48752,
+ 37440,48752,44832,48752,47920,43712,51008,38672,51008,25664,51008,21840,33840,0,36224,-2640,37352,-4872,38480,-7104,
+ 38480,-9136,38480,-12928,35928,-14856,33376,-16784,28368,-16784,26448,-16784,24600,-16528,22752,-16272,20880,-15760,20880,-10208,
+ 22336,-10928,23928,-11248,25520,-11568,27520,-11568,29984,-11568,31280,-10544,32576,-9520,32576,-7568,32576,-6288,31640,-4440,
+ 30704,-2592,28832,0,33840,0,45088,2416,41952,592,38616,-320,35280,-1232,31792,-1232,20736,-1232,14512,5400,
+ 8288,12032,8288,23760,8288,35488,14512,42120,20736,48752,31792,48752,35232,48752,38504,47856,41776,46960,45088,45088,
+ 45088,36896,41984,39648,38864,40880,35744,42112,31792,42112,24432,42112,20480,37352,16528,32592,16528,23760,16528,14960,
+ 20504,10176,24480,5392,31792,5392,35872,5392,39104,6648,42336,7904,45088,10544,45088,2416,47264,25760,47264,21936,
+ 13392,21936,13392,21680,13392,13904,17448,9648,21504,5392,28896,5392,32640,5392,36720,6584,40800,7776,45440,10208,
+ 45440,2416,40976,592,36832,-320,32688,-1232,28816,-1232,17728,-1232,11480,5416,5232,12064,5232,23760,5232,35152,
+ 11352,41952,17472,48752,27664,48752,36768,48752,42016,42584,47264,36416,47264,25760,39440,28048,39264,34928,36184,38520,
+ 33104,42112,27328,42112,21680,42112,18024,38376,14368,34640,13680,28000,39440,28048,21296,69616,33232,53632,26688,53632,
+ 12880,69616,21296,69616,47264,25760,47264,21936,13392,21936,13392,21680,13392,13904,17448,9648,21504,5392,28896,5392,
+ 32640,5392,36720,6584,40800,7776,45440,10208,45440,2416,40976,592,36832,-320,32688,-1232,28816,-1232,17728,-1232,
+ 11480,5416,5232,12064,5232,23760,5232,35152,11352,41952,17472,48752,27664,48752,36768,48752,42016,42584,47264,36416,
+ 47264,25760,39440,28048,39264,34928,36184,38520,33104,42112,27328,42112,21680,42112,18024,38376,14368,34640,13680,28000,
+ 39440,28048,33152,69616,41568,69616,27760,53632,21216,53632,33152,69616,47264,25760,47264,21936,13392,21936,13392,21680,
+ 13392,13904,17448,9648,21504,5392,28896,5392,32640,5392,36720,6584,40800,7776,45440,10208,45440,2416,40976,592,
+ 36832,-320,32688,-1232,28816,-1232,17728,-1232,11480,5416,5232,12064,5232,23760,5232,35152,11352,41952,17472,48752,
+ 27664,48752,36768,48752,42016,42584,47264,36416,47264,25760,39440,28048,39264,34928,36184,38520,33104,42112,27328,42112,
+ 21680,42112,18024,38376,14368,34640,13680,28000,39440,28048,24096,69616,30352,69616,40800,53632,34896,53632,27200,64048,
+ 19552,53632,13648,53632,24096,69616,47264,25760,47264,21936,13392,21936,13392,21680,13392,13904,17448,9648,21504,5392,
+ 28896,5392,32640,5392,36720,6584,40800,7776,45440,10208,45440,2416,40976,592,36832,-320,32688,-1232,28816,-1232,
+ 17728,-1232,11480,5416,5232,12064,5232,23760,5232,35152,11352,41952,17472,48752,27664,48752,36768,48752,42016,42584,
+ 47264,36416,47264,25760,39440,28048,39264,34928,36184,38520,33104,42112,27328,42112,21680,42112,18024,38376,14368,34640,
+ 13680,28000,39440,28048,14576,65968,23216,65968,23216,57376,14576,57376,14576,65968,31248,65968,39824,65968,39824,57376,
+ 31248,57376,31248,65968,10880,47600,30896,47600,30896,6080,46416,6080,46416,0,7568,0,7568,6080,23072,6080,
+ 23072,41520,10880,41520,10880,47600,20272,69616,32208,53632,25664,53632,11856,69616,20272,69616,10880,47600,30896,47600,
+ 30896,6080,46416,6080,46416,0,7568,0,7568,6080,23072,6080,23072,41520,10880,41520,10880,47600,32128,69616,
+ 40544,69616,26736,53632,20192,53632,32128,69616,10880,47600,30896,47600,30896,6080,46416,6080,46416,0,7568,0,
+ 7568,6080,23072,6080,23072,41520,10880,41520,10880,47600,23072,69616,29328,69616,39776,53632,33872,53632,26176,64048,
+ 18528,53632,12624,53632,23072,69616,10880,47600,30896,47600,30896,6080,46416,6080,46416,0,7568,0,7568,6080,
+ 23072,6080,23072,41520,10880,41520,10880,47600,14576,65968,23216,65968,23216,57376,14576,57376,14576,65968,31248,65968,
+ 39824,65968,39824,57376,31248,57376,31248,65968,30480,56400,38848,47392,42712,39312,46576,31232,46576,22736,46576,11344,
+ 41248,5056,35920,-1232,26176,-1232,16496,-1232,11160,5056,5824,11344,5824,22736,5824,34000,11160,40288,16496,46576,
+ 26016,46576,27456,46576,28200,46536,28944,46496,29584,46416,28176,48320,26648,50216,25120,52112,23504,53968,11648,50064,
+ 10368,54224,20448,57632,12704,66128,22016,66128,27408,59968,39696,63968,41104,59792,30480,56400,33696,39008,32208,39568,
+ 30472,39848,28736,40128,26816,40128,20608,40128,17360,35664,14112,31200,14112,22736,14112,14400,17256,9896,20400,5392,
+ 26176,5392,32000,5392,35144,9896,38288,14400,38288,22736,38288,27408,37056,31728,35824,36048,33696,39008,44672,29488,
+ 44672,0,36800,0,36800,29488,36800,35920,34552,38936,32304,41952,27504,41952,22016,41952,19064,38064,16112,34176,
+ 16112,26896,16112,0,8288,0,8288,47600,16112,47600,16112,40464,18192,44544,21760,46648,25328,48752,30224,48752,
+ 37488,48752,41080,43968,44672,39184,44672,29488,26016,58224,23584,60560,22688,61408,21992,61816,21296,62224,20704,62224,
+ 19088,62224,18320,60648,17552,59072,17472,55632,12192,55632,12240,61328,14408,64472,16576,67616,20448,67616,22096,67616,
+ 23456,67024,24816,66432,26400,65024,28816,62688,29712,61840,30408,61432,31104,61024,31664,61024,33328,61024,34088,62600,
+ 34848,64176,34896,67616,40208,67616,40160,61920,37992,58776,35824,55632,31968,55632,30304,55632,28944,56224,27584,56816,
+ 26016,58224,26176,42112,20224,42112,17168,37480,14112,32848,14112,23760,14112,14704,17168,10048,20224,5392,26176,5392,
+ 32176,5392,35232,10048,38288,14704,38288,23760,38288,32848,35232,37480,32176,42112,26176,42112,26176,48752,36080,48752,
+ 41328,42336,46576,35920,46576,23760,46576,11568,41352,5168,36128,-1232,26176,-1232,16272,-1232,11048,5168,5824,11568,
+ 5824,23760,5824,35920,11048,42336,16272,48752,26176,48752,20272,69616,32208,53632,25664,53632,11856,69616,20272,69616,
+ 26176,42112,20224,42112,17168,37480,14112,32848,14112,23760,14112,14704,17168,10048,20224,5392,26176,5392,32176,5392,
+ 35232,10048,38288,14704,38288,23760,38288,32848,35232,37480,32176,42112,26176,42112,26176,48752,36080,48752,41328,42336,
+ 46576,35920,46576,23760,46576,11568,41352,5168,36128,-1232,26176,-1232,16272,-1232,11048,5168,5824,11568,5824,23760,
+ 5824,35920,11048,42336,16272,48752,26176,48752,32128,69616,40544,69616,26736,53632,20192,53632,32128,69616,26176,42112,
+ 20224,42112,17168,37480,14112,32848,14112,23760,14112,14704,17168,10048,20224,5392,26176,5392,32176,5392,35232,10048,
+ 38288,14704,38288,23760,38288,32848,35232,37480,32176,42112,26176,42112,26176,48752,36080,48752,41328,42336,46576,35920,
+ 46576,23760,46576,11568,41352,5168,36128,-1232,26176,-1232,16272,-1232,11048,5168,5824,11568,5824,23760,5824,35920,
+ 11048,42336,16272,48752,26176,48752,23072,69616,29328,69616,39776,53632,33872,53632,26176,64048,18528,53632,12624,53632,
+ 23072,69616,26176,42112,20224,42112,17168,37480,14112,32848,14112,23760,14112,14704,17168,10048,20224,5392,26176,5392,
+ 32176,5392,35232,10048,38288,14704,38288,23760,38288,32848,35232,37480,32176,42112,26176,42112,26176,48752,36080,48752,
+ 41328,42336,46576,35920,46576,23760,46576,11568,41352,5168,36128,-1232,26176,-1232,16272,-1232,11048,5168,5824,11568,
+ 5824,23760,5824,35920,11048,42336,16272,48752,26176,48752,26016,58224,23584,60560,22688,61408,21992,61816,21296,62224,
+ 20704,62224,19088,62224,18320,60648,17552,59072,17472,55632,12192,55632,12240,61328,14408,64472,16576,67616,20448,67616,
+ 22096,67616,23456,67024,24816,66432,26400,65024,28816,62688,29712,61840,30408,61432,31104,61024,31664,61024,33328,61024,
+ 34088,62600,34848,64176,34896,67616,40208,67616,40160,61920,37992,58776,35824,55632,31968,55632,30304,55632,28944,56224,
+ 27584,56816,26016,58224,26176,42112,20224,42112,17168,37480,14112,32848,14112,23760,14112,14704,17168,10048,20224,5392,
+ 26176,5392,32176,5392,35232,10048,38288,14704,38288,23760,38288,32848,35232,37480,32176,42112,26176,42112,26176,48752,
+ 36080,48752,41328,42336,46576,35920,46576,23760,46576,11568,41352,5168,36128,-1232,26176,-1232,16272,-1232,11048,5168,
+ 5824,11568,5824,23760,5824,35920,11048,42336,16272,48752,26176,48752,13552,65968,22192,65968,22192,57376,13552,57376,
+ 13552,65968,30224,65968,38800,65968,38800,57376,30224,57376,30224,65968,20992,16784,31408,16784,31408,6368,20992,6368,
+ 20992,16784,20992,48240,31408,48240,31408,37776,20992,37776,20992,48240,3744,30896,48656,30896,48656,23680,3744,23680,
+ 3744,30896,37280,33152,17600,9392,19120,7392,21272,6392,23424,5392,26176,5392,32176,5392,35232,10048,38288,14704,
+ 38288,23760,38288,25968,38032,28328,37776,30688,37280,33152,34720,38128,33232,40160,31128,41136,29024,42112,26176,42112,
+ 20272,42112,17104,37568,13936,33024,13936,24432,13936,22400,14232,19936,14528,17472,15136,14448,34720,38128,9216,7648,
+ 7568,10672,6696,14816,5824,18960,5824,23760,5824,35920,11048,42336,16272,48752,26176,48752,30432,48752,33792,47584,
+ 37152,46416,39696,44032,45936,51504,49888,48240,42928,39952,44704,37152,45640,33048,46576,28944,46576,23760,46576,11568,
+ 41352,5168,36128,-1232,26176,-1232,21808,-1232,18472,24,15136,1280,12704,3824,5904,-4080,2000,-848,9216,7648,
+ 8288,18016,8288,47520,16112,47520,16112,18016,16112,11600,18384,8584,20656,5568,25408,5568,30944,5568,33872,9456,
+ 36800,13344,36800,20608,36800,47520,44672,47520,44672,0,36800,0,36800,7136,34720,3024,31128,896,27536,-1232,
+ 22736,-1232,15424,-1232,11856,3552,8288,8336,8288,18016,20272,69616,32208,53632,25664,53632,11856,69616,20272,69616,
+ 8288,18016,8288,47520,16112,47520,16112,18016,16112,11600,18384,8584,20656,5568,25408,5568,30944,5568,33872,9456,
+ 36800,13344,36800,20608,36800,47520,44672,47520,44672,0,36800,0,36800,7136,34720,3024,31128,896,27536,-1232,
+ 22736,-1232,15424,-1232,11856,3552,8288,8336,8288,18016,32128,69616,40544,69616,26736,53632,20192,53632,32128,69616,
+ 8288,18016,8288,47520,16112,47520,16112,18016,16112,11600,18384,8584,20656,5568,25408,5568,30944,5568,33872,9456,
+ 36800,13344,36800,20608,36800,47520,44672,47520,44672,0,36800,0,36800,7136,34720,3024,31128,896,27536,-1232,
+ 22736,-1232,15424,-1232,11856,3552,8288,8336,8288,18016,23072,69616,29328,69616,39776,53632,33872,53632,26176,64048,
+ 18528,53632,12624,53632,23072,69616,8288,18016,8288,47520,16112,47520,16112,18016,16112,11600,18384,8584,20656,5568,
+ 25408,5568,30944,5568,33872,9456,36800,13344,36800,20608,36800,47520,44672,47520,44672,0,36800,0,36800,7136,
+ 34720,3024,31128,896,27536,-1232,22736,-1232,15424,-1232,11856,3552,8288,8336,8288,18016,13552,65968,22192,65968,
+ 22192,57376,13552,57376,13552,65968,30224,65968,38800,65968,38800,57376,30224,57376,30224,65968,36464,15296,34512,10320,
+ 31488,2208,27280,-9008,25840,-11472,23888,-14784,20952,-16448,18016,-18112,14112,-18112,7824,-18112,7824,-11568,12448,-11568,
+ 15888,-11568,17848,-9568,19808,-7568,22816,768,4416,47600,12704,47600,26816,10368,40720,47600,49008,47600,36464,15296,
+ 32128,69616,40544,69616,26736,53632,20192,53632,32128,69616,15936,6000,15936,-18112,8080,-18112,8080,66592,15936,66592,
+ 15936,41520,17888,45056,21144,46904,24400,48752,28640,48752,37280,48752,42184,42080,47088,35408,47088,23584,47088,11984,
+ 42160,5376,37232,-1232,28640,-1232,24304,-1232,21056,616,17808,2464,15936,6000,38880,23760,38880,32848,36016,37480,
+ 33152,42112,27504,42112,21808,42112,18872,37464,15936,32816,15936,23760,15936,14752,18872,10072,21808,5392,27504,5392,
+ 33152,5392,36016,10024,38880,14656,38880,23760,36464,15296,34512,10320,31488,2208,27280,-9008,25840,-11472,23888,-14784,
+ 20952,-16448,18016,-18112,14112,-18112,7824,-18112,7824,-11568,12448,-11568,15888,-11568,17848,-9568,19808,-7568,22816,768,
+ 4416,47600,12704,47600,26816,10368,40720,47600,49008,47600,36464,15296,13552,65968,22192,65968,22192,57376,13552,57376,
+ 13552,65968,30224,65968,38800,65968,38800,57376,30224,57376,30224,65968 };
+static const int DejaVuSansMono_glyphAdvances[224] = {
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,52400,
+ 52400,52400,52400,52400 };
+
+static const int DejaVuSansMono_glyphCount = 224;
+static const short DejaVuSansMono_characterMap[256] = {
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
+ 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,
+ 68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,
+ 88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,
+ 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
+ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,
+ 148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,
+ 168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,
+ 188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
+ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223 };
+
diff --git a/tests/font/DejaVuSerif.inc b/tests/font/DejaVuSerif.inc
new file mode 100644
index 0000000..d27a1af
--- /dev/null
+++ b/tests/font/DejaVuSerif.inc
@@ -0,0 +1,1110 @@
+/* Generated by font2openvg. See http://developer.hybrid.fi for more information. */
+
+/* converted from font file /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf */
+/* font family name: DejaVu Serif */
+/* font style name: Book */
+
+static const unsigned char DejaVuSerif_glyphInstructions[5669] = {
+ 2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,0,2,10,10,10,10,4,0,2,10,10,10,10,4,0,
+ 2,4,4,10,10,4,10,10,10,10,4,4,4,10,10,4,4,10,10,4,
+ 10,10,10,10,4,4,4,10,10,0,2,10,10,10,10,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,
+ 2,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,4,10,10,
+ 10,10,10,10,0,2,4,4,10,10,10,10,10,10,10,10,10,10,10,10,
+ 4,4,10,10,10,10,10,10,4,10,10,4,4,4,4,4,10,10,4,4,
+ 4,0,2,4,4,4,4,0,2,10,10,10,10,4,10,10,10,10,4,0,
+ 2,4,10,10,10,10,4,10,10,10,10,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,0,2,10,10,4,4,10,10,4,0,2,4,4,4,4,
+ 0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,10,10,
+ 10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,
+ 4,4,4,4,4,4,4,4,4,0,2,4,4,10,10,10,10,10,10,4,
+ 4,4,4,4,4,4,4,10,10,10,10,10,10,0,2,10,10,10,10,10,
+ 10,10,10,10,10,10,10,4,4,10,10,10,10,10,10,4,4,4,10,10,
+ 10,10,10,10,4,4,0,2,4,4,4,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,0,2,4,4,4,10,10,10,10,10,10,10,
+ 10,4,4,10,10,10,10,10,10,10,10,4,4,4,0,2,10,10,10,10,
+ 10,10,10,10,0,2,10,10,10,10,10,10,10,10,10,10,10,10,4,4,
+ 10,10,10,10,0,2,4,4,4,4,4,4,4,4,4,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,
+ 10,10,10,10,10,10,10,4,4,10,10,10,10,0,2,10,10,10,10,10,
+ 10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,
+ 10,10,10,0,2,10,10,4,4,10,10,4,0,2,10,10,10,10,10,10,
+ 10,10,0,2,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,4,4,4,0,2,10,10,10,10,10,10,
+ 10,10,0,2,10,10,10,10,10,10,4,4,4,10,10,10,10,10,10,4,
+ 4,0,2,10,10,10,10,10,10,10,10,4,4,4,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,4,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,4,0,2,4,10,10,10,10,10,10,10,10,0,
+ 2,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,0,2,4,10,10,10,10,4,4,0,2,4,10,10,10,10,4,4,
+ 0,2,4,4,4,4,4,4,10,10,10,10,10,10,10,10,4,0,2,10,
+ 10,10,10,10,10,10,10,10,10,4,4,10,10,10,10,10,10,10,10,4,
+ 0,2,4,10,10,10,10,4,4,0,2,4,4,4,4,4,4,10,10,10,
+ 10,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,0,2,10,10,10,10,10,10,
+ 10,10,4,4,4,4,4,10,10,10,10,10,10,10,10,4,4,0,2,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,4,4,10,10,10,10,4,4,4,4,4,4,4,10,10,10,10,
+ 0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,0,2,10,10,10,10,10,10,
+ 10,10,0,2,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,2,
+ 4,10,10,10,10,4,4,0,2,4,4,4,4,4,4,10,10,10,10,4,
+ 4,4,4,4,0,2,10,10,10,10,10,10,10,10,10,10,10,10,4,4,
+ 10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,4,4,4,4,
+ 4,10,10,4,4,4,4,4,4,4,4,4,4,4,10,10,10,10,0,2,
+ 4,10,10,10,10,4,4,0,2,4,4,10,10,10,10,10,10,4,10,10,
+ 10,10,10,10,4,4,10,10,10,10,10,10,4,10,10,10,10,10,10,0,
+ 2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,
+ 4,4,4,4,4,10,10,10,10,4,4,4,4,4,4,4,10,10,10,10,
+ 4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,
+ 0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,0,2,4,4,
+ 4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,10,10,10,10,10,10,0,2,4,4,4,4,4,10,10,10,10,10,10,
+ 4,4,10,10,10,10,4,4,10,10,10,10,0,2,4,4,4,4,4,10,
+ 10,10,10,10,10,10,10,4,4,4,4,0,2,10,10,10,10,10,10,10,
+ 10,4,0,2,10,10,10,10,10,10,10,10,4,4,10,10,10,10,10,10,
+ 10,10,4,0,2,4,4,4,4,10,10,10,10,10,10,10,10,4,4,4,
+ 4,4,0,2,4,10,10,10,10,10,10,10,10,0,2,4,4,10,10,10,
+ 10,4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,4,0,2,4,
+ 10,10,10,10,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,10,
+ 10,10,10,4,0,2,4,10,10,10,10,4,4,10,10,10,10,4,10,10,
+ 10,10,10,10,10,10,4,4,4,4,0,2,10,10,10,10,10,10,10,10,
+ 4,0,2,4,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,4,
+ 4,10,10,10,10,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,
+ 2,4,4,4,4,4,4,4,4,4,4,0,2,10,10,10,10,10,10,10,
+ 10,0,2,4,4,4,4,10,10,10,10,4,4,10,10,10,10,4,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,0,2,
+ 10,10,10,10,4,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,
+ 4,4,10,10,10,10,4,4,4,4,4,4,4,4,4,4,4,10,10,10,
+ 10,0,2,4,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,4,
+ 4,10,10,10,10,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,0,2,4,10,10,10,10,10,10,10,10,
+ 0,2,4,4,4,4,10,10,10,10,10,10,10,10,4,4,4,4,4,4,
+ 4,0,2,4,4,4,4,4,4,4,10,10,10,10,10,10,10,10,4,4,
+ 4,4,0,2,10,10,10,10,10,10,10,10,4,0,2,4,4,10,10,10,
+ 10,4,4,4,4,4,4,4,4,4,4,4,10,10,10,10,0,2,4,4,
+ 10,10,10,10,10,10,4,10,10,10,10,10,10,4,4,10,10,10,10,10,
+ 10,4,10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,4,4,4,
+ 10,10,10,10,4,10,10,10,10,4,0,2,4,4,4,4,4,4,10,10,
+ 10,10,4,4,4,4,4,10,10,10,10,4,4,4,0,2,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,10,10,10,10,4,4,10,10,10,10,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,0,2,4,4,10,10,4,10,10,4,4,4,10,
+ 10,4,10,10,4,4,4,10,10,4,10,10,10,10,4,10,10,4,0,2,
+ 4,4,4,4,0,2,4,10,10,4,10,10,10,10,4,10,10,4,4,4,
+ 10,10,4,10,10,4,4,4,10,10,4,10,10,4,4,0,2,4,10,10,
+ 10,4,10,10,10,10,4,10,10,10,4,10,10,10,10,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,
+ 10,0,2,4,4,4,4,4,4,0,2,10,10,10,10,4,0,2,10,10,
+ 4,4,4,10,10,10,10,4,4,4,10,10,4,4,10,10,4,10,10,4,
+ 0,2,4,10,10,10,10,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,10,10,10,10,4,0,2,4,4,4,10,10,10,10,4,4,
+ 4,10,10,10,10,4,4,4,10,10,10,10,4,4,4,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 0,2,10,10,10,4,10,10,10,10,0,2,4,4,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,4,4,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,
+ 10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,4,4,
+ 10,10,10,10,10,10,10,10,4,0,2,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,0,2,4,4,4,4,4,10,10,10,10,10,10,4,4,
+ 10,10,10,10,4,4,10,10,10,10,0,2,4,4,10,10,10,10,10,10,
+ 0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,
+ 4,4,4,4,0,2,4,4,4,4,4,4,0,2,4,4,4,4,0,2,
+ 4,10,10,10,10,4,4,0,2,10,10,4,4,4,4,4,10,10,4,4,
+ 4,4,4,4,4,4,4,4,4,10,10,10,10,0,2,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,10,10,0,2,4,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,
+ 4,10,10,10,10,10,4,4,4,4,4,4,4,4,4,10,10,10,10,10,
+ 10,0,2,10,10,10,10,10,10,10,10,10,10,10,10,4,4,10,10,10,
+ 10,10,10,4,4,4,10,10,10,10,10,10,4,4,0,2,4,4,4,4,
+ 0,2,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,4,4,4,
+ 4,4,4,10,10,10,10,4,4,4,0,2,4,4,4,4,4,4,4,4,
+ 4,4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,
+ 10,10,10,10,4,10,10,10,10,10,10,4,0,2,4,4,4,4,4,4,
+ 4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 0,2,4,4,4,4,4,4,4,0,2,4,4,4,0,2,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,
+ 4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,10,10,10,10,10,4,4,
+ 4,4,4,4,4,4,4,10,10,10,10,10,10,0,2,4,4,4,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,10,10,10,
+ 10,10,10,10,10,10,10,10,10,4,4,10,10,10,10,10,10,4,4,4,
+ 10,10,10,10,10,10,4,4,0,2,4,4,4,4,0,2,10,10,10,10,
+ 10,10,10,10,0,2,10,10,10,10,10,10,4,4,4,10,10,10,10,10,
+ 10,4,4,0,2,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,0,2,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,
+ 4,0,2,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,10,
+ 10,10,10,4,10,10,10,10,4,10,10,10,10,4,10,10,10,4,0,2,
+ 4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,
+ 10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,0,2,4,4,
+ 4,10,10,10,10,10,10,10,10,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,10,10,10,10,10,10,10,10,10,10,4,4,10,10,10,10,10,
+ 10,10,10,4,0,2,10,10,10,10,10,10,4,10,10,10,10,10,10,4,
+ 0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,
+ 4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,0,
+ 2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,
+ 2,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,0,
+ 2,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,4,4,4,4,
+ 4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,
+ 10,10,0,2,4,10,10,10,10,4,4,4,4,4,4,0,2,4,4,4,
+ 4,4,4,4,4,4,4,10,10,10,10,4,0,2,4,4,4,4,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,2,4,10,10,10,
+ 10,4,10,10,10,10,4,10,10,10,10,4,10,10,10,4,0,2,10,10,
+ 10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,10,10,10,10,
+ 10,10,0,2,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,
+ 10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,2,4,4,4,4,
+ 0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,
+ 10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,10,10,10,10,10,
+ 10,0,2,4,10,10,10,10,4,10,10,10,10,4,10,10,10,10,4,10,
+ 10,10,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,
+ 10,10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,
+ 2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,4,4,4,4,4,
+ 4,4,4,0,2,10,10,10,10,10,10,4,0,2,10,10,10,10,10,10,
+ 4,0,2,10,10,10,10,10,10,4,4,4,10,10,10,10,10,10,4,4,
+ 4,0,2,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,4,4,
+ 10,10,10,10,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,10,
+ 10,10,10,4,4,4,4,4,4,4,10,10,10,10,4,0,2,4,4,4,
+ 4,0,2,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,4,4,
+ 10,10,10,10,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,4,
+ 4,4,10,10,10,10,4,4,4,4,4,4,4,10,10,10,10,4,0,2,
+ 10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 4,0,2,4,4,4,4,0,2,4,10,10,10,10,4,4,0,2,4,4,
+ 4,4,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,0,2,10,
+ 10,10,10,4,4,4,4,4,10,10,10,10,4,10,10,10,10,4,10,10,
+ 10,10,10,10,4,4,10,10,10,10,10,10,4,10,10,10,10,0,2,4,
+ 4,10,10,10,10,10,10,0,2,4,4,4,4,4,10,10,10,10,10,10,
+ 4,4,10,10,10,10,4,4,10,10,10,10,0,2,4,4,4,4,0,2,
+ 4,4,10,10,10,10,10,10,0,2,4,4,4,4,4,10,10,10,10,10,
+ 10,4,4,10,10,10,10,4,4,10,10,10,10,0,2,4,4,4,4,0,
+ 2,4,4,10,10,10,10,10,10,0,2,4,4,4,4,4,10,10,10,10,
+ 10,10,4,4,10,10,10,10,4,4,10,10,10,10,0,2,4,4,4,4,
+ 4,4,4,0,2,4,4,10,10,10,10,10,10,0,2,4,4,4,4,4,
+ 10,10,10,10,10,10,4,4,10,10,10,10,4,4,10,10,10,10,0,2,
+ 4,10,10,10,10,4,10,10,10,10,4,10,10,10,10,4,10,10,10,10,
+ 0,2,4,4,10,10,10,10,10,10,0,2,4,4,4,4,4,10,10,10,
+ 10,10,10,4,4,10,10,10,10,4,4,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,10,
+ 10,10,10,10,10,0,2,4,4,4,4,4,10,10,10,10,10,10,4,4,
+ 10,10,10,10,4,4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,
+ 0,2,10,10,10,10,10,10,10,10,0,2,4,4,10,10,10,10,10,10,
+ 0,2,10,10,10,10,10,10,4,4,10,10,10,10,4,4,10,10,10,10,
+ 10,10,10,10,4,4,10,10,10,10,4,10,10,10,10,0,2,10,10,10,
+ 10,4,0,2,10,10,10,10,10,10,10,10,4,4,10,10,10,10,10,10,
+ 10,10,4,0,2,10,10,10,10,10,10,4,10,10,10,10,10,10,4,0,
+ 2,4,4,10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,10,10,
+ 10,10,4,0,2,4,4,4,4,0,2,4,4,10,10,10,10,4,10,10,
+ 10,10,10,10,10,10,0,2,10,10,10,10,4,0,2,4,4,4,4,0,
+ 2,4,4,10,10,10,10,4,10,10,10,10,10,10,10,10,0,2,10,10,
+ 10,10,4,0,2,4,4,4,4,4,4,4,0,2,4,4,10,10,10,10,
+ 4,10,10,10,10,10,10,10,10,0,2,10,10,10,10,4,0,2,10,10,
+ 10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,
+ 4,4,4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,
+ 4,4,4,4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,
+ 4,4,4,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,4,4,
+ 4,4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,10,10,0,2,10,
+ 10,10,10,10,10,10,10,10,10,10,10,4,4,4,10,10,4,10,10,4,
+ 4,4,0,2,4,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,
+ 4,4,10,10,10,10,4,4,4,4,0,2,4,10,10,10,10,4,10,10,
+ 10,10,4,10,10,10,10,4,10,10,10,10,0,2,10,10,10,10,10,10,
+ 10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,4,0,2,
+ 10,10,10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,
+ 4,4,4,4,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,10,
+ 10,10,10,10,0,2,4,4,4,4,4,4,4,0,2,10,10,10,10,10,
+ 10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,10,10,10,10,
+ 4,10,10,10,10,4,10,10,10,10,4,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,10,10,10,
+ 10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,4,
+ 4,0,2,10,10,10,10,10,10,4,0,2,10,10,10,10,10,10,4,0,
+ 2,10,10,10,10,10,10,4,4,4,10,10,10,10,10,10,4,4,4,0,
+ 2,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,10,10,10,10,
+ 4,4,4,0,2,4,4,4,4,0,2,4,4,4,4,4,4,10,10,10,
+ 10,4,4,4,4,4,10,10,10,10,4,4,4,0,2,4,4,4,4,0,
+ 2,4,4,4,4,4,4,10,10,10,10,4,4,4,4,4,10,10,10,10,
+ 4,4,4,0,2,4,4,4,4,4,4,4,0,2,4,4,4,4,4,4,
+ 10,10,10,10,4,4,4,4,4,10,10,10,10,4,4,4,0,2,10,10,
+ 10,10,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,4,4,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,10,10,10,10,4,4,10,
+ 10,10,10,0,2,4,4,4,4,0,2,4,10,10,10,10,10,10,10,10,
+ 0,2,4,4,4,4,10,10,10,10,10,10,10,10,4,4,4,4,4,4,
+ 4,0,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,10,10,
+ 10,10,4,4,10,10,10,10,0,2,10,10,10,10,10,10,10,10,0,2,
+ 10,10,10,10,10,10,10,10,0 };
+static const int DejaVuSerif_glyphInstructionIndices[224] = {
+ 0,0,18,30,66,110,156,202,208,220,232,252,266,275,281,291,297,317,330,354,
+ 387,409,435,465,476,514,544,564,583,592,604,613,642,700,723,758,781,803,829,853,
+ 878,908,922,941,968,984,1011,1033,1059,1085,1113,1148,1180,1198,1222,1239,1262,1292,1315,1331,
+ 1341,1347,1357,1366,1372,1378,1413,1443,1464,1494,1518,1545,1582,1610,1632,1659,1687,1699,1742,1770,
+ 1790,1822,1854,1877,1909,1931,1955,1972,1995,2025,2052,2068,2099,2105,2136,2156,2168,2180,2192,2204,
+ 2216,2228,2240,2252,2264,2276,2288,2300,2312,2324,2336,2348,2360,2372,2384,2396,2408,2420,2432,2444,
+ 2456,2468,2480,2492,2504,2516,2528,2540,2552,2552,2570,2601,2630,2670,2709,2721,2769,2789,2846,2887,
+ 2905,2913,2919,2990,2996,3018,3038,3062,3095,3101,3131,3147,3157,3173,3186,3212,3230,3271,3314,3375,
+ 3404,3433,3462,3494,3539,3582,3622,3662,3701,3733,3765,3800,3846,3866,3886,3909,3943,3973,4017,4049,
+ 4081,4116,4164,4210,4224,4262,4292,4322,4355,4399,4428,4458,4498,4539,4580,4624,4681,4736,4791,4843,
+ 4880,4910,4940,4973,5017,5035,5053,5074,5106,5143,5193,5219,5245,5274,5316,5356,5382,5420,5450,5480,
+ 5513,5557,5590,5622 };
+static const int DejaVuSerif_glyphInstructionCounts[224] = {
+ 0,18,12,36,44,46,46,6,12,12,20,14,9,6,10,6,20,13,24,33,
+ 22,26,30,11,38,30,20,19,9,12,9,29,58,23,35,23,22,26,24,25,
+ 30,14,19,27,16,27,22,26,26,28,35,32,18,24,17,23,30,23,16,10,
+ 6,10,9,6,6,35,30,21,30,24,27,37,28,22,27,28,12,43,28,20,
+ 32,32,23,32,22,24,17,23,30,27,16,31,6,31,20,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,0,18,31,29,40,39,12,48,20,57,41,18,
+ 8,6,71,6,22,20,24,33,6,30,16,10,16,13,26,18,41,43,61,29,
+ 29,29,32,45,43,40,40,39,32,32,35,46,20,20,23,34,30,44,32,32,
+ 35,48,46,14,38,30,30,33,44,29,30,40,41,41,44,57,55,55,52,37,
+ 30,30,33,44,18,18,21,32,37,50,26,26,29,42,40,26,38,30,30,33,
+ 44,33,32,47 };
+
+static const int DejaVuSerif_glyphPointIndices[224] = {
+ 0,0,24,34,68,133,206,278,283,302,321,340,353,365,370,387,392,426,438,473,
+ 529,549,590,642,652,719,771,805,834,842,852,860,907,1011,1032,1080,1120,1148,1173,1196,
+ 1236,1265,1278,1304,1330,1345,1371,1392,1438,1470,1518,1563,1618,1635,1666,1682,1704,1733,1755,1770,
+ 1779,1784,1793,1801,1806,1811,1864,1908,1944,1988,2026,2060,2119,2154,2182,2223,2250,2261,2319,2354,
+ 2388,2434,2480,2510,2565,2594,2625,2641,2663,2692,2726,2741,2787,2792,2838,2871,2881,2891,2901,2911,
+ 2921,2931,2941,2951,2961,2971,2981,2991,3001,3011,3021,3031,3041,3051,3061,3071,3081,3091,3101,3111,
+ 3121,3131,3141,3151,3161,3171,3181,3191,3201,3201,3225,3270,3306,3368,3406,3416,3501,3535,3637,3695,
+ 3711,3718,3723,3834,3839,3877,3895,3929,3985,3990,4027,4046,4063,4090,4102,4141,4157,4194,4245,4326,
+ 4373,4399,4425,4454,4511,4566,4619,4657,4724,4754,4784,4817,4876,4894,4912,4933,4980,5016,5073,5124,
+ 5175,5229,5311,5391,5404,5463,5499,5535,5574,5639,5666,5702,5769,5827,5885,5946,6036,6123,6210,6295,
+ 6358,6401,6444,6490,6562,6578,6594,6613,6658,6719,6791,6830,6869,6911,6982,7050,7089,7148,7184,7220,
+ 7259,7324,7363,7409 };
+static const int DejaVuSerif_glyphPoints[7477*2] = {
+ 11856,4416,11856,6800,13472,8456,15088,10112,17504,10112,19840,10112,21504,8456,23168,6800,23168,4416,23168,2080,
+ 21504,424,19840,-1232,17504,-1232,15088,-1232,13472,408,11856,2048,11856,4416,12032,63456,22992,63456,20096,28560,
+ 20096,17856,14880,17856,14880,28560,12032,63456,15296,63456,15296,39872,8544,39872,8544,63456,15296,63456,31488,63456,
+ 31488,39872,24736,39872,24736,63456,31488,63456,44288,38288,32304,38288,28736,24096,40848,24096,44288,38288,38288,62480,
+ 33952,44832,45936,44832,50320,62480,57632,62480,53168,44832,66256,44832,66256,38288,51504,38288,48032,24096,61376,24096,
+ 61376,17600,46416,17600,42032,0,34720,0,39184,17600,27152,17600,22736,0,15520,0,19840,17600,6720,17600,
+ 6720,24096,21504,24096,24992,38288,11568,38288,11568,44832,26640,44832,31072,62480,38288,62480,29328,2896,34128,3312,
+ 36656,5648,39184,7984,39184,12032,39184,15680,36680,18232,34176,20784,29328,22096,29328,2896,25072,50448,20704,50144,
+ 18280,47912,15856,45680,15856,41952,15856,38544,18088,36296,20320,34048,25072,32640,25072,50448,7488,3056,7488,14784,
+ 12064,14784,12240,8960,15472,5992,18704,3024,25072,2896,25072,23504,15296,26224,11344,29776,7392,33328,7392,39184,
+ 7392,45984,12072,50104,16752,54224,25072,54736,25072,66128,29328,66128,29328,54736,33616,54400,37592,53360,41568,52320,
+ 45344,50576,45344,39440,40720,39440,40208,44368,37272,47216,34336,50064,29328,50448,29328,31232,39776,28384,43968,24712,
+ 48160,21040,48160,14880,48160,7824,43224,3568,38288,-688,29328,-1312,29328,-12800,25072,-12800,25072,-1312,20992,-1232,
+ 16616,-152,12240,928,7488,3056,19504,60640,15760,60640,13664,57120,11568,53600,11568,47264,11568,41008,13712,37440,
+ 15856,33872,19504,33872,23120,33872,25224,37424,27328,40976,27328,47264,27328,53552,25224,57096,23120,60640,19504,60640,
+ 63280,29488,59584,29488,57480,25920,55376,22352,55376,16016,55376,9776,57504,6224,59632,2672,63280,2672,66944,2672,
+ 69024,6224,71104,9776,71104,16016,71104,22320,69000,25904,66896,29488,63280,29488,63280,33328,70000,33328,73952,28648,
+ 77904,23968,77904,16016,77904,8080,73928,3424,69952,-1232,63280,-1232,56480,-1232,52528,3424,48576,8080,48576,16016,
+ 48576,24016,52552,28672,56528,33328,63280,33328,57968,64608,64432,64608,24736,-1232,18272,-1232,57968,64608,19424,64608,
+ 26144,64608,30136,59952,34128,55296,34128,47344,34128,39312,30152,34680,26176,30048,19424,30048,12672,30048,8736,34704,
+ 4800,39360,4800,47344,4800,55248,8752,59928,12704,64608,19424,64608,47008,9824,22272,35872,18576,32560,16728,28712,
+ 14880,24864,14880,20528,14880,13472,19768,8688,24656,3904,31968,3904,36288,3904,40136,5416,43984,6928,47008,9824,
+ 73360,0,56320,0,50496,6160,46032,2416,40976,592,35920,-1232,30048,-1232,19088,-1232,12664,4376,6240,9984,
+ 6240,19600,6240,25248,9496,30152,12752,35056,19344,39360,17168,41952,16152,44520,15136,47088,15136,49888,15136,56656,
+ 20000,60632,24864,64608,33232,64608,36080,64608,39888,63880,43696,63152,48576,61712,48576,50752,43776,50752,43184,55296,
+ 40464,57672,37744,60048,33072,60048,28688,60048,25968,57648,23248,55248,23248,51424,23248,48832,24696,46264,26144,43696,
+ 30720,38880,52656,15760,55584,19168,57264,23096,58944,27024,59376,31488,51728,31488,51728,36048,71824,36048,71824,31488,
+ 64512,31488,63792,25968,61688,21168,59584,16368,56064,12288,63360,4512,73360,4512,73360,0,15296,63456,15296,39872,
+ 8544,39872,8544,63456,15296,63456,27760,-13552,17424,-8928,12152,1128,6880,11184,6880,26272,6880,41392,12152,51448,
+ 17424,61504,27760,66128,27760,61968,21200,57456,18360,49280,15520,41104,15520,26272,15520,11472,18360,3296,21200,-4880,
+ 27760,-9392,27760,-13552,6160,-13552,6160,-9392,12704,-4880,15576,3296,18448,11472,18448,26272,18448,41104,15576,49280,
+ 12704,57456,6160,61968,6160,66128,16528,61504,21800,51448,27072,41392,27072,26272,27072,11184,21800,1128,16528,-8928,
+ 6160,-13552,42112,52576,25504,44832,42112,36976,38880,31968,24096,41184,24656,24992,18864,24992,19424,41184,4640,31968,
+ 1408,36976,18016,44752,1408,52576,4640,57632,19424,48400,18864,64608,24656,64608,24096,48400,38880,57632,42112,52576,
+ 39872,54576,39872,30720,63712,30720,63712,23840,39872,23840,39872,0,33072,0,33072,23840,9216,23840,9216,30720,
+ 33072,30720,33072,54576,39872,54576,3152,-8464,7136,-5520,9008,-1552,10880,2416,10880,8080,10880,9648,19248,9648,
+ 18912,2384,15832,-2824,12752,-8032,6544,-11856,3152,-8464,3824,26640,25584,26640,25584,20016,3824,20016,3824,26640,
+ 8208,4416,8208,6800,9824,8456,11440,10112,13856,10112,16192,10112,17848,8456,19504,6800,19504,4416,19504,2080,
+ 17848,424,16192,-1232,13856,-1232,11440,-1232,9824,408,8208,2048,8208,4416,22528,63456,29328,63456,6800,-8080,
+ 0,-8080,22528,63456,27664,2976,34176,2976,37400,10112,40624,17248,40624,31664,40624,46112,37400,53256,34176,60400,
+ 27664,60400,21168,60400,17936,53256,14704,46112,14704,31664,14704,17248,17936,10112,21168,2976,27664,2976,27664,-1232,
+ 17344,-1232,11544,7440,5744,16112,5744,31664,5744,47264,11544,55936,17344,64608,27664,64608,38032,64608,43816,55936,
+ 49600,47264,49600,31664,49600,16112,43816,7440,38032,-1232,27664,-1232,12368,0,12368,4512,23424,4512,23424,57296,
+ 10624,49008,10624,54576,26096,64608,31968,64608,31968,4512,43008,4512,43008,0,12368,0,11136,48320,6368,48320,
+ 6368,59632,10928,62048,15536,63328,20144,64608,24560,64608,34464,64608,40200,59800,45936,54992,45936,46752,45936,37440,
+ 32944,24480,31920,23504,31408,22992,15392,6976,41856,6976,41856,14784,46832,14784,46832,0,5904,0,5904,4640,
+ 25168,23840,31536,30224,34256,35552,36976,40880,36976,46752,36976,53168,33640,56784,30304,60400,24432,60400,18368,60400,
+ 15048,57376,11728,54352,11136,48320,8464,60768,13424,62640,17992,63624,22560,64608,26560,64608,35872,64608,41096,60584,
+ 46320,56560,46320,49424,46320,43696,42712,39848,39104,36000,32464,34640,40288,33536,44600,28968,48912,24400,48912,17120,
+ 48912,8240,42944,3504,36976,-1232,25760,-1232,20784,-1232,16048,-168,11312,896,6624,3056,6624,15392,11392,15392,
+ 11808,9264,15512,6120,19216,2976,25920,2976,32432,2976,36192,6736,39952,10496,39952,17040,39952,24528,36080,28368,
+ 32208,32208,24736,32208,20704,32208,20704,36544,22816,36544,30256,36544,33976,39632,37696,42720,37696,48912,37696,54480,
+ 34640,57440,31584,60400,25840,60400,20096,60400,16936,57680,13776,54960,13216,49600,8464,49600,8464,60768,30384,21504,
+ 30384,55248,8720,21504,30384,21504,49088,0,20192,0,20192,4512,30384,4512,30384,16960,2672,16960,2672,21584,
+ 30480,64608,38880,64608,38880,21504,51008,21504,51008,16960,38880,16960,38880,4512,49088,4512,49088,0,43776,63456,
+ 43776,56480,14704,56480,14704,38288,16912,39824,19864,40592,22816,41360,26480,41360,36768,41360,42712,35664,48656,29968,
+ 48656,20096,48656,10032,42648,4400,36640,-1232,25760,-1232,21376,-1232,16784,-168,12192,896,7392,3056,7392,15392,
+ 12192,15392,12576,9344,16040,6160,19504,2976,25760,2976,32464,2976,36080,7392,39696,11808,39696,20096,39696,28352,
+ 36104,32752,32512,37152,25760,37152,21936,37152,19024,35792,16112,34432,13856,31584,10208,31584,10208,63456,43776,63456,
+ 28480,2976,34464,2976,37696,7376,40928,11776,40928,20016,40928,28256,37696,32656,34464,37056,28480,37056,22400,37056,
+ 19208,32808,16016,28560,16016,20528,16016,12064,19248,7520,22480,2976,28480,2976,14624,34928,17504,38128,21160,39696,
+ 24816,41264,29408,41264,38880,41264,44384,35568,49888,29872,49888,20016,49888,10368,43960,4568,38032,-1232,28128,-1232,
+ 17376,-1232,11600,6776,5824,14784,5824,29664,5824,46320,12664,55464,19504,64608,31968,64608,35312,64608,39016,63968,
+ 42720,63328,46576,62048,46576,51600,41776,51600,41264,55888,38504,58144,35744,60400,31072,60400,22816,60400,18784,54152,
+ 14752,47904,14624,34928,49088,59120,24272,0,17936,0,41600,56480,12288,56480,12288,48656,7312,48656,7312,63456,
+ 49088,63456,49088,59120,40544,17344,40544,24144,37168,27904,33792,31664,27664,31664,21552,31664,18168,27904,14784,24144,
+ 14784,17344,14784,10496,18168,6736,21552,2976,27664,2976,33792,2976,37168,6736,40544,10496,40544,17344,38800,48160,
+ 38800,53936,35872,57168,32944,60400,27664,60400,22448,60400,19488,57168,16528,53936,16528,48160,16528,42336,19488,39104,
+ 22448,35872,27664,35872,32944,35872,35872,39104,38800,42336,38800,48160,34208,33792,41440,32816,45480,28456,49520,24096,
+ 49520,17344,49520,8416,43864,3592,38208,-1232,27664,-1232,17168,-1232,11496,3592,5824,8416,5824,17344,5824,24096,
+ 9864,28456,13904,32816,21168,33792,14752,34928,11328,38648,7904,42368,7904,48160,7904,55808,13176,60208,18448,64608,
+ 27664,64608,36896,64608,42160,60208,47424,55808,47424,48160,47424,42368,44008,38648,40592,34928,34208,33792,40720,28432,
+ 37872,25248,34176,23672,30480,22096,25840,22096,16400,22096,10944,27792,5488,33488,5488,43344,5488,52992,11416,58800,
+ 17344,64608,27248,64608,38000,64608,43760,56592,49520,48576,49520,33696,49520,17040,42672,7904,35824,-1232,23424,-1232,
+ 20064,-1232,16368,-592,12672,48,8800,1312,8800,11856,13552,11856,14112,7568,16872,5272,19632,2976,24272,2976,
+ 32512,2976,36552,9200,40592,15424,40720,28432,26896,60400,20864,60400,17656,56000,14448,51600,14448,43344,14448,35104,
+ 17656,30688,20864,26272,26896,26272,32944,26272,36152,30536,39360,34800,39360,42848,39360,51296,36128,55848,32896,60400,
+ 26896,60400,9056,4416,9056,6800,10688,8456,12320,10112,14704,10112,17088,10112,18720,8456,20352,6800,20352,4416,
+ 20352,2048,18736,408,17120,-1232,14704,-1232,12288,-1232,10672,408,9056,2048,9056,4416,9056,32128,9056,34512,
+ 10688,36144,12320,37776,14704,37776,17120,37776,18736,36168,20352,34560,20352,32128,20352,29712,18736,28096,17120,26480,
+ 14704,26480,12320,26480,10688,28112,9056,29744,9056,32128,3152,-8464,7136,-5520,9008,-1552,10880,2416,10880,8080,
+ 10880,9648,19248,9648,18912,2384,15832,-2824,12752,-8032,6544,-11856,3152,-8464,9216,32128,9216,34512,10856,36144,
+ 12496,37776,14880,37776,17248,37776,18888,36120,20528,34464,20528,32128,20528,29744,18888,28112,17248,26480,14880,26480,
+ 12496,26480,10856,28112,9216,29744,9216,32128,63712,43344,19600,27248,63712,11216,63712,4000,9216,23760,9216,30816,
+ 63712,50576,63712,43344,9216,39360,63712,39360,63712,32560,9216,32560,9216,39360,9216,22016,63712,22016,63712,15216,
+ 9216,15216,9216,22016,9216,43344,9216,50576,63712,30816,63712,23760,9216,4000,9216,11216,53344,27248,9216,43344,
+ 15296,4416,15296,6800,16936,8456,18576,10112,20992,10112,23328,10112,24984,8456,26640,6800,26640,4416,26640,2080,
+ 24984,424,23328,-1232,20992,-1232,18576,-1232,16936,408,15296,2048,15296,4416,5904,60640,10416,62640,14472,63624,
+ 18528,64608,22096,64608,31536,64608,37000,60056,42464,55504,42464,47776,42464,39872,37768,34856,33072,29840,23584,27664,
+ 23584,16880,18368,16880,18368,30816,25888,32640,29688,36936,33488,41232,33488,47856,33488,53680,30384,57040,27280,60400,
+ 21936,60400,17088,60400,14008,57616,10928,54832,10032,49600,5904,49600,5904,60640,54992,10544,52480,7056,49360,5352,
+ 46240,3648,42288,3648,34848,3648,30216,8968,25584,14288,25584,22816,25584,31360,30216,36656,34848,41952,42288,41952,
+ 46240,41952,49360,40248,52480,38544,54992,35056,54992,41104,61632,41104,61632,8288,68848,9856,72848,15168,76848,20480,
+ 76848,28480,76848,33200,75400,37400,73952,41600,71104,45184,66592,50832,60112,53824,53632,56816,46032,56816,42208,56816,
+ 38464,56008,34720,55200,31072,53552,22480,49600,17720,41584,12960,33568,12960,23072,12960,15984,15088,10008,17216,4032,
+ 21248,-336,25888,-5392,32240,-8048,38592,-10704,45936,-10704,51424,-10704,56184,-9096,60944,-7488,65024,-4256,67280,-7232,
+ 62688,-11184,56864,-13160,51040,-15136,44112,-15136,36336,-15136,29264,-12304,22192,-9472,16880,-4256,11392,1152,8568,8096,
+ 5744,15040,5744,23072,5744,30896,8592,37824,11440,44752,16880,50144,22272,55504,29600,58392,36928,61280,45184,61280,
+ 54272,61280,61776,57752,69280,54224,74336,47600,77568,43440,79224,38552,80880,33664,80880,28384,80880,17008,73952,10392,
+ 67024,3776,55040,3648,54992,10544,54992,20608,54992,25072,54992,30384,51952,33680,48912,36976,44032,36976,38880,36976,
+ 36016,33256,33152,29536,33152,22816,33152,16064,36040,12344,38928,8624,44112,8624,48960,8624,51976,11960,54992,15296,
+ 54992,20608,17424,22992,40720,22992,29072,53168,17424,22992,-512,0,-512,4512,5056,4512,27664,63456,34800,63456,
+ 57456,4512,63712,4512,63712,0,40624,0,40624,4512,47680,4512,42368,18448,15680,18448,10368,4512,17344,4512,
+ 17344,0,-512,0,21504,4512,34208,4512,41856,4512,45384,7824,48912,11136,48912,18368,48912,25536,45408,28832,
+ 41904,32128,34208,32128,21504,32128,21504,4512,21504,36640,32304,36640,39264,36640,42472,39312,45680,41984,45680,47776,
+ 45680,53600,42472,56256,39264,58912,32304,58912,21504,58912,21504,36640,4800,0,4800,4512,12880,4512,12880,58912,
+ 4800,58912,4800,63456,36128,63456,45728,63456,50592,59520,55456,55584,55456,47776,55456,42112,52080,38760,48704,35408,
+ 42208,34640,50272,33616,54464,29472,58656,25328,58656,18368,58656,8928,52704,4464,46752,0,34128,0,4800,0,
+ 61376,16784,58560,7904,51952,3336,45344,-1232,35232,-1232,29024,-1232,23712,896,18400,3024,14288,7136,9520,11904,
+ 7200,17960,4880,24016,4880,31664,4880,46448,13424,55528,21968,64608,35952,64608,41136,64608,47000,63248,52864,61888,
+ 59632,59120,59632,44496,54832,44496,53248,52480,48512,56264,43776,60048,35232,60048,25072,60048,19848,52848,14624,45648,
+ 14624,31664,14624,17728,19848,10520,25072,3312,35232,3312,42336,3312,46920,6696,51504,10080,53552,16784,61376,16784,
+ 21504,4512,29408,4512,41776,4512,48384,11560,54992,18608,54992,31792,54992,44960,48408,51936,41824,58912,29408,58912,
+ 21504,58912,21504,4512,4800,0,4800,4512,12880,4512,12880,58912,4800,58912,4800,63456,30048,63456,46448,63456,
+ 55608,55080,64768,46704,64768,31792,64768,16832,55592,8416,46416,0,30048,0,4800,0,4800,0,4800,4512,
+ 12880,4512,12880,58912,4800,58912,4800,63456,55888,63456,55888,49344,50656,49344,50656,58224,21504,58224,21504,36976,
+ 42288,36976,42288,44928,47520,44928,47520,23840,42288,23840,42288,31792,21504,31792,21504,5232,51344,5232,51344,14112,
+ 56560,14112,56560,0,4800,0,4800,0,4800,4512,12880,4512,12880,58912,4800,58912,4800,63456,56736,63456,
+ 56736,49344,51504,49344,51504,58224,21504,58224,21504,36976,43184,36976,43184,44928,48400,44928,48400,23840,43184,23840,
+ 43184,31792,21504,31792,21504,4512,31664,4512,31664,0,4800,0,55712,44496,54224,52448,49512,56248,44800,60048,
+ 36384,60048,25408,60048,20016,52992,14624,45936,14624,31664,14624,17680,20192,10496,25760,3312,36544,3312,41360,3312,
+ 45736,4504,50112,5696,54064,8080,54064,24432,42112,24432,42112,28992,62688,28992,62688,5312,57040,2048,50512,408,
+ 43984,-1232,36544,-1232,22192,-1232,13536,7760,4880,16752,4880,31664,4880,46704,13552,55656,22224,64608,36896,64608,
+ 42336,64608,48136,63352,53936,62096,60480,59536,60480,44496,55712,44496,4800,0,4800,4512,12880,4512,12880,58912,
+ 4800,58912,4800,63456,29584,63456,29584,58912,21504,58912,21504,36976,54400,36976,54400,58912,46320,58912,46320,63456,
+ 71104,63456,71104,58912,63024,58912,63024,4512,71104,4512,71104,0,46320,0,46320,4512,54400,4512,54400,31792,
+ 21504,31792,21504,4512,29584,4512,29584,0,4800,0,21504,4512,29584,4512,29584,0,4800,0,4800,4512,
+ 12880,4512,12880,58912,4800,58912,4800,63456,29584,63456,29584,58912,21504,58912,21504,4512,-7312,-15216,-7312,-5232,
+ -2464,-5232,-2336,-9440,-464,-11496,1408,-13552,5136,-13552,10208,-13552,12200,-10368,14192,-7184,14192,2080,14192,58912,
+ 4336,58912,4336,63456,30896,63456,30896,58912,22816,58912,22816,1744,22816,-8752,18608,-13432,14400,-18112,5056,-18112,
+ 2048,-18112,-1080,-17384,-4208,-16656,-7312,-15216,4800,0,4800,4512,12880,4512,12880,58912,4800,58912,4800,63456,
+ 29584,63456,29584,58912,21504,58912,21504,34896,48832,58912,41952,58912,41952,63456,63024,63456,63024,58912,55888,58912,
+ 28640,34976,59120,4512,66336,4512,66336,0,51600,0,21504,30128,21504,4512,29584,4512,29584,0,4800,0,
+ 4800,0,4800,4512,12880,4512,12880,58912,4800,58912,4800,63456,29584,63456,29584,58912,21504,58912,21504,5232,
+ 50496,5232,50496,15856,55712,15856,55712,0,4800,0,4800,0,4800,4512,12880,4512,12880,58912,4336,58912,
+ 4336,63456,22816,63456,45088,18272,67360,63456,84704,63456,84704,58912,76240,58912,76240,4512,84368,4512,84368,0,
+ 59536,0,59536,4512,67616,4512,67616,53552,45856,9312,39872,9312,18112,53552,18112,4512,26176,4512,26176,0,
+ 4800,0,4256,0,4256,4512,12800,4512,12800,58912,4256,58912,4256,63456,20528,63456,58560,13392,58560,58912,
+ 50064,58912,50064,63456,72336,63456,72336,58912,63792,58912,63792,-1232,58656,-1232,18016,52240,18016,4512,26560,4512,
+ 26560,0,4256,0,35696,3312,46112,3312,51424,10472,56736,17632,56736,31664,56736,45728,51424,52888,46112,60048,
+ 35696,60048,25248,60048,19936,52888,14624,45728,14624,31664,14624,17632,19936,10472,25248,3312,35696,3312,35696,-1232,
+ 29248,-1232,23824,896,18400,3024,14288,7136,9520,11904,7200,17936,4880,23968,4880,31664,4880,39360,7200,45416,
+ 9520,51472,14288,56224,18448,60400,23800,62504,29152,64608,35696,64608,49520,64608,58016,55552,66512,46496,66512,31664,
+ 66512,24048,64176,17952,61840,11856,57072,7136,52912,2976,47560,872,42208,-1232,35696,-1232,21504,32304,32720,32304,
+ 39056,32304,42368,35720,45680,39136,45680,45600,45680,52112,42368,55512,39056,58912,32720,58912,21504,58912,21504,32304,
+ 4800,0,4800,4512,12880,4512,12880,58912,4800,58912,4800,63456,34800,63456,44320,63456,49888,58632,55456,53808,
+ 55456,45600,55456,37440,49888,32600,44320,27760,34800,27760,21504,27760,21504,4512,31328,4512,31328,0,4800,0,
+ 36720,-1232,22144,-1232,13512,7712,4880,16656,4880,31664,4880,39360,7200,45416,9520,51472,14288,56224,18448,60400,
+ 23800,62504,29152,64608,35696,64608,49520,64608,58016,55552,66512,46496,66512,31664,66512,19088,60136,10520,53760,1952,
+ 42544,-512,44832,-3360,48128,-4720,51424,-6080,56064,-6080,57376,-6080,57376,-13936,50192,-13600,45072,-10432,39952,-7264,
+ 36720,-1232,35696,3312,46112,3312,51424,10472,56736,17632,56736,31664,56736,45728,51424,52888,46112,60048,35696,60048,
+ 25248,60048,19936,52888,14624,45728,14624,31664,14624,17632,19936,10472,25248,3312,35696,3312,41696,31488,44672,30688,
+ 46816,28752,48960,26816,50656,23328,59888,4512,67616,4512,67616,0,52656,0,42752,20192,39904,26048,37528,27768,
+ 35152,29488,30976,29488,21504,29488,21504,4512,30480,4512,30480,0,4800,0,4800,4512,12880,4512,12880,58912,
+ 4800,58912,4800,63456,36976,63456,46240,63456,51280,59032,56320,54608,56320,46496,56320,39952,52640,36192,48960,32432,
+ 41696,31488,21504,34048,34048,34048,40464,34048,43520,37088,46576,40128,46576,46496,46576,52864,43520,55888,40464,58912,
+ 34048,58912,21504,58912,21504,34048,8080,3056,8080,17504,12960,17472,13168,10240,17144,6776,21120,3312,29248,3312,
+ 36800,3312,40776,6312,44752,9312,44752,15040,44752,19632,42352,22096,39952,24560,32208,26896,23840,29408,14752,32176,
+ 11032,36296,7312,40416,7312,47600,7312,55680,13048,60144,18784,64608,29152,64608,33568,64608,38840,63648,44112,62688,
+ 50064,60864,50064,47344,45264,47344,44544,54064,40784,57056,37024,60048,29328,60048,22608,60048,19104,57312,15600,54576,
+ 15600,49344,15600,44800,18232,42208,20864,39616,29408,37056,37280,34720,45904,32128,49576,28112,53248,24096,53248,17344,
+ 53248,8112,47344,3440,41440,-1232,29744,-1232,24528,-1232,19104,-168,13680,896,8080,3056,16624,0,16624,4512,
+ 24736,4512,24736,58400,6080,58400,6080,48496,848,48496,848,63456,57200,63456,57200,48496,51984,48496,51984,58400,
+ 33328,58400,33328,4512,41440,4512,41440,0,16624,0,12192,58912,4080,58912,4080,63456,28896,63456,28896,58912,
+ 20784,58912,20784,26096,20784,13936,24760,9136,28736,4336,38464,4336,48192,4336,52168,9136,56144,13936,56144,26096,
+ 56144,58912,48032,58912,48032,63456,69440,63456,69440,58912,61376,58912,61376,25248,61376,10752,55808,4760,50240,-1232,
+ 36896,-1232,23552,-1232,17872,4800,12192,10832,12192,25248,12192,58912,15216,58912,33952,10208,52656,58912,45520,58912,
+ 45520,63456,64128,63456,64128,58912,57968,58912,35312,0,28000,0,5488,58912,-848,58912,-848,63456,22272,63456,
+ 22272,58912,15216,58912,66336,0,59376,0,44832,51600,30304,0,23328,0,6720,58912,432,58912,432,63456,
+ 23584,63456,23584,58912,15680,58912,28896,12032,43344,63456,50240,63456,64944,11472,78240,58912,70928,58912,70928,63456,
+ 89200,63456,89200,58912,82960,58912,66336,0,28816,27152,13296,4512,21504,4512,21504,0,512,0,512,4512,
+ 7824,4512,26096,31152,7568,58912,768,58912,768,63456,25920,63456,25920,58912,18448,58912,32048,38464,46032,58912,
+ 37872,58912,37872,63456,58656,63456,58656,58912,51504,58912,34720,34464,54736,4512,61536,4512,61536,0,36384,0,
+ 36384,4512,43952,4512,28816,27152,16448,0,16448,4512,24560,4512,24560,27328,4976,58912,-976,58912,-976,63456,
+ 22608,63456,22608,58912,15216,58912,31072,33232,46928,58912,39776,58912,39776,63456,58224,63456,58224,58912,52240,58912,
+ 33152,28128,33152,4512,41264,4512,41264,0,16448,0,3904,0,3904,3056,43440,58224,10624,58224,10624,48752,
+ 5392,48752,5392,63456,55552,63456,55552,60400,16016,5232,51888,5232,51888,14112,57072,14112,57072,0,3904,0,
+ 7488,66128,27248,66128,27248,61632,15600,61632,15600,-6976,27248,-6976,27248,-11472,7488,-11472,7488,66128,6800,63456,
+ 29328,-8080,22528,-8080,0,63456,6800,63456,26480,66128,26480,-11472,6720,-11472,6720,-6976,18368,-6976,18368,61632,
+ 6720,61632,6720,66128,26480,66128,40624,63456,63712,39776,57200,39776,36464,55968,15760,39776,9216,39776,32304,63456,
+ 40624,63456,43520,-17120,43520,-20528,0,-20528,0,-17120,43520,-17120,15600,69536,26640,53552,21680,53552,7232,69536,
+ 15600,69536,34640,14192,34640,23760,24560,23760,18736,23760,15888,21248,13040,18736,13040,13552,13040,8848,15936,6080,
+ 18832,3312,23760,3312,28640,3312,31640,6328,34640,9344,34640,14192,42464,28224,42464,4512,49424,4512,49424,0,
+ 34640,0,34640,4880,32048,1744,28648,256,25248,-1232,20704,-1232,13168,-1232,8752,2760,4336,6752,4336,13552,
+ 4336,20576,9392,24440,14448,28304,23680,28304,34640,28304,34640,31408,34640,36544,31512,39376,28384,42208,22736,42208,
+ 18064,42208,15304,40080,12544,37952,11856,33792,7824,33792,7824,42928,11904,44672,15752,45544,19600,46416,23248,46416,
+ 32640,46416,37552,41760,42464,37104,42464,28224,10032,4512,10032,61632,2512,61632,2512,66128,17856,66128,17856,38128,
+ 20144,42368,23696,44392,27248,46416,32464,46416,40800,46416,46072,39824,51344,33232,51344,22608,51344,11984,46072,5376,
+ 40800,-1232,32464,-1232,27248,-1232,23696,784,20144,2800,17856,7056,17856,0,2512,0,2512,4512,10032,4512,
+ 17856,20352,17856,12192,20976,7920,24096,3648,30048,3648,36048,3648,39128,8456,42208,13264,42208,22608,42208,32000,
+ 39128,36760,36048,41520,30048,41520,24096,41520,20976,37232,17856,32944,17856,24816,17856,20352,44752,13552,43088,6336,
+ 38376,2552,33664,-1232,26176,-1232,16320,-1232,10328,5288,4336,11808,4336,22608,4336,33440,10328,39928,16320,46416,
+ 26176,46416,30480,46416,34728,45416,38976,44416,43264,42368,43264,30816,38720,30816,37824,36768,34832,39488,31840,42208,
+ 26272,42208,19936,42208,16704,37296,13472,32384,13472,22608,13472,12832,16680,7904,19888,2976,26272,2976,31328,2976,
+ 34344,5608,37360,8240,38464,13552,44752,13552,45680,4512,53168,4512,53168,0,37872,0,37872,7056,35568,2800,
+ 32024,784,28480,-1232,23248,-1232,14912,-1232,9624,5376,4336,11984,4336,22608,4336,33232,9608,39824,14880,46416,
+ 23248,46416,28480,46416,32024,44392,35568,42368,37872,38128,37872,61632,30480,61632,30480,66128,45680,66128,45680,4512,
+ 37872,20352,37872,24816,37872,32944,34744,37232,31616,41520,25664,41520,19632,41520,16552,36760,13472,32000,13472,22608,
+ 13472,13264,16552,8456,19632,3648,25664,3648,31616,3648,34744,7920,37872,12192,37872,20352,47168,21760,13472,21760,
+ 13472,21424,13472,12288,16912,7632,20352,2976,27072,2976,32208,2976,35504,5672,38800,8368,40128,13680,46416,13680,
+ 44544,6240,39504,2504,34464,-1232,26272,-1232,16368,-1232,10352,5288,4336,11808,4336,22608,4336,33328,10240,39872,
+ 16144,46416,25760,46416,36000,46416,41480,40104,46960,33792,47168,21760,37952,26272,37696,34176,34616,38192,31536,42208,
+ 25760,42208,20352,42208,17256,38168,14160,34128,13472,26272,37952,26272,37440,55456,33328,55456,33280,58656,31512,60312,
+ 29744,61968,26400,61968,22016,61968,20232,59568,18448,57168,18448,51008,18448,45184,31072,45184,31072,40624,18448,40624,
+ 18448,4512,28480,4512,28480,0,3152,0,3152,4512,10624,4512,10624,40624,3152,40624,3152,45184,10624,45184,
+ 10624,50832,10624,58400,14552,62264,18480,66128,26096,66128,28944,66128,31792,65616,34640,65104,37440,64048,37440,55456,
+ 45680,40624,45680,976,45680,-8752,40328,-14048,34976,-19344,25072,-19344,20608,-19344,16528,-18536,12448,-17728,8720,-16112,
+ 8720,-6624,12800,-6624,13552,-11056,16400,-13096,19248,-15136,24560,-15136,31456,-15136,34664,-11248,37872,-7360,37872,976,
+ 37872,7056,35568,2800,32024,784,28480,-1232,23248,-1232,14912,-1232,9624,5376,4336,11984,4336,22608,4336,33232,
+ 9608,39824,14880,46416,23248,46416,28480,46416,32024,44392,35568,42368,37872,38128,37872,45184,53168,45184,53168,40624,
+ 45680,40624,37872,24816,37872,32944,34744,37232,31616,41520,25664,41520,19632,41520,16552,36760,13472,32000,13472,22608,
+ 13472,13264,16552,8456,19632,3648,25664,3648,31616,3648,34744,7920,37872,12192,37872,20352,37872,24816,3568,0,
+ 3568,4512,10624,4512,10624,61632,3152,61632,3152,66128,18448,66128,18448,37152,20608,41728,24072,44072,27536,46416,
+ 32128,46416,39616,46416,43144,42120,46672,37824,46672,28736,46672,4512,53632,4512,53632,0,32048,0,32048,4512,
+ 38800,4512,38800,26272,38800,34560,36784,37592,34768,40624,29584,40624,24144,40624,21296,36672,18448,32720,18448,25168,
+ 18448,4512,25248,4512,25248,0,3568,0,8464,59200,8464,61152,9888,62600,11312,64048,13296,64048,15264,64048,
+ 16688,62600,18112,61152,18112,59200,18112,57200,16704,55800,15296,54400,13296,54400,11312,54400,9888,55800,8464,57200,
+ 8464,59200,18448,4512,25840,4512,25840,0,3152,0,3152,4512,10624,4512,10624,40624,3152,40624,3152,45184,
+ 18448,45184,18448,4512,8720,59200,8720,61152,10144,62600,11568,64048,13552,64048,15520,64048,16944,62600,18368,61152,
+ 18368,59200,18368,57200,16984,55800,15600,54400,13552,54400,11568,54400,10144,55800,8720,57200,8720,59200,10624,40624,
+ 3232,40624,3232,45184,18448,45184,18448,-4416,18448,-11392,14304,-15368,10160,-19344,2896,-19344,-176,-19344,-2960,-18640,
+ -5744,-17936,-8368,-16528,-8368,-7232,-4336,-7232,-4032,-11312,-2232,-13224,-432,-15136,3056,-15136,6928,-15136,8776,-12520,
+ 10624,-9904,10624,-4416,10624,40624,24912,0,2976,0,2976,4512,10032,4512,10032,61632,2512,61632,2512,66128,
+ 17856,66128,17856,23072,36896,40624,30384,40624,30384,45184,50832,45184,50832,40624,43088,40624,29664,28224,46832,4512,
+ 53344,4512,53344,0,31072,0,31072,4512,37520,4512,24016,23072,17856,17344,17856,4512,24912,4512,24912,0,
+ 17856,4512,25248,4512,25248,0,2512,0,2512,4512,10032,4512,10032,61632,2512,61632,2512,66128,17856,66128,
+ 17856,4512,45088,36384,47344,41360,50848,43888,54352,46416,59040,46416,66128,46416,69616,42016,73104,37616,73104,28736,
+ 73104,4512,80160,4512,80160,0,58480,0,58480,4512,65280,4512,65280,27840,65280,34768,63240,37696,61200,40624,
+ 56480,40624,51248,40624,48512,36672,45776,32720,45776,25168,45776,4512,52576,4512,52576,0,31152,0,31152,4512,
+ 37952,4512,37952,28128,37952,34896,35912,37760,33872,40624,29152,40624,23920,40624,21184,36672,18448,32720,18448,25168,
+ 18448,4512,25248,4512,25248,0,3568,0,3568,4512,10624,4512,10624,40720,3152,40720,3152,45184,18448,45184,
+ 18448,37152,20608,41648,23968,44032,27328,46416,31584,46416,36848,46416,40376,43800,43904,41184,45088,36384,3568,0,
+ 3568,4512,10624,4512,10624,40624,3152,40624,3152,45184,18448,45184,18448,37152,20608,41728,24072,44072,27536,46416,
+ 32128,46416,39616,46416,43144,42120,46672,37824,46672,28736,46672,4512,53632,4512,53632,0,32048,0,32048,4512,
+ 38800,4512,38800,26272,38800,34560,36760,37640,34720,40720,29584,40720,24144,40720,21296,36744,18448,32768,18448,25168,
+ 18448,4512,25248,4512,25248,0,3568,0,26176,2976,32464,2976,35672,7952,38880,12928,38880,22608,38880,32304,
+ 35672,37256,32464,42208,26176,42208,19888,42208,16680,37256,13472,32304,13472,22608,13472,12928,16704,7952,19936,2976,
+ 26176,2976,26176,-1232,16320,-1232,10328,5288,4336,11808,4336,22608,4336,33408,10304,39912,16272,46416,26176,46416,
+ 36080,46416,42056,39912,48032,33408,48032,22608,48032,11808,42056,5288,36080,-1232,26176,-1232,17856,24816,17856,20352,
+ 17856,12192,20976,7920,24096,3648,30048,3648,36048,3648,39128,8456,42208,13264,42208,22608,42208,32000,39128,36760,
+ 36048,41520,30048,41520,24096,41520,20976,37232,17856,32944,17856,24816,10032,40624,2512,40624,2512,45184,17856,45184,
+ 17856,38128,20144,42368,23696,44392,27248,46416,32464,46416,40800,46416,46072,39824,51344,33232,51344,22608,51344,11984,
+ 46072,5376,40800,-1232,32464,-1232,27248,-1232,23696,784,20144,2800,17856,7056,17856,-13552,25248,-13552,25248,-18112,
+ 2512,-18112,2512,-13552,10032,-13552,10032,40624,45680,40624,45680,-13552,53168,-13552,53168,-18112,30480,-18112,30480,-13552,
+ 37872,-13552,37872,7056,35568,2800,32024,784,28480,-1232,23248,-1232,14912,-1232,9624,5376,4336,11984,4336,22608,
+ 4336,33232,9608,39824,14880,46416,23248,46416,28480,46416,32024,44392,35568,42368,37872,38128,37872,45184,53168,45184,
+ 53168,40624,45680,40624,37872,24816,37872,32944,34744,37232,31616,41520,25664,41520,19632,41520,16552,36760,13472,32000,
+ 13472,22608,13472,13264,16552,8456,19632,3648,25664,3648,31616,3648,34744,7920,37872,12192,37872,20352,37872,24816,
+ 41600,45264,41600,33952,37104,33952,36896,37312,35232,38968,33568,40624,30384,40624,24608,40624,21528,36632,18448,32640,
+ 18448,25168,18448,4512,27504,4512,27504,0,3568,0,3568,4512,10624,4512,10624,40720,3152,40720,3152,45184,
+ 18448,45184,18448,37152,20736,41856,24352,44136,27968,46416,33152,46416,35056,46416,37160,46112,39264,45808,41600,45264,
+ 4880,2512,4880,13040,9392,13040,9568,7984,12560,5480,15552,2976,21424,2976,26688,2976,29448,4952,32208,6928,
+ 32208,10704,32208,13680,30192,15512,28176,17344,21680,19424,16016,21328,10208,23200,7592,26008,4976,28816,4976,33152,
+ 4976,39360,9520,42888,14064,46416,22096,46416,25664,46416,29616,45480,33568,44544,37776,42752,37776,32896,33280,32896,
+ 33104,37280,30216,39744,27328,42208,22352,42208,17424,42208,14896,40464,12368,38720,12368,35232,12368,32384,14280,30664,
+ 16192,28944,21936,27152,28128,25248,34560,23248,37384,20248,40208,17248,40208,12544,40208,6128,35296,2448,30384,-1232,
+ 21760,-1232,17376,-1232,13216,-296,9056,640,4880,2512,9392,40624,2512,40624,2512,45184,9392,45184,9392,59200,
+ 17248,59200,17248,45184,31968,45184,31968,40624,17248,40624,17248,11936,17248,6208,18360,4592,19472,2976,22448,2976,
+ 25504,2976,26904,4784,28304,6592,28384,10624,34304,10624,33952,4464,30936,1616,27920,-1232,21760,-1232,15008,-1232,
+ 12200,1768,9392,4768,9392,11936,9392,40624,30816,45184,45440,45184,45440,4512,52832,4512,52832,0,37616,0,
+ 37616,7984,35440,3488,32000,1128,28560,-1232,24016,-1232,16496,-1232,12944,3040,9392,7312,9392,16448,9392,40624,
+ 2336,40624,2336,45184,17248,45184,17248,18864,17248,10624,19272,7568,21296,4512,26480,4512,31920,4512,34768,8504,
+ 37616,12496,37616,20096,37616,40624,30816,40624,30816,45184,21504,0,4880,40624,-256,40624,-256,45184,20528,45184,
+ 20528,40624,13296,40624,26016,9568,38720,40624,31968,40624,31968,45184,48912,45184,48912,40624,43856,40624,27248,0,
+ 21504,0,41776,45184,53344,9904,63536,40624,56992,40624,56992,45184,73360,45184,73360,40624,68336,40624,54912,0,
+ 48400,0,37280,33792,26096,0,19840,0,6464,40624,1408,40624,1408,45184,21840,45184,21840,40624,14528,40624,
+ 24656,9904,36288,45184,41776,45184,25328,27584,34800,40624,28736,40624,28736,45184,46112,45184,46112,40624,40128,40624,
+ 28000,23920,42112,4512,48032,4512,48032,0,27152,0,27152,4512,32896,4512,23072,18016,13216,4512,19088,4512,
+ 19088,0,1920,0,1920,4512,7904,4512,20352,21680,6624,40624,1056,40624,1056,45184,21248,45184,21248,40624,
+ 15856,40624,25328,27584,18784,-8288,21760,-768,4880,40624,-256,40624,-256,45184,20528,45184,20528,40624,13296,40624,
+ 26016,9568,38720,40624,31968,40624,31968,45184,48912,45184,48912,40624,43856,40624,23168,-10208,21040,-15472,18448,-17408,
+ 15856,-19344,11136,-19344,9136,-19344,7032,-19000,4928,-18656,2800,-18016,2800,-9392,6800,-9392,7056,-12288,8264,-13536,
+ 9472,-14784,12032,-14784,14368,-14784,15792,-13488,17216,-12192,18784,-8288,3488,0,3488,3648,31792,40624,9392,40624,
+ 9392,32816,4880,32816,4880,45184,41856,45184,41856,41520,13552,4512,38128,4512,38128,12704,42672,12704,42672,0,
+ 3488,0,44496,-9728,44496,-14192,41856,-14192,31280,-14192,27688,-11048,24096,-7904,24096,1488,24096,12448,24096,18832,
+ 21800,21296,19504,23760,13472,23760,10880,23760,10880,28224,13472,28224,19504,28224,21800,30688,24096,33152,24096,39520,
+ 24096,50496,24096,59888,27688,63008,31280,66128,41856,66128,44496,66128,44496,61712,41600,61712,35616,61712,33792,59840,
+ 31968,57968,31968,51984,31968,39776,31968,33072,29840,30176,27712,27280,22192,26016,27792,24560,29880,21712,31968,18864,
+ 31968,12192,31968,0,31968,-6000,33792,-7864,35616,-9728,41600,-9728,44496,-9728,18112,66512,18112,-20528,11216,-20528,
+ 11216,66512,18112,66512,10880,-9728,13856,-9728,19808,-9728,21616,-7880,23424,-6032,23424,0,23424,12192,23424,18864,
+ 25504,21712,27584,24560,33152,26016,27632,27280,25528,30176,23424,33072,23424,39776,23424,51984,23424,58016,21616,59864,
+ 19808,61712,13856,61712,10880,61712,10880,66128,13552,66128,24144,66128,27688,63008,31232,59888,31232,50496,31232,39520,
+ 31232,33152,33528,30688,35824,28224,41856,28224,44496,28224,44496,23760,41856,23760,35824,23760,33528,21296,31232,18832,
+ 31232,12448,31232,1488,31232,-7904,27688,-11048,24144,-14192,13552,-14192,10880,-14192,10880,-9728,63712,34304,63712,28000,
+ 59456,24272,55632,22488,51808,20704,47856,20704,43776,20704,36384,23504,35952,23680,35488,23840,34560,24224,28304,26640,
+ 24272,26640,20352,26640,16680,25096,13008,23552,9216,20272,9216,26736,13472,30432,17280,32152,21088,33872,25072,33872,
+ 29152,33872,36544,31072,36976,30896,37440,30720,38288,30384,44448,27920,48576,27920,52480,27920,56224,29496,59968,31072,
+ 63712,34304,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,4336,-15392,4336,61376,47856,61376,47856,-15392,4336,-15392,9216,-10544,43008,-10544,43008,56480,9216,56480,
+ 9216,-10544,11856,59040,11856,61408,13472,63048,15088,64688,17504,64688,19840,64688,21504,63032,23168,61376,23168,59040,
+ 23168,56656,21504,55000,19840,53344,17504,53344,15088,53344,13472,55000,11856,56656,11856,59040,12032,0,14880,34896,
+ 14880,45600,20096,45600,20096,34896,22992,0,12032,0,26736,42112,21248,41488,18504,36600,15760,31712,15760,22608,
+ 15760,13472,18504,8584,21248,3696,26736,3056,26736,42112,46928,13552,45440,7008,41440,3336,37440,-336,30976,-1152,
+ 30976,-12624,26736,-12624,26736,-1152,17376,-336,11960,6040,6544,12416,6544,22608,6544,32896,11960,39248,17376,45600,
+ 26736,46320,26736,57632,30976,57632,30976,46320,34896,45984,38464,45008,42032,44032,45440,42368,45440,30816,40928,30816,
+ 40128,36048,37680,38824,35232,41600,30976,42112,30976,3056,34800,3568,37272,6264,39744,8960,40624,13552,46928,13552,
+ 46832,52064,42368,52064,41952,56096,39552,58248,37152,60400,33072,60400,27664,60400,25096,57104,22528,53808,22528,46832,
+ 22528,34304,40032,34304,40032,29744,22528,29744,22528,5136,42848,5136,42848,14784,47776,14784,47776,0,5824,0,
+ 5824,4512,14032,4512,14032,29744,5824,29744,5824,34304,14032,34304,14032,46832,14032,55552,18896,60080,23760,64608,
+ 33152,64608,36768,64608,40208,64072,43648,63536,46832,62480,46832,52064,38288,41856,47168,50656,51168,46672,42288,37776,
+ 44112,35232,44984,32640,45856,30048,45856,27248,45856,24304,44984,21800,44112,19296,42208,16880,51008,8080,46928,4080,
+ 38128,12800,35744,10928,33216,10032,30688,9136,27760,9136,25040,9136,22384,10008,19728,10880,17120,12624,8464,3904,
+ 4416,7904,13136,16704,11392,19344,10520,21936,9648,24528,9648,27248,9648,30224,10544,32752,11440,35280,13296,37696,
+ 4512,46496,8544,50496,17344,41696,19728,43568,22272,44456,24816,45344,27760,45344,30560,45344,33152,44496,35744,43648,
+ 38288,41856,39184,27328,39184,32080,35888,35360,32592,38640,27760,38640,22992,38640,19680,35360,16368,32080,16368,27328,
+ 16368,22480,19656,19168,22944,15856,27760,15856,32560,15856,35872,19192,39184,22528,39184,27328,15296,0,15296,4512,
+ 23424,4512,23424,20096,6240,20096,6240,24560,23424,24560,23424,27328,19936,33328,6240,33328,6240,37776,17424,37776,
+ 5232,58912,-688,58912,-688,63456,22816,63456,22816,58912,15392,58912,29968,33232,44368,58912,37280,58912,37280,63456,
+ 55632,63456,55632,58912,49600,58912,37520,37776,49088,37776,49088,33328,34976,33328,31968,28128,31968,24560,49088,24560,
+ 49088,20096,31968,20096,31968,4512,40032,4512,40032,0,15296,0,18112,17344,18112,-14880,11216,-14880,11216,17344,
+ 18112,17344,18112,60864,18112,28640,11216,28640,11216,60864,18112,60864,16112,39776,13216,37824,12048,36064,10880,34304,
+ 10880,32048,10880,26432,26304,17808,27664,17040,30128,18656,31384,20696,32640,22736,32640,25168,32640,28352,29688,31200,
+ 26736,34048,16112,39776,35232,62224,35232,53632,31328,53632,31232,56688,29024,58456,26816,60224,23072,60224,18832,60224,
+ 16384,58160,13936,56096,13936,52576,13936,48448,24400,42624,25504,41984,26016,41696,34304,37056,36960,33872,39616,30688,
+ 39616,26480,39616,22448,37384,19768,35152,17088,30304,15216,33616,13216,35168,10536,36720,7856,36720,4000,36720,-1568,
+ 32384,-4928,28048,-8288,20704,-8288,16880,-8288,13480,-7712,10080,-7136,6800,-5904,6800,2976,10704,2928,10800,-464,
+ 13096,-2184,15392,-3904,19936,-3904,24352,-3904,26920,-1824,29488,256,29488,3824,29488,8624,19808,14032,18912,14528,
+ 18448,14784,9264,19968,6584,23160,3904,26352,3904,30560,3904,34560,6416,37384,8928,40208,13552,41520,10080,43600,
+ 8400,46280,6720,48960,6720,52320,6720,57840,10968,61224,15216,64608,22272,64608,25584,64608,28816,64008,32048,63408,
+ 35232,62224,13472,66688,15520,66688,16984,65216,18448,63744,18448,61712,18448,59536,17048,58136,15648,56736,13472,56736,
+ 11344,56736,9944,58136,8544,59536,8544,61712,8544,63744,10008,65216,11472,66688,13472,66688,30048,66688,32048,66688,
+ 33512,65216,34976,63744,34976,61712,34976,59536,33576,58136,32176,56736,30048,56736,27888,56736,26480,58136,25072,59536,
+ 25072,61712,25072,63744,26536,65216,28000,66688,30048,66688,58480,24352,57328,18784,53488,15792,49648,12800,43600,12800,
+ 35664,12800,30920,17896,26176,22992,26176,31488,26176,40032,30960,45176,35744,50320,43600,50320,47008,50320,50304,49536,
+ 53600,48752,57296,47088,57296,38032,53728,38032,52992,42672,50576,44840,48160,47008,43696,47008,38640,47008,36064,43120,
+ 33488,39232,33488,31488,33488,23808,36040,19960,38592,16112,43600,16112,47728,16112,50128,18128,52528,20144,53424,24352,
+ 58480,24352,43520,63120,49984,63120,55568,60776,61152,58432,65792,53808,70416,49168,72712,43600,75008,38032,75008,31488,
+ 75008,25040,72712,19488,70416,13936,65792,9312,61152,4672,55568,2336,49984,0,43520,0,37056,0,31472,2336,
+ 25888,4672,21248,9312,16624,13936,14328,19488,12032,25040,12032,31488,12032,38032,14328,43600,16624,49168,21248,53808,
+ 25888,58432,31472,60776,37056,63120,43520,63120,43520,58736,37952,58736,33152,56736,28352,54736,24352,50752,20400,46800,
+ 18384,41928,16368,37056,16368,31488,16368,25968,18384,21168,20400,16368,24352,12368,28352,8368,33152,6352,37952,4336,
+ 43520,4336,49136,4336,53960,6352,58784,8368,62768,12368,66720,16320,68696,21120,70672,25920,70672,31488,70672,37152,
+ 68680,41976,66688,46800,62768,50752,58784,54736,53960,56736,49136,58736,43520,58736,35616,51808,35616,35696,39008,35696,
+ 39008,32128,29328,32128,29328,35536,27280,33360,24624,32344,21968,31328,18272,31328,12288,31328,8800,34088,5312,36848,
+ 5312,41600,5312,46448,9352,49168,13392,51888,20608,51888,29328,51888,29328,53808,29328,57376,26864,59376,24400,61376,
+ 19936,61376,16240,61376,14072,59888,11904,58400,11312,55456,8080,55456,8080,62128,11344,63360,14408,63984,17472,64608,
+ 20272,64608,27792,64608,31704,61328,35616,58048,35616,51808,29328,42368,29328,48656,21328,48656,16880,48656,14584,46960,
+ 12288,45264,12288,41952,12288,38512,14432,36704,16576,34896,20704,34896,24608,34896,26968,36952,29328,39008,29328,42368,
+ 7056,27152,36720,27152,36720,22736,7056,22736,7056,27152,45088,45008,45088,40128,32464,25504,45088,10880,45088,6000,
+ 25168,23760,25168,27248,45088,45008,26640,45008,26640,40128,14032,25504,26640,10880,26640,6000,6720,23760,6720,27248,
+ 26640,45008,9216,36640,63712,36640,63712,12192,56912,12192,56912,29744,9216,29744,9216,36640,3824,26640,25584,26640,
+ 25584,20016,3824,20016,3824,26640,38032,33616,43344,33616,46880,33616,48640,35232,50400,36848,50400,40032,50400,43184,
+ 48616,44800,46832,46416,43344,46416,38032,46416,38032,33616,48496,32048,50272,31456,51528,30368,52784,29280,53632,27584,
+ 58560,17856,61792,17856,61792,14960,53728,14960,48160,25760,46672,28736,45352,29728,44032,30720,41952,30720,38032,30720,
+ 38032,17856,41600,17856,41600,14960,28128,14960,28128,17856,31664,17856,31664,46416,28128,46416,28128,49264,45776,49264,
+ 51216,49264,53976,46880,56736,44496,56736,39872,56736,36336,54696,34400,52656,32464,48496,32048,43520,58736,37952,58736,
+ 33152,56736,28352,54736,24352,50752,20400,46800,18384,41928,16368,37056,16368,31488,16368,25968,18384,21168,20400,16368,
+ 24352,12368,28352,8368,33152,6352,37952,4336,43520,4336,49136,4336,53960,6352,58784,8368,62768,12368,66720,16320,
+ 68696,21120,70672,25920,70672,31488,70672,37152,68680,41976,66688,46800,62768,50752,58784,54736,53960,56736,49136,58736,
+ 43520,58736,43520,63120,49984,63120,55568,60776,61152,58432,65792,53808,70416,49168,72712,43600,75008,38032,75008,31488,
+ 75008,25040,72712,19488,70416,13936,65792,9312,61152,4672,55568,2336,49984,0,43520,0,37056,0,31472,2336,
+ 25888,4672,21248,9312,16624,13936,14328,19488,12032,25040,12032,31488,12032,38032,14328,43600,16624,49168,21248,53808,
+ 25888,58432,31472,60776,37056,63120,43520,63120,9056,64848,34464,64848,34464,58560,9056,58560,9056,64848,21760,58736,
+ 18528,58736,16320,56504,14112,54272,14112,51008,14112,47776,16296,45608,18480,43440,21760,43440,24992,43440,27200,45624,
+ 29408,47808,29408,51008,29408,54192,27160,56464,24912,58736,21760,58736,21760,64608,24480,64608,26984,63560,29488,62512,
+ 31328,60560,33280,58656,34256,56232,35232,53808,35232,51008,35232,45392,31304,41504,27376,37616,21680,37616,15936,37616,
+ 12112,41440,8288,45264,8288,51008,8288,56688,12200,60648,16112,64608,21760,64608,39872,54576,39872,37952,63712,37952,
+ 63712,31072,39872,31072,39872,14448,33072,14448,33072,31072,9216,31072,9216,37952,33072,37952,33072,54576,39872,54576,
+ 9216,6800,63712,6800,63712,0,9216,0,9216,6800,7232,55088,4256,55088,4256,61792,7056,63152,10032,63880,
+ 13008,64608,15936,64608,21808,64608,25440,61800,29072,58992,29072,54576,29072,49392,20832,41984,20016,41264,9904,32128,
+ 26272,32128,26272,36720,29408,36720,29408,28384,3824,28384,3824,31584,15936,42368,19600,45648,21168,48240,22736,50832,
+ 22736,53632,22736,57248,20672,59352,18608,61456,15040,61456,11728,61456,9728,59840,7728,58224,7232,55088,5312,62384,
+ 8416,63488,11264,64048,14112,64608,16624,64608,22480,64608,25648,62312,28816,60016,28816,55808,28816,52736,26560,50616,
+ 24304,48496,20272,47776,25328,47088,27904,44560,30480,42032,30480,37776,30480,32944,26760,30352,23040,27760,16112,27760,
+ 13040,27760,10088,28352,7136,28944,4256,30128,4256,37360,7232,37312,7440,34176,9520,32536,11600,30896,15520,30896,
+ 19504,30896,21672,32768,23840,34640,23840,38128,23840,42080,21672,44096,19504,46112,15216,46112,12960,46112,12960,49264,
+ 14112,49264,18240,49264,20344,50832,22448,52400,22448,55552,22448,58400,20720,59928,18992,61456,15760,61456,12288,61456,
+ 10440,60096,8592,58736,8288,55968,5312,55968,5312,62384,27664,69616,36128,69616,21680,53632,16704,53632,27664,69616,
+ 31408,45184,46032,45184,46032,4416,53424,4416,53424,0,38208,0,38208,7984,36000,3488,32872,1128,29744,-1232,
+ 25920,-1232,23504,-1232,21504,-464,19504,304,17856,1824,17856,-13552,25248,-13552,25248,-18112,2512,-18112,2512,-13552,
+ 10032,-13552,10032,40624,2976,40624,2976,45184,17856,45184,17856,18864,17856,10624,19896,7568,21936,4512,27072,4512,
+ 32512,4512,35360,8504,38208,12496,38208,20096,38208,40624,31408,40624,31408,45184,26896,63456,49760,63456,49760,58912,
+ 44752,58912,44752,-8368,40208,-8368,40208,58912,30384,58912,30384,-8368,25840,-8368,25840,27584,16704,28304,11712,33000,
+ 6720,37696,6720,45520,6720,53600,12240,58528,17760,63456,26896,63456,8080,30224,8080,32592,9712,34232,11344,35872,
+ 13776,35872,16112,35872,17768,34216,19424,32560,19424,30224,19424,27840,17768,26200,16112,24560,13776,24560,11344,24560,
+ 9712,26176,8080,27792,8080,30224,24560,0,27280,-2720,28624,-5104,29968,-7488,29968,-9568,29968,-13008,27288,-14896,
+ 24608,-16784,19840,-16784,18064,-16784,16192,-16528,14320,-16272,12368,-15760,12368,-10208,14112,-10928,15792,-11288,17472,-11648,
+ 18960,-11648,21376,-11648,22776,-10520,24176,-9392,24176,-7488,24176,-6288,23248,-4416,22320,-2544,20448,0,24560,0,
+ 7488,28384,7488,31968,14784,31968,14784,58912,6240,54400,6240,58400,16448,63872,20784,63872,20784,31968,28128,31968,
+ 28128,28384,7488,28384,20448,34560,24944,34560,27216,37936,29488,41312,29488,47936,29488,54576,27200,57976,24912,61376,
+ 20448,61376,16016,61376,13704,57928,11392,54480,11392,47936,11392,41360,13688,37960,15984,34560,20448,34560,20448,31328,
+ 13008,31328,8504,35896,4000,40464,4000,47936,4000,55456,8504,60032,13008,64608,20448,64608,27888,64608,32392,60032,
+ 36896,55456,36896,47936,36896,40416,32408,35872,27920,31328,20448,31328,5824,27152,35056,27152,35056,22736,5824,22736,
+ 5824,27152,26640,45008,46576,27248,46576,23760,26640,6000,26640,10880,39264,25504,26640,40128,26640,45008,8208,45008,
+ 28128,27248,28128,23760,8208,6000,8208,10880,20784,25504,8208,40128,8208,45008,68320,12592,68320,29888,55232,12592,
+ 68320,12592,80560,-288,62112,-288,62112,3296,68320,3296,68320,9104,51408,9104,51408,12688,68400,35200,74400,35200,
+ 74400,12592,81360,12592,81360,9104,74400,9104,74400,3296,80560,3296,80560,-288,7488,28384,7488,31968,14784,31968,
+ 14784,58912,6240,54400,6240,58400,16448,63872,20784,63872,20784,31968,28128,31968,28128,28384,7488,28384,58912,64608,
+ 65296,64608,25248,-1232,18880,-1232,58912,64608,7488,28384,7488,31968,14784,31968,14784,58912,6240,54400,6240,58400,
+ 16448,63872,20784,63872,20784,31968,28128,31968,28128,28384,7488,28384,58912,64608,65296,64608,25248,-1232,18880,-1232,
+ 58912,64608,56384,26416,53408,26416,53408,33120,56208,34480,59184,35208,62160,35936,65088,35936,70960,35936,74592,33128,
+ 78224,30320,78224,25904,78224,20720,69984,13312,69168,12592,59056,3456,75424,3456,75424,8048,78560,8048,78560,-288,
+ 52976,-288,52976,2912,65088,13696,68752,16976,70320,19568,71888,22160,71888,24960,71888,28576,69824,30680,67760,32784,
+ 64192,32784,60880,32784,58880,31168,56880,29552,56384,26416,68320,12592,68320,29888,55232,12592,68320,12592,80560,-288,
+ 62112,-288,62112,3296,68320,3296,68320,9104,51408,9104,51408,12688,68400,35200,74400,35200,74400,12592,81360,12592,
+ 81360,9104,74400,9104,74400,3296,80560,3296,80560,-288,5312,62384,8416,63488,11264,64048,14112,64608,16624,64608,
+ 22480,64608,25648,62312,28816,60016,28816,55808,28816,52736,26560,50616,24304,48496,20272,47776,25328,47088,27904,44560,
+ 30480,42032,30480,37776,30480,32944,26760,30352,23040,27760,16112,27760,13040,27760,10088,28352,7136,28944,4256,30128,
+ 4256,37360,7232,37312,7440,34176,9520,32536,11600,30896,15520,30896,19504,30896,21672,32768,23840,34640,23840,38128,
+ 23840,42080,21672,44096,19504,46112,15216,46112,12960,46112,12960,49264,14112,49264,18240,49264,20344,50832,22448,52400,
+ 22448,55552,22448,58400,20720,59928,18992,61456,15760,61456,12288,61456,10440,60096,8592,58736,8288,55968,5312,55968,
+ 5312,62384,58912,64608,65296,64608,25248,-1232,18880,-1232,58912,64608,33072,59040,33072,56656,31432,55000,29792,53344,
+ 27408,53344,25072,53344,23416,55000,21760,56656,21760,59040,21760,61376,23416,63032,25072,64688,27408,64688,29840,64688,
+ 31456,63048,33072,61408,33072,59040,42464,2800,37952,800,33912,-176,29872,-1152,26272,-1152,16880,-1152,11392,3400,
+ 5904,7952,5904,15680,5904,23584,10624,28600,15344,33616,24816,35792,24816,46576,30048,46576,30048,32640,22528,30816,
+ 18704,26520,14880,22224,14880,15600,14880,9776,18000,6416,21120,3056,26480,3056,31280,3056,34384,5840,37488,8624,
+ 38384,13856,42464,13856,42464,2800,17424,22992,40720,22992,29072,53168,17424,22992,-512,0,-512,4512,5056,4512,
+ 27664,63456,34800,63456,57456,4512,63712,4512,63712,0,40624,0,40624,4512,47680,4512,42368,18448,15680,18448,
+ 10368,4512,17344,4512,17344,0,-512,0,28512,80208,36288,68992,31312,68992,20176,80208,28512,80208,17424,22992,
+ 40720,22992,29072,53168,17424,22992,-512,0,-512,4512,5056,4512,27664,63456,34800,63456,57456,4512,63712,4512,
+ 63712,0,40624,0,40624,4512,47680,4512,42368,18448,15680,18448,10368,4512,17344,4512,17344,0,-512,0,
+ 34160,80208,42544,80208,31408,68992,26432,68992,34160,80208,17424,22992,40720,22992,29072,53168,17424,22992,-512,0,
+ -512,4512,5056,4512,27664,63456,34800,63456,57456,4512,63712,4512,63712,0,40624,0,40624,4512,47680,4512,
+ 42368,18448,15680,18448,10368,4512,17344,4512,17344,0,-512,0,27744,80208,35232,80208,45040,68992,40112,68992,
+ 31488,75840,22864,68992,17936,68992,27744,80208,17424,22992,40720,22992,29072,53168,17424,22992,-512,0,-512,4512,
+ 5056,4512,27664,63456,34800,63456,57456,4512,63712,4512,63712,0,40624,0,40624,4512,47680,4512,42368,18448,
+ 15680,18448,10368,4512,17344,4512,17344,0,-512,0,30928,72400,28896,73584,28048,74144,27176,74440,26304,74736,
+ 25584,74736,23920,74736,22816,73520,21712,72304,21536,70352,17456,70400,17552,74640,19720,77152,21888,79664,25488,79664,
+ 27024,79664,28344,79280,29664,78896,32000,77584,34080,76480,35056,75920,35992,75624,36928,75328,37648,75328,39392,75328,
+ 40392,76496,41392,77664,41392,79664,45520,79664,45424,75200,43240,72776,41056,70352,37056,70352,34208,70352,31152,72272,
+ 30928,72400,17424,22992,40720,22992,29072,53168,17424,22992,-512,0,-512,4512,5056,4512,27664,63456,34800,63456,
+ 57456,4512,63712,4512,63712,0,40624,0,40624,4512,47680,4512,42368,18448,15680,18448,10368,4512,17344,4512,
+ 17344,0,-512,0,23200,79584,25248,79584,26712,78096,28176,76608,28176,74640,28176,72528,26752,71104,25328,69680,
+ 23200,69680,21120,69680,19696,71104,18272,72528,18272,74640,18272,76608,19736,78096,21200,79584,23200,79584,39776,79584,
+ 41776,79584,43240,78096,44704,76608,44704,74640,44704,72528,43280,71104,41856,69680,39776,69680,37648,69680,36224,71104,
+ 34800,72528,34800,74640,34800,76608,36264,78096,37728,79584,39776,79584,37696,69104,37696,71776,35808,73672,33920,75568,
+ 31232,75568,28512,75568,26664,73720,24816,71872,24816,69104,24816,66432,26664,64560,28512,62688,31232,62688,33920,62688,
+ 35808,64560,37696,66432,37696,69104,17424,22992,40624,22992,29072,53168,17424,22992,-512,0,-512,4512,5056,4512,
+ 25840,58816,22784,60400,21192,62992,19600,65584,19600,69104,19600,73952,23000,77376,26400,80800,31232,80800,36080,80800,
+ 39504,77376,42928,73952,42928,69104,42928,65712,41272,63008,39616,60304,36544,58816,57456,4512,63712,4512,63712,0,
+ 40624,0,40624,4512,47680,4512,42368,18448,15680,18448,10368,4512,17344,4512,17344,0,-512,0,18112,22992,
+ 38880,22992,38880,58912,34640,58912,18112,22992,30816,0,30816,4512,38880,4512,38880,18448,16016,18448,9568,4512,
+ 16528,4512,16528,0,-1488,0,-1488,4512,4080,4512,29152,58912,20016,58912,20016,63456,81904,63456,81904,49344,
+ 76672,49344,76672,58224,47424,58224,47424,36976,68336,36976,68336,44928,73568,44928,73568,23840,68336,23840,68336,31792,
+ 47424,31792,47424,5232,77392,5232,77392,14112,82624,14112,82624,0,30816,0,61376,16784,58560,7904,51952,3336,
+ 45344,-1232,35232,-1232,29024,-1232,23712,896,18400,3024,14288,7136,9520,11904,7200,17960,4880,24016,4880,31664,
+ 4880,46448,13424,55528,21968,64608,35952,64608,41136,64608,47000,63248,52864,61888,59632,59120,59632,44496,54832,44496,
+ 53248,52480,48512,56264,43776,60048,35232,60048,25072,60048,19848,52848,14624,45648,14624,31664,14624,17728,19848,10520,
+ 25072,3312,35232,3312,42336,3312,46920,6696,51504,10080,53552,16784,61376,16784,38896,0,41616,-2720,42960,-5104,
+ 44304,-7488,44304,-9568,44304,-13008,41624,-14896,38944,-16784,34176,-16784,32400,-16784,30528,-16528,28656,-16272,26704,-15760,
+ 26704,-10208,28448,-10928,30128,-11288,31808,-11648,33296,-11648,35712,-11648,37112,-10520,38512,-9392,38512,-7488,38512,-6288,
+ 37584,-4416,36656,-2544,34784,0,38896,0,4800,0,4800,4512,12880,4512,12880,58912,4800,58912,4800,63456,
+ 55888,63456,55888,49344,50656,49344,50656,58224,21504,58224,21504,36976,42288,36976,42288,44928,47520,44928,47520,23840,
+ 42288,23840,42288,31792,21504,31792,21504,5232,51344,5232,51344,14112,56560,14112,56560,0,4800,0,28512,80208,
+ 36288,68992,31312,68992,20176,80208,28512,80208,4800,0,4800,4512,12880,4512,12880,58912,4800,58912,4800,63456,
+ 55888,63456,55888,49344,50656,49344,50656,58224,21504,58224,21504,36976,42288,36976,42288,44928,47520,44928,47520,23840,
+ 42288,23840,42288,31792,21504,31792,21504,5232,51344,5232,51344,14112,56560,14112,56560,0,4800,0,34160,80208,
+ 42544,80208,31408,68992,26432,68992,34160,80208,4800,0,4800,4512,12880,4512,12880,58912,4800,58912,4800,63456,
+ 55888,63456,55888,49344,50656,49344,50656,58224,21504,58224,21504,36976,42288,36976,42288,44928,47520,44928,47520,23840,
+ 42288,23840,42288,31792,21504,31792,21504,5232,51344,5232,51344,14112,56560,14112,56560,0,4800,0,27744,80208,
+ 35232,80208,45040,68992,40112,68992,31488,75840,22864,68992,17936,68992,27744,80208,4800,0,4800,4512,12880,4512,
+ 12880,58912,4800,58912,4800,63456,55888,63456,55888,49344,50656,49344,50656,58224,21504,58224,21504,36976,42288,36976,
+ 42288,44928,47520,44928,47520,23840,42288,23840,42288,31792,21504,31792,21504,5232,51344,5232,51344,14112,56560,14112,
+ 56560,0,4800,0,23200,79584,25248,79584,26712,78096,28176,76608,28176,74640,28176,72528,26752,71104,25328,69680,
+ 23200,69680,21120,69680,19696,71104,18272,72528,18272,74640,18272,76608,19736,78096,21200,79584,23200,79584,39776,79584,
+ 41776,79584,43240,78096,44704,76608,44704,74640,44704,72528,43280,71104,41856,69680,39776,69680,37648,69680,36224,71104,
+ 34800,72528,34800,74640,34800,76608,36264,78096,37728,79584,39776,79584,21504,4512,29584,4512,29584,0,4800,0,
+ 4800,4512,12880,4512,12880,58912,4800,58912,4800,63456,29584,63456,29584,58912,21504,58912,21504,4512,14176,80208,
+ 21952,68992,16976,68992,5840,80208,14176,80208,21504,4512,29584,4512,29584,0,4800,0,4800,4512,12880,4512,
+ 12880,58912,4800,58912,4800,63456,29584,63456,29584,58912,21504,58912,21504,4512,19824,80208,28208,80208,17072,68992,
+ 12096,68992,19824,80208,21504,4512,29584,4512,29584,0,4800,0,4800,4512,12880,4512,12880,58912,4800,58912,
+ 4800,63456,29584,63456,29584,58912,21504,58912,21504,4512,13408,80208,20896,80208,30704,68992,25776,68992,17152,75840,
+ 8528,68992,3600,68992,13408,80208,21504,4512,29584,4512,29584,0,4800,0,4800,4512,12880,4512,12880,58912,
+ 4800,58912,4800,63456,29584,63456,29584,58912,21504,58912,21504,4512,8864,79584,10912,79584,12376,78096,13840,76608,
+ 13840,74640,13840,72528,12416,71104,10992,69680,8864,69680,6784,69680,5360,71104,3936,72528,3936,74640,3936,76608,
+ 5400,78096,6864,79584,8864,79584,25440,79584,27440,79584,28904,78096,30368,76608,30368,74640,30368,72528,28944,71104,
+ 27520,69680,25440,69680,23312,69680,21888,71104,20464,72528,20464,74640,20464,76608,21928,78096,23392,79584,25440,79584,
+ 21840,4512,29840,4512,42208,4512,48832,11560,55456,18608,55456,31792,55456,44960,48848,51936,42240,58912,29840,58912,
+ 21840,58912,21840,35872,36128,35872,36128,30560,21840,30560,21840,4512,5232,0,5232,4512,13296,4512,13296,30560,
+ 4800,30560,4800,35872,13296,35872,13296,58912,5232,58912,5232,63456,30480,63456,46880,63456,56040,55080,65200,46704,
+ 65200,31792,65200,16832,56016,8416,46832,0,30480,0,5232,0,4256,0,4256,4512,12800,4512,12800,58912,
+ 4256,58912,4256,63456,20528,63456,58560,13392,58560,58912,50064,58912,50064,63456,72336,63456,72336,58912,63792,58912,
+ 63792,-1232,58656,-1232,18016,52240,18016,4512,26560,4512,26560,0,4256,0,37072,72400,35040,73584,34192,74144,
+ 33320,74440,32448,74736,31728,74736,30064,74736,28960,73520,27856,72304,27680,70352,23600,70400,23696,74640,25864,77152,
+ 28032,79664,31632,79664,33168,79664,34488,79280,35808,78896,38144,77584,40224,76480,41200,75920,42136,75624,43072,75328,
+ 43792,75328,45536,75328,46536,76496,47536,77664,47536,79664,51664,79664,51568,75200,49384,72776,47200,70352,43200,70352,
+ 40352,70352,37296,72272,37072,72400,35696,3312,46112,3312,51424,10472,56736,17632,56736,31664,56736,45728,51424,52888,
+ 46112,60048,35696,60048,25248,60048,19936,52888,14624,45728,14624,31664,14624,17632,19936,10472,25248,3312,35696,3312,
+ 35696,-1232,29248,-1232,23824,896,18400,3024,14288,7136,9520,11904,7200,17936,4880,23968,4880,31664,4880,39360,
+ 7200,45416,9520,51472,14288,56224,18448,60400,23800,62504,29152,64608,35696,64608,49520,64608,58016,55552,66512,46496,
+ 66512,31664,66512,24048,64176,17952,61840,11856,57072,7136,52912,2976,47560,872,42208,-1232,35696,-1232,32608,80208,
+ 40384,68992,35408,68992,24272,80208,32608,80208,35696,3312,46112,3312,51424,10472,56736,17632,56736,31664,56736,45728,
+ 51424,52888,46112,60048,35696,60048,25248,60048,19936,52888,14624,45728,14624,31664,14624,17632,19936,10472,25248,3312,
+ 35696,3312,35696,-1232,29248,-1232,23824,896,18400,3024,14288,7136,9520,11904,7200,17936,4880,23968,4880,31664,
+ 4880,39360,7200,45416,9520,51472,14288,56224,18448,60400,23800,62504,29152,64608,35696,64608,49520,64608,58016,55552,
+ 66512,46496,66512,31664,66512,24048,64176,17952,61840,11856,57072,7136,52912,2976,47560,872,42208,-1232,35696,-1232,
+ 38256,80208,46640,80208,35504,68992,30528,68992,38256,80208,35696,3312,46112,3312,51424,10472,56736,17632,56736,31664,
+ 56736,45728,51424,52888,46112,60048,35696,60048,25248,60048,19936,52888,14624,45728,14624,31664,14624,17632,19936,10472,
+ 25248,3312,35696,3312,35696,-1232,29248,-1232,23824,896,18400,3024,14288,7136,9520,11904,7200,17936,4880,23968,
+ 4880,31664,4880,39360,7200,45416,9520,51472,14288,56224,18448,60400,23800,62504,29152,64608,35696,64608,49520,64608,
+ 58016,55552,66512,46496,66512,31664,66512,24048,64176,17952,61840,11856,57072,7136,52912,2976,47560,872,42208,-1232,
+ 35696,-1232,31840,80208,39328,80208,49136,68992,44208,68992,35584,75840,26960,68992,22032,68992,31840,80208,35696,3312,
+ 46112,3312,51424,10472,56736,17632,56736,31664,56736,45728,51424,52888,46112,60048,35696,60048,25248,60048,19936,52888,
+ 14624,45728,14624,31664,14624,17632,19936,10472,25248,3312,35696,3312,35696,-1232,29248,-1232,23824,896,18400,3024,
+ 14288,7136,9520,11904,7200,17936,4880,23968,4880,31664,4880,39360,7200,45416,9520,51472,14288,56224,18448,60400,
+ 23800,62504,29152,64608,35696,64608,49520,64608,58016,55552,66512,46496,66512,31664,66512,24048,64176,17952,61840,11856,
+ 57072,7136,52912,2976,47560,872,42208,-1232,35696,-1232,35024,72400,32992,73584,32144,74144,31272,74440,30400,74736,
+ 29680,74736,28016,74736,26912,73520,25808,72304,25632,70352,21552,70400,21648,74640,23816,77152,25984,79664,29584,79664,
+ 31120,79664,32440,79280,33760,78896,36096,77584,38176,76480,39152,75920,40088,75624,41024,75328,41744,75328,43488,75328,
+ 44488,76496,45488,77664,45488,79664,49616,79664,49520,75200,47336,72776,45152,70352,41152,70352,38304,70352,35248,72272,
+ 35024,72400,35696,3312,46112,3312,51424,10472,56736,17632,56736,31664,56736,45728,51424,52888,46112,60048,35696,60048,
+ 25248,60048,19936,52888,14624,45728,14624,31664,14624,17632,19936,10472,25248,3312,35696,3312,35696,-1232,29248,-1232,
+ 23824,896,18400,3024,14288,7136,9520,11904,7200,17936,4880,23968,4880,31664,4880,39360,7200,45416,9520,51472,
+ 14288,56224,18448,60400,23800,62504,29152,64608,35696,64608,49520,64608,58016,55552,66512,46496,66512,31664,66512,24048,
+ 64176,17952,61840,11856,57072,7136,52912,2976,47560,872,42208,-1232,35696,-1232,27296,79584,29344,79584,30808,78096,
+ 32272,76608,32272,74640,32272,72528,30848,71104,29424,69680,27296,69680,25216,69680,23792,71104,22368,72528,22368,74640,
+ 22368,76608,23832,78096,25296,79584,27296,79584,43872,79584,45872,79584,47336,78096,48800,76608,48800,74640,48800,72528,
+ 47376,71104,45952,69680,43872,69680,41744,69680,40320,71104,38896,72528,38896,74640,38896,76608,40360,78096,41824,79584,
+ 43872,79584,60944,46928,41264,27248,60944,7648,56064,2896,36464,22448,16880,2896,12032,7648,31584,27248,12032,46928,
+ 16880,51728,36464,32128,56064,51728,60944,46928,51600,52656,48832,56400,44904,58224,40976,60048,35696,60048,25248,60048,
+ 19936,52888,14624,45728,14624,31664,14624,26608,15304,22504,15984,18400,17424,14960,51600,52656,19680,10880,22400,7104,
+ 26392,5208,30384,3312,35696,3312,46112,3312,51424,10472,56736,17632,56736,31664,56736,36640,56032,40824,55328,45008,
+ 53888,48496,19680,10880,59120,54224,62816,49648,64664,44056,66512,38464,66512,31664,66512,17008,57992,7888,49472,-1232,
+ 35696,-1232,29712,-1232,24656,592,19600,2416,15296,6080,7568,-2416,4256,512,12192,9312,8496,13776,6688,19320,
+ 4880,24864,4880,31664,4880,46368,13424,55488,21968,64608,35696,64608,41696,64608,46792,62800,51888,60992,55968,57456,
+ 63536,65872,66944,62864,59120,54224,12192,58912,4080,58912,4080,63456,28896,63456,28896,58912,20784,58912,20784,26096,
+ 20784,13936,24760,9136,28736,4336,38464,4336,48192,4336,52168,9136,56144,13936,56144,26096,56144,58912,48032,58912,
+ 48032,63456,69440,63456,69440,58912,61376,58912,61376,25248,61376,10752,55808,4760,50240,-1232,36896,-1232,23552,-1232,
+ 17872,4800,12192,10832,12192,25248,12192,58912,35680,80208,43456,68992,38480,68992,27344,80208,35680,80208,12192,58912,
+ 4080,58912,4080,63456,28896,63456,28896,58912,20784,58912,20784,26096,20784,13936,24760,9136,28736,4336,38464,4336,
+ 48192,4336,52168,9136,56144,13936,56144,26096,56144,58912,48032,58912,48032,63456,69440,63456,69440,58912,61376,58912,
+ 61376,25248,61376,10752,55808,4760,50240,-1232,36896,-1232,23552,-1232,17872,4800,12192,10832,12192,25248,12192,58912,
+ 41328,80208,49712,80208,38576,68992,33600,68992,41328,80208,12192,58912,4080,58912,4080,63456,28896,63456,28896,58912,
+ 20784,58912,20784,26096,20784,13936,24760,9136,28736,4336,38464,4336,48192,4336,52168,9136,56144,13936,56144,26096,
+ 56144,58912,48032,58912,48032,63456,69440,63456,69440,58912,61376,58912,61376,25248,61376,10752,55808,4760,50240,-1232,
+ 36896,-1232,23552,-1232,17872,4800,12192,10832,12192,25248,12192,58912,34912,80208,42400,80208,52208,68992,47280,68992,
+ 38656,75840,30032,68992,25104,68992,34912,80208,12192,58912,4080,58912,4080,63456,28896,63456,28896,58912,20784,58912,
+ 20784,26096,20784,13936,24760,9136,28736,4336,38464,4336,48192,4336,52168,9136,56144,13936,56144,26096,56144,58912,
+ 48032,58912,48032,63456,69440,63456,69440,58912,61376,58912,61376,25248,61376,10752,55808,4760,50240,-1232,36896,-1232,
+ 23552,-1232,17872,4800,12192,10832,12192,25248,12192,58912,30368,79584,32416,79584,33880,78096,35344,76608,35344,74640,
+ 35344,72528,33920,71104,32496,69680,30368,69680,28288,69680,26864,71104,25440,72528,25440,74640,25440,76608,26904,78096,
+ 28368,79584,30368,79584,46944,79584,48944,79584,50408,78096,51872,76608,51872,74640,51872,72528,50448,71104,49024,69680,
+ 46944,69680,44816,69680,43392,71104,41968,72528,41968,74640,41968,76608,43432,78096,44896,79584,46944,79584,16448,0,
+ 16448,4512,24560,4512,24560,27328,4976,58912,-976,58912,-976,63456,22608,63456,22608,58912,15216,58912,31072,33232,
+ 46928,58912,39776,58912,39776,63456,58224,63456,58224,58912,52240,58912,33152,28128,33152,4512,41264,4512,41264,0,
+ 16448,0,31088,80208,39472,80208,28336,68992,23360,68992,31088,80208,21504,18448,32720,18448,39056,18448,42368,21864,
+ 45680,25280,45680,31792,45680,38256,42368,41672,39056,45088,32720,45088,21504,45088,21504,18448,4800,0,4800,4512,
+ 12880,4512,12880,58912,4800,58912,4800,63456,31328,63456,31328,58912,21504,58912,21504,49600,34800,49600,44320,49600,
+ 49888,44776,55456,39952,55456,31792,55456,23552,49872,18704,44288,13856,34800,13856,21504,13856,21504,4512,31328,4512,
+ 31328,0,4800,0,39952,51424,39616,56480,36656,59224,33696,61968,28640,61968,23040,61968,20448,59224,17856,56480,
+ 17856,50576,17856,0,2512,0,2512,4512,10032,4512,10032,50400,10032,57888,14896,62008,19760,66128,28640,66128,
+ 37696,66128,42432,61712,47168,57296,47680,48320,46752,48320,40592,48320,37040,46024,33488,43728,33488,39776,33488,37568,
+ 34640,35936,35792,34304,38880,32304,42672,29968,49264,25760,51792,22144,54320,18528,54320,13680,54320,7104,49408,2936,
+ 44496,-1232,36640,-1232,33024,-1232,29456,-448,25888,336,22528,1824,22528,11728,27152,11728,27328,7440,29688,5208,
+ 32048,2976,36384,2976,41104,2976,43800,5544,46496,8112,46496,12544,46496,16112,44792,18600,43088,21088,38128,24176,
+ 34464,26480,30048,29248,28160,31984,26272,34720,26272,38208,26272,43392,29856,46880,33440,50368,39952,51424,34640,14192,
+ 34640,23760,24560,23760,18736,23760,15888,21248,13040,18736,13040,13552,13040,8848,15936,6080,18832,3312,23760,3312,
+ 28640,3312,31640,6328,34640,9344,34640,14192,42464,28224,42464,4512,49424,4512,49424,0,34640,0,34640,4880,
+ 32048,1744,28648,256,25248,-1232,20704,-1232,13168,-1232,8752,2760,4336,6752,4336,13552,4336,20576,9392,24440,
+ 14448,28304,23680,28304,34640,28304,34640,31408,34640,36544,31512,39376,28384,42208,22736,42208,18064,42208,15304,40080,
+ 12544,37952,11856,33792,7824,33792,7824,42928,11904,44672,15752,45544,19600,46416,23248,46416,32640,46416,37552,41760,
+ 42464,37104,42464,28224,17648,69536,28688,53552,23728,53552,9280,69536,17648,69536,34640,14192,34640,23760,24560,23760,
+ 18736,23760,15888,21248,13040,18736,13040,13552,13040,8848,15936,6080,18832,3312,23760,3312,28640,3312,31640,6328,
+ 34640,9344,34640,14192,42464,28224,42464,4512,49424,4512,49424,0,34640,0,34640,4880,32048,1744,28648,256,
+ 25248,-1232,20704,-1232,13168,-1232,8752,2760,4336,6752,4336,13552,4336,20576,9392,24440,14448,28304,23680,28304,
+ 34640,28304,34640,31408,34640,36544,31512,39376,28384,42208,22736,42208,18064,42208,15304,40080,12544,37952,11856,33792,
+ 7824,33792,7824,42928,11904,44672,15752,45544,19600,46416,23248,46416,32640,46416,37552,41760,42464,37104,42464,28224,
+ 29712,69616,38176,69616,23728,53632,18752,53632,29712,69616,34640,14192,34640,23760,24560,23760,18736,23760,15888,21248,
+ 13040,18736,13040,13552,13040,8848,15936,6080,18832,3312,23760,3312,28640,3312,31640,6328,34640,9344,34640,14192,
+ 42464,28224,42464,4512,49424,4512,49424,0,34640,0,34640,4880,32048,1744,28648,256,25248,-1232,20704,-1232,
+ 13168,-1232,8752,2760,4336,6752,4336,13552,4336,20576,9392,24440,14448,28304,23680,28304,34640,28304,34640,31408,
+ 34640,36544,31512,39376,28384,42208,22736,42208,18064,42208,15304,40080,12544,37952,11856,33792,7824,33792,7824,42928,
+ 11904,44672,15752,45544,19600,46416,23248,46416,32640,46416,37552,41760,42464,37104,42464,28224,20240,69616,27376,69616,
+ 37360,53632,32432,53632,23808,64688,15184,53632,10256,53632,20240,69616,34640,14192,34640,23760,24560,23760,18736,23760,
+ 15888,21248,13040,18736,13040,13552,13040,8848,15936,6080,18832,3312,23760,3312,28640,3312,31640,6328,34640,9344,
+ 34640,14192,42464,28224,42464,4512,49424,4512,49424,0,34640,0,34640,4880,32048,1744,28648,256,25248,-1232,
+ 20704,-1232,13168,-1232,8752,2760,4336,6752,4336,13552,4336,20576,9392,24440,14448,28304,23680,28304,34640,28304,
+ 34640,31408,34640,36544,31512,39376,28384,42208,22736,42208,18064,42208,15304,40080,12544,37952,11856,33792,7824,33792,
+ 7824,42928,11904,44672,15752,45544,19600,46416,23248,46416,32640,46416,37552,41760,42464,37104,42464,28224,23632,58224,
+ 21216,60560,20112,61584,19408,61904,18704,62224,17904,62224,16112,62224,15096,60544,14080,58864,13856,55632,9776,55632,
+ 9872,61376,12040,64496,14208,67616,18064,67616,19680,67616,21040,67024,22400,66432,23984,65024,26400,62688,27376,61712,
+ 28096,61368,28816,61024,29712,61024,31536,61024,32560,62728,33584,64432,33760,67616,37840,67616,37744,61888,35576,58760,
+ 33408,55632,29552,55632,27936,55632,26576,56224,25216,56816,23632,58224,34640,14192,34640,23760,24560,23760,18736,23760,
+ 15888,21248,13040,18736,13040,13552,13040,8848,15936,6080,18832,3312,23760,3312,28640,3312,31640,6328,34640,9344,
+ 34640,14192,42464,28224,42464,4512,49424,4512,49424,0,34640,0,34640,4880,32048,1744,28648,256,25248,-1232,
+ 20704,-1232,13168,-1232,8752,2760,4336,6752,4336,13552,4336,20576,9392,24440,14448,28304,23680,28304,34640,28304,
+ 34640,31408,34640,36544,31512,39376,28384,42208,22736,42208,18064,42208,15304,40080,12544,37952,11856,33792,7824,33792,
+ 7824,42928,11904,44672,15752,45544,19600,46416,23248,46416,32640,46416,37552,41760,42464,37104,42464,28224,15520,66688,
+ 17568,66688,19032,65216,20496,63744,20496,61712,20496,59536,19096,58136,17696,56736,15520,56736,13392,56736,11992,58136,
+ 10592,59536,10592,61712,10592,63744,12056,65216,13520,66688,15520,66688,32096,66688,34096,66688,35560,65216,37024,63744,
+ 37024,61712,37024,59536,35624,58136,34224,56736,32096,56736,29936,56736,28528,58136,27120,59536,27120,61712,27120,63744,
+ 28584,65216,30048,66688,32096,66688,34640,14192,34640,23760,24560,23760,18736,23760,15888,21248,13040,18736,13040,13552,
+ 13040,8848,15936,6080,18832,3312,23760,3312,28640,3312,31640,6328,34640,9344,34640,14192,42464,28224,42464,4512,
+ 49424,4512,49424,0,34640,0,34640,4880,32048,1744,28648,256,25248,-1232,20704,-1232,13168,-1232,8752,2760,
+ 4336,6752,4336,13552,4336,20576,9392,24440,14448,28304,23680,28304,34640,28304,34640,31408,34640,36544,31512,39376,
+ 28384,42208,22736,42208,18064,42208,15304,40080,12544,37952,11856,33792,7824,33792,7824,42928,11904,44672,15752,45544,
+ 19600,46416,23248,46416,32640,46416,37552,41760,42464,37104,42464,28224,35456,64768,35456,59888,32072,56488,28688,53088,
+ 23808,53088,18928,53088,15544,56488,12160,59888,12160,64768,12160,69664,15544,73040,18928,76416,23808,76416,28688,76416,
+ 32072,73040,35456,69664,35456,64768,30272,64768,30272,67440,28400,69312,26528,71184,23808,71184,21040,71184,19192,69336,
+ 17344,67488,17344,64768,17344,62000,19192,60152,21040,58304,23808,58304,26528,58304,28400,60176,30272,62048,30272,64768,
+ 34640,14192,34640,23760,24560,23760,18736,23760,15888,21248,13040,18736,13040,13552,13040,8848,15936,6080,18832,3312,
+ 23760,3312,28640,3312,31640,6328,34640,9344,34640,14192,39264,6368,35744,2512,31448,640,27152,-1232,21840,-1232,
+ 13472,-1232,8904,2632,4336,6496,4336,13552,4336,20576,9416,24440,14496,28304,23680,28304,34640,28304,34640,31408,
+ 34640,36512,31576,39360,28512,42208,23072,42208,18144,42208,15344,40104,12544,38000,11856,33792,7824,33792,7824,42928,
+ 11904,44672,15752,45544,19600,46416,23248,46416,29248,46416,33344,44568,37440,42720,39776,38880,42928,42624,47008,44520,
+ 51088,46416,56064,46416,66304,46416,71784,40080,77264,33744,77440,21760,43776,21760,43776,21424,43776,12288,47200,7632,
+ 50624,2976,57376,2976,62512,2976,65808,5672,69104,8368,70416,13680,76672,13680,74848,6240,69784,2504,64720,-1232,
+ 56560,-1232,51376,-1232,46984,704,42592,2640,39264,6368,68256,26272,68000,34176,64920,38192,61840,42208,56064,42208,
+ 50656,42208,47536,38168,44416,34128,43776,26272,68256,26272,44752,13552,43088,6336,38376,2552,33664,-1232,26176,-1232,
+ 16320,-1232,10328,5288,4336,11808,4336,22608,4336,33440,10328,39928,16320,46416,26176,46416,30480,46416,34728,45416,
+ 38976,44416,43264,42368,43264,30816,38720,30816,37824,36768,34832,39488,31840,42208,26272,42208,19936,42208,16704,37296,
+ 13472,32384,13472,22608,13472,12832,16680,7904,19888,2976,26272,2976,31328,2976,34344,5608,37360,8240,38464,13552,
+ 44752,13552,28656,0,31376,-2720,32720,-5104,34064,-7488,34064,-9568,34064,-13008,31384,-14896,28704,-16784,23936,-16784,
+ 22160,-16784,20288,-16528,18416,-16272,16464,-15760,16464,-10208,18208,-10928,19888,-11288,21568,-11648,23056,-11648,25472,-11648,
+ 26872,-10520,28272,-9392,28272,-7488,28272,-6288,27344,-4416,26416,-2544,24544,0,28656,0,47168,21760,13472,21760,
+ 13472,21424,13472,12288,16912,7632,20352,2976,27072,2976,32208,2976,35504,5672,38800,8368,40128,13680,46416,13680,
+ 44544,6240,39504,2504,34464,-1232,26272,-1232,16368,-1232,10352,5288,4336,11808,4336,22608,4336,33328,10240,39872,
+ 16144,46416,25760,46416,36000,46416,41480,40104,46960,33792,47168,21760,37952,26272,37696,34176,34616,38192,31536,42208,
+ 25760,42208,20352,42208,17256,38168,14160,34128,13472,26272,37952,26272,19696,69536,30736,53552,25776,53552,11328,69536,
+ 19696,69536,47168,21760,13472,21760,13472,21424,13472,12288,16912,7632,20352,2976,27072,2976,32208,2976,35504,5672,
+ 38800,8368,40128,13680,46416,13680,44544,6240,39504,2504,34464,-1232,26272,-1232,16368,-1232,10352,5288,4336,11808,
+ 4336,22608,4336,33328,10240,39872,16144,46416,25760,46416,36000,46416,41480,40104,46960,33792,47168,21760,37952,26272,
+ 37696,34176,34616,38192,31536,42208,25760,42208,20352,42208,17256,38168,14160,34128,13472,26272,37952,26272,31760,69616,
+ 40224,69616,25776,53632,20800,53632,31760,69616,47168,21760,13472,21760,13472,21424,13472,12288,16912,7632,20352,2976,
+ 27072,2976,32208,2976,35504,5672,38800,8368,40128,13680,46416,13680,44544,6240,39504,2504,34464,-1232,26272,-1232,
+ 16368,-1232,10352,5288,4336,11808,4336,22608,4336,33328,10240,39872,16144,46416,25760,46416,36000,46416,41480,40104,
+ 46960,33792,47168,21760,37952,26272,37696,34176,34616,38192,31536,42208,25760,42208,20352,42208,17256,38168,14160,34128,
+ 13472,26272,37952,26272,22288,69616,29424,69616,39408,53632,34480,53632,25856,64688,17232,53632,12304,53632,22288,69616,
+ 47168,21760,13472,21760,13472,21424,13472,12288,16912,7632,20352,2976,27072,2976,32208,2976,35504,5672,38800,8368,
+ 40128,13680,46416,13680,44544,6240,39504,2504,34464,-1232,26272,-1232,16368,-1232,10352,5288,4336,11808,4336,22608,
+ 4336,33328,10240,39872,16144,46416,25760,46416,36000,46416,41480,40104,46960,33792,47168,21760,37952,26272,37696,34176,
+ 34616,38192,31536,42208,25760,42208,20352,42208,17256,38168,14160,34128,13472,26272,37952,26272,17568,66688,19616,66688,
+ 21080,65216,22544,63744,22544,61712,22544,59536,21144,58136,19744,56736,17568,56736,15440,56736,14040,58136,12640,59536,
+ 12640,61712,12640,63744,14104,65216,15568,66688,17568,66688,34144,66688,36144,66688,37608,65216,39072,63744,39072,61712,
+ 39072,59536,37672,58136,36272,56736,34144,56736,31984,56736,30576,58136,29168,59536,29168,61712,29168,63744,30632,65216,
+ 32096,66688,34144,66688,18448,4512,25840,4512,25840,0,3152,0,3152,4512,10624,4512,10624,40624,3152,40624,
+ 3152,45184,18448,45184,18448,4512,7408,69536,18448,53552,13488,53552,-960,69536,7408,69536,18448,4512,25840,4512,
+ 25840,0,3152,0,3152,4512,10624,4512,10624,40624,3152,40624,3152,45184,18448,45184,18448,4512,19472,69616,
+ 27936,69616,13488,53632,8512,53632,19472,69616,18448,4512,25840,4512,25840,0,3152,0,3152,4512,10624,4512,
+ 10624,40624,3152,40624,3152,45184,18448,45184,18448,4512,10000,69616,17136,69616,27120,53632,22192,53632,13568,64688,
+ 4944,53632,16,53632,10000,69616,18448,4512,25840,4512,25840,0,3152,0,3152,4512,10624,4512,10624,40624,
+ 3152,40624,3152,45184,18448,45184,18448,4512,5280,66688,7328,66688,8792,65216,10256,63744,10256,61712,10256,59536,
+ 8856,58136,7456,56736,5280,56736,3152,56736,1752,58136,352,59536,352,61712,352,63744,1816,65216,3280,66688,
+ 5280,66688,21856,66688,23856,66688,25320,65216,26784,63744,26784,61712,26784,59536,25384,58136,23984,56736,21856,56736,
+ 19696,56736,18288,58136,16880,59536,16880,61712,16880,63744,18344,65216,19808,66688,21856,66688,34896,39440,32976,39824,
+ 31256,40016,29536,40208,27840,40208,20480,40208,16976,35656,13472,31104,13472,21584,13472,12672,16808,7824,20144,2976,
+ 26176,2976,32304,2976,35592,7840,38880,12704,38880,21760,38880,26528,37888,31008,36896,35488,34896,39440,32304,55552,
+ 40080,48448,44056,40144,48032,31840,48032,22608,48032,11808,42056,5288,36080,-1232,26176,-1232,16448,-1232,10392,5208,
+ 4336,11648,4336,22016,4336,32048,10328,38208,16320,44368,26016,44368,27504,44368,29096,44240,30688,44112,32896,43776,
+ 31968,46032,30416,48304,28864,50576,26736,52912,13040,46576,11472,49888,23920,55632,21328,58096,17992,59816,14656,61536,
+ 10624,62480,11392,66128,16448,65024,20888,63024,25328,61024,29248,58144,42928,64512,44496,61200,32304,55552,3568,0,
+ 3568,4512,10624,4512,10624,40624,3152,40624,3152,45184,18448,45184,18448,37152,20608,41728,24072,44072,27536,46416,
+ 32128,46416,39616,46416,43144,42120,46672,37824,46672,28736,46672,4512,53632,4512,53632,0,32048,0,32048,4512,
+ 38800,4512,38800,26272,38800,34560,36760,37640,34720,40720,29584,40720,24144,40720,21296,36744,18448,32768,18448,25168,
+ 18448,4512,25248,4512,25248,0,3568,0,27728,58224,25312,60560,24208,61584,23504,61904,22800,62224,22000,62224,
+ 20208,62224,19192,60544,18176,58864,17952,55632,13872,55632,13968,61376,16136,64496,18304,67616,22160,67616,23776,67616,
+ 25136,67024,26496,66432,28080,65024,30496,62688,31472,61712,32192,61368,32912,61024,33808,61024,35632,61024,36656,62728,
+ 37680,64432,37856,67616,41936,67616,41840,61888,39672,58760,37504,55632,33648,55632,32032,55632,30672,56224,29312,56816,
+ 27728,58224,26176,2976,32464,2976,35672,7952,38880,12928,38880,22608,38880,32304,35672,37256,32464,42208,26176,42208,
+ 19888,42208,16680,37256,13472,32304,13472,22608,13472,12928,16704,7952,19936,2976,26176,2976,26176,-1232,16320,-1232,
+ 10328,5288,4336,11808,4336,22608,4336,33408,10304,39912,16272,46416,26176,46416,36080,46416,42056,39912,48032,33408,
+ 48032,22608,48032,11808,42056,5288,36080,-1232,26176,-1232,19696,69536,30736,53552,25776,53552,11328,69536,19696,69536,
+ 26176,2976,32464,2976,35672,7952,38880,12928,38880,22608,38880,32304,35672,37256,32464,42208,26176,42208,19888,42208,
+ 16680,37256,13472,32304,13472,22608,13472,12928,16704,7952,19936,2976,26176,2976,26176,-1232,16320,-1232,10328,5288,
+ 4336,11808,4336,22608,4336,33408,10304,39912,16272,46416,26176,46416,36080,46416,42056,39912,48032,33408,48032,22608,
+ 48032,11808,42056,5288,36080,-1232,26176,-1232,31760,69616,40224,69616,25776,53632,20800,53632,31760,69616,26176,2976,
+ 32464,2976,35672,7952,38880,12928,38880,22608,38880,32304,35672,37256,32464,42208,26176,42208,19888,42208,16680,37256,
+ 13472,32304,13472,22608,13472,12928,16704,7952,19936,2976,26176,2976,26176,-1232,16320,-1232,10328,5288,4336,11808,
+ 4336,22608,4336,33408,10304,39912,16272,46416,26176,46416,36080,46416,42056,39912,48032,33408,48032,22608,48032,11808,
+ 42056,5288,36080,-1232,26176,-1232,22288,69616,29424,69616,39408,53632,34480,53632,25856,64688,17232,53632,12304,53632,
+ 22288,69616,26176,2976,32464,2976,35672,7952,38880,12928,38880,22608,38880,32304,35672,37256,32464,42208,26176,42208,
+ 19888,42208,16680,37256,13472,32304,13472,22608,13472,12928,16704,7952,19936,2976,26176,2976,26176,-1232,16320,-1232,
+ 10328,5288,4336,11808,4336,22608,4336,33408,10304,39912,16272,46416,26176,46416,36080,46416,42056,39912,48032,33408,
+ 48032,22608,48032,11808,42056,5288,36080,-1232,26176,-1232,25680,58224,23264,60560,22160,61584,21456,61904,20752,62224,
+ 19952,62224,18160,62224,17144,60544,16128,58864,15904,55632,11824,55632,11920,61376,14088,64496,16256,67616,20112,67616,
+ 21728,67616,23088,67024,24448,66432,26032,65024,28448,62688,29424,61712,30144,61368,30864,61024,31760,61024,33584,61024,
+ 34608,62728,35632,64432,35808,67616,39888,67616,39792,61888,37624,58760,35456,55632,31600,55632,29984,55632,28624,56224,
+ 27264,56816,25680,58224,26176,2976,32464,2976,35672,7952,38880,12928,38880,22608,38880,32304,35672,37256,32464,42208,
+ 26176,42208,19888,42208,16680,37256,13472,32304,13472,22608,13472,12928,16704,7952,19936,2976,26176,2976,26176,-1232,
+ 16320,-1232,10328,5288,4336,11808,4336,22608,4336,33408,10304,39912,16272,46416,26176,46416,36080,46416,42056,39912,
+ 48032,33408,48032,22608,48032,11808,42056,5288,36080,-1232,26176,-1232,17568,66688,19616,66688,21080,65216,22544,63744,
+ 22544,61712,22544,59536,21144,58136,19744,56736,17568,56736,15440,56736,14040,58136,12640,59536,12640,61712,12640,63744,
+ 14104,65216,15568,66688,17568,66688,34144,66688,36144,66688,37608,65216,39072,63744,39072,61712,39072,59536,37672,58136,
+ 36272,56736,34144,56736,31984,56736,30576,58136,29168,59536,29168,61712,29168,63744,30632,65216,32096,66688,34144,66688,
+ 30816,43008,30816,45392,32448,47024,34080,48656,36464,48656,38800,48656,40456,47000,42112,45344,42112,43008,42112,40624,
+ 40456,38992,38800,37360,36464,37360,34048,37360,32432,38976,30816,40592,30816,43008,30816,11568,30816,13936,32448,15592,
+ 34080,17248,36464,17248,38800,17248,40456,15592,42112,13936,42112,11568,42112,9216,40456,7560,38800,5904,36464,5904,
+ 34048,5904,32432,7544,30816,9184,30816,11568,9216,30720,63712,30720,63712,23840,9216,23840,9216,30720,35696,37360,
+ 34080,39776,31704,40992,29328,42208,26176,42208,19936,42208,16704,37232,13472,32256,13472,22608,13472,19552,13792,17040,
+ 14112,14528,14704,12448,35696,37360,16624,8080,18320,5488,20680,4232,23040,2976,26176,2976,32432,2976,35656,7968,
+ 38880,12960,38880,22608,38880,25840,38568,28408,38256,30976,37616,33152,16624,8080,42672,39184,45312,36048,46672,31840,
+ 48032,27632,48032,22608,48032,11808,42056,5288,36080,-1232,26176,-1232,22192,-1232,18792,-104,15392,1024,12544,3312,
+ 6464,-4000,3232,-1312,9568,6240,6976,9520,5656,13624,4336,17728,4336,22608,4336,33408,10304,39912,16272,46416,
+ 26176,46416,30176,46416,33576,45328,36976,44240,39696,42112,45600,49168,48832,46496,42672,39184,30816,45184,45440,45184,
+ 45440,4512,52832,4512,52832,0,37616,0,37616,7984,35440,3488,32000,1128,28560,-1232,24016,-1232,16496,-1232,
+ 12944,3040,9392,7312,9392,16448,9392,40624,2336,40624,2336,45184,17248,45184,17248,18864,17248,10624,19272,7568,
+ 21296,4512,26480,4512,31920,4512,34768,8504,37616,12496,37616,20096,37616,40624,30816,40624,30816,45184,18672,69536,
+ 29712,53552,24752,53552,10304,69536,18672,69536,30816,45184,45440,45184,45440,4512,52832,4512,52832,0,37616,0,
+ 37616,7984,35440,3488,32000,1128,28560,-1232,24016,-1232,16496,-1232,12944,3040,9392,7312,9392,16448,9392,40624,
+ 2336,40624,2336,45184,17248,45184,17248,18864,17248,10624,19272,7568,21296,4512,26480,4512,31920,4512,34768,8504,
+ 37616,12496,37616,20096,37616,40624,30816,40624,30816,45184,30736,69616,39200,69616,24752,53632,19776,53632,30736,69616,
+ 30816,45184,45440,45184,45440,4512,52832,4512,52832,0,37616,0,37616,7984,35440,3488,32000,1128,28560,-1232,
+ 24016,-1232,16496,-1232,12944,3040,9392,7312,9392,16448,9392,40624,2336,40624,2336,45184,17248,45184,17248,18864,
+ 17248,10624,19272,7568,21296,4512,26480,4512,31920,4512,34768,8504,37616,12496,37616,20096,37616,40624,30816,40624,
+ 30816,45184,21264,69616,28400,69616,38384,53632,33456,53632,24832,64688,16208,53632,11280,53632,21264,69616,30816,45184,
+ 45440,45184,45440,4512,52832,4512,52832,0,37616,0,37616,7984,35440,3488,32000,1128,28560,-1232,24016,-1232,
+ 16496,-1232,12944,3040,9392,7312,9392,16448,9392,40624,2336,40624,2336,45184,17248,45184,17248,18864,17248,10624,
+ 19272,7568,21296,4512,26480,4512,31920,4512,34768,8504,37616,12496,37616,20096,37616,40624,30816,40624,30816,45184,
+ 16544,66688,18592,66688,20056,65216,21520,63744,21520,61712,21520,59536,20120,58136,18720,56736,16544,56736,14416,56736,
+ 13016,58136,11616,59536,11616,61712,11616,63744,13080,65216,14544,66688,16544,66688,33120,66688,35120,66688,36584,65216,
+ 38048,63744,38048,61712,38048,59536,36648,58136,35248,56736,33120,56736,30960,56736,29552,58136,28144,59536,28144,61712,
+ 28144,63744,29608,65216,31072,66688,33120,66688,18784,-8288,21760,-768,4880,40624,-256,40624,-256,45184,20528,45184,
+ 20528,40624,13296,40624,26016,9568,38720,40624,31968,40624,31968,45184,48912,45184,48912,40624,43856,40624,23168,-10208,
+ 21040,-15472,18448,-17408,15856,-19344,11136,-19344,9136,-19344,7032,-19000,4928,-18656,2800,-18016,2800,-9392,6800,-9392,
+ 7056,-12288,8264,-13536,9472,-14784,12032,-14784,14368,-14784,15792,-13488,17216,-12192,18784,-8288,30736,69616,39200,69616,
+ 24752,53632,19776,53632,30736,69616,17856,24816,17856,20352,17856,12192,20976,7920,24096,3648,30048,3648,36048,3648,
+ 39128,8456,42208,13264,42208,22608,42208,32000,39128,36760,36048,41520,30048,41520,24096,41520,20976,37232,17856,32944,
+ 17856,24816,10032,61632,2512,61632,2512,66128,17856,66128,17856,38128,20144,42368,23696,44392,27248,46416,32464,46416,
+ 40800,46416,46072,39824,51344,33232,51344,22608,51344,11984,46072,5376,40800,-1232,32464,-1232,27248,-1232,23696,784,
+ 20144,2800,17856,7056,17856,-13552,25248,-13552,25248,-18112,2512,-18112,2512,-13552,10032,-13552,10032,61632,18784,-8288,
+ 21760,-768,4880,40624,-256,40624,-256,45184,20528,45184,20528,40624,13296,40624,26016,9568,38720,40624,31968,40624,
+ 31968,45184,48912,45184,48912,40624,43856,40624,23168,-10208,21040,-15472,18448,-17408,15856,-19344,11136,-19344,9136,-19344,
+ 7032,-19000,4928,-18656,2800,-18016,2800,-9392,6800,-9392,7056,-12288,8264,-13536,9472,-14784,12032,-14784,14368,-14784,
+ 15792,-13488,17216,-12192,18784,-8288,16544,66688,18592,66688,20056,65216,21520,63744,21520,61712,21520,59536,20120,58136,
+ 18720,56736,16544,56736,14416,56736,13016,58136,11616,59536,11616,61712,11616,63744,13080,65216,14544,66688,16544,66688,
+ 33120,66688,35120,66688,36584,65216,38048,63744,38048,61712,38048,59536,36648,58136,35248,56736,33120,56736,30960,56736,
+ 29552,58136,28144,59536,28144,61712,28144,63744,29608,65216,31072,66688,33120,66688 };
+static const int DejaVuSerif_glyphAdvances[224] = {
+ 27664,34976,40032,72928,55376,82704,77472,23920,33952,33952,43520,72928,27664,29408,27664,29328,55376,55376,55376,55376,
+ 55376,55376,55376,55376,55376,55376,29328,29328,72928,72928,72928,46672,87040,62864,63968,66592,69792,63536,60400,69536,
+ 75904,34384,34896,65024,57808,89120,76160,71360,58560,71360,65536,59632,58048,73360,62864,89456,61968,57456,60480,33952,
+ 29328,33952,72928,43520,43520,51888,55712,48752,55712,51504,32208,55712,56064,27840,26992,52736,27840,82528,56064,52400,
+ 55712,55712,41600,44672,34976,56064,49168,74496,49088,49168,45856,55376,29328,55376,72928,52240,52240,52240,52240,52240,
+ 52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,52240,
+ 52240,52240,52240,52240,52240,52240,52240,52240,27664,34976,55376,55376,55376,55376,29328,43520,43520,87040,41360,53248,
+ 72928,29408,87040,43520,43520,72928,34896,34896,43520,56560,55376,27664,43520,34896,40928,53248,84368,84368,84368,46672,
+ 62864,62864,62864,62864,62864,62864,87120,66592,63536,63536,63536,63536,34384,34384,34384,34384,70256,76160,71360,71360,
+ 71360,71360,71360,72928,71360,73360,73360,73360,73360,57456,58816,58144,51888,51888,51888,51888,51888,51888,81808,48752,
+ 51504,51504,51504,51504,27840,27840,27840,27840,52400,56064,52400,52400,52400,52400,52400,72928,52400,56064,56064,56064,
+ 56064,49168,55712,49168 };
+
+static const int DejaVuSerif_glyphCount = 224;
+static const short DejaVuSerif_characterMap[256] = {
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,
+ 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
+ 28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
+ 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,
+ 68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,
+ 88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,
+ 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
+ 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,
+ 148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,
+ 168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,
+ 188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
+ 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223 };
+
diff --git a/tests/font/arial.fnt b/tests/font/arial.fnt
new file mode 100644
index 0000000..f1042d7
--- /dev/null
+++ b/tests/font/arial.fnt
@@ -0,0 +1,202 @@
+info face="Arial-BoldMT" size=64 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2
+common lineHeight=74 base=58 scaleW=512 scaleH=512 pages=1 packed=0
+page id=0 file="arial.png"
+chars count=95
+char id=64 x=2 y=2 width=65 height=65 xoffset=2 yoffset=9 xadvance=62 page=0 chnl=0 letter="@"
+char id=123 x=69 y=2 width=27 height=65 xoffset=2 yoffset=9 xadvance=25 page=0 chnl=0 letter="{"
+char id=125 x=98 y=2 width=26 height=65 xoffset=1 yoffset=9 xadvance=25 page=0 chnl=0 letter="}"
+char id=41 x=126 y=2 width=21 height=65 xoffset=2 yoffset=9 xadvance=21 page=0 chnl=0 letter=")"
+char id=106 x=149 y=2 width=21 height=65 xoffset=-3 yoffset=9 xadvance=18 page=0 chnl=0 letter="j"
+char id=40 x=172 y=2 width=20 height=65 xoffset=3 yoffset=9 xadvance=21 page=0 chnl=0 letter="("
+char id=124 x=194 y=2 width=11 height=65 xoffset=6 yoffset=9 xadvance=18 page=0 chnl=0 letter="|"
+char id=91 x=207 y=2 width=20 height=63 xoffset=5 yoffset=11 xadvance=21 page=0 chnl=0 letter="["
+char id=93 x=229 y=2 width=20 height=63 xoffset=1 yoffset=11 xadvance=21 page=0 chnl=0 letter="]"
+char id=36 x=251 y=2 width=36 height=60 xoffset=2 yoffset=7 xadvance=36 page=0 chnl=0 letter="$"
+char id=81 x=289 y=2 width=51 height=56 xoffset=3 yoffset=10 xadvance=50 page=0 chnl=0 letter="Q"
+char id=37 x=342 y=2 width=56 height=53 xoffset=3 yoffset=10 xadvance=57 page=0 chnl=0 letter="%"
+char id=79 x=400 y=2 width=49 height=52 xoffset=3 yoffset=10 xadvance=50 page=0 chnl=0 letter="O"
+char id=38 x=451 y=2 width=47 height=52 xoffset=3 yoffset=10 xadvance=46 page=0 chnl=0 letter="&"
+char id=71 x=2 y=69 width=47 height=52 xoffset=3 yoffset=10 xadvance=50 page=0 chnl=0 letter="G"
+char id=67 x=51 y=69 width=45 height=52 xoffset=3 yoffset=10 xadvance=46 page=0 chnl=0 letter="C"
+char id=83 x=98 y=69 width=42 height=52 xoffset=2 yoffset=10 xadvance=43 page=0 chnl=0 letter="S"
+char id=85 x=142 y=69 width=41 height=52 xoffset=5 yoffset=10 xadvance=46 page=0 chnl=0 letter="U"
+char id=35 x=185 y=69 width=39 height=52 xoffset=1 yoffset=10 xadvance=36 page=0 chnl=0 letter="#"
+char id=103 x=226 y=69 width=37 height=52 xoffset=3 yoffset=22 xadvance=39 page=0 chnl=0 letter="g"
+char id=100 x=265 y=69 width=37 height=52 xoffset=3 yoffset=10 xadvance=39 page=0 chnl=0 letter="d"
+char id=63 x=304 y=69 width=37 height=52 xoffset=3 yoffset=9 xadvance=39 page=0 chnl=0 letter="?"
+char id=98 x=343 y=69 width=37 height=52 xoffset=4 yoffset=10 xadvance=39 page=0 chnl=0 letter="b"
+char id=74 x=382 y=69 width=34 height=52 xoffset=1 yoffset=10 xadvance=36 page=0 chnl=0 letter="J"
+char id=102 x=418 y=69 width=27 height=52 xoffset=1 yoffset=9 xadvance=21 page=0 chnl=0 letter="f"
+char id=47 x=447 y=69 width=22 height=52 xoffset=-0 yoffset=10 xadvance=18 page=0 chnl=0 letter="/"
+char id=92 x=471 y=69 width=22 height=52 xoffset=-0 yoffset=10 xadvance=18 page=0 chnl=0 letter="\"
+char id=121 x=2 y=123 width=39 height=51 xoffset=0 yoffset=23 xadvance=36 page=0 chnl=0 letter="y"
+char id=113 x=43 y=123 width=37 height=51 xoffset=3 yoffset=23 xadvance=39 page=0 chnl=0 letter="q"
+char id=112 x=82 y=123 width=37 height=51 xoffset=4 yoffset=23 xadvance=39 page=0 chnl=0 letter="p"
+char id=51 x=121 y=123 width=36 height=51 xoffset=2 yoffset=11 xadvance=36 page=0 chnl=0 letter="3"
+char id=57 x=159 y=123 width=35 height=51 xoffset=2 yoffset=11 xadvance=36 page=0 chnl=0 letter="9"
+char id=56 x=196 y=123 width=35 height=51 xoffset=3 yoffset=11 xadvance=36 page=0 chnl=0 letter="8"
+char id=54 x=233 y=123 width=35 height=51 xoffset=3 yoffset=11 xadvance=36 page=0 chnl=0 letter="6"
+char id=48 x=270 y=123 width=34 height=51 xoffset=3 yoffset=11 xadvance=36 page=0 chnl=0 letter="0"
+char id=87 x=306 y=123 width=65 height=50 xoffset=0 yoffset=11 xadvance=60 page=0 chnl=0 letter="W"
+char id=77 x=373 y=123 width=50 height=50 xoffset=5 yoffset=11 xadvance=53 page=0 chnl=0 letter="M"
+char id=65 x=425 y=123 width=50 height=50 xoffset=0 yoffset=11 xadvance=46 page=0 chnl=0 letter="A"
+char id=86 x=2 y=176 width=47 height=50 xoffset=-0 yoffset=11 xadvance=43 page=0 chnl=0 letter="V"
+char id=88 x=51 y=176 width=47 height=50 xoffset=0 yoffset=11 xadvance=43 page=0 chnl=0 letter="X"
+char id=89 x=100 y=176 width=47 height=50 xoffset=-0 yoffset=11 xadvance=43 page=0 chnl=0 letter="Y"
+char id=75 x=149 y=176 width=46 height=50 xoffset=5 yoffset=11 xadvance=46 page=0 chnl=0 letter="K"
+char id=82 x=197 y=176 width=46 height=50 xoffset=5 yoffset=11 xadvance=46 page=0 chnl=0 letter="R"
+char id=66 x=245 y=176 width=43 height=50 xoffset=5 yoffset=11 xadvance=46 page=0 chnl=0 letter="B"
+char id=68 x=290 y=176 width=43 height=50 xoffset=5 yoffset=11 xadvance=46 page=0 chnl=0 letter="D"
+char id=90 x=335 y=176 width=42 height=50 xoffset=1 yoffset=11 xadvance=39 page=0 chnl=0 letter="Z"
+char id=78 x=379 y=176 width=41 height=50 xoffset=5 yoffset=11 xadvance=46 page=0 chnl=0 letter="N"
+char id=84 x=422 y=176 width=41 height=50 xoffset=1 yoffset=11 xadvance=39 page=0 chnl=0 letter="T"
+char id=72 x=465 y=176 width=41 height=50 xoffset=5 yoffset=11 xadvance=46 page=0 chnl=0 letter="H"
+char id=80 x=2 y=228 width=40 height=50 xoffset=5 yoffset=11 xadvance=43 page=0 chnl=0 letter="P"
+char id=69 x=44 y=228 width=39 height=50 xoffset=5 yoffset=11 xadvance=43 page=0 chnl=0 letter="E"
+char id=76 x=85 y=228 width=38 height=50 xoffset=5 yoffset=11 xadvance=39 page=0 chnl=0 letter="L"
+char id=52 x=125 y=228 width=37 height=50 xoffset=1 yoffset=11 xadvance=36 page=0 chnl=0 letter="4"
+char id=70 x=164 y=228 width=36 height=50 xoffset=5 yoffset=11 xadvance=39 page=0 chnl=0 letter="F"
+char id=107 x=202 y=228 width=35 height=50 xoffset=4 yoffset=11 xadvance=36 page=0 chnl=0 letter="k"
+char id=104 x=239 y=228 width=35 height=50 xoffset=5 yoffset=11 xadvance=39 page=0 chnl=0 letter="h"
+char id=55 x=276 y=228 width=35 height=50 xoffset=3 yoffset=11 xadvance=36 page=0 chnl=0 letter="7"
+char id=53 x=313 y=228 width=35 height=50 xoffset=3 yoffset=12 xadvance=36 page=0 chnl=0 letter="5"
+char id=50 x=350 y=228 width=35 height=50 xoffset=2 yoffset=11 xadvance=36 page=0 chnl=0 letter="2"
+char id=49 x=387 y=228 width=25 height=50 xoffset=5 yoffset=11 xadvance=36 page=0 chnl=0 letter="1"
+char id=116 x=414 y=228 width=24 height=50 xoffset=1 yoffset=12 xadvance=21 page=0 chnl=0 letter="t"
+char id=73 x=440 y=228 width=14 height=50 xoffset=4 yoffset=11 xadvance=18 page=0 chnl=0 letter="I"
+char id=33 x=456 y=228 width=14 height=50 xoffset=6 yoffset=11 xadvance=21 page=0 chnl=0 letter="!"
+char id=105 x=472 y=228 width=13 height=50 xoffset=5 yoffset=11 xadvance=18 page=0 chnl=0 letter="i"
+char id=108 x=487 y=228 width=13 height=50 xoffset=5 yoffset=11 xadvance=18 page=0 chnl=0 letter="l"
+char id=59 x=2 y=280 width=14 height=48 xoffset=5 yoffset=23 xadvance=21 page=0 chnl=0 letter=";"
+char id=111 x=18 y=280 width=39 height=39 xoffset=3 yoffset=23 xadvance=39 page=0 chnl=0 letter="o"
+char id=60 x=59 y=280 width=36 height=39 xoffset=3 yoffset=17 xadvance=37 page=0 chnl=0 letter="<"
+char id=62 x=97 y=280 width=36 height=39 xoffset=3 yoffset=17 xadvance=37 page=0 chnl=0 letter=">"
+char id=99 x=135 y=280 width=36 height=39 xoffset=3 yoffset=23 xadvance=36 page=0 chnl=0 letter="c"
+char id=115 x=173 y=280 width=36 height=39 xoffset=2 yoffset=23 xadvance=36 page=0 chnl=0 letter="s"
+char id=97 x=211 y=280 width=36 height=39 xoffset=2 yoffset=23 xadvance=36 page=0 chnl=0 letter="a"
+char id=101 x=249 y=280 width=35 height=39 xoffset=2 yoffset=23 xadvance=36 page=0 chnl=0 letter="e"
+char id=119 x=286 y=280 width=54 height=38 xoffset=0 yoffset=23 xadvance=50 page=0 chnl=0 letter="w"
+char id=109 x=342 y=280 width=53 height=38 xoffset=4 yoffset=23 xadvance=57 page=0 chnl=0 letter="m"
+char id=120 x=397 y=280 width=39 height=38 xoffset=0 yoffset=23 xadvance=36 page=0 chnl=0 letter="x"
+char id=118 x=438 y=280 width=39 height=38 xoffset=0 yoffset=23 xadvance=36 page=0 chnl=0 letter="v"
+char id=110 x=2 y=330 width=35 height=38 xoffset=5 yoffset=23 xadvance=39 page=0 chnl=0 letter="n"
+char id=117 x=39 y=330 width=35 height=38 xoffset=4 yoffset=24 xadvance=39 page=0 chnl=0 letter="u"
+char id=122 x=76 y=330 width=34 height=38 xoffset=1 yoffset=23 xadvance=32 page=0 chnl=0 letter="z"
+char id=114 x=112 y=330 width=26 height=38 xoffset=4 yoffset=23 xadvance=25 page=0 chnl=0 letter="r"
+char id=58 x=140 y=330 width=13 height=38 xoffset=6 yoffset=23 xadvance=21 page=0 chnl=0 letter=":"
+char id=43 x=155 y=330 width=37 height=37 xoffset=3 yoffset=17 xadvance=37 page=0 chnl=0 letter="+"
+char id=94 x=194 y=330 width=35 height=29 xoffset=4 yoffset=10 xadvance=37 page=0 chnl=0 letter="^"
+char id=42 x=231 y=330 width=28 height=27 xoffset=1 yoffset=9 xadvance=25 page=0 chnl=0 letter="*"
+char id=61 x=261 y=330 width=37 height=26 xoffset=3 yoffset=23 xadvance=37 page=0 chnl=0 letter="="
+char id=44 x=300 y=330 width=15 height=23 xoffset=4 yoffset=48 xadvance=18 page=0 chnl=0 letter=","
+char id=34 x=317 y=330 width=28 height=21 xoffset=4 yoffset=10 xadvance=30 page=0 chnl=0 letter="""
+char id=39 x=347 y=330 width=14 height=21 xoffset=3 yoffset=10 xadvance=15 page=0 chnl=0 letter="'"
+char id=126 x=363 y=330 width=38 height=17 xoffset=2 yoffset=28 xadvance=37 page=0 chnl=0 letter="~"
+char id=96 x=403 y=330 width=18 height=14 xoffset=1 yoffset=10 xadvance=21 page=0 chnl=0 letter="`"
+char id=45 x=423 y=330 width=22 height=13 xoffset=2 yoffset=36 xadvance=21 page=0 chnl=0 letter="-"
+char id=46 x=447 y=330 width=13 height=13 xoffset=5 yoffset=48 xadvance=18 page=0 chnl=0 letter="."
+char id=95 x=462 y=330 width=42 height=10 xoffset=-1 yoffset=64 xadvance=36 page=0 chnl=0 letter="_"
+char id=32 x=506 y=330 width=0 height=0 xoffset=18 yoffset=78 xadvance=18 page=0 chnl=0 letter="space"
+kernings count=102
+kerning first=64 second=51 amount=-1
+kerning first=64 second=56 amount=-1
+kerning first=64 second=42 amount=-2
+kerning first=63 second=126 amount=-2
+kerning first=47 second=52 amount=-4
+kerning first=121 second=44 amount=-5
+kerning first=121 second=46 amount=-5
+kerning first=87 second=121 amount=-1
+kerning first=87 second=65 amount=-4
+kerning first=87 second=105 amount=-1
+kerning first=87 second=59 amount=-1
+kerning first=87 second=111 amount=-1
+kerning first=87 second=97 amount=-2
+kerning first=87 second=101 amount=-1
+kerning first=87 second=117 amount=-1
+kerning first=87 second=114 amount=-1
+kerning first=87 second=58 amount=-1
+kerning first=87 second=44 amount=-4
+kerning first=87 second=45 amount=-1
+kerning first=87 second=46 amount=-4
+kerning first=65 second=121 amount=-2
+kerning first=65 second=87 amount=-4
+kerning first=65 second=86 amount=-5
+kerning first=65 second=89 amount=-6
+kerning first=65 second=84 amount=-5
+kerning first=65 second=119 amount=-1
+kerning first=65 second=118 amount=-2
+kerning first=65 second=32 amount=-2
+kerning first=86 second=121 amount=-2
+kerning first=86 second=65 amount=-5
+kerning first=86 second=105 amount=-1
+kerning first=86 second=59 amount=-4
+kerning first=86 second=111 amount=-5
+kerning first=86 second=97 amount=-4
+kerning first=86 second=101 amount=-4
+kerning first=86 second=117 amount=-2
+kerning first=86 second=114 amount=-4
+kerning first=86 second=58 amount=-4
+kerning first=86 second=44 amount=-6
+kerning first=86 second=45 amount=-4
+kerning first=86 second=46 amount=-6
+kerning first=89 second=113 amount=-5
+kerning first=89 second=112 amount=-4
+kerning first=89 second=65 amount=-6
+kerning first=89 second=105 amount=-2
+kerning first=89 second=59 amount=-5
+kerning first=89 second=111 amount=-5
+kerning first=89 second=97 amount=-4
+kerning first=89 second=101 amount=-4
+kerning first=89 second=118 amount=-4
+kerning first=89 second=117 amount=-4
+kerning first=89 second=58 amount=-5
+kerning first=89 second=44 amount=-7
+kerning first=89 second=45 amount=-4
+kerning first=89 second=46 amount=-7
+kerning first=89 second=32 amount=-1
+kerning first=82 second=87 amount=-1
+kerning first=82 second=86 amount=-1
+kerning first=82 second=89 amount=-2
+kerning first=84 second=79 amount=-1
+kerning first=84 second=121 amount=-5
+kerning first=84 second=65 amount=-5
+kerning first=84 second=105 amount=-1
+kerning first=84 second=59 amount=-7
+kerning first=84 second=111 amount=-5
+kerning first=84 second=99 amount=-5
+kerning first=84 second=115 amount=-5
+kerning first=84 second=97 amount=-5
+kerning first=84 second=101 amount=-5
+kerning first=84 second=119 amount=-5
+kerning first=84 second=117 amount=-5
+kerning first=84 second=114 amount=-4
+kerning first=84 second=58 amount=-7
+kerning first=84 second=44 amount=-7
+kerning first=84 second=45 amount=-4
+kerning first=84 second=46 amount=-7
+kerning first=80 second=65 amount=-5
+kerning first=80 second=44 amount=-8
+kerning first=80 second=46 amount=-8
+kerning first=80 second=32 amount=-1
+kerning first=76 second=121 amount=-2
+kerning first=76 second=87 amount=-4
+kerning first=76 second=86 amount=-5
+kerning first=76 second=89 amount=-6
+kerning first=76 second=84 amount=-5
+kerning first=76 second=32 amount=-1
+kerning first=70 second=65 amount=-4
+kerning first=70 second=44 amount=-7
+kerning first=70 second=46 amount=-7
+kerning first=49 second=49 amount=-4
+kerning first=33 second=102 amount=-1
+kerning first=62 second=35 amount=-2
+kerning first=119 second=44 amount=-2
+kerning first=119 second=46 amount=-2
+kerning first=118 second=44 amount=-5
+kerning first=118 second=46 amount=-5
+kerning first=114 second=44 amount=-4
+kerning first=114 second=46 amount=-4
+kerning first=34 second=42 amount=-1
+kerning first=32 second=92 amount=-2
+kerning first=32 second=65 amount=-2
+kerning first=32 second=89 amount=-1
diff --git a/tests/font/arial.png b/tests/font/arial.png
new file mode 100644
index 0000000..8dc442f
--- /dev/null
+++ b/tests/font/arial.png
Binary files differ
diff --git a/tests/font/circle_poly.svg b/tests/font/circle_poly.svg
new file mode 100644
index 0000000..b0d6f4d
--- /dev/null
+++ b/tests/font/circle_poly.svg
@@ -0,0 +1,20 @@
+<?xml version="1.0" standalone="yes"?>
+
+<svg version="1.1" viewBox="0.0 0.0 960.0 720.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <path d="M0 100.314964L0 100.314964
+ C0 44.91254 43.981853 1.19127095E-14 98.23621 0
+ L98.23621 0
+ C124.290085 0 149.27686 10.568868 167.6997 29.381573
+ C186.12257 48.19428 196.47243 73.709785 196.47243 100.314964
+ L196.47243 100.314964
+ C196.47243 155.71739 152.49059 200.62993 98.23621 200.62993
+ L98.23621 200.62993
+ C43.981853 200.62993 -1.19127095E-14 155.71739 -2.3825419E-14 100.314964
+ Z"
+ fill-rule="nonzero" fill="#ff0000"
+ stroke="#073763" stroke-width="2.0" stroke-linejoin="round" stroke-linecap="butt">
+ </path>
+ <path d="M144.2098 150.47835L174.51588 338.57742L204.82062 263.33948L269.613 335.4441L284.24435 221.53781L200.64043 212.13359L295.73752 86.73491L203.77591 160.92981L132.71391 94.048836Z" fill-rule="nonzero" fill="#0000ff" stroke="#073763" stroke-width="2.0" stroke-linejoin="round" stroke-linecap="butt"></path>
+ <path d="M249.75812 52.24987L223.63052 95.093094L243.48741 125.39746L210.0482 179.73561L246.62373 216.30823L247.66853 239.30043L203.77751 261.24637L203.77751 281.09738L275.8857 324.98688L303.05423 309.31155L304.099 281.09738L286.33365 267.51227L289.46802 292.59467L262.29953 288.4119L263.3443 264.37814L276.9305 256.01968L287.37845 208.99371L237.2167 165.10422L279.01816 115.99274L264.3891 94.049164L286.33365 62.70087L300.96463 63.744793L323.95398 101.36369L297.83026 132.71199L225.72398 119.12686L156.75015 99.27349L108.67996 55.386345L107.63517 75.237366L156.75015 134.80219L243.48741 151.52379L294.69394 150.47516L328.13702 145.25319L340.67453 86.73464L284.24405 42.845146Z" fill-rule="nonzero" fill="#ffff00" stroke="#073763" stroke-width="2.0" stroke-linejoin="round" stroke-linecap="butt"></path>
+</svg>
+
diff --git a/tests/font/cmake/modules/FindEGL.cmake b/tests/font/cmake/modules/FindEGL.cmake
new file mode 100644
index 0000000..6f502bd
--- /dev/null
+++ b/tests/font/cmake/modules/FindEGL.cmake
@@ -0,0 +1,15 @@
+# Find EGL
+#
+# EGL_INCLUDE_DIR
+# EGL_LIBRARY
+# EGL_FOUND
+
+find_path(EGL_INCLUDE_DIR NAMES EGL/egl.h)
+
+set(EGL_NAMES ${EGL_NAMES} egl EGL)
+find_library(EGL_LIBRARY NAMES ${EGL_NAMES})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)
+
+mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY)
diff --git a/tests/font/delorean.png b/tests/font/delorean.png
new file mode 100644
index 0000000..27c6329
--- /dev/null
+++ b/tests/font/delorean.png
Binary files differ
diff --git a/tests/font/eglstate.h b/tests/font/eglstate.h
new file mode 100644
index 0000000..0674a7b
--- /dev/null
+++ b/tests/font/eglstate.h
@@ -0,0 +1,11 @@
+typedef struct {
+ uint32_t screen_width;
+ uint32_t screen_height;
+ // OpenGL|ES objects
+ EGLDisplay display;
+ EGLConfig config;
+ EGLSurface surface;
+ EGLContext context;
+} STATE_T;
+
+
diff --git a/tests/font/fontinfo.h b/tests/font/fontinfo.h
new file mode 100644
index 0000000..a1c312f
--- /dev/null
+++ b/tests/font/fontinfo.h
@@ -0,0 +1,19 @@
+#ifndef OPENVG_FONTINFO_H
+#define OPENVG_FONTINFO_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+ typedef struct {
+ const short *CharacterMap;
+ const int *GlyphAdvances;
+ int Count;
+ VGPath Glyphs[256];
+ } Fontinfo;
+
+ extern Fontinfo SansTypeface, SerifTypeface, MonoTypeface;
+
+#if defined(__cplusplus)
+}
+#endif // OPENVG_FONTINFO_H
+#endif
diff --git a/tests/font/inc/EGL/egl.h b/tests/font/inc/EGL/egl.h
new file mode 100644
index 0000000..99ea342
--- /dev/null
+++ b/tests/font/inc/EGL/egl.h
@@ -0,0 +1,329 @@
+/* -*- 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/tests/font/inc/EGL/eglext.h b/tests/font/inc/EGL/eglext.h
new file mode 100644
index 0000000..8e9e610
--- /dev/null
+++ b/tests/font/inc/EGL/eglext.h
@@ -0,0 +1,539 @@
+#ifndef __eglext_h_
+#define __eglext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007-2012 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: 19987 $ on $Date: 2012-12-13 16:46:46 -0800 (Thu, 13 Dec 2012) $ */
+#define EGL_EGLEXT_VERSION 14
+
+#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
+
+#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */
+#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
+#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_KHR_lock_surface2
+#define EGL_KHR_lock_surface2 1
+#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110
+#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
+
+#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */
+#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 khronos_utime_nanoseconds_t EGLTimeNV;
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync);
+EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync);
+EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
+EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
+EGLAPI EGLBoolean EGLAPIENTRY 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
+#endif
+
+#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */
+#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
+#endif
+
+#ifndef EGL_HI_clientpixmap
+#define EGL_HI_clientpixmap 1
+
+/* Surface Attribute */
+#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74
+/*
+ * Structure representing a client pixmap
+ * (pixmap's data is in client-space memory).
+ */
+struct EGLClientPixmapHI
+{
+ void* pData;
+ EGLint iWidth;
+ EGLint iHeight;
+ EGLint iStride;
+};
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
+#endif /* EGL_HI_clientpixmap */
+
+#ifndef EGL_HI_colorformats
+#define EGL_HI_colorformats 1
+/* Config Attribute */
+#define EGL_COLOR_FORMAT_HI 0x8F70
+/* Color Formats */
+#define EGL_COLOR_RGB_HI 0x8F71
+#define EGL_COLOR_RGBA_HI 0x8F72
+#define EGL_COLOR_ARGB_HI 0x8F73
+#endif /* EGL_HI_colorformats */
+
+#ifndef EGL_MESA_drm_image
+#define EGL_MESA_drm_image 1
+#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */
+#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */
+#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */
+#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */
+#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4
+#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */
+#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
+#endif
+
+#ifndef EGL_NV_post_sub_buffer
+#define EGL_NV_post_sub_buffer 1
+#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
+#endif
+
+#ifndef EGL_ANGLE_query_surface_pointer
+#define EGL_ANGLE_query_surface_pointer 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
+#endif
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
+#endif
+
+#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
+#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
+#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
+#endif
+
+#ifndef EGL_NV_coverage_sample_resolve
+#define EGL_NV_coverage_sample_resolve 1
+#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131
+#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
+#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133
+#endif
+
+#if KHRONOS_SUPPORT_INT64 /* EGLuint64NV requires 64-bit uint support */
+#ifndef EGL_NV_system_time
+#define EGL_NV_system_time 1
+typedef khronos_utime_nanoseconds_t EGLuint64NV;
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
+EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
+typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
+#endif
+#endif
+
+#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */
+#ifndef EGL_KHR_stream
+#define EGL_KHR_stream 1
+typedef void* EGLStreamKHR;
+typedef khronos_uint64_t EGLuint64KHR;
+#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0)
+#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210
+#define EGL_PRODUCER_FRAME_KHR 0x3212
+#define EGL_CONSUMER_FRAME_KHR 0x3213
+#define EGL_STREAM_STATE_KHR 0x3214
+#define EGL_STREAM_STATE_CREATED_KHR 0x3215
+#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216
+#define EGL_STREAM_STATE_EMPTY_KHR 0x3217
+#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218
+#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219
+#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A
+#define EGL_BAD_STREAM_KHR 0x321B
+#define EGL_BAD_STATE_KHR 0x321C
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_consumer_gltexture
+#define EGL_KHR_stream_consumer_gltexture 1
+#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_producer_eglsurface
+#define EGL_KHR_stream_producer_eglsurface 1
+#define EGL_STREAM_BIT_KHR 0x0800
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_producer_aldatalocator
+#define EGL_KHR_stream_producer_aldatalocator 1
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_fifo
+#define EGL_KHR_stream_fifo 1
+/* reuse EGLTimeKHR */
+#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC
+#define EGL_STREAM_TIME_NOW_KHR 0x31FD
+#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE
+#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
+#endif
+#endif
+
+#ifndef EGL_EXT_create_context_robustness
+#define EGL_EXT_create_context_robustness 1
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
+#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE
+#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF
+#endif
+
+#ifndef EGL_ANGLE_d3d_share_handle_client_buffer
+#define EGL_ANGLE_d3d_share_handle_client_buffer 1
+/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */
+#endif
+
+#ifndef EGL_KHR_create_context
+#define EGL_KHR_create_context 1
+#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
+#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
+#define EGL_CONTEXT_FLAGS_KHR 0x30FC
+#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD
+#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE
+#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF
+#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
+#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
+#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
+#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
+#define EGL_OPENGL_ES3_BIT_KHR 0x00000040
+#endif
+
+#ifndef EGL_KHR_surfaceless_context
+#define EGL_KHR_surfaceless_context 1
+/* No tokens/entry points, just relaxes an error condition */
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_cross_process_fd
+#define EGL_KHR_stream_cross_process_fd 1
+typedef int EGLNativeFileDescriptorKHR;
+#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1))
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
+#endif
+#endif
+
+#ifndef EGL_EXT_multiview_window
+#define EGL_EXT_multiview_window 1
+#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134
+#endif
+
+#ifndef EGL_KHR_wait_sync
+#define EGL_KHR_wait_sync 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+#endif
+
+#ifndef EGL_NV_post_convert_rounding
+#define EGL_NV_post_convert_rounding 1
+/* No tokens or entry points, just relaxes behavior of SwapBuffers */
+#endif
+
+#ifndef EGL_NV_native_query
+#define EGL_NV_native_query 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV( EGLDisplay dpy, EGLNativeDisplayType* display_id);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV( EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType* window);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV( EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType* pixmap);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)(EGLDisplay dpy, EGLNativeDisplayType *display_id);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap);
+#endif
+
+#ifndef EGL_NV_3dvision_surface
+#define EGL_NV_3dvision_surface 1
+#define EGL_AUTO_STEREO_NV 0x3136
+#endif
+
+#ifndef EGL_ANDROID_framebuffer_target
+#define EGL_ANDROID_framebuffer_target 1
+#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147
+#endif
+
+#ifndef EGL_ANDROID_blob_cache
+#define EGL_ANDROID_blob_cache 1
+typedef khronos_ssize_t EGLsizeiANDROID;
+typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);
+typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
+#endif
+
+#ifndef EGL_ANDROID_image_native_buffer
+#define EGL_ANDROID_image_native_buffer 1
+#define EGL_NATIVE_BUFFER_ANDROID 0x3140
+#endif
+
+#ifndef EGL_ANDROID_native_fence_sync
+#define EGL_ANDROID_native_fence_sync 1
+#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
+#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
+#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146
+#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, EGLSyncKHR);
+#endif
+
+#ifndef EGL_ANDROID_recordable
+#define EGL_ANDROID_recordable 1
+#define EGL_RECORDABLE_ANDROID 0x3142
+#endif
+
+#ifndef EGL_EXT_buffer_age
+#define EGL_EXT_buffer_age 1
+#define EGL_BUFFER_AGE_EXT 0x313D
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __eglext_h_ */
diff --git a/tests/font/inc/EGL/eglplatform.h b/tests/font/inc/EGL/eglplatform.h
new file mode 100644
index 0000000..41c11d8
--- /dev/null
+++ b/tests/font/inc/EGL/eglplatform.h
@@ -0,0 +1,122 @@
+#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: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $
+ *
+ * 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".
+ *
+ * Khronos STRONGLY RECOMMENDS that you use the default definitions
+ * provided below, since these changes affect both binary and source
+ * portability of applications using EGL running on different EGL
+ * implementations.
+ */
+
+#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(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
+
+typedef int EGLNativeDisplayType;
+typedef void *EGLNativeWindowType;
+typedef void *EGLNativePixmapType;
+
+#elif defined(__arm__) && defined(__gnu_linux__) /* ARM Linux Mali */
+#include <EGL/fbdev_window.h>
+
+typedef void* EGLNativeDisplayType;
+typedef void* EGLNativePixmapType;
+typedef fbdev_window* 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/tests/font/inc/EGL/fbdev_window.h b/tests/font/inc/EGL/fbdev_window.h
new file mode 100644
index 0000000..f5f90b5
--- /dev/null
+++ b/tests/font/inc/EGL/fbdev_window.h
@@ -0,0 +1,50 @@
+/* vim:set sts=4 ts=4 noexpandtab: */
+/*
+ * This confidential and proprietary software may be used only as
+ * authorised by a licensing agreement from ARM Limited
+ * (C) COPYRIGHT 2008,2009 ARM Limited
+ * ALL RIGHTS RESERVED
+ * The entire notice above must be reproduced on all authorised
+ * copies and copies may only be made to the extent permitted
+ * by a licensing agreement from ARM Limited.
+ */
+
+#ifndef _FBDEV_WINDOW_H_
+#define _FBDEV_WINDOW_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum
+{
+ FBDEV_PIXMAP_SUPPORTS_UMP = (1<<0)
+} fbdev_pixmap_flags;
+
+typedef struct fbdev_window
+{
+ unsigned short width;
+ unsigned short height;
+} fbdev_window;
+
+typedef struct fbdev_pixmap
+{
+ unsigned int height;
+ unsigned int width;
+ unsigned int bytes_per_pixel;
+ unsigned char buffer_size;
+ unsigned char red_size;
+ unsigned char green_size;
+ unsigned char blue_size;
+ unsigned char alpha_size;
+ unsigned char luminance_size;
+ fbdev_pixmap_flags flags;
+ unsigned short *data;
+} fbdev_pixmap;
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/tests/font/inc/GLES/gl.h b/tests/font/inc/GLES/gl.h
new file mode 100644
index 0000000..5b8d85a
--- /dev/null
+++ b/tests/font/inc/GLES/gl.h
@@ -0,0 +1,770 @@
+#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/tests/font/inc/GLES/glext.h b/tests/font/inc/GLES/glext.h
new file mode 100644
index 0000000..5b46ae6
--- /dev/null
+++ b/tests/font/inc/GLES/glext.h
@@ -0,0 +1,1278 @@
+#ifndef __glext_h_
+#define __glext_h_
+
+/* $Revision: 19260 $ on $Date:: 2012-09-20 11:30:36 -0700 #$ */
+
+#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_required_internalformat */
+/* No new tokens introduced by this extension. */
+
+/* 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_copy_texture_levels */
+/* 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_sync */
+#ifndef GL_APPLE_sync
+
+/* These types are defined with reference to <inttypes.h>
+ * in the Apple extension spec, but here we use the Khronos
+ * portable types in khrplatform.h, and assume those types
+ * are always defined.
+ * If any other extensions using these types are defined,
+ * the typedefs must move out of this block and be shared.
+ */
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef struct __GLsync *GLsync;
+
+#define GL_SYNC_OBJECT_APPLE 0x8A53
+#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
+#define GL_OBJECT_TYPE_APPLE 0x9112
+#define GL_SYNC_CONDITION_APPLE 0x9113
+#define GL_SYNC_STATUS_APPLE 0x9114
+#define GL_SYNC_FLAGS_APPLE 0x9115
+#define GL_SYNC_FENCE_APPLE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117
+#define GL_UNSIGNALED_APPLE 0x9118
+#define GL_SIGNALED_APPLE 0x9119
+#define GL_ALREADY_SIGNALED_APPLE 0x911A
+#define GL_TIMEOUT_EXPIRED_APPLE 0x911B
+#define GL_CONDITION_SATISFIED_APPLE 0x911C
+#define GL_WAIT_FAILED_APPLE 0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001
+#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull
+#endif
+
+/* GL_APPLE_texture_2D_limited_npot */
+/* No new tokens introduced by this extension. */
+
+/* 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_map_buffer_range */
+#ifndef GL_EXT_map_buffer_range
+#define GL_MAP_READ_BIT_EXT 0x0001
+#define GL_MAP_WRITE_BIT_EXT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
+#endif
+
+/* GL_EXT_multisampled_render_to_texture */
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
+/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */
+#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_MAX_SAMPLES_EXT 0x8D57
+#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_robustness */
+#ifndef GL_EXT_robustness
+/* reuse GL_NO_ERROR */
+#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253
+#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255
+#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3
+#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
+#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252
+#define GL_NO_RESET_NOTIFICATION_EXT 0x8261
+#endif
+
+/* GL_EXT_sRGB */
+#ifndef GL_EXT_sRGB
+#define GL_SRGB_EXT 0x8C40
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
+#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_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
+
+/* GL_EXT_texture_storage */
+#ifndef GL_EXT_texture_storage
+#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
+#define GL_ALPHA8_EXT 0x803C
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_RGBA32F_EXT 0x8814
+#define GL_RGB32F_EXT 0x8815
+#define GL_ALPHA32F_EXT 0x8816
+#define GL_LUMINANCE32F_EXT 0x8818
+#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
+/* reuse GL_RGBA16F_EXT */
+#define GL_RGB16F_EXT 0x881B
+#define GL_ALPHA16F_EXT 0x881C
+#define GL_LUMINANCE16F_EXT 0x881E
+#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
+#define GL_RGB10_A2_EXT 0x8059
+#define GL_RGB10_EXT 0x8052
+#define GL_BGRA8_EXT 0x93A1
+#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_required_internalformat */
+#ifndef GL_OES_required_internalformat
+#define GL_OES_required_internalformat 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_copy_texture_levels */
+#ifndef GL_APPLE_copy_texture_levels
+#define GL_APPLE_copy_texture_levels 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
+#endif
+typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
+#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_sync */
+#ifndef GL_APPLE_sync
+#define GL_APPLE_sync 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags);
+GL_API GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync);
+GL_API void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync);
+GL_API GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_API void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_API void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params);
+GL_API void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif
+typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
+typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
+typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
+typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
+typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif
+
+/* GL_APPLE_texture_2D_limited_npot */
+#ifndef GL_APPLE_texture_2D_limited_npot
+#define GL_APPLE_texture_2D_limited_npot 1
+#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_map_buffer_range */
+#ifndef GL_EXT_map_buffer_range
+#define GL_EXT_map_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY *glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GL_API void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+
+/* GL_EXT_multisampled_render_to_texture */
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_EXT_multisampled_render_to_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
+#endif
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#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_robustness */
+#ifndef GL_EXT_robustness
+#define GL_EXT_robustness 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void);
+GL_API void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+GL_API void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, float *params);
+GL_API void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+#endif
+typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void);
+typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, float *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+#endif
+
+/* GL_EXT_sRGB */
+#ifndef GL_EXT_sRGB
+#define GL_EXT_sRGB 1
+#endif
+
+/* GL_EXT_texture_compression_dxt1 */
+#ifndef GL_EXT_texture_compression_dxt1
+#define GL_EXT_texture_compression_dxt1 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
+
+/* GL_EXT_texture_storage */
+#ifndef GL_EXT_texture_storage
+#define GL_EXT_texture_storage 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GL_API void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GL_API void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GL_API void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#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 PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (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/tests/font/inc/GLES/glplatform.h b/tests/font/inc/GLES/glplatform.h
new file mode 100644
index 0000000..2db6ee2
--- /dev/null
+++ b/tests/font/inc/GLES/glplatform.h
@@ -0,0 +1,30 @@
+#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/tests/font/inc/GLES2/gl2.h b/tests/font/inc/GLES2/gl2.h
new file mode 100644
index 0000000..b7fe76e
--- /dev/null
+++ b/tests/font/inc/GLES2/gl2.h
@@ -0,0 +1,620 @@
+#ifndef __gl2_h_
+#define __gl2_h_
+
+/* $Revision: 16803 $ on $Date:: 2012-02-02 09:49:18 -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_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/tests/font/inc/GLES2/gl2ext.h b/tests/font/inc/GLES2/gl2ext.h
new file mode 100644
index 0000000..f7e7a61
--- /dev/null
+++ b/tests/font/inc/GLES2/gl2ext.h
@@ -0,0 +1,1809 @@
+#ifndef __gl2ext_h_
+#define __gl2ext_h_
+
+/* $Revision: 19436 $ on $Date:: 2012-10-10 10:37:04 -0700 #$ */
+
+#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_required_internalformat */
+#ifndef GL_OES_required_internalformat
+#define GL_ALPHA8_OES 0x803C
+#define GL_DEPTH_COMPONENT16_OES 0x81A5
+/* reuse GL_DEPTH_COMPONENT24_OES */
+/* reuse GL_DEPTH24_STENCIL8_OES */
+/* reuse GL_DEPTH_COMPONENT32_OES */
+#define GL_LUMINANCE4_ALPHA4_OES 0x8043
+#define GL_LUMINANCE8_ALPHA8_OES 0x8045
+#define GL_LUMINANCE8_OES 0x8040
+#define GL_RGBA4_OES 0x8056
+#define GL_RGB5_A1_OES 0x8057
+#define GL_RGB565_OES 0x8D62
+/* reuse GL_RGB8_OES */
+/* reuse GL_RGBA8_OES */
+/* reuse GL_RGB10_EXT */
+/* reuse GL_RGB10_A2_EXT */
+#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
+
+#ifndef GL_OES_surfaceless_context
+#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219
+#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
+
+/*------------------------------------------------------------------------*
+ * KHR extension tokens
+ *------------------------------------------------------------------------*/
+
+#ifndef GL_KHR_debug
+typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
+#define GL_DEBUG_SOURCE_API 0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
+#define GL_DEBUG_SOURCE_APPLICATION 0x824A
+#define GL_DEBUG_SOURCE_OTHER 0x824B
+#define GL_DEBUG_TYPE_ERROR 0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
+#define GL_DEBUG_TYPE_PORTABILITY 0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
+#define GL_DEBUG_TYPE_OTHER 0x8251
+#define GL_DEBUG_TYPE_MARKER 0x8268
+#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
+#define GL_DEBUG_TYPE_POP_GROUP 0x826A
+#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
+#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
+#define GL_BUFFER 0x82E0
+#define GL_SHADER 0x82E1
+#define GL_PROGRAM 0x82E2
+#define GL_QUERY 0x82E3
+/* PROGRAM_PIPELINE only in GL */
+#define GL_SAMPLER 0x82E6
+/* DISPLAY_LIST only in GL */
+#define GL_MAX_LABEL_LENGTH 0x82E8
+#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
+#define GL_DEBUG_LOGGED_MESSAGES 0x9145
+#define GL_DEBUG_SEVERITY_HIGH 0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
+#define GL_DEBUG_SEVERITY_LOW 0x9148
+#define GL_DEBUG_OUTPUT 0x92E0
+#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
+#define GL_STACK_OVERFLOW 0x0503
+#define GL_STACK_UNDERFLOW 0x0504
+#endif
+
+#ifndef GL_KHR_texture_compression_astc_ldr
+#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
+#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
+#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
+#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
+#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
+#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
+#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
+#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
+#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
+#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
+#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
+#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
+#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
+#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
+#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
+
+/* GL_ANGLE_instanced_arrays */
+#ifndef GL_ANGLE_instanced_arrays
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
+#endif
+
+/* GL_ANGLE_pack_reverse_row_order */
+#ifndef GL_ANGLE_pack_reverse_row_order
+#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
+#endif
+
+/* GL_ANGLE_texture_compression_dxt3 */
+#ifndef GL_ANGLE_texture_compression_dxt3
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
+#endif
+
+/* GL_ANGLE_texture_compression_dxt5 */
+#ifndef GL_ANGLE_texture_compression_dxt5
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
+#endif
+
+/* GL_ANGLE_texture_usage */
+#ifndef GL_ANGLE_texture_usage
+#define GL_TEXTURE_USAGE_ANGLE 0x93A2
+#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3
+#endif
+
+/* GL_ANGLE_translated_shader_source */
+#ifndef GL_ANGLE_translated_shader_source
+#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
+#endif
+
+/*------------------------------------------------------------------------*
+ * APPLE extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_APPLE_copy_texture_levels */
+/* 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_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_sync */
+#ifndef GL_APPLE_sync
+
+#ifndef __gl3_h_
+/* These types are defined with reference to <inttypes.h>
+ * in the Apple extension spec, but here we use the Khronos
+ * portable types in khrplatform.h, and assume those types
+ * are always defined.
+ * If any other extensions using these types are defined,
+ * the typedefs must move out of this block and be shared.
+ */
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef struct __GLsync *GLsync;
+#endif
+
+#define GL_SYNC_OBJECT_APPLE 0x8A53
+#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
+#define GL_OBJECT_TYPE_APPLE 0x9112
+#define GL_SYNC_CONDITION_APPLE 0x9113
+#define GL_SYNC_STATUS_APPLE 0x9114
+#define GL_SYNC_FLAGS_APPLE 0x9115
+#define GL_SYNC_FENCE_APPLE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117
+#define GL_UNSIGNALED_APPLE 0x9118
+#define GL_SIGNALED_APPLE 0x9119
+#define GL_ALREADY_SIGNALED_APPLE 0x911A
+#define GL_TIMEOUT_EXPIRED_APPLE 0x911B
+#define GL_CONDITION_SATISFIED_APPLE 0x911C
+#define GL_WAIT_FAILED_APPLE 0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001
+#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull
+#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_program_binary */
+#ifndef GL_ARM_mali_program_binary
+#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61
+#endif
+
+/* 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_color_buffer_half_float */
+#ifndef GL_EXT_color_buffer_half_float
+#define GL_RGBA16F_EXT 0x881A
+#define GL_RGB16F_EXT 0x881B
+#define GL_RG16F_EXT 0x822F
+#define GL_R16F_EXT 0x822D
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211
+#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17
+#endif
+
+/* GL_EXT_debug_label */
+#ifndef GL_EXT_debug_label
+#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
+#define GL_PROGRAM_OBJECT_EXT 0x8B40
+#define GL_SHADER_OBJECT_EXT 0x8B48
+#define GL_BUFFER_OBJECT_EXT 0x9151
+#define GL_QUERY_OBJECT_EXT 0x9153
+#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
+#endif
+
+/* GL_EXT_debug_marker */
+/* No new tokens introduced by this extension. */
+
+/* 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_map_buffer_range */
+#ifndef GL_EXT_map_buffer_range
+#define GL_MAP_READ_BIT_EXT 0x0001
+#define GL_MAP_WRITE_BIT_EXT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
+#endif
+
+/* GL_EXT_multisampled_render_to_texture */
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
+/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */
+#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_MAX_SAMPLES_EXT 0x8D57
+#endif
+
+/* GL_EXT_multiview_draw_buffers */
+#ifndef GL_EXT_multiview_draw_buffers
+#define GL_COLOR_ATTACHMENT_EXT 0x90F0
+#define GL_MULTIVIEW_EXT 0x90F1
+#define GL_DRAW_BUFFER_EXT 0x0C01
+#define GL_READ_BUFFER_EXT 0x0C02
+#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2
+#endif
+
+/* GL_EXT_multi_draw_arrays */
+/* No new tokens introduced by this extension. */
+
+/* GL_EXT_occlusion_query_boolean */
+#ifndef GL_EXT_occlusion_query_boolean
+#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
+#define GL_CURRENT_QUERY_EXT 0x8865
+#define GL_QUERY_RESULT_EXT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
+#endif
+
+/* 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_robustness */
+#ifndef GL_EXT_robustness
+/* reuse GL_NO_ERROR */
+#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253
+#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255
+#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3
+#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
+#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252
+#define GL_NO_RESET_NOTIFICATION_EXT 0x8261
+#endif
+
+/* GL_EXT_separate_shader_objects */
+#ifndef GL_EXT_separate_shader_objects
+#define GL_VERTEX_SHADER_BIT_EXT 0x00000001
+#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002
+#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF
+#define GL_PROGRAM_SEPARABLE_EXT 0x8258
+#define GL_ACTIVE_PROGRAM_EXT 0x8259
+#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A
+#endif
+
+/* GL_EXT_shader_framebuffer_fetch */
+#ifndef GL_EXT_shader_framebuffer_fetch
+#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
+#endif
+
+/* GL_EXT_shader_texture_lod */
+/* No new tokens introduced by this extension. */
+
+/* GL_EXT_shadow_samplers */
+#ifndef GL_EXT_shadow_samplers
+#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C
+#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D
+#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E
+#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62
+#endif
+
+/* GL_EXT_sRGB */
+#ifndef GL_EXT_sRGB
+#define GL_SRGB_EXT 0x8C40
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
+#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_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_rg */
+#ifndef GL_EXT_texture_rg
+#define GL_RED_EXT 0x1903
+#define GL_RG_EXT 0x8227
+#define GL_R8_EXT 0x8229
+#define GL_RG8_EXT 0x822B
+#endif
+
+/* GL_EXT_texture_storage */
+#ifndef GL_EXT_texture_storage
+#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
+#define GL_ALPHA8_EXT 0x803C
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_RGBA32F_EXT 0x8814
+#define GL_RGB32F_EXT 0x8815
+#define GL_ALPHA32F_EXT 0x8816
+#define GL_LUMINANCE32F_EXT 0x8818
+#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
+/* reuse GL_RGBA16F_EXT */
+/* reuse GL_RGB16F_EXT */
+#define GL_ALPHA16F_EXT 0x881C
+#define GL_LUMINANCE16F_EXT 0x881E
+#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
+#define GL_RGB10_A2_EXT 0x8059
+#define GL_RGB10_EXT 0x8052
+#define GL_BGRA8_EXT 0x93A1
+#define GL_R8_EXT 0x8229
+#define GL_RG8_EXT 0x822B
+#define GL_R32F_EXT 0x822E
+#define GL_RG32F_EXT 0x8230
+#define GL_R16F_EXT 0x822D
+#define GL_RG16F_EXT 0x822F
+#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_unpack_subimage */
+#ifndef GL_EXT_unpack_subimage
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#endif
+
+/*------------------------------------------------------------------------*
+ * DMP extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_DMP_shader_binary */
+#ifndef GL_DMP_shader_binary
+#define GL_SHADER_BINARY_DMP 0x9250
+#endif
+
+/*------------------------------------------------------------------------*
+ * FJ extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_FJ_shader_binary_GCCSO */
+#ifndef GL_FJ_shader_binary_GCCSO
+#define GCCSO_SHADER_BINARY_FJ 0x9260
+#endif
+
+/*------------------------------------------------------------------------*
+ * 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_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
+
+/* GL_NV_draw_buffers */
+#ifndef GL_NV_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_NV 0x8824
+#define GL_DRAW_BUFFER0_NV 0x8825
+#define GL_DRAW_BUFFER1_NV 0x8826
+#define GL_DRAW_BUFFER2_NV 0x8827
+#define GL_DRAW_BUFFER3_NV 0x8828
+#define GL_DRAW_BUFFER4_NV 0x8829
+#define GL_DRAW_BUFFER5_NV 0x882A
+#define GL_DRAW_BUFFER6_NV 0x882B
+#define GL_DRAW_BUFFER7_NV 0x882C
+#define GL_DRAW_BUFFER8_NV 0x882D
+#define GL_DRAW_BUFFER9_NV 0x882E
+#define GL_DRAW_BUFFER10_NV 0x882F
+#define GL_DRAW_BUFFER11_NV 0x8830
+#define GL_DRAW_BUFFER12_NV 0x8831
+#define GL_DRAW_BUFFER13_NV 0x8832
+#define GL_DRAW_BUFFER14_NV 0x8833
+#define GL_DRAW_BUFFER15_NV 0x8834
+#define GL_COLOR_ATTACHMENT0_NV 0x8CE0
+#define GL_COLOR_ATTACHMENT1_NV 0x8CE1
+#define GL_COLOR_ATTACHMENT2_NV 0x8CE2
+#define GL_COLOR_ATTACHMENT3_NV 0x8CE3
+#define GL_COLOR_ATTACHMENT4_NV 0x8CE4
+#define GL_COLOR_ATTACHMENT5_NV 0x8CE5
+#define GL_COLOR_ATTACHMENT6_NV 0x8CE6
+#define GL_COLOR_ATTACHMENT7_NV 0x8CE7
+#define GL_COLOR_ATTACHMENT8_NV 0x8CE8
+#define GL_COLOR_ATTACHMENT9_NV 0x8CE9
+#define GL_COLOR_ATTACHMENT10_NV 0x8CEA
+#define GL_COLOR_ATTACHMENT11_NV 0x8CEB
+#define GL_COLOR_ATTACHMENT12_NV 0x8CEC
+#define GL_COLOR_ATTACHMENT13_NV 0x8CED
+#define GL_COLOR_ATTACHMENT14_NV 0x8CEE
+#define GL_COLOR_ATTACHMENT15_NV 0x8CEF
+#endif
+
+/* GL_NV_fbo_color_attachments */
+#ifndef GL_NV_fbo_color_attachments
+#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF
+/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */
+#endif
+
+/* 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_read_buffer */
+#ifndef GL_NV_read_buffer
+#define GL_READ_BUFFER_NV 0x0C02
+#endif
+
+/* GL_NV_read_buffer_front */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_read_depth */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_read_depth_stencil */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_read_stencil */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_texture_compression_s3tc_update */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_texture_npot_2D_mipmap */
+/* No new tokens introduced by this extension. */
+
+/*------------------------------------------------------------------------*
+ * QCOM extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_QCOM_alpha_test */
+#ifndef GL_QCOM_alpha_test
+#define GL_ALPHA_TEST_QCOM 0x0BC0
+#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1
+#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
+#endif
+
+/* GL_QCOM_binning_control */
+#ifndef GL_QCOM_binning_control
+#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0
+#define GL_CPU_OPTIMIZED_QCOM 0x8FB1
+#define GL_GPU_OPTIMIZED_QCOM 0x8FB2
+#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3
+#endif
+
+/* 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_required_internalformat */
+#ifndef GL_OES_required_internalformat
+#define GL_OES_required_internalformat 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
+
+#ifndef GL_OES_surfaceless_context
+#define GL_OES_surfaceless_context 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
+
+/*------------------------------------------------------------------------*
+ * KHR extension functions
+ *------------------------------------------------------------------------*/
+
+#ifndef GL_KHR_debug
+#define GL_KHR_debug 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GL_APICALL void GL_APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GL_APICALL void GL_APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam);
+GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+GL_APICALL void GL_APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+GL_APICALL void GL_APIENTRY glPopDebugGroup (void);
+GL_APICALL void GL_APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glGetPointerv (GLenum pname, void **params);
+#endif
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);
+typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);
+typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params);
+#endif
+
+#ifndef GL_KHR_texture_compression_astc_ldr
+#define GL_KHR_texture_compression_astc_ldr 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
+
+#ifndef GL_ANGLE_instanced_arrays
+#define GL_ANGLE_instanced_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor);
+#endif
+typedef void (GL_APIENTRYP PFLGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFLGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+typedef void (GL_APIENTRYP PFLGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
+#endif
+
+/* GL_ANGLE_pack_reverse_row_order */
+#ifndef GL_ANGLE_pack_reverse_row_order
+#define GL_ANGLE_pack_reverse_row_order 1
+#endif
+
+/* GL_ANGLE_texture_compression_dxt3 */
+#ifndef GL_ANGLE_texture_compression_dxt3
+#define GL_ANGLE_texture_compression_dxt3 1
+#endif
+
+/* GL_ANGLE_texture_compression_dxt5 */
+#ifndef GL_ANGLE_texture_compression_dxt5
+#define GL_ANGLE_texture_compression_dxt5 1
+#endif
+
+/* GL_ANGLE_texture_usage */
+#ifndef GL_ANGLE_texture_usage
+#define GL_ANGLE_texture_usage 1
+#endif
+
+#ifndef GL_ANGLE_translated_shader_source
+#define GL_ANGLE_translated_shader_source 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
+#endif
+typedef void (GL_APIENTRYP PFLGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
+#endif
+
+/*------------------------------------------------------------------------*
+ * APPLE extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_APPLE_copy_texture_levels */
+#ifndef GL_APPLE_copy_texture_levels
+#define GL_APPLE_copy_texture_levels 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
+#endif
+typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
+#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_rgb_422 */
+#ifndef GL_APPLE_rgb_422
+#define GL_APPLE_rgb_422 1
+#endif
+
+/* GL_APPLE_sync */
+#ifndef GL_APPLE_sync
+#define GL_APPLE_sync 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags);
+GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync);
+GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync);
+GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params);
+GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif
+typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
+typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
+typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
+typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
+typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#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_program_binary */
+#ifndef GL_ARM_mali_program_binary
+#define GL_ARM_mali_program_binary 1
+#endif
+
+/* 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_color_buffer_half_float */
+#ifndef GL_EXT_color_buffer_half_float
+#define GL_EXT_color_buffer_half_float 1
+#endif
+
+/* GL_EXT_debug_label */
+#ifndef GL_EXT_debug_label
+#define GL_EXT_debug_label 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
+#endif
+typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
+#endif
+
+/* GL_EXT_debug_marker */
+#ifndef GL_EXT_debug_marker
+#define GL_EXT_debug_marker 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker);
+GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker);
+GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void);
+#endif
+typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker);
+typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker);
+typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void);
+#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
+
+/* GL_EXT_map_buffer_range */
+#ifndef GL_EXT_map_buffer_range
+#define GL_EXT_map_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+
+/* GL_EXT_multisampled_render_to_texture */
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_EXT_multisampled_render_to_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
+#endif
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif
+
+/* GL_EXT_multiview_draw_buffers */
+#ifndef GL_EXT_multiview_draw_buffers
+#define GL_EXT_multiview_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index);
+GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices);
+GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data);
+#endif
+typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index);
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices);
+typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data);
+#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_occlusion_query_boolean */
+#ifndef GL_EXT_occlusion_query_boolean
+#define GL_EXT_occlusion_query_boolean 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids);
+GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids);
+GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id);
+GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id);
+GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target);
+GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params);
+#endif
+typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids);
+typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id);
+typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id);
+typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+/* GL_EXT_read_format_bgra */
+#ifndef GL_EXT_read_format_bgra
+#define GL_EXT_read_format_bgra 1
+#endif
+
+/* GL_EXT_robustness */
+#ifndef GL_EXT_robustness
+#define GL_EXT_robustness 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void);
+GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, float *params);
+GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+#endif
+typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void);
+typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, float *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+#endif
+
+/* GL_EXT_separate_shader_objects */
+#ifndef GL_EXT_separate_shader_objects
+#define GL_EXT_separate_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program);
+GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program);
+GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings);
+GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines);
+GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines);
+GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint x);
+GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint x, GLint y);
+GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z);
+GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);
+GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat x);
+GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat x, GLfloat y);
+GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+#endif
+typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
+typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program);
+typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings);
+typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines);
+typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines);
+typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint x);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint x, GLint y);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat x);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+#endif
+
+/* GL_EXT_shader_framebuffer_fetch */
+#ifndef GL_EXT_shader_framebuffer_fetch
+#define GL_EXT_shader_framebuffer_fetch 1
+#endif
+
+/* GL_EXT_shader_texture_lod */
+#ifndef GL_EXT_shader_texture_lod
+#define GL_EXT_shader_texture_lod 1
+#endif
+
+/* GL_EXT_shadow_samplers */
+#ifndef GL_EXT_shadow_samplers
+#define GL_EXT_shadow_samplers 1
+#endif
+
+/* GL_EXT_sRGB */
+#ifndef GL_EXT_sRGB
+#define GL_EXT_sRGB 1
+#endif
+
+/* GL_EXT_texture_compression_dxt1 */
+#ifndef GL_EXT_texture_compression_dxt1
+#define GL_EXT_texture_compression_dxt1 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_rg */
+#ifndef GL_EXT_texture_rg
+#define GL_EXT_texture_rg 1
+#endif
+
+/* GL_EXT_texture_storage */
+#ifndef GL_EXT_texture_storage
+#define GL_EXT_texture_storage 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#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_unpack_subimage */
+#ifndef GL_EXT_unpack_subimage
+#define GL_EXT_unpack_subimage 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * DMP extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_DMP_shader_binary */
+#ifndef GL_DMP_shader_binary
+#define GL_DMP_shader_binary 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * FJ extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_FJ_shader_binary_GCCSO */
+#ifndef GL_FJ_shader_binary_GCCSO
+#define GL_FJ_shader_binary_GCCSO 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 PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif
+
+/*------------------------------------------------------------------------*
+ * NV extension functions
+ *------------------------------------------------------------------------*/
+
+/* 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
+
+/* GL_NV_draw_buffers */
+#ifndef GL_NV_draw_buffers
+#define GL_NV_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);
+#endif
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+/* GL_NV_fbo_color_attachments */
+#ifndef GL_NV_fbo_color_attachments
+#define GL_NV_fbo_color_attachments 1
+#endif
+
+/* 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_read_buffer */
+#ifndef GL_NV_read_buffer
+#define GL_NV_read_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode);
+#endif
+typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
+#endif
+
+/* GL_NV_read_buffer_front */
+#ifndef GL_NV_read_buffer_front
+#define GL_NV_read_buffer_front 1
+#endif
+
+/* GL_NV_read_depth */
+#ifndef GL_NV_read_depth
+#define GL_NV_read_depth 1
+#endif
+
+/* GL_NV_read_depth_stencil */
+#ifndef GL_NV_read_depth_stencil
+#define GL_NV_read_depth_stencil 1
+#endif
+
+/* GL_NV_read_stencil */
+#ifndef GL_NV_read_stencil
+#define GL_NV_read_stencil 1
+#endif
+
+/* GL_NV_texture_compression_s3tc_update */
+#ifndef GL_NV_texture_compression_s3tc_update
+#define GL_NV_texture_compression_s3tc_update 1
+#endif
+
+/* GL_NV_texture_npot_2D_mipmap */
+#ifndef GL_NV_texture_npot_2D_mipmap
+#define GL_NV_texture_npot_2D_mipmap 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * QCOM extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_QCOM_alpha_test */
+#ifndef GL_QCOM_alpha_test
+#define GL_QCOM_alpha_test 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref);
+#endif
+typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
+#endif
+
+/* GL_QCOM_binning_control */
+#ifndef GL_QCOM_binning_control
+#define GL_QCOM_binning_control 1
+#endif
+
+/* 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/tests/font/inc/GLES2/gl2platform.h b/tests/font/inc/GLES2/gl2platform.h
new file mode 100644
index 0000000..c9fa3c4
--- /dev/null
+++ b/tests/font/inc/GLES2/gl2platform.h
@@ -0,0 +1,30 @@
+#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/tests/font/inc/GLES3/gl3.h b/tests/font/inc/GLES3/gl3.h
new file mode 100644
index 0000000..b9399e9
--- /dev/null
+++ b/tests/font/inc/GLES3/gl3.h
@@ -0,0 +1,1061 @@
+#ifndef __gl3_h_
+#define __gl3_h_
+
+/*
+ * gl3.h last updated on $Date: 2012-09-12 10:13:02 -0700 (Wed, 12 Sep 2012) $
+ */
+
+#include <GLES3/gl3platform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007-2012 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.
+*/
+
+/*-------------------------------------------------------------------------
+ * Data type definitions
+ *-----------------------------------------------------------------------*/
+
+/* OpenGL ES 2.0 */
+
+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_intptr_t GLintptr;
+typedef khronos_ssize_t GLsizeiptr;
+
+/* OpenGL ES 3.0 */
+
+typedef unsigned short GLhalf;
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef struct __GLsync *GLsync;
+
+/*-------------------------------------------------------------------------
+ * Token definitions
+ *-----------------------------------------------------------------------*/
+
+/* OpenGL ES core versions */
+#define GL_ES_VERSION_3_0 1
+#define GL_ES_VERSION_2_0 1
+
+/* OpenGL ES 2.0 */
+
+/* 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
+
+/* 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_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
+
+/* OpenGL ES 3.0 */
+
+#define GL_READ_BUFFER 0x0C02
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#define GL_PACK_ROW_LENGTH 0x0D02
+#define GL_PACK_SKIP_ROWS 0x0D03
+#define GL_PACK_SKIP_PIXELS 0x0D04
+#define GL_COLOR 0x1800
+#define GL_DEPTH 0x1801
+#define GL_STENCIL 0x1802
+#define GL_RED 0x1903
+#define GL_RGB8 0x8051
+#define GL_RGBA8 0x8058
+#define GL_RGB10_A2 0x8059
+#define GL_TEXTURE_BINDING_3D 0x806A
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_DEPTH_COMPONENT24 0x81A6
+#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+#define GL_CURRENT_QUERY 0x8865
+#define GL_QUERY_RESULT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE 0x8867
+#define GL_BUFFER_MAPPED 0x88BC
+#define GL_BUFFER_MAP_POINTER 0x88BD
+#define GL_STREAM_READ 0x88E1
+#define GL_STREAM_COPY 0x88E2
+#define GL_STATIC_READ 0x88E5
+#define GL_STATIC_COPY 0x88E6
+#define GL_DYNAMIC_READ 0x88E9
+#define GL_DYNAMIC_COPY 0x88EA
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_PIXEL_PACK_BUFFER 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
+#define GL_FLOAT_MAT2x3 0x8B65
+#define GL_FLOAT_MAT2x4 0x8B66
+#define GL_FLOAT_MAT3x2 0x8B67
+#define GL_FLOAT_MAT3x4 0x8B68
+#define GL_FLOAT_MAT4x2 0x8B69
+#define GL_FLOAT_MAT4x3 0x8B6A
+#define GL_SRGB 0x8C40
+#define GL_SRGB8 0x8C41
+#define GL_SRGB8_ALPHA8 0x8C43
+#define GL_COMPARE_REF_TO_TEXTURE 0x884E
+#define GL_MAJOR_VERSION 0x821B
+#define GL_MINOR_VERSION 0x821C
+#define GL_NUM_EXTENSIONS 0x821D
+#define GL_RGBA32F 0x8814
+#define GL_RGB32F 0x8815
+#define GL_RGBA16F 0x881A
+#define GL_RGB16F 0x881B
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
+#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
+#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
+#define GL_MAX_VARYING_COMPONENTS 0x8B4B
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
+#define GL_R11F_G11F_B10F 0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
+#define GL_RGB9_E5 0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
+#define GL_RASTERIZER_DISCARD 0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
+#define GL_INTERLEAVED_ATTRIBS 0x8C8C
+#define GL_SEPARATE_ATTRIBS 0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
+#define GL_RGBA32UI 0x8D70
+#define GL_RGB32UI 0x8D71
+#define GL_RGBA16UI 0x8D76
+#define GL_RGB16UI 0x8D77
+#define GL_RGBA8UI 0x8D7C
+#define GL_RGB8UI 0x8D7D
+#define GL_RGBA32I 0x8D82
+#define GL_RGB32I 0x8D83
+#define GL_RGBA16I 0x8D88
+#define GL_RGB16I 0x8D89
+#define GL_RGBA8I 0x8D8E
+#define GL_RGB8I 0x8D8F
+#define GL_RED_INTEGER 0x8D94
+#define GL_RGB_INTEGER 0x8D98
+#define GL_RGBA_INTEGER 0x8D99
+#define GL_SAMPLER_2D_ARRAY 0x8DC1
+#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
+#define GL_UNSIGNED_INT_VEC2 0x8DC6
+#define GL_UNSIGNED_INT_VEC3 0x8DC7
+#define GL_UNSIGNED_INT_VEC4 0x8DC8
+#define GL_INT_SAMPLER_2D 0x8DCA
+#define GL_INT_SAMPLER_3D 0x8DCB
+#define GL_INT_SAMPLER_CUBE 0x8DCC
+#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
+#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
+#define GL_BUFFER_ACCESS_FLAGS 0x911F
+#define GL_BUFFER_MAP_LENGTH 0x9120
+#define GL_BUFFER_MAP_OFFSET 0x9121
+#define GL_DEPTH_COMPONENT32F 0x8CAC
+#define GL_DEPTH32F_STENCIL8 0x8CAD
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
+#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
+#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
+#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
+#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
+#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
+#define GL_FRAMEBUFFER_DEFAULT 0x8218
+#define GL_FRAMEBUFFER_UNDEFINED 0x8219
+#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
+#define GL_DEPTH_STENCIL 0x84F9
+#define GL_UNSIGNED_INT_24_8 0x84FA
+#define GL_DEPTH24_STENCIL8 0x88F0
+#define GL_UNSIGNED_NORMALIZED 0x8C17
+#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING
+#define GL_READ_FRAMEBUFFER 0x8CA8
+#define GL_DRAW_FRAMEBUFFER 0x8CA9
+#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
+#define GL_RENDERBUFFER_SAMPLES 0x8CAB
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
+#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
+#define GL_COLOR_ATTACHMENT1 0x8CE1
+#define GL_COLOR_ATTACHMENT2 0x8CE2
+#define GL_COLOR_ATTACHMENT3 0x8CE3
+#define GL_COLOR_ATTACHMENT4 0x8CE4
+#define GL_COLOR_ATTACHMENT5 0x8CE5
+#define GL_COLOR_ATTACHMENT6 0x8CE6
+#define GL_COLOR_ATTACHMENT7 0x8CE7
+#define GL_COLOR_ATTACHMENT8 0x8CE8
+#define GL_COLOR_ATTACHMENT9 0x8CE9
+#define GL_COLOR_ATTACHMENT10 0x8CEA
+#define GL_COLOR_ATTACHMENT11 0x8CEB
+#define GL_COLOR_ATTACHMENT12 0x8CEC
+#define GL_COLOR_ATTACHMENT13 0x8CED
+#define GL_COLOR_ATTACHMENT14 0x8CEE
+#define GL_COLOR_ATTACHMENT15 0x8CEF
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
+#define GL_MAX_SAMPLES 0x8D57
+#define GL_HALF_FLOAT 0x140B
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_WRITE_BIT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
+#define GL_RG 0x8227
+#define GL_RG_INTEGER 0x8228
+#define GL_R8 0x8229
+#define GL_RG8 0x822B
+#define GL_R16F 0x822D
+#define GL_R32F 0x822E
+#define GL_RG16F 0x822F
+#define GL_RG32F 0x8230
+#define GL_R8I 0x8231
+#define GL_R8UI 0x8232
+#define GL_R16I 0x8233
+#define GL_R16UI 0x8234
+#define GL_R32I 0x8235
+#define GL_R32UI 0x8236
+#define GL_RG8I 0x8237
+#define GL_RG8UI 0x8238
+#define GL_RG16I 0x8239
+#define GL_RG16UI 0x823A
+#define GL_RG32I 0x823B
+#define GL_RG32UI 0x823C
+#define GL_VERTEX_ARRAY_BINDING 0x85B5
+#define GL_R8_SNORM 0x8F94
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGB8_SNORM 0x8F96
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_SIGNED_NORMALIZED 0x8F9C
+#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
+#define GL_COPY_READ_BUFFER 0x8F36
+#define GL_COPY_WRITE_BUFFER 0x8F37
+#define GL_COPY_READ_BUFFER_BINDING GL_COPY_READ_BUFFER
+#define GL_COPY_WRITE_BUFFER_BINDING GL_COPY_WRITE_BUFFER
+#define GL_UNIFORM_BUFFER 0x8A11
+#define GL_UNIFORM_BUFFER_BINDING 0x8A28
+#define GL_UNIFORM_BUFFER_START 0x8A29
+#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
+#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
+#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
+#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
+#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
+#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
+#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
+#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
+#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
+#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
+#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
+#define GL_UNIFORM_TYPE 0x8A37
+#define GL_UNIFORM_SIZE 0x8A38
+#define GL_UNIFORM_NAME_LENGTH 0x8A39
+#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
+#define GL_UNIFORM_OFFSET 0x8A3B
+#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
+#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
+#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
+#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
+#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
+#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
+#define GL_INVALID_INDEX 0xFFFFFFFFu
+#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
+#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
+#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
+#define GL_OBJECT_TYPE 0x9112
+#define GL_SYNC_CONDITION 0x9113
+#define GL_SYNC_STATUS 0x9114
+#define GL_SYNC_FLAGS 0x9115
+#define GL_SYNC_FENCE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
+#define GL_UNSIGNALED 0x9118
+#define GL_SIGNALED 0x9119
+#define GL_ALREADY_SIGNALED 0x911A
+#define GL_TIMEOUT_EXPIRED 0x911B
+#define GL_CONDITION_SATISFIED 0x911C
+#define GL_WAIT_FAILED 0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
+#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
+#define GL_ANY_SAMPLES_PASSED 0x8C2F
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
+#define GL_SAMPLER_BINDING 0x8919
+#define GL_RGB10_A2UI 0x906F
+#define GL_TEXTURE_SWIZZLE_R 0x8E42
+#define GL_TEXTURE_SWIZZLE_G 0x8E43
+#define GL_TEXTURE_SWIZZLE_B 0x8E44
+#define GL_TEXTURE_SWIZZLE_A 0x8E45
+#define GL_GREEN 0x1904
+#define GL_BLUE 0x1905
+#define GL_INT_2_10_10_10_REV 0x8D9F
+#define GL_TRANSFORM_FEEDBACK 0x8E22
+#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23
+#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24
+#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25
+#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
+#define GL_PROGRAM_BINARY_LENGTH 0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
+#define GL_PROGRAM_BINARY_FORMATS 0x87FF
+#define GL_COMPRESSED_R11_EAC 0x9270
+#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
+#define GL_COMPRESSED_RG11_EAC 0x9272
+#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
+#define GL_COMPRESSED_RGB8_ETC2 0x9274
+#define GL_COMPRESSED_SRGB8_ETC2 0x9275
+#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
+#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
+#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
+#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
+#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F
+#define GL_MAX_ELEMENT_INDEX 0x8D6B
+#define GL_NUM_SAMPLE_COUNTS 0x9380
+#define GL_TEXTURE_IMMUTABLE_LEVELS 0x8D63
+
+/*-------------------------------------------------------------------------
+ * Entrypoint definitions
+ *-----------------------------------------------------------------------*/
+
+/* OpenGL ES 2.0 */
+
+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 (GLfloat red, GLfloat green, GLfloat blue, GLfloat 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 (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat 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 (GLfloat n, GLfloat f);
+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 (GLfloat 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);
+
+/* OpenGL ES 3.0 */
+
+GL_APICALL void GL_APIENTRY glReadBuffer (GLenum mode);
+GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices);
+GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void GL_APIENTRY glTexSubImage3D (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 glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (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 glGenQueries (GLsizei n, GLuint* ids);
+GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint* ids);
+GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id);
+GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id);
+GL_APICALL void GL_APIENTRY glEndQuery (GLenum target);
+GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint* params);
+GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target);
+GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid** params);
+GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum* bufs);
+GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GL_APICALL GLvoid* GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length);
+GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array);
+GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint* arrays);
+GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint* arrays);
+GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array);
+GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint* data);
+GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode);
+GL_APICALL void GL_APIENTRY glEndTransformFeedback (void);
+GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer);
+GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode);
+GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name);
+GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint* params);
+GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w);
+GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint* v);
+GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint* v);
+GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint* params);
+GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name);
+GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0);
+GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1);
+GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2);
+GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint* value);
+GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint* value);
+GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint* value);
+GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint* value);
+GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint* value);
+GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint* value);
+GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat* value);
+GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+GL_APICALL const GLubyte* GL_APIENTRY glGetStringi (GLenum name, GLuint index);
+GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices);
+GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);
+GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar* uniformBlockName);
+GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);
+GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount);
+GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags);
+GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync);
+GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync);
+GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64* params);
+GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values);
+GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64* data);
+GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64* params);
+GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint* samplers);
+GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint* samplers);
+GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler);
+GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler);
+GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint* param);
+GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param);
+GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat* param);
+GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint* params);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat* params);
+GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor);
+GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id);
+GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint* ids);
+GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint* ids);
+GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id);
+GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void);
+GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void);
+GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary);
+GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length);
+GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value);
+GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments);
+GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/tests/font/inc/GLES3/gl3ext.h b/tests/font/inc/GLES3/gl3ext.h
new file mode 100644
index 0000000..4d4ea96
--- /dev/null
+++ b/tests/font/inc/GLES3/gl3ext.h
@@ -0,0 +1,24 @@
+#ifndef __gl3ext_h_
+#define __gl3ext_h_
+
+/* $Revision: 17809 $ on $Date:: 2012-05-14 08:03:36 -0700 #$ */
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/* OpenGL ES 3 Extensions
+ *
+ * After an OES extension's interactions with OpenGl ES 3.0 have been documented,
+ * its tokens and function definitions should be added to this file in a manner
+ * that does not conflict with gl2ext.h or gl3.h.
+ *
+ * Tokens and function definitions for extensions that have become standard
+ * features in OpenGL ES 3.0 will not be added to this file.
+ *
+ * Applications using OpenGL-ES-2-only extensions should include gl2ext.h
+ */
+
+#endif /* __gl3ext_h_ */
+
diff --git a/tests/font/inc/GLES3/gl3platform.h b/tests/font/inc/GLES3/gl3platform.h
new file mode 100644
index 0000000..1bd1a85
--- /dev/null
+++ b/tests/font/inc/GLES3/gl3platform.h
@@ -0,0 +1,30 @@
+#ifndef __gl3platform_h_
+#define __gl3platform_h_
+
+/* $Revision: 18437 $ on $Date:: 2012-07-08 23:31:39 -0700 #$ */
+
+/*
+ * 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 3.X gl3.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 /* __gl3platform_h_ */
diff --git a/tests/font/inc/KHR/khrplatform.h b/tests/font/inc/KHR/khrplatform.h
new file mode 100644
index 0000000..11e873e
--- /dev/null
+++ b/tests/font/inc/KHR/khrplatform.h
@@ -0,0 +1,273 @@
+#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: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
+ *
+ * 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__)
+# if defined (_DLL_EXPORTS)
+# define KHRONOS_APICALL __declspec(dllexport)
+# else
+# define KHRONOS_APICALL __declspec(dllimport)
+# endif
+#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;
+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;
+
+#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/tests/font/inc/VG/openvg.h b/tests/font/inc/VG/openvg.h
new file mode 100644
index 0000000..456a8bb
--- /dev/null
+++ b/tests/font/inc/VG/openvg.h
@@ -0,0 +1,746 @@
+/* $Revision: 6838 $ on $Date:: 2008-11-04 12:46:08 +0100 #$ */
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -------------------------------------
+ *
+ * Copyright (c) 2008 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.
+ *
+ *//**
+ * \file
+ * \brief OpenVG 1.1 API.
+ *//*-------------------------------------------------------------------*/
+
+#ifndef _OPENVG_H
+#define _OPENVG_H
+
+#include <VG/vgplatform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OPENVG_VERSION_1_0 1
+#define OPENVG_VERSION_1_0_1 1
+#define OPENVG_VERSION_1_1 2
+
+#ifndef VG_MAXSHORT
+#define VG_MAXSHORT 0x7FFF
+#endif
+
+#ifndef VG_MAXINT
+#define VG_MAXINT 0x7FFFFFFF
+#endif
+
+#ifndef VG_MAX_ENUM
+#define VG_MAX_ENUM 0x7FFFFFFF
+#endif
+
+typedef VGuint VGHandle;
+
+typedef VGHandle VGPath;
+typedef VGHandle VGImage;
+typedef VGHandle VGMaskLayer;
+typedef VGHandle VGFont;
+typedef VGHandle VGPaint;
+
+#define VG_INVALID_HANDLE ((VGHandle)0)
+
+typedef enum {
+ VG_FALSE = 0,
+ VG_TRUE = 1,
+
+ VG_BOOLEAN_FORCE_SIZE = VG_MAX_ENUM
+} VGboolean;
+
+typedef enum {
+ VG_NO_ERROR = 0,
+ VG_BAD_HANDLE_ERROR = 0x1000,
+ VG_ILLEGAL_ARGUMENT_ERROR = 0x1001,
+ VG_OUT_OF_MEMORY_ERROR = 0x1002,
+ VG_PATH_CAPABILITY_ERROR = 0x1003,
+ VG_UNSUPPORTED_IMAGE_FORMAT_ERROR = 0x1004,
+ VG_UNSUPPORTED_PATH_FORMAT_ERROR = 0x1005,
+ VG_IMAGE_IN_USE_ERROR = 0x1006,
+ VG_NO_CONTEXT_ERROR = 0x1007,
+
+ VG_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM
+} VGErrorCode;
+
+typedef enum {
+ /* Mode settings */
+ VG_MATRIX_MODE = 0x1100,
+ VG_FILL_RULE = 0x1101,
+ VG_IMAGE_QUALITY = 0x1102,
+ VG_RENDERING_QUALITY = 0x1103,
+ VG_BLEND_MODE = 0x1104,
+ VG_IMAGE_MODE = 0x1105,
+
+ /* Scissoring rectangles */
+ VG_SCISSOR_RECTS = 0x1106,
+
+ /* Color Transformation */
+ VG_COLOR_TRANSFORM = 0x1170,
+ VG_COLOR_TRANSFORM_VALUES = 0x1171,
+
+ /* Stroke parameters */
+ VG_STROKE_LINE_WIDTH = 0x1110,
+ VG_STROKE_CAP_STYLE = 0x1111,
+ VG_STROKE_JOIN_STYLE = 0x1112,
+ VG_STROKE_MITER_LIMIT = 0x1113,
+ VG_STROKE_DASH_PATTERN = 0x1114,
+ VG_STROKE_DASH_PHASE = 0x1115,
+ VG_STROKE_DASH_PHASE_RESET = 0x1116,
+
+ /* Edge fill color for VG_TILE_FILL tiling mode */
+ VG_TILE_FILL_COLOR = 0x1120,
+
+ /* Color for vgClear */
+ VG_CLEAR_COLOR = 0x1121,
+
+ /* Glyph origin */
+ VG_GLYPH_ORIGIN = 0x1122,
+
+ /* Enable/disable alpha masking and scissoring */
+ VG_MASKING = 0x1130,
+ VG_SCISSORING = 0x1131,
+
+ /* Pixel layout information */
+ VG_PIXEL_LAYOUT = 0x1140,
+ VG_SCREEN_LAYOUT = 0x1141,
+
+ /* Source format selection for image filters */
+ VG_FILTER_FORMAT_LINEAR = 0x1150,
+ VG_FILTER_FORMAT_PREMULTIPLIED = 0x1151,
+
+ /* Destination write enable mask for image filters */
+ VG_FILTER_CHANNEL_MASK = 0x1152,
+
+ /* Implementation limits (read-only) */
+ VG_MAX_SCISSOR_RECTS = 0x1160,
+ VG_MAX_DASH_COUNT = 0x1161,
+ VG_MAX_KERNEL_SIZE = 0x1162,
+ VG_MAX_SEPARABLE_KERNEL_SIZE = 0x1163,
+ VG_MAX_COLOR_RAMP_STOPS = 0x1164,
+ VG_MAX_IMAGE_WIDTH = 0x1165,
+ VG_MAX_IMAGE_HEIGHT = 0x1166,
+ VG_MAX_IMAGE_PIXELS = 0x1167,
+ VG_MAX_IMAGE_BYTES = 0x1168,
+ VG_MAX_FLOAT = 0x1169,
+ VG_MAX_GAUSSIAN_STD_DEVIATION = 0x116A,
+
+ VG_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGParamType;
+
+typedef enum {
+ VG_RENDERING_QUALITY_NONANTIALIASED = 0x1200,
+ VG_RENDERING_QUALITY_FASTER = 0x1201,
+ VG_RENDERING_QUALITY_BETTER = 0x1202, /* Default */
+
+ VG_RENDERING_QUALITY_FORCE_SIZE = VG_MAX_ENUM
+} VGRenderingQuality;
+
+typedef enum {
+ VG_PIXEL_LAYOUT_UNKNOWN = 0x1300,
+ VG_PIXEL_LAYOUT_RGB_VERTICAL = 0x1301,
+ VG_PIXEL_LAYOUT_BGR_VERTICAL = 0x1302,
+ VG_PIXEL_LAYOUT_RGB_HORIZONTAL = 0x1303,
+ VG_PIXEL_LAYOUT_BGR_HORIZONTAL = 0x1304,
+
+ VG_PIXEL_LAYOUT_FORCE_SIZE = VG_MAX_ENUM
+} VGPixelLayout;
+
+typedef enum {
+ VG_MATRIX_PATH_USER_TO_SURFACE = 0x1400,
+ VG_MATRIX_IMAGE_USER_TO_SURFACE = 0x1401,
+ VG_MATRIX_FILL_PAINT_TO_USER = 0x1402,
+ VG_MATRIX_STROKE_PAINT_TO_USER = 0x1403,
+ VG_MATRIX_GLYPH_USER_TO_SURFACE = 0x1404,
+
+ VG_MATRIX_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGMatrixMode;
+
+typedef enum {
+ VG_CLEAR_MASK = 0x1500,
+ VG_FILL_MASK = 0x1501,
+ VG_SET_MASK = 0x1502,
+ VG_UNION_MASK = 0x1503,
+ VG_INTERSECT_MASK = 0x1504,
+ VG_SUBTRACT_MASK = 0x1505,
+
+ VG_MASK_OPERATION_FORCE_SIZE = VG_MAX_ENUM
+} VGMaskOperation;
+
+#define VG_PATH_FORMAT_STANDARD 0
+
+typedef enum {
+ VG_PATH_DATATYPE_S_8 = 0,
+ VG_PATH_DATATYPE_S_16 = 1,
+ VG_PATH_DATATYPE_S_32 = 2,
+ VG_PATH_DATATYPE_F = 3,
+
+ VG_PATH_DATATYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGPathDatatype;
+
+typedef enum {
+ VG_ABSOLUTE = 0,
+ VG_RELATIVE = 1,
+
+ VG_PATH_ABS_REL_FORCE_SIZE = VG_MAX_ENUM
+} VGPathAbsRel;
+
+typedef enum {
+ VG_CLOSE_PATH = ( 0 << 1),
+ VG_MOVE_TO = ( 1 << 1),
+ VG_LINE_TO = ( 2 << 1),
+ VG_HLINE_TO = ( 3 << 1),
+ VG_VLINE_TO = ( 4 << 1),
+ VG_QUAD_TO = ( 5 << 1),
+ VG_CUBIC_TO = ( 6 << 1),
+ VG_SQUAD_TO = ( 7 << 1),
+ VG_SCUBIC_TO = ( 8 << 1),
+ VG_SCCWARC_TO = ( 9 << 1),
+ VG_SCWARC_TO = (10 << 1),
+ VG_LCCWARC_TO = (11 << 1),
+ VG_LCWARC_TO = (12 << 1),
+
+ VG_PATH_SEGMENT_FORCE_SIZE = VG_MAX_ENUM
+} VGPathSegment;
+
+typedef enum {
+ VG_MOVE_TO_ABS = VG_MOVE_TO | VG_ABSOLUTE,
+ VG_MOVE_TO_REL = VG_MOVE_TO | VG_RELATIVE,
+ VG_LINE_TO_ABS = VG_LINE_TO | VG_ABSOLUTE,
+ VG_LINE_TO_REL = VG_LINE_TO | VG_RELATIVE,
+ VG_HLINE_TO_ABS = VG_HLINE_TO | VG_ABSOLUTE,
+ VG_HLINE_TO_REL = VG_HLINE_TO | VG_RELATIVE,
+ VG_VLINE_TO_ABS = VG_VLINE_TO | VG_ABSOLUTE,
+ VG_VLINE_TO_REL = VG_VLINE_TO | VG_RELATIVE,
+ VG_QUAD_TO_ABS = VG_QUAD_TO | VG_ABSOLUTE,
+ VG_QUAD_TO_REL = VG_QUAD_TO | VG_RELATIVE,
+ VG_CUBIC_TO_ABS = VG_CUBIC_TO | VG_ABSOLUTE,
+ VG_CUBIC_TO_REL = VG_CUBIC_TO | VG_RELATIVE,
+ VG_SQUAD_TO_ABS = VG_SQUAD_TO | VG_ABSOLUTE,
+ VG_SQUAD_TO_REL = VG_SQUAD_TO | VG_RELATIVE,
+ VG_SCUBIC_TO_ABS = VG_SCUBIC_TO | VG_ABSOLUTE,
+ VG_SCUBIC_TO_REL = VG_SCUBIC_TO | VG_RELATIVE,
+ VG_SCCWARC_TO_ABS = VG_SCCWARC_TO | VG_ABSOLUTE,
+ VG_SCCWARC_TO_REL = VG_SCCWARC_TO | VG_RELATIVE,
+ VG_SCWARC_TO_ABS = VG_SCWARC_TO | VG_ABSOLUTE,
+ VG_SCWARC_TO_REL = VG_SCWARC_TO | VG_RELATIVE,
+ VG_LCCWARC_TO_ABS = VG_LCCWARC_TO | VG_ABSOLUTE,
+ VG_LCCWARC_TO_REL = VG_LCCWARC_TO | VG_RELATIVE,
+ VG_LCWARC_TO_ABS = VG_LCWARC_TO | VG_ABSOLUTE,
+ VG_LCWARC_TO_REL = VG_LCWARC_TO | VG_RELATIVE,
+
+ VG_PATH_COMMAND_FORCE_SIZE = VG_MAX_ENUM
+} VGPathCommand;
+
+typedef enum {
+ VG_PATH_CAPABILITY_APPEND_FROM = (1 << 0),
+ VG_PATH_CAPABILITY_APPEND_TO = (1 << 1),
+ VG_PATH_CAPABILITY_MODIFY = (1 << 2),
+ VG_PATH_CAPABILITY_TRANSFORM_FROM = (1 << 3),
+ VG_PATH_CAPABILITY_TRANSFORM_TO = (1 << 4),
+ VG_PATH_CAPABILITY_INTERPOLATE_FROM = (1 << 5),
+ VG_PATH_CAPABILITY_INTERPOLATE_TO = (1 << 6),
+ VG_PATH_CAPABILITY_PATH_LENGTH = (1 << 7),
+ VG_PATH_CAPABILITY_POINT_ALONG_PATH = (1 << 8),
+ VG_PATH_CAPABILITY_TANGENT_ALONG_PATH = (1 << 9),
+ VG_PATH_CAPABILITY_PATH_BOUNDS = (1 << 10),
+ VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS = (1 << 11),
+ VG_PATH_CAPABILITY_ALL = (1 << 12) - 1,
+
+ VG_PATH_CAPABILITIES_FORCE_SIZE = VG_MAX_ENUM
+} VGPathCapabilities;
+
+typedef enum {
+ VG_PATH_FORMAT = 0x1600,
+ VG_PATH_DATATYPE = 0x1601,
+ VG_PATH_SCALE = 0x1602,
+ VG_PATH_BIAS = 0x1603,
+ VG_PATH_NUM_SEGMENTS = 0x1604,
+ VG_PATH_NUM_COORDS = 0x1605,
+
+ VG_PATH_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGPathParamType;
+
+typedef enum {
+ VG_CAP_BUTT = 0x1700,
+ VG_CAP_ROUND = 0x1701,
+ VG_CAP_SQUARE = 0x1702,
+
+ VG_CAP_STYLE_FORCE_SIZE = VG_MAX_ENUM
+} VGCapStyle;
+
+typedef enum {
+ VG_JOIN_MITER = 0x1800,
+ VG_JOIN_ROUND = 0x1801,
+ VG_JOIN_BEVEL = 0x1802,
+
+ VG_JOIN_STYLE_FORCE_SIZE = VG_MAX_ENUM
+} VGJoinStyle;
+
+typedef enum {
+ VG_EVEN_ODD = 0x1900,
+ VG_NON_ZERO = 0x1901,
+
+ VG_FILL_RULE_FORCE_SIZE = VG_MAX_ENUM
+} VGFillRule;
+
+typedef enum {
+ VG_STROKE_PATH = (1 << 0),
+ VG_FILL_PATH = (1 << 1),
+
+ VG_PAINT_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGPaintMode;
+
+typedef enum {
+ /* Color paint parameters */
+ VG_PAINT_TYPE = 0x1A00,
+ VG_PAINT_COLOR = 0x1A01,
+ VG_PAINT_COLOR_RAMP_SPREAD_MODE = 0x1A02,
+ VG_PAINT_COLOR_RAMP_PREMULTIPLIED = 0x1A07,
+ VG_PAINT_COLOR_RAMP_STOPS = 0x1A03,
+
+ /* Linear gradient paint parameters */
+ VG_PAINT_LINEAR_GRADIENT = 0x1A04,
+
+ /* Radial gradient paint parameters */
+ VG_PAINT_RADIAL_GRADIENT = 0x1A05,
+
+ /* Pattern paint parameters */
+ VG_PAINT_PATTERN_TILING_MODE = 0x1A06,
+
+ VG_PAINT_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGPaintParamType;
+
+typedef enum {
+ VG_PAINT_TYPE_COLOR = 0x1B00,
+ VG_PAINT_TYPE_LINEAR_GRADIENT = 0x1B01,
+ VG_PAINT_TYPE_RADIAL_GRADIENT = 0x1B02,
+ VG_PAINT_TYPE_PATTERN = 0x1B03,
+
+ VG_PAINT_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGPaintType;
+
+typedef enum {
+ VG_COLOR_RAMP_SPREAD_PAD = 0x1C00,
+ VG_COLOR_RAMP_SPREAD_REPEAT = 0x1C01,
+ VG_COLOR_RAMP_SPREAD_REFLECT = 0x1C02,
+
+ VG_COLOR_RAMP_SPREAD_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGColorRampSpreadMode;
+
+typedef enum {
+ VG_TILE_FILL = 0x1D00,
+ VG_TILE_PAD = 0x1D01,
+ VG_TILE_REPEAT = 0x1D02,
+ VG_TILE_REFLECT = 0x1D03,
+
+ VG_TILING_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGTilingMode;
+
+typedef enum {
+ /* RGB{A,X} channel ordering */
+ VG_sRGBX_8888 = 0,
+ VG_sRGBA_8888 = 1,
+ VG_sRGBA_8888_PRE = 2,
+ VG_sRGB_565 = 3,
+ VG_sRGBA_5551 = 4,
+ VG_sRGBA_4444 = 5,
+ VG_sL_8 = 6,
+ VG_lRGBX_8888 = 7,
+ VG_lRGBA_8888 = 8,
+ VG_lRGBA_8888_PRE = 9,
+ VG_lL_8 = 10,
+ VG_A_8 = 11,
+ VG_BW_1 = 12,
+ VG_A_1 = 13,
+ VG_A_4 = 14,
+
+ /* {A,X}RGB channel ordering */
+ VG_sXRGB_8888 = 0 | (1 << 6),
+ VG_sARGB_8888 = 1 | (1 << 6),
+ VG_sARGB_8888_PRE = 2 | (1 << 6),
+ VG_sARGB_1555 = 4 | (1 << 6),
+ VG_sARGB_4444 = 5 | (1 << 6),
+ VG_lXRGB_8888 = 7 | (1 << 6),
+ VG_lARGB_8888 = 8 | (1 << 6),
+ VG_lARGB_8888_PRE = 9 | (1 << 6),
+
+ /* BGR{A,X} channel ordering */
+ VG_sBGRX_8888 = 0 | (1 << 7),
+ VG_sBGRA_8888 = 1 | (1 << 7),
+ VG_sBGRA_8888_PRE = 2 | (1 << 7),
+ VG_sBGR_565 = 3 | (1 << 7),
+ VG_sBGRA_5551 = 4 | (1 << 7),
+ VG_sBGRA_4444 = 5 | (1 << 7),
+ VG_lBGRX_8888 = 7 | (1 << 7),
+ VG_lBGRA_8888 = 8 | (1 << 7),
+ VG_lBGRA_8888_PRE = 9 | (1 << 7),
+
+ /* {A,X}BGR channel ordering */
+ VG_sXBGR_8888 = 0 | (1 << 6) | (1 << 7),
+ VG_sABGR_8888 = 1 | (1 << 6) | (1 << 7),
+ VG_sABGR_8888_PRE = 2 | (1 << 6) | (1 << 7),
+ VG_sABGR_1555 = 4 | (1 << 6) | (1 << 7),
+ VG_sABGR_4444 = 5 | (1 << 6) | (1 << 7),
+ VG_lXBGR_8888 = 7 | (1 << 6) | (1 << 7),
+ VG_lABGR_8888 = 8 | (1 << 6) | (1 << 7),
+ VG_lABGR_8888_PRE = 9 | (1 << 6) | (1 << 7),
+
+ VG_IMAGE_FORMAT_FORCE_SIZE = VG_MAX_ENUM
+} VGImageFormat;
+
+typedef enum {
+ VG_IMAGE_QUALITY_NONANTIALIASED = (1 << 0),
+ VG_IMAGE_QUALITY_FASTER = (1 << 1),
+ VG_IMAGE_QUALITY_BETTER = (1 << 2),
+
+ VG_IMAGE_QUALITY_FORCE_SIZE = VG_MAX_ENUM
+} VGImageQuality;
+
+typedef enum {
+ VG_IMAGE_FORMAT = 0x1E00,
+ VG_IMAGE_WIDTH = 0x1E01,
+ VG_IMAGE_HEIGHT = 0x1E02,
+
+ VG_IMAGE_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGImageParamType;
+
+typedef enum {
+ VG_DRAW_IMAGE_NORMAL = 0x1F00,
+ VG_DRAW_IMAGE_MULTIPLY = 0x1F01,
+ VG_DRAW_IMAGE_STENCIL = 0x1F02,
+
+ VG_IMAGE_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGImageMode;
+
+typedef enum {
+ VG_RED = (1 << 3),
+ VG_GREEN = (1 << 2),
+ VG_BLUE = (1 << 1),
+ VG_ALPHA = (1 << 0),
+
+ VG_IMAGE_CHANNEL_FORCE_SIZE = VG_MAX_ENUM
+} VGImageChannel;
+
+typedef enum {
+ VG_BLEND_SRC = 0x2000,
+ VG_BLEND_SRC_OVER = 0x2001,
+ VG_BLEND_DST_OVER = 0x2002,
+ VG_BLEND_SRC_IN = 0x2003,
+ VG_BLEND_DST_IN = 0x2004,
+ VG_BLEND_MULTIPLY = 0x2005,
+ VG_BLEND_SCREEN = 0x2006,
+ VG_BLEND_DARKEN = 0x2007,
+ VG_BLEND_LIGHTEN = 0x2008,
+ VG_BLEND_ADDITIVE = 0x2009,
+
+ VG_BLEND_MODE_FORCE_SIZE = VG_MAX_ENUM
+} VGBlendMode;
+
+typedef enum {
+ VG_FONT_NUM_GLYPHS = 0x2F00,
+
+ VG_FONT_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGFontParamType;
+
+typedef enum {
+ VG_IMAGE_FORMAT_QUERY = 0x2100,
+ VG_PATH_DATATYPE_QUERY = 0x2101,
+
+ VG_HARDWARE_QUERY_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGHardwareQueryType;
+
+typedef enum {
+ VG_HARDWARE_ACCELERATED = 0x2200,
+ VG_HARDWARE_UNACCELERATED = 0x2201,
+
+ VG_HARDWARE_QUERY_RESULT_FORCE_SIZE = VG_MAX_ENUM
+} VGHardwareQueryResult;
+
+typedef enum {
+ VG_VENDOR = 0x2300,
+ VG_RENDERER = 0x2301,
+ VG_VERSION = 0x2302,
+ VG_EXTENSIONS = 0x2303,
+
+ VG_STRING_ID_FORCE_SIZE = VG_MAX_ENUM
+} VGStringID;
+
+/* Function Prototypes */
+
+#ifndef VG_API_CALL
+# error VG_API_CALL must be defined
+#endif
+
+#ifndef VG_API_ENTRY
+# error VG_API_ENTRY must be defined
+#endif
+
+#ifndef VG_API_EXIT
+# error VG_API_EXIT must be defined
+#endif
+
+VG_API_CALL VGErrorCode VG_API_ENTRY vgGetError(void) VG_API_EXIT;
+
+VG_API_CALL void VG_API_ENTRY vgFlush(void) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgFinish(void) VG_API_EXIT;
+
+/* Getters and Setters */
+VG_API_CALL void VG_API_ENTRY vgSetf (VGParamType type, VGfloat value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSeti (VGParamType type, VGint value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetfv(VGParamType type, VGint count,
+ const VGfloat * values) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetiv(VGParamType type, VGint count,
+ const VGint * values) VG_API_EXIT;
+
+VG_API_CALL VGfloat VG_API_ENTRY vgGetf(VGParamType type) VG_API_EXIT;
+VG_API_CALL VGint VG_API_ENTRY vgGeti(VGParamType type) VG_API_EXIT;
+VG_API_CALL VGint VG_API_ENTRY vgGetVectorSize(VGParamType type) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetfv(VGParamType type, VGint count, VGfloat * values) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetiv(VGParamType type, VGint count, VGint * values) VG_API_EXIT;
+
+VG_API_CALL void VG_API_ENTRY vgSetParameterf(VGHandle object,
+ VGint paramType,
+ VGfloat value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetParameteri(VGHandle object,
+ VGint paramType,
+ VGint value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetParameterfv(VGHandle object,
+ VGint paramType,
+ VGint count, const VGfloat * values) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetParameteriv(VGHandle object,
+ VGint paramType,
+ VGint count, const VGint * values) VG_API_EXIT;
+
+VG_API_CALL VGfloat VG_API_ENTRY vgGetParameterf(VGHandle object,
+ VGint paramType) VG_API_EXIT;
+VG_API_CALL VGint VG_API_ENTRY vgGetParameteri(VGHandle object,
+ VGint paramType);
+VG_API_CALL VGint VG_API_ENTRY vgGetParameterVectorSize(VGHandle object,
+ VGint paramType) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetParameterfv(VGHandle object,
+ VGint paramType,
+ VGint count, VGfloat * values) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetParameteriv(VGHandle object,
+ VGint paramType,
+ VGint count, VGint * values) VG_API_EXIT;
+
+/* Matrix Manipulation */
+VG_API_CALL void VG_API_ENTRY vgLoadIdentity(void) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgLoadMatrix(const VGfloat * m) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetMatrix(VGfloat * m) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgMultMatrix(const VGfloat * m) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgTranslate(VGfloat tx, VGfloat ty) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgScale(VGfloat sx, VGfloat sy) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgShear(VGfloat shx, VGfloat shy) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgRotate(VGfloat angle) VG_API_EXIT;
+
+/* Masking and Clearing */
+VG_API_CALL void VG_API_ENTRY vgMask(VGHandle mask, VGMaskOperation operation,
+ VGint x, VGint y,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgRenderToMask(VGPath path,
+ VGbitfield paintModes,
+ VGMaskOperation operation) VG_API_EXIT;
+VG_API_CALL VGMaskLayer VG_API_ENTRY vgCreateMaskLayer(VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyMaskLayer(VGMaskLayer maskLayer) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgFillMaskLayer(VGMaskLayer maskLayer,
+ VGint x, VGint y,
+ VGint width, VGint height,
+ VGfloat value) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgCopyMask(VGMaskLayer maskLayer,
+ VGint dx, VGint dy,
+ VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgClear(VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
+
+/* Paths */
+VG_API_CALL VGPath VG_API_ENTRY vgCreatePath(VGint pathFormat,
+ VGPathDatatype datatype,
+ VGfloat scale, VGfloat bias,
+ VGint segmentCapacityHint,
+ VGint coordCapacityHint,
+ VGbitfield capabilities) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgClearPath(VGPath path, VGbitfield capabilities) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyPath(VGPath path) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgRemovePathCapabilities(VGPath path,
+ VGbitfield capabilities) VG_API_EXIT;
+VG_API_CALL VGbitfield VG_API_ENTRY vgGetPathCapabilities(VGPath path) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgAppendPath(VGPath dstPath, VGPath srcPath) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgAppendPathData(VGPath dstPath,
+ VGint numSegments,
+ const VGubyte * pathSegments,
+ const void * pathData) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgModifyPathCoords(VGPath dstPath, VGint startIndex,
+ VGint numSegments,
+ const void * pathData) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgTransformPath(VGPath dstPath, VGPath srcPath) VG_API_EXIT;
+VG_API_CALL VGboolean VG_API_ENTRY vgInterpolatePath(VGPath dstPath,
+ VGPath startPath,
+ VGPath endPath,
+ VGfloat amount) VG_API_EXIT;
+VG_API_CALL VGfloat VG_API_ENTRY vgPathLength(VGPath path,
+ VGint startSegment, VGint numSegments) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgPointAlongPath(VGPath path,
+ VGint startSegment, VGint numSegments,
+ VGfloat distance,
+ VGfloat * x, VGfloat * y,
+ VGfloat * tangentX, VGfloat * tangentY) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgPathBounds(VGPath path,
+ VGfloat * minX, VGfloat * minY,
+ VGfloat * width, VGfloat * height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgPathTransformedBounds(VGPath path,
+ VGfloat * minX, VGfloat * minY,
+ VGfloat * width, VGfloat * height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDrawPath(VGPath path, VGbitfield paintModes) VG_API_EXIT;
+
+/* Paint */
+VG_API_CALL VGPaint VG_API_ENTRY vgCreatePaint(void) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyPaint(VGPaint paint) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetPaint(VGPaint paint, VGbitfield paintModes) VG_API_EXIT;
+VG_API_CALL VGPaint VG_API_ENTRY vgGetPaint(VGPaintMode paintMode) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetColor(VGPaint paint, VGuint rgba) VG_API_EXIT;
+VG_API_CALL VGuint VG_API_ENTRY vgGetColor(VGPaint paint) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgPaintPattern(VGPaint paint, VGImage pattern) VG_API_EXIT;
+
+/* Images */
+VG_API_CALL VGImage VG_API_ENTRY vgCreateImage(VGImageFormat format,
+ VGint width, VGint height,
+ VGbitfield allowedQuality) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyImage(VGImage image) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgClearImage(VGImage image,
+ VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgImageSubData(VGImage image,
+ const void * data, VGint dataStride,
+ VGImageFormat dataFormat,
+ VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetImageSubData(VGImage image,
+ void * data, VGint dataStride,
+ VGImageFormat dataFormat,
+ VGint x, VGint y,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL VGImage VG_API_ENTRY vgChildImage(VGImage parent,
+ VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL VGImage VG_API_ENTRY vgGetParent(VGImage image) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgCopyImage(VGImage dst, VGint dx, VGint dy,
+ VGImage src, VGint sx, VGint sy,
+ VGint width, VGint height,
+ VGboolean dither) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDrawImage(VGImage image) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetPixels(VGint dx, VGint dy,
+ VGImage src, VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgWritePixels(const void * data, VGint dataStride,
+ VGImageFormat dataFormat,
+ VGint dx, VGint dy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGetPixels(VGImage dst, VGint dx, VGint dy,
+ VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgReadPixels(void * data, VGint dataStride,
+ VGImageFormat dataFormat,
+ VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgCopyPixels(VGint dx, VGint dy,
+ VGint sx, VGint sy,
+ VGint width, VGint height) VG_API_EXIT;
+
+/* Text */
+VG_API_CALL VGFont VG_API_ENTRY vgCreateFont(VGint glyphCapacityHint) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDestroyFont(VGFont font) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetGlyphToPath(VGFont font,
+ VGuint glyphIndex,
+ VGPath path,
+ VGboolean isHinted,
+ VGfloat glyphOrigin [2],
+ VGfloat escapement[2]) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSetGlyphToImage(VGFont font,
+ VGuint glyphIndex,
+ VGImage image,
+ VGfloat glyphOrigin [2],
+ VGfloat escapement[2]) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgClearGlyph(VGFont font,VGuint glyphIndex) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDrawGlyph(VGFont font,
+ VGuint glyphIndex,
+ VGbitfield paintModes,
+ VGboolean allowAutoHinting) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgDrawGlyphs(VGFont font,
+ VGint glyphCount,
+ VGuint *glyphIndices,
+ VGfloat *adjustments_x,
+ VGfloat *adjustments_y,
+ VGbitfield paintModes,
+ VGboolean allowAutoHinting) VG_API_EXIT;
+
+/* Image Filters */
+VG_API_CALL void VG_API_ENTRY vgColorMatrix(VGImage dst, VGImage src,
+ const VGfloat * matrix) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgConvolve(VGImage dst, VGImage src,
+ VGint kernelWidth, VGint kernelHeight,
+ VGint shiftX, VGint shiftY,
+ const VGshort * kernel,
+ VGfloat scale,
+ VGfloat bias,
+ VGTilingMode tilingMode) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgSeparableConvolve(VGImage dst, VGImage src,
+ VGint kernelWidth,
+ VGint kernelHeight,
+ VGint shiftX, VGint shiftY,
+ const VGshort * kernelX,
+ const VGshort * kernelY,
+ VGfloat scale,
+ VGfloat bias,
+ VGTilingMode tilingMode) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgGaussianBlur(VGImage dst, VGImage src,
+ VGfloat stdDeviationX,
+ VGfloat stdDeviationY,
+ VGTilingMode tilingMode) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgLookup(VGImage dst, VGImage src,
+ const VGubyte * redLUT,
+ const VGubyte * greenLUT,
+ const VGubyte * blueLUT,
+ const VGubyte * alphaLUT,
+ VGboolean outputLinear,
+ VGboolean outputPremultiplied) VG_API_EXIT;
+VG_API_CALL void VG_API_ENTRY vgLookupSingle(VGImage dst, VGImage src,
+ const VGuint * lookupTable,
+ VGImageChannel sourceChannel,
+ VGboolean outputLinear,
+ VGboolean outputPremultiplied) VG_API_EXIT;
+
+/* Hardware Queries */
+VG_API_CALL VGHardwareQueryResult VG_API_ENTRY vgHardwareQuery(VGHardwareQueryType key,
+ VGint setting) VG_API_EXIT;
+
+/* Renderer and Extension Information */
+VG_API_CALL const VGubyte * VG_API_ENTRY vgGetString(VGStringID name) VG_API_EXIT;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _OPENVG_H */
diff --git a/tests/font/inc/VG/vgext.h b/tests/font/inc/VG/vgext.h
new file mode 100644
index 0000000..ae07d99
--- /dev/null
+++ b/tests/font/inc/VG/vgext.h
@@ -0,0 +1,233 @@
+/* $Revision: 6810 $ on $Date:: 2008-10-29 15:31:37 +0100 #$ */
+
+/*------------------------------------------------------------------------
+ *
+ * VG extensions Reference Implementation
+ * -------------------------------------
+ *
+ * Copyright (c) 2008 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.
+ *
+ *//**
+ * \file
+ * \brief VG extensions
+ *//*-------------------------------------------------------------------*/
+
+
+
+#ifndef _VGEXT_H
+#define _VGEXT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <VG/openvg.h>
+#include <VG/vgu.h>
+
+#ifndef VG_API_ENTRYP
+# define VG_API_ENTRYP VG_API_ENTRY*
+#endif
+
+#ifndef VGU_API_ENTRYP
+# define VGU_API_ENTRYP VGU_API_ENTRY*
+#endif
+
+/*-------------------------------------------------------------------------------
+ * KHR extensions
+ *------------------------------------------------------------------------------*/
+
+typedef enum {
+
+#ifndef VG_KHR_iterative_average_blur
+ VG_MAX_AVERAGE_BLUR_DIMENSION_KHR = 0x116B,
+ VG_AVERAGE_BLUR_DIMENSION_RESOLUTION_KHR = 0x116C,
+ VG_MAX_AVERAGE_BLUR_ITERATIONS_KHR = 0x116D,
+#endif
+
+ VG_PARAM_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
+} VGParamTypeKHR;
+
+#ifndef VG_KHR_EGL_image
+#define VG_KHR_EGL_image 1
+/* VGEGLImageKHR is an opaque handle to an EGLImage */
+typedef void* VGeglImageKHR;
+
+#ifdef VG_VGEXT_PROTOTYPES
+VG_API_CALL VGImage VG_API_ENTRY vgCreateEGLImageTargetKHR(VGeglImageKHR image);
+#endif
+typedef VGImage (VG_API_ENTRYP PFNVGCREATEEGLIMAGETARGETKHRPROC) (VGeglImageKHR image);
+
+#endif
+
+
+#ifndef VG_KHR_iterative_average_blur
+#define VG_KHR_iterative_average_blur 1
+
+#ifdef VG_VGEXT_PROTOTYPES
+VG_API_CALL void vgIterativeAverageBlurKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
+#endif
+typedef void (VG_API_ENTRYP PFNVGITERATIVEAVERAGEBLURKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
+
+#endif
+
+
+#ifndef VG_KHR_advanced_blending
+#define VG_KHR_advanced_blending 1
+
+typedef enum {
+ VG_BLEND_OVERLAY_KHR = 0x2010,
+ VG_BLEND_HARDLIGHT_KHR = 0x2011,
+ VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012,
+ VG_BLEND_SOFTLIGHT_KHR = 0x2013,
+ VG_BLEND_COLORDODGE_KHR = 0x2014,
+ VG_BLEND_COLORBURN_KHR = 0x2015,
+ VG_BLEND_DIFFERENCE_KHR = 0x2016,
+ VG_BLEND_SUBTRACT_KHR = 0x2017,
+ VG_BLEND_INVERT_KHR = 0x2018,
+ VG_BLEND_EXCLUSION_KHR = 0x2019,
+ VG_BLEND_LINEARDODGE_KHR = 0x201a,
+ VG_BLEND_LINEARBURN_KHR = 0x201b,
+ VG_BLEND_VIVIDLIGHT_KHR = 0x201c,
+ VG_BLEND_LINEARLIGHT_KHR = 0x201d,
+ VG_BLEND_PINLIGHT_KHR = 0x201e,
+ VG_BLEND_HARDMIX_KHR = 0x201f,
+ VG_BLEND_CLEAR_KHR = 0x2020,
+ VG_BLEND_DST_KHR = 0x2021,
+ VG_BLEND_SRC_OUT_KHR = 0x2022,
+ VG_BLEND_DST_OUT_KHR = 0x2023,
+ VG_BLEND_SRC_ATOP_KHR = 0x2024,
+ VG_BLEND_DST_ATOP_KHR = 0x2025,
+ VG_BLEND_XOR_KHR = 0x2026,
+
+ VG_BLEND_MODE_KHR_FORCE_SIZE= VG_MAX_ENUM
+} VGBlendModeKHR;
+#endif
+
+#ifndef VG_KHR_parametric_filter
+#define VG_KHR_parametric_filter 1
+
+typedef enum {
+ VG_PF_OBJECT_VISIBLE_FLAG_KHR = (1 << 0),
+ VG_PF_KNOCKOUT_FLAG_KHR = (1 << 1),
+ VG_PF_OUTER_FLAG_KHR = (1 << 2),
+ VG_PF_INNER_FLAG_KHR = (1 << 3),
+
+ VG_PF_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
+} VGPfTypeKHR;
+
+typedef enum {
+ VGU_IMAGE_IN_USE_ERROR = 0xF010,
+
+ VGU_ERROR_CODE_KHR_FORCE_SIZE = VG_MAX_ENUM
+} VGUErrorCodeKHR;
+
+#ifdef VG_VGEXT_PROTOTYPES
+VG_API_CALL void VG_API_ENTRY vgParametricFilterKHR(VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguDropShadowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA) ;
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
+#endif
+typedef void (VG_API_ENTRYP PFNVGPARAMETRICFILTERKHRPROC) (VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUDROPSHADOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
+
+#endif
+
+
+/*-------------------------------------------------------------------------------
+ * NDS extensions
+ *------------------------------------------------------------------------------*/
+
+#ifndef VG_NDS_paint_generation
+#define VG_NDS_paint_generation 1
+
+typedef enum {
+ VG_PAINT_COLOR_RAMP_LINEAR_NDS = 0x1A10,
+ VG_COLOR_MATRIX_NDS = 0x1A11,
+ VG_PAINT_COLOR_TRANSFORM_LINEAR_NDS = 0x1A12,
+
+ VG_PAINT_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGPaintParamTypeNds;
+
+typedef enum {
+ VG_DRAW_IMAGE_COLOR_MATRIX_NDS = 0x1F10,
+
+ VG_IMAGE_MODE_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGImageModeNds;
+#endif
+
+
+#ifndef VG_NDS_projective_geometry
+#define VG_NDS_projective_geometry 1
+
+typedef enum {
+ VG_CLIP_MODE_NDS = 0x1180,
+ VG_CLIP_LINES_NDS = 0x1181,
+ VG_MAX_CLIP_LINES_NDS = 0x1182,
+
+ VG_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGParamTypeNds;
+
+typedef enum {
+ VG_CLIPMODE_NONE_NDS = 0x3000,
+ VG_CLIPMODE_CLIP_CLOSED_NDS = 0x3001,
+ VG_CLIPMODE_CLIP_OPEN_NDS = 0x3002,
+ VG_CLIPMODE_CULL_NDS = 0x3003,
+
+ VG_CLIPMODE_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGClipModeNds;
+
+typedef enum {
+ VG_RQUAD_TO_NDS = ( 13 << 1 ),
+ VG_RCUBIC_TO_NDS = ( 14 << 1 ),
+
+ VG_PATH_SEGMENT_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGPathSegmentNds;
+
+typedef enum {
+ VG_RQUAD_TO_ABS_NDS = (VG_RQUAD_TO_NDS | VG_ABSOLUTE),
+ VG_RQUAD_TO_REL_NDS = (VG_RQUAD_TO_NDS | VG_RELATIVE),
+ VG_RCUBIC_TO_ABS_NDS = (VG_RCUBIC_TO_NDS | VG_ABSOLUTE),
+ VG_RCUBIC_TO_REL_NDS = (VG_RCUBIC_TO_NDS | VG_RELATIVE),
+
+ VG_PATH_COMMAND_NDS_FORCE_SIZE = VG_MAX_ENUM
+} VGPathCommandNds;
+
+#ifdef VG_VGEXT_PROTOTYPES
+VG_API_CALL void VG_API_ENTRY vgProjectiveMatrixNDS(VGboolean enable) ;
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguTransformClipLineNDS(const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
+#endif
+typedef void (VG_API_ENTRYP PFNVGPROJECTIVEMATRIXNDSPROC) (VGboolean enable) ;
+typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUTRANSFORMCLIPLINENDSPROC) (const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
+
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _VGEXT_H */
diff --git a/tests/font/inc/VG/vgplatform.h b/tests/font/inc/VG/vgplatform.h
new file mode 100644
index 0000000..aa9896e
--- /dev/null
+++ b/tests/font/inc/VG/vgplatform.h
@@ -0,0 +1,106 @@
+/* $Revision: 6810 $ on $Date:: 2008-10-29 15:31:37 +0100 #$ */
+
+/*------------------------------------------------------------------------
+ *
+ * VG platform specific header Reference Implementation
+ * ----------------------------------------------------
+ *
+ * Copyright (c) 2008 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.
+ *
+ *//**
+ * \file
+ * \brief VG platform specific header
+ *//*-------------------------------------------------------------------*/
+
+#ifndef _VGPLATFORM_H
+#define _VGPLATFORM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef VG_API_CALL
+#if defined(OPENVG_STATIC_LIBRARY)
+# define VG_API_CALL
+#else
+# if defined(_WIN32) || defined(__VC32__) /* Win32 */
+# if defined (OPENVG_DLL_EXPORTS)
+# define VG_API_CALL __declspec(dllexport)
+# else
+# define VG_API_CALL __declspec(dllimport)
+# endif
+# else
+# define VG_API_CALL extern
+# endif /* defined(_WIN32) ||... */
+#endif /* defined OPENVG_STATIC_LIBRARY */
+#endif /* ifndef VG_API_CALL */
+
+#ifndef VGU_API_CALL
+#if defined(OPENVG_STATIC_LIBRARY)
+# define VGU_API_CALL
+#else
+# if defined(_WIN32) || defined(__VC32__) /* Win32 */
+# if defined (OPENVG_DLL_EXPORTS)
+# define VGU_API_CALL __declspec(dllexport)
+# else
+# define VGU_API_CALL __declspec(dllimport)
+# endif
+# else
+# define VGU_API_CALL extern
+# endif /* defined(_WIN32) ||... */
+#endif /* defined OPENVG_STATIC_LIBRARY */
+#endif /* ifndef VGU_API_CALL */
+
+
+#ifndef VG_API_ENTRY
+#define VG_API_ENTRY
+#endif
+
+#ifndef VG_API_EXIT
+#define VG_API_EXIT
+#endif
+
+#ifndef VGU_API_ENTRY
+#define VGU_API_ENTRY
+#endif
+
+#ifndef VGU_API_EXIT
+#define VGU_API_EXIT
+#endif
+
+typedef float VGfloat;
+typedef signed char VGbyte;
+typedef unsigned char VGubyte;
+typedef signed short VGshort;
+typedef signed int VGint;
+typedef unsigned int VGuint;
+typedef unsigned int VGbitfield;
+
+#ifndef VG_VGEXT_PROTOTYPES
+#define VG_VGEXT_PROTOTYPES
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _VGPLATFORM_H */
diff --git a/tests/font/inc/VG/vgu.h b/tests/font/inc/VG/vgu.h
new file mode 100644
index 0000000..7c814f7
--- /dev/null
+++ b/tests/font/inc/VG/vgu.h
@@ -0,0 +1,131 @@
+/* $Revision: 6810 $ on $Date:: 2008-10-29 15:31:37 +0100 #$ */
+
+/*------------------------------------------------------------------------
+ *
+ * VGU 1.1 Reference Implementation
+ * -------------------------------------
+ *
+ * Copyright (c) 2008 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.
+ *
+ *//**
+ * \file
+ * \brief VGU 1.1 API.
+ *//*-------------------------------------------------------------------*/
+
+#ifndef _VGU_H
+#define _VGU_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <VG/openvg.h>
+
+#define VGU_VERSION_1_0 1
+#define VGU_VERSION_1_1 2
+
+#ifndef VGU_API_CALL
+# error VGU_API_CALL must be defined
+#endif
+
+#ifndef VGU_API_ENTRY
+# error VGU_API_ENTRY must be defined
+#endif
+
+#ifndef VGU_API_EXIT
+# error VGU_API_EXIT must be defined
+#endif
+
+
+typedef enum {
+ VGU_NO_ERROR = 0,
+ VGU_BAD_HANDLE_ERROR = 0xF000,
+ VGU_ILLEGAL_ARGUMENT_ERROR = 0xF001,
+ VGU_OUT_OF_MEMORY_ERROR = 0xF002,
+ VGU_PATH_CAPABILITY_ERROR = 0xF003,
+ VGU_BAD_WARP_ERROR = 0xF004,
+
+ VGU_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM
+} VGUErrorCode;
+
+typedef enum {
+ VGU_ARC_OPEN = 0xF100,
+ VGU_ARC_CHORD = 0xF101,
+ VGU_ARC_PIE = 0xF102,
+
+ VGU_ARC_TYPE_FORCE_SIZE = VG_MAX_ENUM
+} VGUArcType;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguLine(VGPath path,
+ VGfloat x0, VGfloat y0,
+ VGfloat x1, VGfloat y1) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguPolygon(VGPath path,
+ const VGfloat * points, VGint count,
+ VGboolean closed) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRect(VGPath path,
+ VGfloat x, VGfloat y,
+ VGfloat width, VGfloat height) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRoundRect(VGPath path,
+ VGfloat x, VGfloat y,
+ VGfloat width, VGfloat height,
+ VGfloat arcWidth, VGfloat arcHeight) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguEllipse(VGPath path,
+ VGfloat cx, VGfloat cy,
+ VGfloat width, VGfloat height) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguArc(VGPath path,
+ VGfloat x, VGfloat y,
+ VGfloat width, VGfloat height,
+ VGfloat startAngle, VGfloat angleExtent,
+ VGUArcType arcType) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0,
+ VGfloat sx1, VGfloat sy1,
+ VGfloat sx2, VGfloat sy2,
+ VGfloat sx3, VGfloat sy3,
+ VGfloat * matrix) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0,
+ VGfloat dx1, VGfloat dy1,
+ VGfloat dx2, VGfloat dy2,
+ VGfloat dx3, VGfloat dy3,
+ VGfloat * matrix) VGU_API_EXIT;
+
+VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0,
+ VGfloat dx1, VGfloat dy1,
+ VGfloat dx2, VGfloat dy2,
+ VGfloat dx3, VGfloat dy3,
+ VGfloat sx0, VGfloat sy0,
+ VGfloat sx1, VGfloat sy1,
+ VGfloat sx2, VGfloat sy2,
+ VGfloat sx3, VGfloat sy3,
+ VGfloat * matrix) VGU_API_EXIT;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* #ifndef _VGU_H */
diff --git a/tests/font/inc/tiger.h b/tests/font/inc/tiger.h
new file mode 100644
index 0000000..ffbf6ac
--- /dev/null
+++ b/tests/font/inc/tiger.h
@@ -0,0 +1,45 @@
+#ifndef __TIGER_H
+#define __TIGER_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.0.1 Reference Implementation sample code
+ * -------------------------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Header for including the Tiger image data.
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+extern const int tigerCommandCount;
+extern const char tigerCommands[];
+extern const float tigerMinX;
+extern const float tigerMaxX;
+extern const float tigerMinY;
+extern const float tigerMaxY;
+extern const int tigerPointCount;
+extern const float tigerPoints[];
+
+#endif /* __TIGER_H */
diff --git a/tests/font/main.c b/tests/font/main.c
new file mode 100644
index 0000000..d65cc09
--- /dev/null
+++ b/tests/font/main.c
@@ -0,0 +1,663 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.0.1 Reference Implementation sample code
+ * -------------------------------------------------
+ *
+ * Copyright (c) 2007 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.
+ *
+ *//**
+ * \file
+ * \brief Tiger sample application. Resizing the application window
+ * rerenders the tiger in the new resolution. Pressing 1,2,3
+ * or 4 sets pixel zoom factor, mouse moves inside the zoomed
+ * image (mouse move works on OpenGL >= 1.2).
+ * \note
+ *//*-------------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#define UNREF(X) ((void)(X))
+
+#include <VG/openvg.h>
+#include <VG/vgext.h>
+#include <VG/vgu.h>
+#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+
+#include "DejaVuSans.inc" // font data
+#include "DejaVuSerif.inc"
+#include "DejaVuSansMono.inc"
+#include "fontinfo.h" // font data structure
+#include "eglstate.h"
+
+#include "esUtil.h"
+
+
+#define DEBUG
+#ifdef DEBUG
+#define DBG(M, ...) printf("[FONT][%s]:" M "\n", __func__, ##__VA_ARGS__)
+#else
+#define DBG(M, ...)
+#endif
+
+#define GL_CHECK(x) \
+ x; \
+ { \
+ GLenum glError = glGetError(); \
+ if(glError != GL_NO_ERROR) { \
+ DBG("glGetError() = %i (0x%.8x) at %s:%i\n", glError, glError, __FILE__, __LINE__); \
+ exit(1); \
+ } \
+ }
+
+/*--------------------------------------------------------------*/
+#define WINDOW_W 1024
+#define WINDOW_H 768
+
+unsigned char tgTextureBuffer [1024 * 768 * 4];
+
+static STATE_T _state, *state = &_state; // global graphics state
+static const int MAXFONTPATH = 256;
+
+Fontinfo SansTypeface, SerifTypeface, MonoTypeface;
+
+//EGLDisplay egldisplay;
+//EGLConfig eglconfig;
+//EGLSurface eglsurface;
+//EGLContext eglcontext;
+
+
+ VGFont font;
+ VGPath fontpath1;
+ VGImage fontimg1;
+
+/*--------------------------------------------------------------*/
+
+void init(NativeWindowType window)
+{
+ static const EGLint s_configAttribs[] =
+ {
+ EGL_SAMPLES, 4,
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_ALPHA_SIZE, 0,
+ EGL_BUFFER_SIZE, 32,
+ //EGL_LUMINANCE_SIZE, EGL_DONT_CARE, //EGL_DONT_CARE
+ EGL_STENCIL_SIZE, 0,
+ EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,//EGL_OPENGL_ES2_BIT,
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_DEPTH_SIZE, 0,
+ EGL_NONE
+ };
+
+ EGLint numconfigs;
+
+ static const EGLint contextAttributes[] =
+ {
+// EGL_CONTEXT_CLIENT_VERSION, 2, /* This field will be completed according to application request. */
+ EGL_NONE
+ };
+
+ static const EGLint windowAttributes[] =
+ {
+ //EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER,
+ EGL_NONE
+ /*
+ * Uncomment and remove EGL_NONE above to specify EGL_RENDER_BUFFER value to eglCreateWindowSurface.
+ * EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
+ * EGL_NONE
+ */
+ };
+
+
+ state->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ eglInitialize(state->display, NULL, NULL);
+ assert(eglGetError() == EGL_SUCCESS);
+// eglBindAPI(EGL_OPENVG_API);
+ eglBindAPI(EGL_OPENGL_ES_API);
+ eglChooseConfig(state->display, s_configAttribs, &state->config, 1, &numconfigs);
+ assert(eglGetError() == EGL_SUCCESS);
+ assert(numconfigs == 1);
+
+ state->surface = eglCreateWindowSurface(state->display, state->config, window, windowAttributes);
+ assert(eglGetError() == EGL_SUCCESS);
+ state->context = eglCreateContext(state->display, state->config, EGL_NO_CONTEXT, contextAttributes);
+ assert(eglGetError() == EGL_SUCCESS);
+ eglMakeCurrent(state->display, state->surface, state->surface, state->context);
+ assert(eglGetError() == EGL_SUCCESS);
+
+}
+
+/*--------------------------------------------------------------*/
+
+void deinit(void)
+{
+ eglMakeCurrent(state->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ assert(eglGetError() == EGL_SUCCESS);
+ eglTerminate(state->display);
+ assert(eglGetError() == EGL_SUCCESS);
+ eglReleaseThread();
+}
+
+/*--------------------------------------------------------------*/
+
+typedef struct
+{
+ // Handle to a program object
+ GLuint programObject;
+
+ // Attribute locations
+ GLint positionLoc;
+ GLint texCoordLoc;
+
+ // Sampler location
+ GLint samplerLoc;
+
+ // Texture handle
+ GLuint textureId;
+
+ float time;
+} UserData;
+
+
+// newpath creates path data
+VGPath newpath()
+{
+ return vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0.0f, 0.0f, VG_PATH_CAPABILITY_ALL);
+}
+
+// Rect makes a rectangle at the specified location and dimensions
+void Rect(VGfloat x, VGfloat y, VGfloat w, VGfloat h)
+{
+
+ VGPath path = newpath();
+ vguRect(path, x, y, w, h);
+ vgDrawPath(path, VG_FILL_PATH);
+ vgDrawPath(path, VG_STROKE_PATH);
+ vgDestroyPath(path);
+}
+
+// setfill sets the fill color
+void setfill(VGfloat color[4]) {
+ VGPaint fillPaint = vgCreatePaint();
+ vgSetParameteri(fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+ vgSetParameterfv(fillPaint, VG_PAINT_COLOR, 4, color);
+ vgSetPaint(fillPaint, VG_FILL_PATH);
+ vgDestroyPaint(fillPaint);
+}
+
+// setstroke sets the stroke color
+void setstroke(VGfloat color[4]) {
+ VGPaint strokePaint = vgCreatePaint();
+ vgSetParameteri(strokePaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+ vgSetParameterfv(strokePaint, VG_PAINT_COLOR, 4, color);
+ vgSetPaint(strokePaint, VG_STROKE_PATH);
+ vgDestroyPaint(strokePaint);
+}
+
+// StrokeWidth sets the stroke width
+void StrokeWidth(VGfloat width) {
+ vgSetf(VG_STROKE_LINE_WIDTH, width);
+ vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_BUTT);
+ vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_MITER);
+}
+
+// RGBA fills a color vectors from a RGBA quad.
+void RGBA(unsigned int r, unsigned int g, unsigned int b, VGfloat a, VGfloat color[4]) {
+ if (r > 255) {
+ r = 0;
+ }
+ if (g > 255) {
+ g = 0;
+ }
+ if (b > 255) {
+ b = 0;
+ }
+ if (a < 0.0 || a > 1.0) {
+ a = 1.0;
+ }
+ color[0] = (VGfloat) r / 255.0f;
+ color[1] = (VGfloat) g / 255.0f;
+ color[2] = (VGfloat) b / 255.0f;
+ color[3] = a;
+}
+
+// RGB returns a solid color from a RGB triple
+void RGB(unsigned int r, unsigned int g, unsigned int b, VGfloat color[4]) {
+ RGBA(r, g, b, 1.0f, color);
+}
+
+// Fill sets the fillcolor, defined as a RGBA quad.
+void Fill(unsigned int r, unsigned int g, unsigned int b, VGfloat a) {
+ VGfloat color[4];
+ RGBA(r, g, b, a, color);
+ setfill(color);
+}
+
+// Ellipse makes an ellipse at the specified location and dimensions
+void Ellipse(VGfloat x, VGfloat y, VGfloat w, VGfloat h) {
+ VGPath path = newpath();
+ vguEllipse(path, x, y, w, h);
+ vgDrawPath(path, VG_FILL_PATH | VG_STROKE_PATH);
+ vgDestroyPath(path);
+}
+
+// Circle makes a circle at the specified location and dimensions
+void Circle(VGfloat x, VGfloat y, VGfloat r) {
+ Ellipse(x, y, r, r);
+}
+
+
+// Text renders a string of text at a specified location, size, using the specified font glyphs
+// derived from http://web.archive.org/web/20070808195131/http://developer.hybrid.fi/font2openvg/renderFont.cpp.txt
+void Text(VGfloat x, VGfloat y, char *s, Fontinfo f, int pointsize) {
+ VGfloat size = (VGfloat) pointsize, xx = x, mm[9];
+ int i;
+
+ vgGetMatrix(mm);
+ for (i = 0; i < (int)strlen(s); i++) {
+ unsigned int character = (unsigned int)s[i];
+ int glyph = f.CharacterMap[character];
+ if (glyph == -1) {
+ continue; //glyph is undefined
+ }
+ VGfloat mat[9] = {
+ size, 0.0f, 0.0f,
+ 0.0f, size, 0.0f,
+ xx, y, 1.0f
+ };
+ vgLoadMatrix(mm);
+ vgMultMatrix(mat);
+ vgDrawPath(f.Glyphs[glyph], VG_FILL_PATH);
+ xx += size * f.GlyphAdvances[glyph] / 65536.0f;
+ }
+ vgLoadMatrix(mm);
+}
+
+// TextWidth returns the width of a text string at the specified font and size.
+VGfloat TextWidth(char *s, Fontinfo f, int pointsize) {
+ int i;
+ VGfloat tw = 0.0;
+ VGfloat size = (VGfloat) pointsize;
+ for (i = 0; i < (int)strlen(s); i++) {
+ unsigned int character = (unsigned int)s[i];
+ int glyph = f.CharacterMap[character];
+ if (glyph == -1) {
+ continue; //glyph is undefined
+ }
+ tw += size * f.GlyphAdvances[glyph] / 65536.0f;
+ }
+ return tw;
+}
+
+// TextMid draws text, centered on (x,y)
+void TextMid(VGfloat x, VGfloat y, char *s, Fontinfo f, int pointsize) {
+ VGfloat tw = TextWidth(s, f, pointsize);
+ Text(x - (tw / 2.0), y, s, f, pointsize);
+}
+
+// TextEnd draws text, with its end aligned to (x,y)
+void TextEnd(VGfloat x, VGfloat y, char *s, Fontinfo f, int pointsize) {
+ VGfloat tw = TextWidth(s, f, pointsize);
+ Text(x - tw, y, s, f, pointsize);
+}
+
+// Start begins the picture, clearing a rectangular region with a specified color
+void Start(int width, int height) {
+ VGfloat color[4] = { 255, 255, 255, 1 };
+ vgSetfv(VG_CLEAR_COLOR, 4, color);
+ vgClear(0, 0, width, height);
+ color[0] = 0, color[1] = 0, color[2] = 0;
+ setfill(color);
+ setstroke(color);
+ StrokeWidth(0);
+ vgLoadIdentity();
+}
+
+// End checks for errors, and renders to the display
+void End() {
+ assert(vgGetError() == VG_NO_ERROR);
+ eglSwapBuffers(state->display, state->surface);
+ assert(eglGetError() == EGL_SUCCESS);
+}
+
+// clear the screen to a solid background color
+void Background(ESContext *esContext, unsigned int r, unsigned int g, unsigned int b)
+{
+ Fill(r, g, b, 1);
+
+// DBG("state->screen_width = %d", state->screen_width);
+// DBG("state->screen_height = %d", state->screen_height);
+
+ Rect(0, 0, esContext->width, esContext->height);
+}
+
+// clear the screen to a background color with alpha
+void BackgroundRGB(ESContext * esContext, unsigned int r, unsigned int g, unsigned int b, VGfloat a) {
+ Fill(r, g, b, a);
+ Rect(0, 0, esContext->width, esContext->height);
+}
+
+
+/*--------------------------------------------------------------*/
+//
+// Font functions
+//
+/*--------------------------------------------------------------*/
+// loadfont loads font path data
+// derived from http://web.archive.org/web/20070808195131/http://developer.hybrid.fi/font2openvg/renderFont.cpp.txt
+Fontinfo loadfont(const int *Points,
+ const int *PointIndices,
+ const unsigned char *Instructions,
+ const int *InstructionIndices, const int *InstructionCounts, const int *adv, const short *cmap, int ng) {
+
+ Fontinfo f;
+ int i;
+
+ memset(f.Glyphs, 0, MAXFONTPATH * sizeof(VGPath));
+ if (ng > MAXFONTPATH) {
+ return f;
+ }
+ for (i = 0; i < ng; i++) {
+ const int *p = &Points[PointIndices[i] * 2];
+ const unsigned char *instructions = &Instructions[InstructionIndices[i]];
+ int ic = InstructionCounts[i];
+ VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_S_32,
+// VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
+ 1.0f / 65536.0f, 0.0f, 0, 0,
+ VG_PATH_CAPABILITY_ALL);
+ f.Glyphs[i] = path;
+ if (ic) {
+ vgAppendPathData(path, ic, instructions, p);
+ }
+ }
+ f.CharacterMap = cmap;
+ f.GlyphAdvances = adv;
+ f.Count = ng;
+ return f;
+}
+
+// unloadfont frees font path data
+void unloadfont(VGPath * glyphs, int n) {
+ int i;
+ for (i = 0; i < n; i++) {
+ vgDestroyPath(glyphs[i]);
+ }
+}
+
+void initFont()
+{
+
+ SansTypeface = loadfont(DejaVuSans_glyphPoints,
+ DejaVuSans_glyphPointIndices,
+ DejaVuSans_glyphInstructions,
+ DejaVuSans_glyphInstructionIndices,
+ DejaVuSans_glyphInstructionCounts,
+ DejaVuSans_glyphAdvances, DejaVuSans_characterMap, DejaVuSans_glyphCount);
+
+ SerifTypeface = loadfont(DejaVuSerif_glyphPoints,
+ DejaVuSerif_glyphPointIndices,
+ DejaVuSerif_glyphInstructions,
+ DejaVuSerif_glyphInstructionIndices,
+ DejaVuSerif_glyphInstructionCounts,
+ DejaVuSerif_glyphAdvances, DejaVuSerif_characterMap, DejaVuSerif_glyphCount);
+
+ MonoTypeface = loadfont(DejaVuSansMono_glyphPoints,
+ DejaVuSansMono_glyphPointIndices,
+ DejaVuSansMono_glyphInstructions,
+ DejaVuSansMono_glyphInstructionIndices,
+ DejaVuSansMono_glyphInstructionCounts,
+ DejaVuSansMono_glyphAdvances, DejaVuSansMono_characterMap, DejaVuSansMono_glyphCount);
+
+}
+
+void deinitFont()
+{
+ unloadfont(SansTypeface.Glyphs, SansTypeface.Count);
+ unloadfont(SerifTypeface.Glyphs, SerifTypeface.Count);
+ unloadfont(MonoTypeface.Glyphs, MonoTypeface.Count);
+}
+
+/*--------------------------------------------------------------*/
+GLuint CreateSimpleTexture2D( )
+{
+ // Texture object handle
+ GLuint textureId;
+
+ // 2x2 Image, 3 bytes per pixel (R, G, B)
+ GLubyte pixels[4 * 3] =
+ {
+ 255, 0, 0, // Red
+ 0, 255, 0, // Green
+ 0, 0, 255, // Blue
+ 255, 255, 0 // Yellow
+ };
+
+ // Use tightly packed data
+ glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
+
+ // Generate a texture object
+ glGenTextures ( 1, &textureId );
+
+ // Bind the texture object
+ glBindTexture ( GL_TEXTURE_2D, textureId );
+
+ // Load the texture
+ glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
+
+ // Set the filtering mode
+ glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+
+ return textureId;
+
+}
+
+///
+// Initialize the shader and program object
+//
+int Init ( ESContext *esContext )
+{
+ esContext->userData = malloc(sizeof(UserData));
+ UserData *userData = esContext->userData;
+ GLbyte vShaderStr[] =
+ "attribute vec4 a_position; \n"
+ "attribute vec2 a_texCoord; \n"
+ "varying vec2 v_texCoord; \n"
+ "void main() \n"
+ "{ \n"
+ " gl_Position = a_position; \n"
+ " v_texCoord = a_texCoord; \n"
+ "} \n";
+
+ GLbyte fShaderStr[] =
+ "precision mediump float; \n"
+ "varying vec2 v_texCoord; \n"
+ "uniform sampler2D s_texture; \n"
+ "void main() \n"
+ "{ \n"
+ " gl_FragColor = texture2D( s_texture, v_texCoord );\n"
+ "} \n";
+
+ // Load the shaders and get a linked program object
+ userData->programObject = esLoadProgram ( vShaderStr, fShaderStr );
+
+ // Get the attribute locations
+ userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
+ userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" );
+
+ // Get the sampler location
+ userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" );
+
+ // Load the texture
+ userData->textureId = CreateSimpleTexture2D ();
+ userData->time = 1.0f;
+
+ glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
+ return GL_TRUE;
+}
+
+void Draw ( ESContext *esContext )
+{
+ UserData *userData = esContext->userData;
+ GLfloat vVertices[] = { -0.5f, 0.5f, 0.0f, // Position 0
+ 0.0f, 0.0f, // TexCoord 0
+ -0.5f, -0.5f, 0.0f, // Position 1
+ 0.0f, 1.0f, // TexCoord 1
+ 0.5f, -0.5f, 0.0f, // Position 2
+ 1.0f, 1.0f, // TexCoord 2
+ 0.5f, 0.5f, 0.0f, // Position 3
+ 1.0f, 0.0f // TexCoord 3
+ };
+ GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
+ VGImageFormat f;
+ char text[] = "hello world\0";
+
+
+ Start(esContext->width, esContext->height); // Start the picture
+ Background(esContext, 5, 5, 5); // Black background
+ Fill(44, 77, 232, 1.0); // Big blue marble
+ Circle((VGfloat) (esContext->width / 2), 0.0, (VGfloat)esContext->width); // The "world"
+ Fill(255, 255, 255, 1.0); // White text
+ TextMid((VGfloat)(esContext->width / 2),(VGfloat) ( esContext->height / 2),(char *) &text, SerifTypeface, esContext->width/10); // Greetings
+// End();
+
+ f = VG_sARGB_8888;
+
+ vgReadPixels(tgTextureBuffer, esContext->width*sizeof(unsigned int), f, 0, 0, esContext->width, esContext->height);
+
+ // Set the viewport
+ glViewport ( 0, 0, esContext->width, esContext->height );
+
+ // Clear the color buffer
+ glClear ( GL_COLOR_BUFFER_BIT );
+
+ // Use the program object
+ glUseProgram ( userData->programObject );
+
+ // Load the vertex position
+ glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT,
+ GL_FALSE, 5 * sizeof(GLfloat), vVertices );
+ // Load the texture coordinate
+ glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT,
+ GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3] );
+
+ glEnableVertexAttribArray ( userData->positionLoc );
+ glEnableVertexAttribArray ( userData->texCoordLoc );
+
+ // Bind the texture
+ glActiveTexture ( GL_TEXTURE0 );
+ glBindTexture ( GL_TEXTURE_2D, userData->textureId );
+
+ // Set the sampler texture unit to 0
+ glUniform1i ( userData->samplerLoc, 0 );
+
+ glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
+
+}
+
+int main ( int argc, char *argv[] )
+{
+ ESContext esContext;
+ UserData userData;
+ VGPath myvgPath;
+
+ memset(tgTextureBuffer, 0x00, WINDOW_W * WINDOW_H * 4);
+
+ esInitContext ( &esContext );
+ esContext.userData = &userData;
+
+ DBG("Step 1. initial EGL");
+ esCreateWindow ( &esContext, "Simple Texture 2D", WINDOW_W, WINDOW_H, ES_WINDOW_RGB );
+
+ Init(&esContext);
+ initFont();
+
+ esRegisterDrawFunc ( &esContext, Draw );
+
+ esMainLoop ( &esContext );
+
+// ShutDown ( &esContext );
+
+ return 0;
+}
+
+
+#if 0
+
+int main(void)
+{
+ fbdev_window window;
+
+ VGPath myvgPath;
+
+ window.width= WINDOW_W;
+ window.height= WINDOW_H;
+
+ state->screen_width = window.width;
+ state->screen_height = window.height;
+
+
+ DBG("Step 1. initial EGL");
+ init((NativeWindowType)&window);
+
+// vgCreateContextMNK((VGint)window.width, (VGint)window.height, VG_RENDERING_BACKEND_TYPE_OPENGLES20);
+
+#if 1 /* font */
+ //font = vgCreateFont(0);
+ //fontpath1 = vgCreatePath(VG_PATH_FORMAT_STANDARD,VG_PATH_DATATYPE_F, 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
+ //fontimg1 = vgCreateImage( VG_sRGBA_8888, window.width, window.height, VG_IMAGE_QUALITY_FASTER );
+
+ //vguEllipse(fontpath1, 5.0f,5.0f,5.0f,5.0f);
+ //vgImageSubData( fontimg1, image_data, window.width*4, VG_sRGBA_8888, 0, 0, window.width, window.height);
+
+ //vgSetGlyphToPath(font, 'a',fontpath1, 1, origin, escapement);
+ //vgDestroyPath(fontpath1);
+ //vgSetGlyphToImage(font, 'b',fontimg1, origin, escapement);
+
+
+ //draw(window.width, window.height);
+
+ //eglSwapBuffers(state->display, state->surface);
+ initFont();
+
+ Start(state->screen_width, state->screen_height); // Start the picture
+ Background( 0, 0, 0); // Black background
+ Fill(44, 77, 232, 1); // Big blue marble
+ Circle(state->screen_width / 2, 0, state->screen_width); // The "world"
+ Fill(255, 255, 255, 1); // White text
+ TextMid(state->screen_width / 2, state->screen_height / 2, "hello, world", SerifTypeface, state->screen_width/10); // Greetings
+ End();
+
+
+#endif
+ deinitFont();
+ deinit();
+ return(0);
+}
+
+#endif
+
diff --git a/tests/font/square.svg b/tests/font/square.svg
new file mode 100644
index 0000000..c4966a4
--- /dev/null
+++ b/tests/font/square.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" standalone="yes"?>
+
+<svg version="1.1" viewBox="0.0 0.0 960.0 720.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M23.574802 38.307087L160.11023 38.307087L160.11023 127.69292L23.574802 127.69292Z" fill-rule="nonzero" fill="#ff0000" stroke="#0000ff" stroke-width="12.0" stroke-linejoin="round" stroke-linecap="butt"></path></svg>
+
diff --git a/tests/font/testfont.fnt b/tests/font/testfont.fnt
new file mode 100644
index 0000000..aefe6b1
--- /dev/null
+++ b/tests/font/testfont.fnt
@@ -0,0 +1,99 @@
+info face="ArialMT" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
+common lineHeight=37 base=26 scaleW=512 scaleH=512 pages=1 packed=0
+page id=0 file="testfont.png"
+chars count=94
+char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=29 xadvance=8 page=0 chnl=0
+char id=64 x=0 y=0 width=33 height=32 xoffset=1 yoffset=5 xadvance=32 page=0 chnl=0
+char id=124 x=33 y=0 width=6 height=32 xoffset=2 yoffset=5 xadvance=8 page=0 chnl=0
+char id=125 x=39 y=0 width=12 height=32 xoffset=0 yoffset=5 xadvance=10 page=0 chnl=0
+char id=123 x=51 y=0 width=12 height=32 xoffset=0 yoffset=5 xadvance=10 page=0 chnl=0
+char id=41 x=63 y=0 width=11 height=32 xoffset=1 yoffset=5 xadvance=10 page=0 chnl=0
+char id=40 x=74 y=0 width=11 height=32 xoffset=1 yoffset=5 xadvance=10 page=0 chnl=0
+char id=36 x=85 y=0 width=18 height=31 xoffset=1 yoffset=3 xadvance=17 page=0 chnl=0
+char id=93 x=103 y=0 width=9 height=31 xoffset=0 yoffset=6 xadvance=8 page=0 chnl=0
+char id=91 x=112 y=0 width=9 height=31 xoffset=2 yoffset=6 xadvance=8 page=0 chnl=0
+char id=106 x=121 y=0 width=11 height=31 xoffset=-2 yoffset=6 xadvance=7 page=0 chnl=0
+char id=81 x=132 y=0 width=25 height=27 xoffset=1 yoffset=5 xadvance=24 page=0 chnl=0
+char id=38 x=157 y=0 width=22 height=26 xoffset=1 yoffset=5 xadvance=21 page=0 chnl=0
+char id=35 x=179 y=0 width=20 height=26 xoffset=0 yoffset=5 xadvance=17 page=0 chnl=0
+char id=37 x=199 y=0 width=28 height=26 xoffset=1 yoffset=5 xadvance=28 page=0 chnl=0
+char id=92 x=227 y=0 width=11 height=26 xoffset=0 yoffset=5 xadvance=8 page=0 chnl=0
+char id=47 x=238 y=0 width=11 height=26 xoffset=0 yoffset=5 xadvance=8 page=0 chnl=0
+char id=83 x=249 y=0 width=21 height=26 xoffset=1 yoffset=5 xadvance=21 page=0 chnl=0
+char id=79 x=270 y=0 width=25 height=26 xoffset=1 yoffset=5 xadvance=24 page=0 chnl=0
+char id=71 x=295 y=0 width=24 height=26 xoffset=1 yoffset=5 xadvance=24 page=0 chnl=0
+char id=67 x=319 y=0 width=23 height=26 xoffset=1 yoffset=5 xadvance=23 page=0 chnl=0
+char id=63 x=342 y=0 width=18 height=25 xoffset=1 yoffset=5 xadvance=17 page=0 chnl=0
+char id=48 x=360 y=0 width=18 height=25 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=0
+char id=57 x=378 y=0 width=18 height=25 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=0
+char id=56 x=396 y=0 width=18 height=25 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=0
+char id=54 x=414 y=0 width=18 height=25 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=0
+char id=53 x=432 y=0 width=18 height=25 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=0
+char id=51 x=450 y=0 width=18 height=25 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=0
+char id=121 x=468 y=0 width=18 height=25 xoffset=0 yoffset=12 xadvance=16 page=0 chnl=0
+char id=116 x=486 y=0 width=11 height=25 xoffset=0 yoffset=6 xadvance=8 page=0 chnl=0
+char id=113 x=0 y=32 width=17 height=25 xoffset=1 yoffset=12 xadvance=17 page=0 chnl=0
+char id=112 x=17 y=32 width=17 height=25 xoffset=2 yoffset=12 xadvance=17 page=0 chnl=0
+char id=103 x=34 y=32 width=17 height=25 xoffset=1 yoffset=12 xadvance=17 page=0 chnl=0
+char id=102 x=51 y=32 width=13 height=25 xoffset=0 yoffset=5 xadvance=8 page=0 chnl=0
+char id=100 x=64 y=32 width=17 height=25 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=0
+char id=98 x=81 y=32 width=17 height=25 xoffset=2 yoffset=6 xadvance=17 page=0 chnl=0
+char id=85 x=98 y=32 width=21 height=25 xoffset=2 yoffset=6 xadvance=23 page=0 chnl=0
+char id=74 x=119 y=32 width=16 height=25 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=0
+char id=33 x=135 y=32 width=7 height=24 xoffset=2 yoffset=6 xadvance=8 page=0 chnl=0
+char id=55 x=142 y=32 width=18 height=24 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=0
+char id=52 x=160 y=32 width=19 height=24 xoffset=0 yoffset=6 xadvance=17 page=0 chnl=0
+char id=50 x=179 y=32 width=19 height=24 xoffset=0 yoffset=6 xadvance=17 page=0 chnl=0
+char id=49 x=198 y=32 width=11 height=24 xoffset=3 yoffset=6 xadvance=17 page=0 chnl=0
+char id=108 x=209 y=32 width=5 height=24 xoffset=2 yoffset=6 xadvance=7 page=0 chnl=0
+char id=107 x=214 y=32 width=16 height=24 xoffset=2 yoffset=6 xadvance=16 page=0 chnl=0
+char id=105 x=230 y=32 width=5 height=24 xoffset=2 yoffset=6 xadvance=7 page=0 chnl=0
+char id=104 x=235 y=32 width=16 height=24 xoffset=2 yoffset=6 xadvance=17 page=0 chnl=0
+char id=90 x=251 y=32 width=21 height=24 xoffset=0 yoffset=6 xadvance=19 page=0 chnl=0
+char id=89 x=272 y=32 width=24 height=24 xoffset=0 yoffset=6 xadvance=21 page=0 chnl=0
+char id=88 x=296 y=32 width=24 height=24 xoffset=0 yoffset=6 xadvance=21 page=0 chnl=0
+char id=87 x=320 y=32 width=32 height=24 xoffset=0 yoffset=6 xadvance=30 page=0 chnl=0
+char id=86 x=352 y=32 width=24 height=24 xoffset=0 yoffset=6 xadvance=21 page=0 chnl=0
+char id=84 x=376 y=32 width=21 height=24 xoffset=0 yoffset=6 xadvance=19 page=0 chnl=0
+char id=82 x=397 y=32 width=23 height=24 xoffset=2 yoffset=6 xadvance=23 page=0 chnl=0
+char id=80 x=420 y=32 width=20 height=24 xoffset=2 yoffset=6 xadvance=21 page=0 chnl=0
+char id=78 x=440 y=32 width=21 height=24 xoffset=2 yoffset=6 xadvance=23 page=0 chnl=0
+char id=77 x=461 y=32 width=25 height=24 xoffset=2 yoffset=6 xadvance=26 page=0 chnl=0
+char id=76 x=486 y=32 width=17 height=24 xoffset=2 yoffset=6 xadvance=17 page=0 chnl=0
+char id=75 x=0 y=57 width=22 height=24 xoffset=2 yoffset=6 xadvance=21 page=0 chnl=0
+char id=73 x=22 y=57 width=7 height=24 xoffset=2 yoffset=6 xadvance=8 page=0 chnl=0
+char id=72 x=29 y=57 width=21 height=24 xoffset=2 yoffset=6 xadvance=23 page=0 chnl=0
+char id=70 x=50 y=57 width=19 height=24 xoffset=2 yoffset=6 xadvance=19 page=0 chnl=0
+char id=69 x=69 y=57 width=20 height=24 xoffset=2 yoffset=6 xadvance=21 page=0 chnl=0
+char id=68 x=89 y=57 width=22 height=24 xoffset=2 yoffset=6 xadvance=23 page=0 chnl=0
+char id=66 x=111 y=57 width=20 height=24 xoffset=2 yoffset=6 xadvance=21 page=0 chnl=0
+char id=65 x=131 y=57 width=25 height=24 xoffset=-1 yoffset=6 xadvance=21 page=0 chnl=0
+char id=59 x=156 y=57 width=7 height=23 xoffset=2 yoffset=12 xadvance=8 page=0 chnl=0
+char id=117 x=163 y=57 width=15 height=19 xoffset=2 yoffset=12 xadvance=17 page=0 chnl=0
+char id=115 x=178 y=57 width=17 height=19 xoffset=0 yoffset=12 xadvance=16 page=0 chnl=0
+char id=111 x=195 y=57 width=18 height=19 xoffset=1 yoffset=12 xadvance=17 page=0 chnl=0
+char id=101 x=213 y=57 width=17 height=19 xoffset=1 yoffset=12 xadvance=17 page=0 chnl=0
+char id=99 x=230 y=57 width=17 height=19 xoffset=1 yoffset=12 xadvance=16 page=0 chnl=0
+char id=97 x=247 y=57 width=18 height=19 xoffset=1 yoffset=12 xadvance=17 page=0 chnl=0
+char id=62 x=265 y=57 width=18 height=18 xoffset=1 yoffset=9 xadvance=18 page=0 chnl=0
+char id=60 x=283 y=57 width=18 height=18 xoffset=1 yoffset=9 xadvance=18 page=0 chnl=0
+char id=58 x=301 y=57 width=7 height=18 xoffset=2 yoffset=12 xadvance=8 page=0 chnl=0
+char id=122 x=308 y=57 width=18 height=18 xoffset=0 yoffset=12 xadvance=16 page=0 chnl=0
+char id=120 x=326 y=57 width=18 height=18 xoffset=0 yoffset=12 xadvance=16 page=0 chnl=0
+char id=119 x=344 y=57 width=25 height=18 xoffset=0 yoffset=12 xadvance=23 page=0 chnl=0
+char id=118 x=369 y=57 width=18 height=18 xoffset=0 yoffset=12 xadvance=16 page=0 chnl=0
+char id=114 x=387 y=57 width=13 height=18 xoffset=2 yoffset=12 xadvance=10 page=0 chnl=0
+char id=110 x=400 y=57 width=16 height=18 xoffset=2 yoffset=12 xadvance=17 page=0 chnl=0
+char id=109 x=416 y=57 width=25 height=18 xoffset=2 yoffset=12 xadvance=26 page=0 chnl=0
+char id=43 x=441 y=57 width=18 height=17 xoffset=1 yoffset=10 xadvance=18 page=0 chnl=0
+char id=94 x=459 y=57 width=17 height=15 xoffset=0 yoffset=5 xadvance=15 page=0 chnl=0
+char id=42 x=476 y=57 width=13 height=12 xoffset=1 yoffset=5 xadvance=12 page=0 chnl=0
+char id=61 x=489 y=57 width=18 height=12 xoffset=1 yoffset=12 xadvance=18 page=0 chnl=0
+char id=44 x=0 y=81 width=7 height=10 xoffset=2 yoffset=25 xadvance=8 page=0 chnl=0
+char id=39 x=7 y=81 width=6 height=10 xoffset=1 yoffset=6 xadvance=6 page=0 chnl=0
+char id=34 x=13 y=81 width=11 height=10 xoffset=1 yoffset=6 xadvance=11 page=0 chnl=0
+char id=126 x=24 y=81 width=19 height=7 xoffset=1 yoffset=15 xadvance=18 page=0 chnl=0
+char id=96 x=43 y=81 width=9 height=7 xoffset=1 yoffset=5 xadvance=10 page=0 chnl=0
+char id=45 x=52 y=81 width=11 height=5 xoffset=1 yoffset=19 xadvance=10 page=0 chnl=0
+char id=46 x=63 y=81 width=7 height=5 xoffset=2 yoffset=25 xadvance=8 page=0 chnl=0
+char id=95 x=70 y=81 width=24 height=4 xoffset=-1 yoffset=33 xadvance=17 page=0 chnl=0
diff --git a/tests/font/testfont.png b/tests/font/testfont.png
new file mode 100644
index 0000000..a8088cd
--- /dev/null
+++ b/tests/font/testfont.png
Binary files differ
diff --git a/tests/font/zero.png b/tests/font/zero.png
new file mode 100644
index 0000000..9b3322f
--- /dev/null
+++ b/tests/font/zero.png
Binary files differ